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:
@@ -9,16 +9,20 @@
|
|||||||
<Setter Property="Opacity" Value="0.7" />
|
<Setter Property="Opacity" Value="0.7" />
|
||||||
<Setter Property="Margin" Value="0,6,0,1" />
|
<Setter Property="Margin" Value="0,6,0,1" />
|
||||||
</Style>
|
</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>
|
</Window.Styles>
|
||||||
|
|
||||||
<TabControl Name="Tabs">
|
<TabControl Name="Tabs">
|
||||||
<TabItem Header="Telnet">
|
<TabItem Header="Telnet">
|
||||||
<DockPanel>
|
<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 Name="StateText" FontSize="11" Opacity="0.7" VerticalAlignment="Center" />
|
||||||
<TextBlock Grid.Column="1" Name="PausedText" Text="scrolling paused" FontSize="11"
|
<Button Grid.Column="1" Name="ReconnectButton" Content="Reconnect" Click="OnReconnect" />
|
||||||
Margin="0,0,8,0" IsVisible="False" VerticalAlignment="Center" />
|
|
||||||
<Button Grid.Column="2" Name="ReconnectButton" Content="Reconnect" Click="OnReconnect" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel DockPanel.Dock="Bottom" Margin="8,4,8,8" Spacing="4">
|
<StackPanel DockPanel.Dock="Bottom" Margin="8,4,8,8" Spacing="4">
|
||||||
<WrapPanel Name="ButtonRow" />
|
<WrapPanel Name="ButtonRow" />
|
||||||
@@ -29,8 +33,7 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ListBox Name="Traffic" FontFamily="monospace" FontSize="12" Margin="8,0"
|
<ListBox Name="Traffic" FontFamily="monospace" FontSize="12" Margin="8,0"
|
||||||
DoubleTapped="OnJumpToSpot"
|
DoubleTapped="OnJumpToSpot">
|
||||||
PointerEntered="OnTrafficEntered" PointerExited="OnTrafficExited">
|
|
||||||
<ListBox.ContextMenu>
|
<ListBox.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Jump to this spot" Click="OnJumpToSpot" />
|
<MenuItem Header="Jump to this spot" Click="OnJumpToSpot" />
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ namespace Nonemm.App.Windows;
|
|||||||
/// clicking a spot line puts the radio on it.
|
/// clicking a spot line puts the radio on it.
|
||||||
public sealed partial class TelnetWindow : RefreshableWindow
|
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);
|
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 Action<Frequency, string> tune;
|
||||||
private readonly List<string> history = [];
|
private readonly List<string> history = [];
|
||||||
private int recalled = -1;
|
private int recalled = -1;
|
||||||
private bool paused;
|
private bool scrollPending;
|
||||||
|
|
||||||
public TelnetWindow(AppSession session, Action<Frequency, string> tune)
|
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) =>
|
private void OnConnectionChanged(object? sender, bool connected) =>
|
||||||
Dispatcher.UIThread.Post(Refresh);
|
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(() =>
|
private void Show(string line, IBrush? colour, bool strong = false) => Dispatcher.UIThread.Post(() =>
|
||||||
{
|
{
|
||||||
while (Traffic.Items.Count >= LinesKept)
|
while (Traffic.Items.Count >= LinesKept)
|
||||||
@@ -154,25 +157,16 @@ public sealed partial class TelnetWindow : RefreshableWindow
|
|||||||
Foreground = colour,
|
Foreground = colour,
|
||||||
FontWeight = strong ? FontWeight.Bold : FontWeight.Normal,
|
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
|
private void ScrollToNewest()
|
||||||
/// read or copied while the node keeps sending.
|
|
||||||
private void OnTrafficEntered(object? sender, PointerEventArgs e)
|
|
||||||
{
|
{
|
||||||
paused = true;
|
scrollPending = false;
|
||||||
PausedText.IsVisible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTrafficExited(object? sender, PointerEventArgs e)
|
|
||||||
{
|
|
||||||
paused = false;
|
|
||||||
PausedText.IsVisible = false;
|
|
||||||
if (Traffic.Items.Count > 0)
|
if (Traffic.Items.Count > 0)
|
||||||
{
|
{
|
||||||
Traffic.ScrollIntoView(Traffic.Items.Count - 1);
|
Traffic.ScrollIntoView(Traffic.Items.Count - 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user