diff --git a/API.py b/API.py index af1f3fc..ec6ea50 100644 --- a/API.py +++ b/API.py @@ -1,7 +1,6 @@ import requests - class Fetcher: def __init__(self, URL, token): self.URL = URL diff --git a/App.py b/App.py index 19a6c77..5b58699 100644 --- a/App.py +++ b/App.py @@ -171,7 +171,8 @@ class TUI(urwid.Frame): def create(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( tui, palette, @@ -199,39 +200,43 @@ class TUI(urwid.Frame): self.articleView = RightPane([]) self.leftBox = urwid.LineBox(self.feedView, title="Categories") self.rightBox = urwid.LineBox(self.articleView, title="Articles") - self.container = urwid.Columns( + self.views = urwid.Columns( [(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.articles = [] 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): focus_widget, idx = self.feedView.get_focus() item = focus_widget.attr_map[None][0][13:] self.fetcher.articlesFromCategory(item, str(focus_widget.attr_map[None][1])) self.articles = tui.fetcher.articles[item] self.articleView.fill(self.articles) + self.handle = self.loop.event_loop.alarm(0, self.fetchAll) self.loop.run() + tui.loop.event_loop.remove_enter_idle(self.handle) self.executor.shutdown(wait=False) def unhandled_input(self, key): if key == "tab": self.activePane = not self.activePane - self.container.set_focus(int(self.activePane)) + self.views.set_focus(int(self.activePane)) elif key == "q": raise urwid.ExitMainLoop() elif key == "r": - olb = urwid.ListBox(urwid.SimpleListWalker([urwid.Text("")])) - 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 + self.fetchAll() focus_widget, idx = self.feedView.get_focus() itemId = focus_widget.attr_map[None][0] self.articles = tui.fetcher.articles[itemId[13:]] diff --git a/Render.py b/Render.py index bf5ed3c..b73835f 100644 --- a/Render.py +++ b/Render.py @@ -9,6 +9,7 @@ class Article: self.currentPageNumber = 1 terminal_width, terminal_height = os.get_terminal_size() terminal_width -= 60 + terminal_height -= 1 start_of_chunk = 0 end_of_chunk = 0 rows_passed = 0