From 8c837e68a0b9323bd71c1517f914fa622ff1acac Mon Sep 17 00:00:00 2001 From: pdxlocations <117498748+pdxlocations@users.noreply.github.com> Date: Tue, 18 Feb 2025 22:30:42 -0800 Subject: [PATCH] keep cursor in the input window (#130) --- ui/curses_ui.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ui/curses_ui.py b/ui/curses_ui.py index 11e7e68..7388b9d 100644 --- a/ui/curses_ui.py +++ b/ui/curses_ui.py @@ -74,7 +74,6 @@ def handle_resize(stdscr, firstrun): win.box() win.refresh() - entry_win.keypad(True) curses.curs_set(1) @@ -90,13 +89,12 @@ def handle_resize(stdscr, firstrun): def main_ui(stdscr): - + global input_text + input_text = "" stdscr.keypad(True) get_channels() - handle_resize(stdscr, True) - input_text = "" while True: draw_text_field(entry_win, f"Input: {input_text[-(stdscr.getmaxyx()[1] - 10):]}", get_color("input")) @@ -444,6 +442,11 @@ def draw_node_list(): refresh_pad(2) + # Restore cursor to input field + entry_win.move(1, len("Input: ") + len(input_text)+1) + entry_win.refresh() + curses.curs_set(1) + def select_channel(idx): old_selected_channel = globals.selected_channel globals.selected_channel = max(0, min(idx, len(globals.channel_list) - 1)) @@ -540,6 +543,11 @@ def draw_packetlog_win(): packetlog_win.box() packetlog_win.refresh() + # Restore cursor to input field + entry_win.move(1, len("Input: ") + len(input_text)+1) + entry_win.refresh() + curses.curs_set(1) + def search(win): start_idx = globals.selected_node select_func = select_node