Made arrow keys and mouse wheel work in the help page.
This commit is contained in:
parent
8b25e6e89a
commit
73f046c44d
2 changed files with 30 additions and 15 deletions
2
BUGS
2
BUGS
|
|
@ -1,5 +1,4 @@
|
||||||
Current
|
Current
|
||||||
- Scrolling in the help screen doesn't work with the arrow keys.
|
|
||||||
- Within the sandbox sudo is not working for tools.
|
- Within the sandbox sudo is not working for tools.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -210,6 +209,7 @@ Fixed
|
||||||
- Some jobs are always recalculated when restarting vigil.
|
- Some jobs are always recalculated when restarting vigil.
|
||||||
e.g. vigil.py pylint, BUGS metadata, BUGS _pygments
|
e.g. vigil.py pylint, BUGS metadata, BUGS _pygments
|
||||||
- Tracebacks occur if you pause during early startup.
|
- Tracebacks occur if you pause during early startup.
|
||||||
|
- Scrolling in the help screen doesn't work with the arrow keys.
|
||||||
|
|
||||||
|
|
||||||
Won't fix
|
Won't fix
|
||||||
|
|
|
||||||
43
vigil
43
vigil
|
|
@ -529,6 +529,14 @@ def _get_help_text(is_status_simple=True):
|
||||||
meaning for status, meaning in tools.STATUS_MEANINGS])
|
meaning for status, meaning in tools.STATUS_MEANINGS])
|
||||||
|
|
||||||
|
|
||||||
|
def _make_key_map(key_data):
|
||||||
|
key_map = {}
|
||||||
|
for keys, action in key_data:
|
||||||
|
for key in keys:
|
||||||
|
key_map[key] = action
|
||||||
|
return key_map
|
||||||
|
|
||||||
|
|
||||||
class Help:
|
class Help:
|
||||||
|
|
||||||
def __init__(self, summary, screen):
|
def __init__(self, summary, screen):
|
||||||
|
|
@ -538,20 +546,34 @@ class Help:
|
||||||
self.view = fill3.View.from_widget(self.body)
|
self.view = fill3.View.from_widget(self.body)
|
||||||
self.widget = fill3.Border(self.view, title="Help")
|
self.widget = fill3.Border(self.view, title="Help")
|
||||||
portal = self.view.portal
|
portal = self.view.portal
|
||||||
self.key_map = {"h": self.exit_help, "d": portal.scroll_up,
|
self.key_map = _make_key_map([
|
||||||
"c": portal.scroll_down, "j": portal.scroll_left,
|
({"h"}, self.exit_help), ({"d", "up"}, portal.scroll_up),
|
||||||
"k": portal.scroll_right, "q": self.exit_help}
|
({"c", "down"}, portal.scroll_down),
|
||||||
|
({"j", "left"}, portal.scroll_left),
|
||||||
|
({"k", "right"}, portal.scroll_right), ({"q"}, self.exit_help)])
|
||||||
|
|
||||||
def exit_help(self):
|
def exit_help(self):
|
||||||
self.screen._is_help_visible = False
|
self.screen._is_help_visible = False
|
||||||
|
|
||||||
def on_input_event(self, event):
|
def on_mouse_event(self, event, appearance_changed_event):
|
||||||
|
if event[1] == 4: # Mouse wheel up
|
||||||
|
self.view.portal.scroll_up()
|
||||||
|
appearance_changed_event.set()
|
||||||
|
elif event[1] == 5: # Mouse wheel down
|
||||||
|
self.view.portal.scroll_down()
|
||||||
|
appearance_changed_event.set()
|
||||||
|
|
||||||
|
def on_input_event(self, event, appearance_changed_event):
|
||||||
|
if type(event) == tuple:
|
||||||
|
self.on_mouse_event(event, appearance_changed_event)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
action = self.key_map[event]
|
action = self.key_map[event]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
action()
|
action()
|
||||||
|
appearance_changed_event.set()
|
||||||
|
|
||||||
def appearance(self, dimensions):
|
def appearance(self, dimensions):
|
||||||
text = _get_help_text(self.summary.is_status_simple)
|
text = _get_help_text(self.summary.is_status_simple)
|
||||||
|
|
@ -582,7 +604,7 @@ class Screen:
|
||||||
self._is_help_visible = False
|
self._is_help_visible = False
|
||||||
self._is_paused = False
|
self._is_paused = False
|
||||||
self._make_widgets()
|
self._make_widgets()
|
||||||
self._make_keymap()
|
self._key_map = _make_key_map(Screen._KEY_DATA)
|
||||||
|
|
||||||
def _partition(self, widgets, height):
|
def _partition(self, widgets, height):
|
||||||
smaller_height = max(height // 4, 10)
|
smaller_height = max(height // 4, 10)
|
||||||
|
|
@ -608,13 +630,6 @@ class Screen:
|
||||||
land_no_log = fill3.Column([summary, self._listing], self._partition_2)
|
land_no_log = fill3.Column([summary, self._listing], self._partition_2)
|
||||||
self._layouts = [[land_no_log, port_no_log], [land_log, port_log]]
|
self._layouts = [[land_no_log, port_no_log], [land_log, port_log]]
|
||||||
|
|
||||||
def _make_keymap(self):
|
|
||||||
key_map = {}
|
|
||||||
for keys, action in self._KEY_DATA:
|
|
||||||
for key in keys:
|
|
||||||
key_map[key] = action
|
|
||||||
self._key_map = key_map
|
|
||||||
|
|
||||||
def toggle_help(self):
|
def toggle_help(self):
|
||||||
self._is_help_visible = not self._is_help_visible
|
self._is_help_visible = not self._is_help_visible
|
||||||
|
|
||||||
|
|
@ -729,8 +744,8 @@ class Screen:
|
||||||
|
|
||||||
def on_input_event(self, event):
|
def on_input_event(self, event):
|
||||||
if self._is_help_visible:
|
if self._is_help_visible:
|
||||||
self._help_widget.on_input_event(event)
|
self._help_widget.on_input_event(
|
||||||
self._appearance_changed_event.set()
|
event, self._appearance_changed_event)
|
||||||
return
|
return
|
||||||
if type(event) == tuple:
|
if type(event) == tuple:
|
||||||
self.on_mouse_event(event)
|
self.on_mouse_event(event)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue