Work QTC traffic on RTTY the way N1MM does

The QTC window put nothing on the air on RTTY except the lines themselves,
so the operator typed the rest into the digital window's transmit pane and
copied the lines by hand. N1MM sends a message for each step and fills the
lines in from a click. Both are here now, with N1MM's messages, N1MM's
defaults and N1MM's settings behind them.

The messages, all of them settings in the QTC window's setup area:

- RX Ready, `WAERXReadyText`, `{ENTERLF}I AM QRV BK`
- All Agn, `WAEAllAgnText`, `{ENTERLF}ALL AGN ALL AGN BK`
- Agn n, `WAEAGNText`, `{ENTERLF}AGN QTC: $ $ $ `, where `$` is the line
- Save, `WAESaveQTCText`, `{ENTERLF}R R R ALL OK BK`
- R U QRV, `WAERUQRVText`, `{ENTERLF}R U QRV BK`
- Save, reading traffic out, `WAESSaveQTCText`, `{ENTERLF}GL DE {MYCALL}`

Each keys the transmitter, sends the text and drops it again, and an empty
one sends nothing. The line spacing default is N1MM's `{ENTERLF}` rather
than `{ENTER}`, which was wrong.

The buttons: R U QRV and Snd Hdr were hidden while reading traffic out on
RTTY, though that is where N1MM starts — R U QRV is the first button
pressed. All Agn is new, and so is the S button on each line, which strikes
a line through a QTC that arrived too broken to read so the rows after it
keep their places; Agn n clears the strike and asks for that line again.

Clicking a line in the digital window fills the next row, which is how the
series is copied on RTTY: the other station sends the header and all ten
lines in one transmission. A click anywhere in a line hands the whole line
to the QTC window, which reads the time, the callsign and the serial number
out of it by shape and flashes the line to show it was taken. A line that is
not a QTC is left to mean what a click always means there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157i7PiZyqBkquxS9A6FTdQ
This commit is contained in:
2026-09-10 20:03:18 +00:00
co-authored by Claude Opus 5
parent e0f307968e
commit f24cab0ae5
11 changed files with 418 additions and 27 deletions
@@ -3,7 +3,9 @@ using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media;
using Avalonia.Threading;
using Avalonia.VisualTree;
using Nonemm.App.Theming;
using Nonemm.Session;
namespace Nonemm.App.Windows;
@@ -229,6 +231,10 @@ public sealed partial class DigitalWindow
RightClick(e);
return;
}
if (TakenAsQtc(e))
{
return;
}
string clicked = e.Source is TextBlock block ? DigitalReceiver.Scrub(block.Text ?? "") : "";
if (clicked.Length == 0)
{
@@ -250,6 +256,51 @@ public sealed partial class DigitalWindow
Copy(clicked, keys.HasFlag(KeyModifiers.Alt), e.ClickCount > 1);
}
/// While the QTC window is taking traffic down on RTTY, a click anywhere in
/// a line hands the whole line to it rather than picking the word out: the
/// other station sends the header and the whole series in one
/// transmission, and the operator clicks each line as it prints. The line
/// flashes to show which one was taken, which is what N1MM does with it.
/// False when there is no QTC window, or the line is not a QTC, and then
/// the click means what it always means.
private bool TakenAsQtc(PointerPressedEventArgs e)
{
if (session.QtcLines is not { } take || LineUnder(e.Source as Visual) is not { } border)
{
return false;
}
string text = DigitalReceiver.Scrub(string.Concat(
Body(border).Children.OfType<TextBlock>().Select(b => b.Text ?? "")));
if (text.Trim().Length == 0 || !take(text))
{
return false;
}
Flash(border);
return true;
}
/// The line a clicked control belongs to: the border a printed line lives
/// in, walking up from whatever was under the pointer.
private static Border? LineUnder(Visual? clicked)
{
for (Visual? at = clicked; at is not null; at = at.GetVisualParent())
{
if (at is Border border && border.Child is WrapPanel)
{
return border;
}
}
return null;
}
/// A moment of colour behind the line that was taken.
private static void Flash(Border border)
{
IBrush was = border.Background ?? Brushes.Transparent;
border.Background = Themes.Brush(Themes.Current.QuickEdit);
DispatcherTimer.RunOnce(() => border.Background = was, TimeSpan.FromMilliseconds(400));
}
/// Where a clicked word goes. N1MM's order: an empty callsign box takes a
/// call, a callsign box that already holds one takes another only onto the
/// call stack or on a double click, and everything else is an exchange
+1
View File
@@ -23,6 +23,7 @@
<TextBox Name="HeaderBox" Width="170" />
<Button Name="ReadyButton" Content="RX Ready" Click="OnReady" />
<Button Name="HeaderAgainButton" Content="Hdr Agn" Click="OnHeaderAgain" />
<Button Name="AllAgainButton" Content="All Agn" Click="OnAllAgain" />
<Button Name="HeaderCfmButton" Content="Cfm" Click="OnHeaderConfirm" />
<Button Name="SendAllButton" Content="Send All" Click="OnSendAll" />
</StackPanel>
+159 -16
View File
@@ -77,7 +77,11 @@ public sealed partial class QtcWindow : Window
Reset();
AddHandler(KeyDownEvent, OnWindowKeyDown, RoutingStrategies.Tunnel);
HeaderBox.LostFocus += (_, _) => ApplyHeaderLimit();
Closed += (_, _) => ShowCall(null);
Closed += (_, _) =>
{
ShowCall(null);
session.QtcLines = null;
};
// focus set before the window is on screen does not stick
Opened += (_, _) => FirstBox().Focus();
}
@@ -112,6 +116,13 @@ public sealed partial class QtcWindow : Window
private bool IsRtty => position.Contest.Modes.Contains(ModeCategory.Digital);
/// Whether this window puts anything on the air. SSB needs a voice keyer
/// and there is none here, so on SSB the operator speaks and the window
/// only writes the traffic down.
private bool Keys => IsCw || IsRtty;
private Settings Settings => session.Settings;
/// The header of the series as it goes out in a message, which is N1MM's
/// `QTC 3/10`. The box shows the station callsign after it on RTTY, and
/// that is for the operator rather than for the air.
@@ -131,15 +142,22 @@ public sealed partial class QtcWindow : Window
/// Everything that follows from which way the traffic goes.
private void Reset()
{
// taking traffic down on RTTY, a line clicked in the digital window
// fills the next row, which is how the series is copied there
session.QtcLines = !isSending && IsRtty ? TakeLine : null;
Title = isSending ? $"Send QTC · {station.Text}" : $"Receive QTC · {station.Text}";
CountsText.Text = traffic.CountsFor(station).Text;
KeysText.Text = KeysLine();
// N1MM's labels: the buttons say what they do in the direction the
// traffic is going, and the ones with nothing to do are hidden
ReadyButton.IsVisible = IsCw || !isSending;
ReadyButton.Content = !IsCw ? "RX Ready" : isSending ? "R U QRV" : "QRV";
HeaderAgainButton.Content = isSending && IsCw ? "Snd Hdr" : "Hdr Agn";
HeaderAgainButton.IsVisible = !isSending || IsCw;
ReadyButton.IsVisible = Keys || !isSending;
ReadyButton.Content = !IsCw ? isSending ? "R U QRV" : "RX Ready"
: isSending ? "R U QRV" : "QRV";
HeaderAgainButton.Content = isSending ? "Snd Hdr" : "Hdr Agn";
HeaderAgainButton.IsVisible = !isSending || Keys;
// N1MM's All Agn, which asks for the whole series again. It is one
// message, so it is RTTY only
AllAgainButton.IsVisible = !isSending && IsRtty;
HeaderCfmButton.IsVisible = !isSending;
// N1MM's Send All, which reads a whole series out in one message. It
// needs the engine to hold the text, so it is RTTY only
@@ -157,7 +175,7 @@ public sealed partial class QtcWindow : Window
Lines.RowDefinitions.Clear();
Lines.Children.Clear();
rows.Clear();
foreach (string width in new[] { "60", "120", "60", "Auto", "Auto" })
foreach (string width in new[] { "60", "120", "60", "Auto", "Auto", "Auto" })
{
Lines.ColumnDefinitions.Add(new ColumnDefinition(
width == "Auto" ? GridLength.Auto : new GridLength(double.Parse(width))));
@@ -174,19 +192,28 @@ public sealed partial class QtcWindow : Window
Margin = new Avalonia.Thickness(2, 1, 2, 1),
};
Button confirm = new() { Content = $"Cfm{at + 1}", Margin = new Avalonia.Thickness(2, 1, 2, 1) };
Button skip = new() { Content = "S", Margin = new Avalonia.Thickness(2, 1, 2, 1) };
int line = at;
again.Click += (_, _) => OnLineAgain(line);
confirm.Click += (_, _) => OnLineConfirm(line);
skip.Click += (_, _) => OnSkip(line);
// nothing to confirm while reading our own log out, which is how
// N1MM hides the column
confirm.IsVisible = !isSending;
// N1MM's skip button, for a line that arrived too broken to read.
// It belongs to the RTTY way of working, where the lines come in
// one transmission and the rows have to stay in step with them
skip.IsVisible = !isSending && IsRtty;
Grid.SetRow(again, at);
Grid.SetColumn(again, 3);
Grid.SetRow(confirm, at);
Grid.SetColumn(confirm, 4);
Grid.SetRow(skip, at);
Grid.SetColumn(skip, 5);
Lines.Children.Add(again);
Lines.Children.Add(confirm);
rows.Add(new Row(time, call, number, again, confirm));
Lines.Children.Add(skip);
rows.Add(new Row(time, call, number, again, confirm, skip));
}
}
@@ -280,6 +307,40 @@ public sealed partial class QtcWindow : Window
Paint();
}
/// A line of received text the operator clicked in the digital window. The
/// header goes in the header box, and a line goes in the first row that is
/// still to come, so the rows stay in step with the series even when a
/// line was skipped. False when the line is not a QTC or there is no room
/// left, and then the digital window treats the click as it always does.
private bool TakeLine(string text)
{
if ((HeaderBox.Text ?? "").Trim().Length == 0
&& QtcTraffic.ReadHeader(text) is not null)
{
HeaderBox.Text = text.Trim().ToUpperInvariant();
ApplyHeaderLimit();
Paint();
return true;
}
if (QtcTraffic.SplitLine(text) is not { } line)
{
return false;
}
for (int at = 0; at < rows.Count && at < activeLines; at++)
{
if (!rows[at].IsEmpty || rows[at].IsStruck)
{
continue;
}
rows[at].Time.Text = line.Time;
rows[at].Call.Text = line.Call;
rows[at].Number.Text = line.Number;
Paint();
return true;
}
return false;
}
/// Narrows the live lines to what the header asks for. `4/5` is series 4
/// with five QTCs in it, so five lines take traffic and the other five are
/// switched off. A station with fewer than five of its ten left gets that
@@ -435,7 +496,13 @@ public sealed partial class QtcWindow : Window
{
_ = send(isSending ? QtcMessages.AreYouReady : QtcMessages.ReadyToReceive);
}
Control next = isSending ? rows[0].Again : rows[0].Time;
else if (IsRtty)
{
_ = send(QtcMessages.Rtty(
isSending ? Settings.QtcRttyAreYouReady : Settings.QtcRttyReady));
}
Control next = isSending ? SendAllButton.IsVisible ? SendAllButton : rows[0].Again
: HeaderBox;
next.Focus();
}
@@ -445,7 +512,9 @@ public sealed partial class QtcWindow : Window
{
if (isSending)
{
_ = send(HeaderBox.Text ?? "");
// the box shows the station callsign after the header on RTTY, and
// that is for the operator rather than for the air
_ = send(IsRtty ? QtcMessages.Rtty(SeriesHeader) : HeaderBox.Text ?? "");
rows[0].Again.Focus();
return;
}
@@ -453,6 +522,10 @@ public sealed partial class QtcWindow : Window
{
_ = send(QtcMessages.HeaderAgain);
}
else if (IsRtty)
{
_ = send(QtcMessages.Rtty(QtcMessages.RttyHeaderAgain));
}
if (session.Settings.QtcHeaderAgainClears)
{
HeaderBox.Text = "";
@@ -462,6 +535,19 @@ public sealed partial class QtcWindow : Window
private void OnHeaderConfirm(object? sender, RoutedEventArgs e) => rows[0].Time.Focus();
/// N1MM's All Agn: asks for the header and every line of the series again,
/// and clears what was taken down so the series can be copied afresh.
private void OnAllAgain(object? sender, RoutedEventArgs e)
{
_ = send(QtcMessages.Rtty(Settings.QtcRttyAllAgain));
foreach (Row row in rows)
{
row.Clear();
}
HeaderBox.Focus();
Paint();
}
/// Ask for a line again: N1MM sends its Agn message and comes back to the
/// line. Here it clears the line and puts the cursor in it.
private void OnLineAgain(int at)
@@ -476,10 +562,27 @@ public sealed partial class QtcWindow : Window
rows[at].Time.Focus();
return;
}
if (session.Settings.QtcAgainClearsLine)
// N1MM asks for the line by number — `AGN QTC: 5 5 5` on RTTY, `AGN
// QTC 5` on CW — and the RTTY message always clears the line, because
// the line is copied again from the top
if (IsRtty)
{
_ = send(QtcMessages.Rtty(
QtcMessages.LineAgain(Settings.QtcRttyLineAgain, at + 1),
Settings.QtcRttySpacing));
rows[at].Clear();
}
else
{
if (IsCw)
{
_ = send($"AGN QTC {at + 1}");
}
if (Settings.QtcAgainClearsLine)
{
rows[at].Clear();
}
}
rows[at].Time.Focus();
Paint();
}
@@ -597,6 +700,19 @@ public sealed partial class QtcWindow : Window
rows.FirstOrDefault(r => r.Time.IsFocused || r.Call.IsFocused || r.Number.IsFocused)
?? rows.FirstOrDefault();
/// N1MM's S button: the line was too broken to read, so it is struck
/// through and the ones after it keep their places. Agn n clears the
/// strike and asks for the line again.
private void OnSkip(int at)
{
rows[at].Skip();
if (at + 1 < rows.Count && at + 1 < activeLines)
{
rows[at + 1].Time.Focus();
}
Paint();
}
private void OnLineConfirm(int at)
{
Control next = at + 1 < rows.Count ? rows[at + 1].Time : CloseButton;
@@ -631,9 +747,17 @@ public sealed partial class QtcWindow : Window
}
}
Save(lines);
if (IsCw && session.Settings.QtcCwTu.Trim().Length > 0)
// N1MM sends a message as the window closes: the TU on CW, and on RTTY
// `R R R ALL OK BK` from the station that took the traffic down or
// `GL DE <call>` from the one that read it out
if (IsCw && Settings.QtcCwTu.Trim().Length > 0)
{
_ = send(QtcMessages.Tu(session.Settings.QtcCwTu, HeaderBox.Text ?? ""));
_ = send(QtcMessages.Tu(Settings.QtcCwTu, HeaderBox.Text ?? ""));
}
else if (IsRtty)
{
_ = send(QtcMessages.Rtty(
isSending ? Settings.QtcRttySendSave : Settings.QtcRttySave));
}
Close(true);
}
@@ -683,12 +807,30 @@ public sealed partial class QtcWindow : Window
TextBox Call,
TextBox Number,
Button Again,
Button Confirm)
Button Confirm,
Button SkipButton)
{
/// The mark a skipped line carries in each of its boxes, which is
/// N1MM's line through the fields.
private const string Struck = "-";
/// A line that was skipped holds nothing worth logging, so it counts
/// as empty: it is not saved, and the window paints it as a line still
/// to come.
public bool IsEmpty =>
(Time.Text ?? "").Trim().Length == 0
&& (Call.Text ?? "").Trim().Length == 0
&& (Number.Text ?? "").Trim().Length == 0;
IsStruck
|| ((Time.Text ?? "").Trim().Length == 0
&& (Call.Text ?? "").Trim().Length == 0
&& (Number.Text ?? "").Trim().Length == 0);
public bool IsStruck => (Time.Text ?? "").Trim() == Struck;
public void Skip()
{
Time.Text = Struck;
Call.Text = Struck;
Number.Text = Struck;
}
/// A null colour is a line that is switched off, which keeps the
/// window's own background rather than any of the three.
@@ -721,6 +863,7 @@ public sealed partial class QtcWindow : Window
Number.IsEnabled = enabled;
Again.IsEnabled = enabled;
Confirm.IsEnabled = enabled;
SkipButton.IsEnabled = enabled;
}
}
}