summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-05-05 23:28:06 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-05-05 23:28:06 +0200
commit897aa5bd70b07831f98e884c63f52333f5a67439 (patch)
tree9d6fc061bb0e1152e0ac76023e09318fb07a19a7 /src
parent118a81992dd7ea8ef34eeac565d092f0e5191eb1 (diff)
downloadpoezio-897aa5bd70b07831f98e884c63f52333f5a67439.tar.gz
poezio-897aa5bd70b07831f98e884c63f52333f5a67439.tar.bz2
poezio-897aa5bd70b07831f98e884c63f52333f5a67439.tar.xz
poezio-897aa5bd70b07831f98e884c63f52333f5a67439.zip
M-backspace deletes a word
Diffstat (limited to 'src')
-rw-r--r--src/windows.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/windows.py b/src/windows.py
index ea4bfca2..bfe3102e 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -732,6 +732,7 @@ class Input(Win):
'M-f': self.jump_word_right,
"M-[1;5C": self.jump_word_right,
"KEY_BACKSPACE": self.key_backspace,
+ "M-KEY_BACKSPACE": self.delete_word,
'^?': self.key_backspace,
'^J': self.add_line_break,
}
@@ -756,6 +757,19 @@ class Input(Win):
def is_empty(self):
return len(self.text) == 0
+ def delete_word(self):
+ """
+ Delete the word behind the cursor.
+ """
+ if not len(self.text) or self.pos == 0:
+ return
+ separators = string.punctuation+' '
+ while self.pos > 0 and self.text[self.pos+self.line_pos-1] in separators:
+ self.key_backspace()
+ while self.pos > 0 and self.text[self.pos+self.line_pos-1] not in separators:
+ self.key_backspace()
+ return True
+
def jump_word_left(self):
"""
Move the cursor one word to the left