its alpha babyyy
This commit is contained in:
parent
44b19a6043
commit
dfc37a5b4f
26
bink.py
26
bink.py
@ -6,6 +6,7 @@ import os
|
|||||||
from sys import argv
|
from sys import argv
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from math import floor
|
||||||
|
|
||||||
home = os.path.expanduser("~/.bink")
|
home = os.path.expanduser("~/.bink")
|
||||||
max_body_length = 64_000
|
max_body_length = 64_000
|
||||||
@ -68,8 +69,11 @@ elif "pipe" in argv:
|
|||||||
|
|
||||||
import urwid
|
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 = [
|
attrmap = [
|
||||||
("bold", "default,bold", "default")
|
("bold", "default,bold", "default"),
|
||||||
|
("reverse", "standout", "default")
|
||||||
]
|
]
|
||||||
|
|
||||||
class App():
|
class App():
|
||||||
@ -78,7 +82,10 @@ class App():
|
|||||||
self.post_to_widget(post) for post in generate_feed()
|
self.post_to_widget(post) for post in generate_feed()
|
||||||
])
|
])
|
||||||
self.loop = urwid.MainLoop(
|
self.loop = urwid.MainLoop(
|
||||||
ActionBox(self.walker),
|
urwid.Frame(
|
||||||
|
ActionBox(self.walker),
|
||||||
|
footer=urwid.Text(("reverse", footer))
|
||||||
|
),
|
||||||
palette=attrmap
|
palette=attrmap
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -107,6 +114,10 @@ class App():
|
|||||||
self.update()
|
self.update()
|
||||||
self.loop.start()
|
self.loop.start()
|
||||||
|
|
||||||
|
def exit(self, message=""):
|
||||||
|
app.loop.stop()
|
||||||
|
run(["clear"])
|
||||||
|
exit(message)
|
||||||
|
|
||||||
class ActionBox(urwid.ListBox):
|
class ActionBox(urwid.ListBox):
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
@ -116,8 +127,7 @@ class ActionBox(urwid.ListBox):
|
|||||||
elif keyl == "r":
|
elif keyl == "r":
|
||||||
app.update()
|
app.update()
|
||||||
elif keyl in ("q", "x"):
|
elif keyl in ("q", "x"):
|
||||||
app.loop.stop()
|
app.exit()
|
||||||
exit()
|
|
||||||
elif keyl == " ":
|
elif keyl == " ":
|
||||||
super().keypress(size, "page down")
|
super().keypress(size, "page down")
|
||||||
elif keyl in ("j", "n", "ctrl n"):
|
elif keyl in ("j", "n", "ctrl n"):
|
||||||
@ -128,10 +138,16 @@ class ActionBox(urwid.ListBox):
|
|||||||
super().keypress(size, "home")
|
super().keypress(size, "home")
|
||||||
elif key == "G":
|
elif key == "G":
|
||||||
super().keypress(size, "end")
|
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)
|
return super().keypress(size, key)
|
||||||
|
|
||||||
app = App()
|
app = App()
|
||||||
try:
|
try:
|
||||||
app.loop.run()
|
app.loop.run()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
app.loop.stop()
|
app.exit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user