commit 37feaf1d634655fe2e2136c7d96ab8d5a148e143
parent 27f060230f5fd62aba73fac3df50960055775bfb
Author: luke8086 <55237178+luke8086@users.noreply.github.com>
Date: Mon, 25 Jul 2022 22:32:27 +0000
Initial content for the middle menu
Diffstat:
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/retronews.py b/retronews.py
@@ -611,6 +611,31 @@ def app_render_index(app: AppState) -> None:
app_render_index_row(app, app.layout.index_start + i, app.messages[i + offset])
+def app_render_top_menu(app: AppState) -> None:
+ lt = app.layout
+ cols = lt.cols
+ app.screen.insstr(lt.top_menu_row, 0, KEY_BINDINGS_HELP[:cols].ljust(cols), app.colors.menu | curses.A_BOLD)
+
+
+def app_render_middle_menu(app: AppState) -> None:
+ if (row := app.layout.middle_menu_row) is None:
+ return
+
+ if (message := app.selected_message) is None:
+ return
+
+ if (story_message := app.messages_by_id.get(message.story_id)) is None:
+ return
+
+ cols = app.layout.cols
+ total = story_message.total_comments
+ unread = total - story_message.read_comments
+
+ text = f"--({unread}/{total} unread)--"[:cols].ljust(cols, "-")
+
+ app.screen.insstr(row, 0, text, app.colors.menu | curses.A_BOLD)
+
+
def app_render_bottom_menu(app: AppState) -> None:
lt = app.layout
@@ -628,17 +653,6 @@ def app_render_bottom_menu(app: AppState) -> None:
app.screen.addstr(f"{text} ", attr)
-def app_render_menus(app: AppState) -> None:
- lt = app.layout
-
- app.screen.insstr(lt.top_menu_row, 0, KEY_BINDINGS_HELP[: lt.cols].ljust(lt.cols), app.colors.menu | curses.A_BOLD)
-
- if lt.middle_menu_row is not None:
- app.screen.insstr(lt.middle_menu_row, 0, "middle menu".ljust(lt.cols), app.colors.menu | curses.A_BOLD)
-
- app.screen.insstr(lt.flash_menu_row, 0, app.flash or "")
-
-
def app_update_layout(app: AppState) -> None:
lt = app.layout
@@ -664,8 +678,10 @@ def app_render(app: AppState) -> None:
if app.pager_visible:
app_render_pager(app)
- app_render_menus(app)
+ app_render_top_menu(app)
+ app_render_middle_menu(app)
app_render_bottom_menu(app)
+ app.screen.insstr(app.layout.flash_menu_row, 0, app.flash or "")
app.screen.refresh()