From 06e71331b65b34ca1076607b13668683d6d08334 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Tue, 21 Jan 2025 09:54:00 -0800 Subject: [PATCH] select last message when changing channels --- main.py | 2 +- ui/curses_ui.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index b48e12b..a23501b 100644 --- a/main.py +++ b/main.py @@ -3,7 +3,7 @@ ''' Contact - A Console UI for Meshtastic by http://github.com/pdxlocations Powered by Meshtastic.org -V 1.0.1 +V 1.0.3 ''' import curses diff --git a/ui/curses_ui.py b/ui/curses_ui.py index ff30193..6cd30d5 100644 --- a/ui/curses_ui.py +++ b/ui/curses_ui.py @@ -103,8 +103,12 @@ def draw_messages_window(): if max_messages < 1: max_messages = 1 - # Calculate the scroll position based on the current selection + # Set the initial scroll position to the bottom of the list max_scroll_position = max(0, num_messages - max_messages) + + # if globals.selected_message is None or globals.selected_message == 0 or globals.selected_message >= num_messages: + # globals.selected_message = num_messages - 1 # Default to the last message + start_index = max(0, min(globals.selected_message, max_scroll_position)) # Dynamically calculate max_messages based on visible messages and wraps @@ -142,7 +146,6 @@ def draw_messages_window(): messages_win.refresh() draw_packetlog_win() - def draw_node_list(): nodes_win.clear() @@ -169,6 +172,8 @@ def select_channels(direction): elif globals.selected_channel >= channel_list_length: globals.selected_channel = 0 + globals.selected_message = len(globals.all_messages[globals.channel_list[globals.selected_channel]]) - 1 + draw_channel_list() draw_messages_window()