From bd024c3d31b93e0342db2d6b1d24dc8830e79842 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 Jan 2021 15:45:52 +0100 Subject: [PATCH] Manage suppr key, fix backspace --- squinnondation/hazel.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/squinnondation/hazel.py b/squinnondation/hazel.py index d56f9d9..b31cb57 100644 --- a/squinnondation/hazel.py +++ b/squinnondation/hazel.py @@ -270,12 +270,16 @@ class Squirrel(Hazelnut): """ Process the key press from the user. """ - if key == "\x7f": # backspace + if key == "\x7f" or key == curses.KEY_BACKSPACE: # backspace # delete character at the good position if self.input_index: self.input_index -= 1 self.input_buffer = self.input_buffer[:self.input_index] + self.input_buffer[self.input_index + 1:] return + elif key == curses.KEY_DC: # key + if self.input_index < len(self.input_buffer): + self.input_buffer = self.input_buffer[:self.input_index] + self.input_buffer[self.input_index + 1:] + return elif key == curses.KEY_LEFT: # Navigate in the message to the left self.input_index = max(0, self.input_index - 1) @@ -310,6 +314,7 @@ class Squirrel(Hazelnut): return elif isinstance(key, int): # Unmanaged complex key + self.add_system_message(str(key)) return elif key != "\n": # Insert the pressed key in the current message