feat: Add "m" key to toggle mouse support with help text update

This commit is contained in:
n loewen (aider) 2025-06-08 10:08:00 +01:00
parent ecb452990b
commit 125bc3173e
1 changed files with 23 additions and 0 deletions

23
gtm
View File

@ -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)