From 125bc3173e45f7a0eb1ef309552fb91d636eefcf Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Sun, 8 Jun 2025 10:08:00 +0100 Subject: [PATCH] feat: Add "m" key to toggle mouse support with help text update --- gtm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gtm b/gtm index a4945bb..8795b23 100755 --- a/gtm +++ b/gtm @@ -785,6 +785,7 @@ def draw_help_popup(stdscr, state): ("s", "Toggle sidebar"), ("w", "Toggle line wrapping"), ("L", "Toggle line numbers"), + ("m", "Toggle mouse support"), ("q / Esc", "Quit"), ("?", "Show/hide this help") ] @@ -1371,6 +1372,28 @@ def handle_keyboard_input(key, state: AppState) -> AppState: return replace(state, wrap_lines=not state.wrap_lines) elif key == ord('L'): return replace(state, show_line_numbers=not state.show_line_numbers) + elif key == ord('m'): + # Toggle mouse support + new_mouse_state = not state.enable_mouse + if new_mouse_state: + # Enable mouse + curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION) + # Enable mouse motion events for better drag tracking + if os.environ.get("TERM") != "nsterm": + try: + print("\033[?1003h", end="", flush=True) + except Exception: + pass + else: + # Disable mouse + curses.mousemask(0) + # Disable mouse motion events + if os.environ.get("TERM") != "nsterm": + try: + print("\033[?1003l", end="", flush=True) + except Exception: + pass + return replace(state, enable_mouse=new_mouse_state) elif key in [110, ord('n')]: # ASCII code for 'n' if state.search_matches: return jump_to_next_match(state)