|
|
|
@ -94,6 +94,18 @@ class Client:
|
|
|
|
|
footer_text = footer_text[:self.cols - 1]
|
|
|
|
|
self.set_footer(footer_text)
|
|
|
|
|
|
|
|
|
|
def page_up(self):
|
|
|
|
|
# scroll up a page (:
|
|
|
|
|
self.cursor_pos = self.stories_in_a_site-1
|
|
|
|
|
self.story_pos -= self.stories_in_a_site
|
|
|
|
|
self.story_pos = 0 if self.story_pos < 0 else self.story_pos
|
|
|
|
|
|
|
|
|
|
async def page_down(self):
|
|
|
|
|
# scroll up down a page :)
|
|
|
|
|
self.cursor_pos = 0
|
|
|
|
|
self.story_pos += self.stories_in_a_site
|
|
|
|
|
await self.load_more_if_needed()
|
|
|
|
|
|
|
|
|
|
async def handle_input(self):
|
|
|
|
|
c = self.screen.getch()
|
|
|
|
|
story = self.loadedstories[self.topstories[self.story_pos + self.cursor_pos]]
|
|
|
|
@ -104,18 +116,18 @@ class Client:
|
|
|
|
|
elif c == curses.KEY_UP or c == ord('k'):
|
|
|
|
|
self.cursor_pos -= 1
|
|
|
|
|
if self.cursor_pos < 0:
|
|
|
|
|
self.cursor_pos = self.stories_in_a_site-1
|
|
|
|
|
# scroll up a page (:
|
|
|
|
|
self.story_pos -= self.stories_in_a_site
|
|
|
|
|
self.story_pos = 0 if self.story_pos < 0 else self.story_pos
|
|
|
|
|
self.page_up()
|
|
|
|
|
|
|
|
|
|
elif c == curses.KEY_DOWN or c == ord('j'):
|
|
|
|
|
self.cursor_pos += 1
|
|
|
|
|
if self.cursor_pos >= self.stories_in_a_site:
|
|
|
|
|
self.cursor_pos = 0
|
|
|
|
|
# scroll up down a page :)
|
|
|
|
|
self.story_pos += self.stories_in_a_site
|
|
|
|
|
await self.load_more_if_needed()
|
|
|
|
|
await self.page_down()
|
|
|
|
|
|
|
|
|
|
elif c == curses.KEY_NPAGE:
|
|
|
|
|
await self.page_down()
|
|
|
|
|
|
|
|
|
|
elif c == curses.KEY_PPAGE:
|
|
|
|
|
self.page_up()
|
|
|
|
|
|
|
|
|
|
elif c == ord('c'):
|
|
|
|
|
# open comments
|
|
|
|
|