feat: Improve text selection highlighting during mouse drag

This commit is contained in:
n loewen (aider) 2025-06-07 22:16:04 +01:00
parent ccefbcef03
commit e6915060b1
1 changed files with 10 additions and 0 deletions

10
gtm2.py
View File

@ -445,6 +445,8 @@ def handle_mouse_input(stdscr, state):
state.update_divider(mx)
elif state.is_selecting:
state.selection_end_coord = (mx, my)
# Redraw immediately to show selection highlight during drag
draw_ui(stdscr, state)
if bstate & curses.BUTTON1_RELEASED:
# End of drag/selection
@ -470,6 +472,8 @@ def handle_mouse_input(stdscr, state):
state.is_selecting = True
state.selection_start_coord = (mx, my)
state.selection_end_coord = (mx, my)
# Redraw immediately to show selection highlight as soon as it starts
draw_ui(stdscr, state)
except curses.error:
pass
@ -522,6 +526,8 @@ 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
print("\033[?1003h", end="", flush=True)
state.load_commit_content()
@ -543,6 +549,10 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse):
# After every action, redraw the UI to reflect changes immediately.
# This is crucial for real-time feedback during mouse drags.
draw_ui(stdscr, state)
# Disable mouse motion events when exiting
if state.enable_mouse:
print("\033[?1003l", end="", flush=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="A \"Git Time Machine\" for viewing file history")