feat: Add "m" key to toggle mouse support with help text update
This commit is contained in:
parent
ecb452990b
commit
125bc3173e
23
gtm
23
gtm
|
|
@ -785,6 +785,7 @@ def draw_help_popup(stdscr, state):
|
||||||
("s", "Toggle sidebar"),
|
("s", "Toggle sidebar"),
|
||||||
("w", "Toggle line wrapping"),
|
("w", "Toggle line wrapping"),
|
||||||
("L", "Toggle line numbers"),
|
("L", "Toggle line numbers"),
|
||||||
|
("m", "Toggle mouse support"),
|
||||||
("q / Esc", "Quit"),
|
("q / Esc", "Quit"),
|
||||||
("?", "Show/hide this help")
|
("?", "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)
|
return replace(state, wrap_lines=not state.wrap_lines)
|
||||||
elif key == ord('L'):
|
elif key == ord('L'):
|
||||||
return replace(state, show_line_numbers=not state.show_line_numbers)
|
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'
|
elif key in [110, ord('n')]: # ASCII code for 'n'
|
||||||
if state.search_matches:
|
if state.search_matches:
|
||||||
return jump_to_next_match(state)
|
return jump_to_next_match(state)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue