mirror of
https://github.com/kennethreitz-archive/bpython-gist.git
synced 2026-06-05 23:50:18 +00:00
Added C-w to delete a word to the left of the cursor.
This commit is contained in:
committed by
Bob Farrell
parent
e2d0cf4611
commit
f8c37e843e
+16
@@ -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 ''
|
||||
|
||||
Reference in New Issue
Block a user