Manage suppr key, fix backspace
This commit is contained in:
parent
89bb6ddc3a
commit
bd024c3d31
|
@ -270,12 +270,16 @@ class Squirrel(Hazelnut):
|
||||||
"""
|
"""
|
||||||
Process the key press from the user.
|
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
|
# delete character at the good position
|
||||||
if self.input_index:
|
if self.input_index:
|
||||||
self.input_index -= 1
|
self.input_index -= 1
|
||||||
self.input_buffer = self.input_buffer[:self.input_index] + self.input_buffer[self.input_index + 1:]
|
self.input_buffer = self.input_buffer[:self.input_index] + self.input_buffer[self.input_index + 1:]
|
||||||
return
|
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:
|
elif key == curses.KEY_LEFT:
|
||||||
# Navigate in the message to the left
|
# Navigate in the message to the left
|
||||||
self.input_index = max(0, self.input_index - 1)
|
self.input_index = max(0, self.input_index - 1)
|
||||||
|
@ -310,6 +314,7 @@ class Squirrel(Hazelnut):
|
||||||
return
|
return
|
||||||
elif isinstance(key, int):
|
elif isinstance(key, int):
|
||||||
# Unmanaged complex key
|
# Unmanaged complex key
|
||||||
|
self.add_system_message(str(key))
|
||||||
return
|
return
|
||||||
elif key != "\n":
|
elif key != "\n":
|
||||||
# Insert the pressed key in the current message
|
# Insert the pressed key in the current message
|
||||||
|
|
Loading…
Reference in New Issue