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:
|
while True:
|
||||||
squirrel.refresh_history()
|
squirrel.refresh_history()
|
||||||
squirrel.refresh_input()
|
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
|
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
|
continue
|
||||||
elif len(key) > 1:
|
elif len(key) > 1:
|
||||||
squirrel.history.append(f"<system> *unmanaged key press: {key}*")
|
squirrel.history.append(f"<system> *unmanaged key press: {key}*")
|
||||||
continue
|
continue
|
||||||
elif key != "\n":
|
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
|
continue
|
||||||
|
|
||||||
msg = squirrel.input_buffer
|
msg = squirrel.input_buffer
|
||||||
squirrel.input_buffer = ""
|
squirrel.input_buffer = ""
|
||||||
|
squirrel.input_index = 0
|
||||||
|
|
||||||
if not msg:
|
if not msg:
|
||||||
continue
|
continue
|
||||||
|
@ -408,6 +426,7 @@ class Squirrel(Hazelnut):
|
||||||
self.squinnondation = instance
|
self.squinnondation = instance
|
||||||
|
|
||||||
self.input_buffer = ""
|
self.input_buffer = ""
|
||||||
|
self.input_index = 0
|
||||||
|
|
||||||
self.history = []
|
self.history = []
|
||||||
self.history_pad = curses.newpad(curses.LINES - 2, curses.COLS)
|
self.history_pad = curses.newpad(curses.LINES - 2, curses.COLS)
|
||||||
|
|
Loading…
Reference in New Issue