fix: Improve divider dragging responsiveness and mouse handling
This commit is contained in:
parent
494d25bf1b
commit
d27563742e
|
|
@ -99,53 +99,33 @@ def main(stdscr, filename):
|
|||
except curses.error:
|
||||
pass
|
||||
|
||||
# Force a mouse position check every loop iteration while dragging
|
||||
# Set timeout for more responsive updates during dragging
|
||||
if dragging_divider:
|
||||
stdscr.timeout(1) # Very short timeout for responsive updates
|
||||
else:
|
||||
stdscr.timeout(-1) # Blocking mode when not dragging
|
||||
|
||||
# Handle divider dragging - check mouse position every iteration when dragging
|
||||
if dragging_divider:
|
||||
# Set a very short timeout to make the UI responsive
|
||||
stdscr.timeout(1)
|
||||
try:
|
||||
# Get current mouse position
|
||||
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
|
||||
_, mx, my, _, bstate = curses.getmouse()
|
||||
|
||||
# Always update divider position while dragging
|
||||
# Update divider position based on mouse x position
|
||||
min_col = 10
|
||||
max_col = width - 20 # leave space for right pane
|
||||
divider_col = max(min_col, min(mx, max_col))
|
||||
|
||||
# Check for mouse button release
|
||||
if bstate & curses.BUTTON1_RELEASED or not (bstate & curses.BUTTON1_PRESSED):
|
||||
# Check if mouse button has been released
|
||||
if not (bstate & curses.BUTTON1_PRESSED):
|
||||
dragging_divider = False
|
||||
stdscr.timeout(-1) # Reset to blocking mode when done dragging
|
||||
except curses.error:
|
||||
# If we can't get mouse state, try again on next iteration
|
||||
pass
|
||||
|
||||
#
|
||||
# # Mouse click changes focus
|
||||
# if key == curses.KEY_MOUSE:
|
||||
# try:
|
||||
# _, mx, my, _, bstate = curses.getmouse()
|
||||
#
|
||||
# if bstate & curses.BUTTON1_PRESSED:
|
||||
# if dragging_divider:
|
||||
# # Update divider while dragging
|
||||
# min_col = 10
|
||||
# max_col = width - 20 # leave space for right pane
|
||||
# divider_col = max(min_col, min(mx, max_col))
|
||||
# elif mx == divider_col:
|
||||
# dragging_divider = True
|
||||
#
|
||||
# elif bstate & curses.BUTTON1_RELEASED:
|
||||
# dragging_divider = False
|
||||
#
|
||||
# elif bstate & curses.BUTTON1_CLICKED:
|
||||
# focus = "left" if mx < divider_col else "right"
|
||||
#
|
||||
# except curses.error:
|
||||
# pass
|
||||
#
|
||||
#
|
||||
# elif key in [ord('q'), 27]:
|
||||
# break
|
||||
# Exit on 'q' or ESC
|
||||
if key in [ord('q'), 27]:
|
||||
break
|
||||
|
||||
# Left pane movement
|
||||
elif focus == "left":
|
||||
|
|
|
|||
Loading…
Reference in New Issue