|
|
|
|
@ -22,6 +22,22 @@ class Items(urwid.ListBox):
|
|
|
|
|
idx = idx - 1
|
|
|
|
|
self.set_focus(idx)
|
|
|
|
|
return
|
|
|
|
|
elif key in ("l", "right"):
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
value = next(focus_widget.render((100,), focus=False).content())[1][2].decode().strip()
|
|
|
|
|
feeds = tui.leftPaneItems[value]["feeds"]
|
|
|
|
|
feedItems = [urwid.Columns([(4, urwid.Text(item["count"])), urwid.Text(item["name"])])
|
|
|
|
|
for item in feeds]
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.AttrMap(item, None, 'reveal focus') for item in feedItems])
|
|
|
|
|
self.body = walker
|
|
|
|
|
tui.leftBox.set_title(value)
|
|
|
|
|
return
|
|
|
|
|
elif key in ("h", "left"):
|
|
|
|
|
feedItems = tui.feedItems
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.AttrMap(item, None, 'reveal focus') for item in feedItems])
|
|
|
|
|
self.body = walker
|
|
|
|
|
tui.leftBox.set_title("Categories")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
return super().keypress(size, key)
|
|
|
|
|
|
|
|
|
|
@ -44,13 +60,24 @@ class TUI(urwid.Frame):
|
|
|
|
|
return tui
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
|
|
self.leftPaneItems = {}
|
|
|
|
|
self.activePane = False
|
|
|
|
|
for i in range(0, 15):
|
|
|
|
|
self.leftPaneItems["Category# " + str(i)] = {"count": str(i),
|
|
|
|
|
"feeds": [{"count": str(k), "name": "Feed# " + str(k)} for k in range(0, 10)]}
|
|
|
|
|
|
|
|
|
|
self.executor = ThreadPoolExecutor(max_workers=1)
|
|
|
|
|
self.loop = None
|
|
|
|
|
self.feedItems = [urwid.Text("Feed# " + str(i)) for i in range(0, 15)]
|
|
|
|
|
self.feedItems = [urwid.Columns([(4, urwid.Text(self.leftPaneItems[item]["count"])), urwid.Text(item)])
|
|
|
|
|
for item in self.leftPaneItems.keys()]
|
|
|
|
|
self.articleItems = [urwid.Text("Article# " + str(i)) for i in range(0, 10)]
|
|
|
|
|
self.feeds = Items(self.feedItems)
|
|
|
|
|
self.articles = Items(self.articleItems)
|
|
|
|
|
self.container = urwid.Columns([urwid.LineBox(self.feeds, title="Feeds"), urwid.LineBox(self.articles, title="Articles")])
|
|
|
|
|
self.leftBox = urwid.LineBox(self.feeds, title="Categories")
|
|
|
|
|
self.container = urwid.Columns(
|
|
|
|
|
[(40, self.leftBox),
|
|
|
|
|
urwid.LineBox(self.articles, title="Articles")])
|
|
|
|
|
self.body = self.container
|
|
|
|
|
|
|
|
|
|
super().__init__(self.body)
|
|
|
|
|
@ -61,7 +88,8 @@ class TUI(urwid.Frame):
|
|
|
|
|
|
|
|
|
|
def unhandled_input(self, key):
|
|
|
|
|
if key == "tab":
|
|
|
|
|
self.container.set_focus(1)
|
|
|
|
|
self.activePane = not self.activePane
|
|
|
|
|
self.container.set_focus(int(self.activePane))
|
|
|
|
|
elif key == "q":
|
|
|
|
|
raise urwid.ExitMainLoop()
|
|
|
|
|
|
|
|
|
|
|