|
|
|
@ -171,7 +171,8 @@ class TUI(urwid.Frame):
|
|
|
|
def create(cls):
|
|
|
|
def create(cls):
|
|
|
|
|
|
|
|
|
|
|
|
tui = cls()
|
|
|
|
tui = cls()
|
|
|
|
palette = [("text", "dark cyan", "dark cyan"), ('header', 'white', 'black'), ('reveal focus', 'black', 'dark cyan', 'standout')]
|
|
|
|
palette = [("linebox", "dark blue", "black"), ("text", "dark cyan", "dark cyan"),
|
|
|
|
|
|
|
|
('header', 'white', 'black'), ('reveal focus', 'black', 'dark cyan', 'standout')]
|
|
|
|
loop = urwid.MainLoop(
|
|
|
|
loop = urwid.MainLoop(
|
|
|
|
tui,
|
|
|
|
tui,
|
|
|
|
palette,
|
|
|
|
palette,
|
|
|
|
@ -199,39 +200,43 @@ class TUI(urwid.Frame):
|
|
|
|
self.articleView = RightPane([])
|
|
|
|
self.articleView = RightPane([])
|
|
|
|
self.leftBox = urwid.LineBox(self.feedView, title="Categories")
|
|
|
|
self.leftBox = urwid.LineBox(self.feedView, title="Categories")
|
|
|
|
self.rightBox = urwid.LineBox(self.articleView, title="Articles")
|
|
|
|
self.rightBox = urwid.LineBox(self.articleView, title="Articles")
|
|
|
|
self.container = urwid.Columns(
|
|
|
|
self.views = urwid.Columns(
|
|
|
|
[(40, self.leftBox), self.rightBox])
|
|
|
|
[(40, self.leftBox), self.rightBox])
|
|
|
|
|
|
|
|
self.status = urwid.Text("")
|
|
|
|
|
|
|
|
self.footer = urwid.ListBox([self.status])
|
|
|
|
|
|
|
|
self.container = urwid.Pile([self.views, (1, self.footer)])
|
|
|
|
self.body = self.container
|
|
|
|
self.body = self.container
|
|
|
|
self.articles = []
|
|
|
|
self.articles = []
|
|
|
|
|
|
|
|
|
|
|
|
super().__init__(self.body)
|
|
|
|
super().__init__(self.body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fetchAll(self):
|
|
|
|
|
|
|
|
articles = tui.fetcher.fetch()
|
|
|
|
|
|
|
|
for text in articles:
|
|
|
|
|
|
|
|
self.status.set_text(text)
|
|
|
|
|
|
|
|
tui.loop.entering_idle()
|
|
|
|
|
|
|
|
self.status.set_text("")
|
|
|
|
|
|
|
|
self.loop.event_loop.remove_alarm(self.handle)
|
|
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
item = focus_widget.attr_map[None][0][13:]
|
|
|
|
item = focus_widget.attr_map[None][0][13:]
|
|
|
|
self.fetcher.articlesFromCategory(item, str(focus_widget.attr_map[None][1]))
|
|
|
|
self.fetcher.articlesFromCategory(item, str(focus_widget.attr_map[None][1]))
|
|
|
|
self.articles = tui.fetcher.articles[item]
|
|
|
|
self.articles = tui.fetcher.articles[item]
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
|
|
|
|
self.handle = self.loop.event_loop.alarm(0, self.fetchAll)
|
|
|
|
self.loop.run()
|
|
|
|
self.loop.run()
|
|
|
|
|
|
|
|
tui.loop.event_loop.remove_enter_idle(self.handle)
|
|
|
|
self.executor.shutdown(wait=False)
|
|
|
|
self.executor.shutdown(wait=False)
|
|
|
|
|
|
|
|
|
|
|
|
def unhandled_input(self, key):
|
|
|
|
def unhandled_input(self, key):
|
|
|
|
if key == "tab":
|
|
|
|
if key == "tab":
|
|
|
|
self.activePane = not self.activePane
|
|
|
|
self.activePane = not self.activePane
|
|
|
|
self.container.set_focus(int(self.activePane))
|
|
|
|
self.views.set_focus(int(self.activePane))
|
|
|
|
elif key == "q":
|
|
|
|
elif key == "q":
|
|
|
|
raise urwid.ExitMainLoop()
|
|
|
|
raise urwid.ExitMainLoop()
|
|
|
|
elif key == "r":
|
|
|
|
elif key == "r":
|
|
|
|
olb = urwid.ListBox(urwid.SimpleListWalker([urwid.Text("")]))
|
|
|
|
self.fetchAll()
|
|
|
|
overlay = urwid.Overlay(
|
|
|
|
|
|
|
|
urwid.LineBox(olb),
|
|
|
|
|
|
|
|
self.body, align="center", width=("relative", 50), valign="middle", height=3)
|
|
|
|
|
|
|
|
self.body = overlay
|
|
|
|
|
|
|
|
articles = tui.fetcher.fetch()
|
|
|
|
|
|
|
|
for text in articles:
|
|
|
|
|
|
|
|
olb.body = urwid.SimpleListWalker([urwid.Text(text)])
|
|
|
|
|
|
|
|
tui.loop.entering_idle()
|
|
|
|
|
|
|
|
self.body = overlay.bottom_w
|
|
|
|
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
itemId = focus_widget.attr_map[None][0]
|
|
|
|
itemId = focus_widget.attr_map[None][0]
|
|
|
|
self.articles = tui.fetcher.articles[itemId[13:]]
|
|
|
|
self.articles = tui.fetcher.articles[itemId[13:]]
|
|
|
|
|