We can navigate in order to edit our message
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
a21b0aa652
commit
f5baea585e
|
@ -74,19 +74,37 @@ class Squinnondation:
|
|||
while True:
|
||||
squirrel.refresh_history()
|
||||
squirrel.refresh_input()
|
||||
key = screen.getkey(curses.LINES - 1, 3 + len(squirrel.nickname) + len(squirrel.input_buffer))
|
||||
key = screen.getkey(curses.LINES - 1, 3 + len(squirrel.nickname) + squirrel.input_index)
|
||||
if key == "\x7f": # backspace
|
||||
squirrel.input_buffer = squirrel.input_buffer[:-1]
|
||||
if squirrel.input_index:
|
||||
squirrel.input_index -= 1
|
||||
squirrel.input_buffer = squirrel.input_buffer[:squirrel.input_index] \
|
||||
+ squirrel.input_buffer[squirrel.input_index + 1:]
|
||||
continue
|
||||
elif key == "KEY_LEFT":
|
||||
squirrel.input_index = max(0, squirrel.input_index - 1)
|
||||
continue
|
||||
elif key == "KEY_RIGHT":
|
||||
squirrel.input_index = min(len(squirrel.input_buffer), squirrel.input_index + 1)
|
||||
continue
|
||||
elif key == "KEY_HOME":
|
||||
squirrel.input_index = 0
|
||||
continue
|
||||
elif key == "KEY_END":
|
||||
squirrel.input_index = len(squirrel.input_buffer)
|
||||
continue
|
||||
elif len(key) > 1:
|
||||
squirrel.history.append(f"<system> *unmanaged key press: {key}*")
|
||||
continue
|
||||
elif key != "\n":
|
||||
squirrel.input_buffer += key
|
||||
squirrel.input_buffer = squirrel.input_buffer[:squirrel.input_index] + key \
|
||||
+ squirrel.input_buffer[squirrel.input_index:]
|
||||
squirrel.input_index += 1
|
||||
continue
|
||||
|
||||
msg = squirrel.input_buffer
|
||||
squirrel.input_buffer = ""
|
||||
squirrel.input_index = 0
|
||||
|
||||
if not msg:
|
||||
continue
|
||||
|
@ -408,6 +426,7 @@ class Squirrel(Hazelnut):
|
|||
self.squinnondation = instance
|
||||
|
||||
self.input_buffer = ""
|
||||
self.input_index = 0
|
||||
|
||||
self.history = []
|
||||
self.history_pad = curses.newpad(curses.LINES - 2, curses.COLS)
|
||||
|
|
Loading…
Reference in New Issue