Coding style.

- Rename mouse actions.
This commit is contained in:
Andrew Hamilton 2021-12-12 23:05:47 +10:00
parent abc5b15d90
commit 7ce8c0b9dc
2 changed files with 18 additions and 18 deletions

View file

@ -615,10 +615,10 @@ class Help:
def on_mouse_input(self, term_code):
event = terminal.decode_mouse_input(term_code)
if event[1] == terminal.WHEEL_UP_MOUSE:
if event[1] == terminal.MOUSE_WHEEL_UP:
self.view.portal.scroll_up()
fiil3.APPEARANCE_CHANGED_EVENT.set()
elif event[1] == terminal.WHEEL_DOWN_MOUSE:
elif event[1] == terminal.MOUSE_WHEEL_DOWN:
self.view.portal.scroll_down()
fill3.APPEARANCE_CHANGED_EVENT.set()
@ -866,10 +866,10 @@ class Screen:
self._help_widget.on_mouse_input(term_code)
return
event = terminal.decode_mouse_input(term_code)
if event[0] not in [terminal.PRESS_MOUSE, terminal.DRAG_MOUSE]:
if event[0] not in [terminal.MOUSE_PRESS, terminal.MOUSE_DRAG]:
return
x, y = event[2:4]
if event[0] == terminal.DRAG_MOUSE:
if event[0] == terminal.MOUSE_DRAG:
last_x, last_y = self._last_mouse_position
dx, dy = x - last_x, y - last_y
if self._is_summary_focused:
@ -877,9 +877,9 @@ class Screen:
else:
self._move_listing((-dx, -dy))
else: # Mouse press
if event[1] == terminal.WHEEL_UP_MOUSE:
if event[1] == terminal.MOUSE_WHEEL_UP:
self.listing_page_up()
elif event[1] == terminal.WHEEL_DOWN_MOUSE:
elif event[1] == terminal.MOUSE_WHEEL_DOWN:
self.listing_page_down()
else:
view_width, view_height = self._summary._view_widget.portal.last_dimensions

View file

@ -81,12 +81,12 @@ def interactive():
MOUSE = ESC + "[M"
RELEASE_MOUSE = 0
DRAG_MOUSE = 1
CLICK_MOUSE = 2
PRESS_MOUSE = 3
WHEEL_UP_MOUSE = 4
WHEEL_DOWN_MOUSE = 5
MOUSE_RELEASE = 0
MOUSE_DRAG = 1
MOUSE_CLICK = 2
MOUSE_PRESS = 3
MOUSE_WHEEL_UP = 4
MOUSE_WHEEL_DOWN = 5
def decode_mouse_input(term_code):
@ -95,14 +95,14 @@ def decode_mouse_input(term_code):
x, y = (keys[1] - 33) % 256, (keys[2] - 33) % 256
button = ((b & 64) / 64 * 3) + (b & 3) + 1
if b & 3 == 3:
action = RELEASE_MOUSE
action = MOUSE_RELEASE
button = 0
elif b & 2048:
action = RELEASE_MOUSE
action = MOUSE_RELEASE
elif b & 32:
action = DRAG_MOUSE
action = MOUSE_DRAG
elif b & 1536:
action = CLICK_MOUSE
action = MOUSE_CLICK
else:
action = PRESS_MOUSE
return (action, button, x, y)
action = MOUSE_PRESS
return action, button, x, y