diff options
author | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-15 16:57:27 -0500 |
---|---|---|
committer | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-15 16:57:27 -0500 |
commit | bf64d640710816d40a2f03b22b690dd06f57fb60 (patch) | |
tree | a6449592e3ea12149801bd1bd5a23dcc2cdc644e /clients/urwid/main.py | |
parent | eb8e4fa8447fcd006a9c2ed976ff3e7c1579e30a (diff) | |
download | bbj-bf64d640710816d40a2f03b22b690dd06f57fb60.tar.gz |
header nav via </>: can now get current focus post
Diffstat (limited to 'clients/urwid/main.py')
-rw-r--r-- | clients/urwid/main.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/clients/urwid/main.py b/clients/urwid/main.py index 4acdec9..7720487 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -176,7 +176,7 @@ default_prefs = { bars = { "index": "[RET]Open [C]ompose [R]efresh [O]ptions [?]Help [Q]uit", - "thread": "[C]ompose [RET]Interact [Q]Back [R]efresh [0-9]Goto [B/T]End [?]Help" + "thread": "[C]ompose [RET]Interact [Q]Back [R]efresh [0-9]Goto [B/T]End [<>]Jump [?]Help" } colormap = [ @@ -675,13 +675,36 @@ class App(object): self.index() + def get_focus_post(self): + pos = self.box.get_focus_path()[0] + if self.mode == "thread": + return (pos - (pos % 5)) // 5 + return pos + + + def header_jump_next(self): + if self.mode == "index": + return self.box.keypress(self.loop.screen_size, "down") + post = self.get_focus_post() + if post != self.thread["reply_count"]: + self.goto_post(post + 1) + + + def header_jump_previous(self): + if self.mode == "index": + return self.box.keypress(self.loop.screen_size, "up") + post = self.get_focus_post() + if post != 0: + self.goto_post(post - 1) + + def goto_post(self, number): if self.mode != "thread": return size = self.loop.screen_size - new_pos = number*5 - cur_pos = self.box.get_cursor_coords(size)[0] + new_pos = number * 5 + cur_pos = self.box.get_focus_path()[0] try: self.box.change_focus( @@ -1477,6 +1500,12 @@ class ActionBox(urwid.ListBox): elif key == "ctrl l": wipe_screen() + elif key == ">": + app.header_jump_next() + + elif key == "<": + app.header_jump_previous() + elif keyl in ["h", "left"]: app.back() |