console: add g/G shortcuts throughout

g: go to end
G: go to beginning
This commit is contained in:
Aldo Cortesi
2015-04-07 16:13:42 +12:00
parent e76467e977
commit 8e2e83a3c6
4 changed files with 18 additions and 7 deletions

View File

@@ -309,6 +309,12 @@ class FlowListBox(urwid.ListBox):
self.master.clear_flows()
elif key == "e":
self.master.toggle_eventlog()
elif key == "G":
self.master.state.set_focus(0)
signals.flowlist_change.send(self)
elif key == "g":
self.master.state.set_focus(self.master.state.flow_count())
signals.flowlist_change.send(self)
elif key == "l":
signals.status_prompt.send(
prompt = "Limit",

View File

@@ -28,6 +28,7 @@ class HelpView(urwid.ListBox):
keys = [
("j, k", "down, up"),
("h, l", "left, right (in some contexts)"),
("g, G", "go to end, beginning"),
("space", "page down"),
("pg up/down", "page up/down"),
("arrows", "up, down, left, right"),

View File

@@ -15,10 +15,8 @@ class Highlight(urwid.AttrMap):
class Searchable(urwid.ListBox):
def __init__(self, state, contents):
urwid.ListBox.__init__(
self,
urwid.SimpleFocusListWalker(contents)
)
self.walker = urwid.SimpleFocusListWalker(contents)
urwid.ListBox.__init__(self, self.walker)
self.state = state
self.search_offset = 0
self.current_highlight = None
@@ -31,10 +29,16 @@ class Searchable(urwid.ListBox):
text = "",
callback = self.set_search
)
if key == "n":
elif key == "n":
self.find_next(False)
if key == "N":
elif key == "N":
self.find_next(True)
elif key == "G":
self.set_focus(0)
self.walker._modified()
elif key == "g":
self.set_focus(len(self.walker)-1)
self.walker._modified()
else:
return super(self.__class__, self).keypress(size, key)

View File

@@ -24,7 +24,7 @@ update_settings = blinker.Signal()
# Fired when a flow changes
flow_change = blinker.Signal()
# Fired when the flow list changes
# Fired when the flow list or focus changes
flowlist_change = blinker.Signal()
# Pop and push view state onto a stack