From 0e590eefed0680a437046cc196e3ae5bf76676a0 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Tue, 29 Aug 2023 22:44:42 +0200 Subject: [PATCH] add pagecount --- hn.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hn.py b/hn.py index 9a9a958..fb8af98 100755 --- a/hn.py +++ b/hn.py @@ -9,6 +9,7 @@ import requests from bs4 import BeautifulSoup as Soup import curses import webbrowser +import math import api @@ -43,6 +44,7 @@ class Client: def set_footer(self, footer): self.screen.addstr(curses.LINES - 1, 0, footer, curses.A_REVERSE) + self.screen.clrtoeol() def draw(self): self.screen.clear() @@ -68,8 +70,6 @@ class Client: link = story.link.replace('https://', '').replace('http://', '') link = link[:max_url_len-1] + "…" if len(link) > max_url_len else link - #text = '{}{} ({})\n'.format(prefix, title, link) - self.screen.addstr(prefix) if i == self.cursor_pos: self.screen.addstr(title, curses.A_UNDERLINE) @@ -79,7 +79,10 @@ class Client: else: self.screen.addstr(title) self.screen.addstr(f' ({link})\n', curses.A_DIM ) - self.set_footer(f'Loaded {len(self.loadedstories)} stories.') + + page = int(self.story_pos / self.stories_in_a_site + 1) + total_pages = math.ceil(len(self.loadedstories)/self.stories_in_a_site) + self.set_footer(f'Page {page}/{total_pages}, loaded {len(self.loadedstories)} stories.') def handle_input(self): c = self.screen.getch()