fix: Prevent terminal-specific mouse handling crash for nsterm

This commit is contained in:
n loewen (aider) 2025-06-08 00:38:04 +01:00
parent 96f7b80226
commit 7f34cd86eb
1 changed files with 12 additions and 8 deletions

View File

@ -649,9 +649,11 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse):
if state.enable_mouse:
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
# Enable mouse motion events for better drag tracking
# This escape code is not supported by all terminals (e.g., nsterm)
if os.environ.get("TERM") != "nsterm":
try:
print("\033[?1003h", end="", flush=True)
except:
except Exception:
pass
state.load_commit_content()
@ -686,9 +688,11 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse):
# Disable mouse motion events when exiting
if state.enable_mouse:
# This escape code is not supported by all terminals (e.g., nsterm)
if os.environ.get("TERM") != "nsterm":
try:
print("\033[?1003l", end="", flush=True)
except:
except Exception:
pass
if __name__ == "__main__":