Make the telnet traffic a compact terminal view

Lines were as tall as a list item, with padding of more than the text. A
line is now as tall as its text, the view always follows the newest line
instead of pausing under the pointer, and a burst of lines is scrolled
once. The scrollback is a thousand lines.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 00:46:54 +00:00
co-authored by Claude Sonnet 5.5
parent f336b89c37
commit 476844a9f0
2 changed files with 20 additions and 23 deletions
+9 -6
View File
@@ -9,16 +9,20 @@
<Setter Property="Opacity" Value="0.7" />
<Setter Property="Margin" Value="0,6,0,1" />
</Style>
<!-- the traffic is a terminal: a line is as tall as its text -->
<Style Selector="ListBox#Traffic > ListBoxItem">
<Setter Property="Padding" Value="2,0" />
<Setter Property="MinHeight" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
</Window.Styles>
<TabControl Name="Tabs">
<TabItem Header="Telnet">
<DockPanel>
<Grid DockPanel.Dock="Top" ColumnDefinitions="*,Auto,Auto" Margin="8,6,8,4">
<Grid DockPanel.Dock="Top" ColumnDefinitions="*,Auto" Margin="8,6,8,4">
<TextBlock Name="StateText" FontSize="11" Opacity="0.7" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Name="PausedText" Text="scrolling paused" FontSize="11"
Margin="0,0,8,0" IsVisible="False" VerticalAlignment="Center" />
<Button Grid.Column="2" Name="ReconnectButton" Content="Reconnect" Click="OnReconnect" />
<Button Grid.Column="1" Name="ReconnectButton" Content="Reconnect" Click="OnReconnect" />
</Grid>
<StackPanel DockPanel.Dock="Bottom" Margin="8,4,8,8" Spacing="4">
<WrapPanel Name="ButtonRow" />
@@ -29,8 +33,7 @@
</DockPanel>
</StackPanel>
<ListBox Name="Traffic" FontFamily="monospace" FontSize="12" Margin="8,0"
DoubleTapped="OnJumpToSpot"
PointerEntered="OnTrafficEntered" PointerExited="OnTrafficExited">
DoubleTapped="OnJumpToSpot">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Jump to this spot" Click="OnJumpToSpot" />
+11 -17
View File
@@ -17,7 +17,9 @@ namespace Nonemm.App.Windows;
/// clicking a spot line puts the radio on it.
public sealed partial class TelnetWindow : RefreshableWindow
{
private const int LinesKept = 500;
/// A node can send a spot a second for many hours, so the window keeps
/// the last thousand lines and no more.
private const int LinesKept = 1000;
private static IBrush SpotColour => Themes.Brush(Themes.Current.Multipliers);
@@ -29,7 +31,7 @@ public sealed partial class TelnetWindow : RefreshableWindow
private readonly Action<Frequency, string> tune;
private readonly List<string> history = [];
private int recalled = -1;
private bool paused;
private bool scrollPending;
public TelnetWindow(AppSession session, Action<Frequency, string> tune)
{
@@ -141,7 +143,8 @@ public sealed partial class TelnetWindow : RefreshableWindow
private void OnConnectionChanged(object? sender, bool connected) =>
Dispatcher.UIThread.Post(Refresh);
/// `strong` marks the lines from a preferred spotter.
/// `strong` marks the lines from a preferred spotter. The view stays on the
/// newest line; a burst of lines is scrolled once, after the last of them.
private void Show(string line, IBrush? colour, bool strong = false) => Dispatcher.UIThread.Post(() =>
{
while (Traffic.Items.Count >= LinesKept)
@@ -154,25 +157,16 @@ public sealed partial class TelnetWindow : RefreshableWindow
Foreground = colour,
FontWeight = strong ? FontWeight.Bold : FontWeight.Normal,
});
if (!paused && Traffic.Items.Count > 0)
if (!scrollPending)
{
Traffic.ScrollIntoView(Traffic.Items.Count - 1);
scrollPending = true;
Dispatcher.UIThread.Post(ScrollToNewest, DispatcherPriority.Background);
}
Refresh();
});
/// Scrolling stops while the pointer is over the traffic, so a line can be
/// read or copied while the node keeps sending.
private void OnTrafficEntered(object? sender, PointerEventArgs e)
private void ScrollToNewest()
{
paused = true;
PausedText.IsVisible = true;
}
private void OnTrafficExited(object? sender, PointerEventArgs e)
{
paused = false;
PausedText.IsVisible = false;
scrollPending = false;
if (Traffic.Items.Count > 0)
{
Traffic.ScrollIntoView(Traffic.Items.Count - 1);