|
|
|
|
@ -65,9 +65,10 @@ class LeftPane(urwid.ListBox):
|
|
|
|
|
tui.articleView.fill(tui.articles)
|
|
|
|
|
self.setArticlesPaneTitle(attrMap[1])
|
|
|
|
|
|
|
|
|
|
def keypress(self, size, key):
|
|
|
|
|
def keypress(self, size, key): # noqa
|
|
|
|
|
if key in ("j", "down"):
|
|
|
|
|
item_size = len(self.body)
|
|
|
|
|
try:
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
if idx < item_size - 1:
|
|
|
|
|
idx = idx + 1
|
|
|
|
|
@ -78,8 +79,11 @@ class LeftPane(urwid.ListBox):
|
|
|
|
|
self.setCategoryArticles(focus_widget.attr_map[None])
|
|
|
|
|
else:
|
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("k", "up"):
|
|
|
|
|
try:
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
if idx > 0:
|
|
|
|
|
idx = idx - 1
|
|
|
|
|
@ -90,8 +94,11 @@ class LeftPane(urwid.ListBox):
|
|
|
|
|
self.setCategoryArticles(focus_widget.attr_map[None])
|
|
|
|
|
else:
|
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("l", "right"):
|
|
|
|
|
try:
|
|
|
|
|
if self.isCategoryView:
|
|
|
|
|
self.isCategoryView = False
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
@ -103,6 +110,8 @@ class LeftPane(urwid.ListBox):
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
self.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
|
tui.leftBox.set_title(categoryName)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("h", "left"):
|
|
|
|
|
if not self.isCategoryView:
|
|
|
|
|
@ -157,20 +166,26 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
self.body = walker
|
|
|
|
|
self.setArticleTitle()
|
|
|
|
|
item_size = len(self.body)
|
|
|
|
|
try:
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
if idx < item_size - 1:
|
|
|
|
|
idx = idx + 1
|
|
|
|
|
self.set_focus(idx)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("k", "up"):
|
|
|
|
|
if not self.isList:
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.scrollUp())])
|
|
|
|
|
self.body = walker
|
|
|
|
|
self.setArticleTitle()
|
|
|
|
|
try:
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
if idx > 0:
|
|
|
|
|
idx = idx - 1
|
|
|
|
|
self.set_focus(idx)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("r"):
|
|
|
|
|
if self.isList is True:
|
|
|
|
|
@ -186,23 +201,33 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
tui.feedView.setFeedArticles(itemAttrMap)
|
|
|
|
|
if article_idx > 0:
|
|
|
|
|
article_idx -= 1
|
|
|
|
|
try:
|
|
|
|
|
self.set_focus(article_idx)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
tui.categories = tui.cache.getCategories(tui.show_read)
|
|
|
|
|
if tui.feedView.isCategoryView:
|
|
|
|
|
feeds = tui.cache.getCategories(tui.show_read)
|
|
|
|
|
tui.categories = feeds
|
|
|
|
|
feeds = tui.categories
|
|
|
|
|
else:
|
|
|
|
|
feeds = tui.cache.getFeeds(tui.feedView.currentCategory, tui.show_read)
|
|
|
|
|
tui.feedView.fill(feeds, tui.feedView.isCategoryView)
|
|
|
|
|
new_idx = tui.feedView.findById(itemAttrMap[0])
|
|
|
|
|
try:
|
|
|
|
|
tui.feedView.set_focus(new_idx)
|
|
|
|
|
focus_widget, idx = tui.feedView.get_focus()
|
|
|
|
|
if tui.feedView.isCategoryView:
|
|
|
|
|
tui.feedView.currentCategory = focus_widget.attr_map[None][0]
|
|
|
|
|
tui.feedView.setCategoryArticles(focus_widget.attr_map[None])
|
|
|
|
|
else:
|
|
|
|
|
tui.feedView.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
|
try:
|
|
|
|
|
self.set_focus(article_idx)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("l", "right"):
|
|
|
|
|
if self.isList is True:
|
|
|
|
|
self.isList = False
|
|
|
|
|
self.chunkNumber = 0
|
|
|
|
|
try:
|
|
|
|
|
focus_widget, idx = self.get_focus()
|
|
|
|
|
self.articlePosition = idx
|
|
|
|
|
articleId = focus_widget.attr_map[None]
|
|
|
|
|
@ -210,6 +235,8 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
walker = urwid.SimpleListWalker([urwid.Text(self.article.firstPage)])
|
|
|
|
|
self.body = walker
|
|
|
|
|
self.setArticleTitle()
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key in ("c"):
|
|
|
|
|
if self.isList is False:
|
|
|
|
|
@ -218,12 +245,15 @@ class RightPane(urwid.ListBox):
|
|
|
|
|
self.body = walker
|
|
|
|
|
return
|
|
|
|
|
elif key in ("h", "left"):
|
|
|
|
|
try:
|
|
|
|
|
if self.isList is False:
|
|
|
|
|
self.isList = True
|
|
|
|
|
self.fill(tui.articles)
|
|
|
|
|
focusFeed, idx = tui.feedView.get_focus()
|
|
|
|
|
tui.rightBox.set_title(focusFeed.attr_map[None][1])
|
|
|
|
|
self.set_focus(self.articlePosition)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
elif key == "m":
|
|
|
|
|
if self.isList is False and len(self.article.links) > 0:
|
|
|
|
|
@ -383,7 +413,15 @@ class TUI(urwid.Frame):
|
|
|
|
|
else:
|
|
|
|
|
self.feedView.setFeedArticles(focus_widget.attr_map[None])
|
|
|
|
|
self.categories = tui.cache.getCategories(self.show_read)
|
|
|
|
|
self.feedView.fill(self.categories, True)
|
|
|
|
|
feeds = tui.cache.getFeeds(self.feedView.currentCategory, self.show_read)
|
|
|
|
|
if self.feedView.isCategoryView:
|
|
|
|
|
self.feedView.fill(self.categories, self.show_read)
|
|
|
|
|
else:
|
|
|
|
|
self.feedView.fill(feeds, self.show_read)
|
|
|
|
|
try:
|
|
|
|
|
self.feedView.set_focus(idx)
|
|
|
|
|
except BaseException:
|
|
|
|
|
pass
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|