|
|
|
|
@ -116,15 +116,16 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
article = [item for item in tui.fetcher.articles[tui.feedView.currentCategory[13:]] if item["id"] == articleId][0]
|
|
|
|
|
return article
|
|
|
|
|
|
|
|
|
|
def setArticleTitle(self):
|
|
|
|
|
tui.rightBox.set_title(self.article.title + " (" + str(self.article.currentPageNumber) + "/" +
|
|
|
|
|
str(self.article.numberOfPages) + ")")
|
|
|
|
|
|
|
|
|
|
def keypress(self, size, key):
|
|
|
|
|
if key in ("j", "down"):
|
|
|
|
|
if not self.isList:
|
|
|
|
|
if self.chunkNumber >= len(self.article.chunks) - 1:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
self.chunkNumber += 1
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.chunks[self.chunkNumber])])
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.scrollDown())])
|
|
|
|
|
self.body = walker
|
|
|
|
|
self.setArticleTitle()
|
|
|
|
|
item_size = len(self.body)
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
if idx < item_size - 1:
|
|
|
|
|
@ -133,12 +134,9 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
return
|
|
|
|
|
elif key in ("k", "up"):
|
|
|
|
|
if not self.isList:
|
|
|
|
|
if self.chunkNumber == 0:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
self.chunkNumber -= 1
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.chunks[self.chunkNumber])])
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.scrollUp())])
|
|
|
|
|
self.body = walker
|
|
|
|
|
self.setArticleTitle()
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
if idx > 0:
|
|
|
|
|
idx = idx - 1
|
|
|
|
|
@ -152,9 +150,9 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
self.articlePosition = idx
|
|
|
|
|
articleId = focus_widget.attr_map[None]
|
|
|
|
|
self.article = Article(self.getArticle(articleId))
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.chunks[self.chunkNumber])])
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.firstPage)])
|
|
|
|
|
self.body = walker
|
|
|
|
|
tui.rightBox.set_title(self.article.title)
|
|
|
|
|
self.setArticleTitle()
|
|
|
|
|
return
|
|
|
|
|
elif key in ("h", "left"):
|
|
|
|
|
if self.isList is False:
|
|
|
|
|
@ -173,7 +171,7 @@ class TUI(urwid.Frame):
|
|
|
|
|
def create(cls):
|
|
|
|
|
|
|
|
|
|
tui = cls()
|
|
|
|
|
palette = [('header', 'white', 'black'), ('reveal focus', 'black', 'dark cyan', 'standout')]
|
|
|
|
|
palette = [("text", "dark cyan", "dark cyan"), ('header', 'white', 'black'), ('reveal focus', 'black', 'dark cyan', 'standout')]
|
|
|
|
|
loop = urwid.MainLoop(
|
|
|
|
|
tui,
|
|
|
|
|
palette,
|
|
|
|
|
@ -210,10 +208,9 @@ class TUI(urwid.Frame):
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
focus_widget, idx = self.feedView.get_focus()
|
|
|
|
|
itemId = focus_widget.attr_map[None][0]
|
|
|
|
|
number = focus_widget.attr_map[None][1]
|
|
|
|
|
tui.fetcher.articlesFromCategory(itemId[13:], str(number))
|
|
|
|
|
self.articles = tui.fetcher.articles[itemId[13:]]
|
|
|
|
|
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.loop.run()
|
|
|
|
|
self.executor.shutdown(wait=False)
|
|
|
|
|
@ -224,18 +221,21 @@ class TUI(urwid.Frame):
|
|
|
|
|
self.container.set_focus(int(self.activePane))
|
|
|
|
|
elif key == "q":
|
|
|
|
|
raise urwid.ExitMainLoop()
|
|
|
|
|
elif key == "f":
|
|
|
|
|
self.olb = urwid.ListBox(urwid.SimpleListWalker([urwid.Text("TEST")]))
|
|
|
|
|
elif key == "r":
|
|
|
|
|
olb = urwid.ListBox(urwid.SimpleListWalker([urwid.Text("")]))
|
|
|
|
|
overlay = urwid.Overlay(
|
|
|
|
|
urwid.LineBox(self.olb),
|
|
|
|
|
urwid.LineBox(olb),
|
|
|
|
|
self.body, align="center", width=("relative", 50), valign="middle", height=3)
|
|
|
|
|
self.body = overlay
|
|
|
|
|
elif key == "F":
|
|
|
|
|
articles = tui.fetcher.fetch()
|
|
|
|
|
# for text in articles:
|
|
|
|
|
# print(text)
|
|
|
|
|
# self.olb.body = urwid.SimpleListWalker([urwid.Text(text)])
|
|
|
|
|
# self.body = overlay.bottom_w
|
|
|
|
|
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()
|
|
|
|
|
itemId = focus_widget.attr_map[None][0]
|
|
|
|
|
self.articles = tui.fetcher.articles[itemId[13:]]
|
|
|
|
|
self.articleView.fill(self.articles)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tui = TUI.create()
|
|
|
|
|
|