From 2572f3e9f66f035cc41c1c67162856b29116cbb5 Mon Sep 17 00:00:00 2001 From: pemessage <1165739182@qq.com> Date: Thu, 4 Apr 2024 23:56:23 +0800 Subject: [PATCH] [key-bindings] ctrl-w for delete a word --- sweep.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sweep.py b/sweep.py index e591c2d..d5156c0 100755 --- a/sweep.py +++ b/sweep.py @@ -2243,6 +2243,21 @@ def __call__(self, event: TTYEvent): del self.buffer[self.cursor :] self.notify() return True + elif name == "w": + sep = (' ', '/') + first_meet = False + while self.cursor > 0: + cur = self.buffer[self.cursor - 1] + if cur not in sep: + self.cursor -= 1 + del self.buffer[self.cursor] + first_meet = True + elif not first_meet: + self.cursor -= 1 + del self.buffer[self.cursor] + else: + break + self.notify() elif type == TTY_CHAR: self.buffer.insert(self.cursor, attrs) self.notify()