Added C-w to delete a word to the left of the cursor.

This commit is contained in:
Jørgen P. Tjernø
2008-08-21 13:21:55 +02:00
committed by Bob Farrell
parent e2d0cf4611
commit f8c37e843e
+16
View File
@@ -937,6 +937,17 @@ class Repl( object ):
for _ in range(n):
self.scr.delch( y, x - n )
return n
def bs_word(self):
pos = len(self.s) - self.cpos - 1
# First we delete any space to the left of the cursor.
while pos >= 0 and self.s[pos] == ' ':
pos -= self.bs()
# Then we delete a full word.
while pos >= 0 and self.s[pos] != ' ':
pos -= self.bs()
def delete( self ):
"""Process a del"""
if not len(self.s):
@@ -1004,6 +1015,11 @@ class Repl( object ):
elif self.c == "KEY_END":
self.mvc(-self.cpos)
elif self.c in ('^W', chr(23)): # C-w
self.bs_word()
self.complete()
return ''
elif self.c in ('^U', chr(21) ): # C-u
self.clrtobol()
return ''