diff --git a/bink.py b/bink.py index 2aecf42..7b6ede3 100755 --- a/bink.py +++ b/bink.py @@ -6,6 +6,7 @@ import os from sys import argv from subprocess import run import tempfile +from math import floor home = os.path.expanduser("~/.bink") max_body_length = 64_000 @@ -68,8 +69,11 @@ elif "pipe" in argv: import urwid +footer = "[c]reate new post [q]uit [g]top [G]bottom | scrolling: arrows, space, page up/page down, ctrl-d/ctrl-u" + attrmap = [ - ("bold", "default,bold", "default") + ("bold", "default,bold", "default"), + ("reverse", "standout", "default") ] class App(): @@ -78,7 +82,10 @@ class App(): self.post_to_widget(post) for post in generate_feed() ]) self.loop = urwid.MainLoop( - ActionBox(self.walker), + urwid.Frame( + ActionBox(self.walker), + footer=urwid.Text(("reverse", footer)) + ), palette=attrmap ) @@ -107,6 +114,10 @@ class App(): self.update() self.loop.start() + def exit(self, message=""): + app.loop.stop() + run(["clear"]) + exit(message) class ActionBox(urwid.ListBox): def keypress(self, size, key): @@ -116,8 +127,7 @@ class ActionBox(urwid.ListBox): elif keyl == "r": app.update() elif keyl in ("q", "x"): - app.loop.stop() - exit() + app.exit() elif keyl == " ": super().keypress(size, "page down") elif keyl in ("j", "n", "ctrl n"): @@ -128,10 +138,16 @@ class ActionBox(urwid.ListBox): super().keypress(size, "home") elif key == "G": super().keypress(size, "end") + elif key == "ctrl d": + for i in range(1, floor(size[1] / 2)): + super().keypress(size, "down") + elif key == "ctrl u": + for i in range(1, floor(size[1] / 2)): + super().keypress(size, "up") return super().keypress(size, key) app = App() try: app.loop.run() except KeyboardInterrupt: - app.loop.stop() + app.exit()