From d5788da240913411f274089238eaaa69f24bee9b Mon Sep 17 00:00:00 2001 From: ericek111 Date: Thu, 10 Sep 2026 11:30:07 +0000 Subject: [PATCH] Wipe on Alt+W as well as put the boxes back Alt+W only put the boxes back, so wiping needed Ctrl+W or the button. It now goes both ways, the way N1MM's Wipe button does: with something in the boxes it clears them, and pressed again on empty boxes it puts back what it cleared. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_015NZkFxHde1iifAQemFTHxf --- src/Nonemm.App/Windows/EntryWindow.axaml | 2 +- src/Nonemm.App/Windows/EntryWindow.axaml.cs | 15 +++++---------- src/Nonemm.Session/OperatingPosition.cs | 13 ++++++++++++- .../OperatingPositionTests.cs | 18 +++++++++++++++++- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/Nonemm.App/Windows/EntryWindow.axaml b/src/Nonemm.App/Windows/EntryWindow.axaml index fa14b7c..b6c0c28 100644 --- a/src/Nonemm.App/Windows/EntryWindow.axaml +++ b/src/Nonemm.App/Windows/EntryWindow.axaml @@ -71,7 +71,7 @@ - + diff --git a/src/Nonemm.App/Windows/EntryWindow.axaml.cs b/src/Nonemm.App/Windows/EntryWindow.axaml.cs index 2c1fcc2..81eff16 100644 --- a/src/Nonemm.App/Windows/EntryWindow.axaml.cs +++ b/src/Nonemm.App/Windows/EntryWindow.axaml.cs @@ -390,7 +390,7 @@ public sealed partial class EntryWindow : Window break; case Key.W when e.KeyModifiers.HasFlag(KeyModifiers.Alt): e.Handled = true; - OnRestoreWiped(this, new RoutedEventArgs()); + OnWipeOrRestore(this, new RoutedEventArgs()); break; case Key.L when e.KeyModifiers.HasFlag(KeyModifiers.Control): e.Handled = true; @@ -686,20 +686,15 @@ public sealed partial class EntryWindow : Window Refresh(); } - /// N1MM's Alt+W: the boxes the last wipe cleared are filled in again. With - /// something typed in them there is nowhere to put it back, so the status - /// line says so rather than throwing the typing away. - private void OnRestoreWiped(object? sender, RoutedEventArgs e) + /// N1MM's Alt+W: it wipes the boxes, and pressed again on empty boxes it + /// puts back what it wiped. + private void OnWipeOrRestore(object? sender, RoutedEventArgs e) { if (Logging is null) { return; } - if (!Logging.RestoreWiped()) - { - Status(Logging.Entry.IsEmpty ? "no wiped contact to put back" : "wipe the boxes first"); - return; - } + Logging.WipeOrRestore(); ResetEsm(); SyncBoxes(); boxes[0].Focus(); diff --git a/src/Nonemm.Session/OperatingPosition.cs b/src/Nonemm.Session/OperatingPosition.cs index fca6848..59ccbe8 100644 --- a/src/Nonemm.Session/OperatingPosition.cs +++ b/src/Nonemm.Session/OperatingPosition.cs @@ -448,7 +448,18 @@ public sealed class OperatingPosition ClearEntry(); } - /// N1MM's Alt+W: puts back what the last wipe cleared. False when no wipe + /// N1MM's Alt+W and its Wipe button: one key both ways. With something in + /// the boxes it clears them; with the boxes empty it puts back what the + /// last wipe cleared. + public void WipeOrRestore() + { + if (!RestoreWiped()) + { + Wipe(); + } + } + + /// Puts back what the last wipe cleared. False when no wipe /// has anything to put back, or when the boxes have something in them /// again — N1MM restores into an empty entry only, so nothing typed since /// the wipe is lost. diff --git a/tests/Nonemm.Session.Tests/OperatingPositionTests.cs b/tests/Nonemm.Session.Tests/OperatingPositionTests.cs index 618f381..e34f325 100644 --- a/tests/Nonemm.Session.Tests/OperatingPositionTests.cs +++ b/tests/Nonemm.Session.Tests/OperatingPositionTests.cs @@ -649,7 +649,23 @@ public class OperatingPositionTests public void EmptyBoxesGiveNoProblem() => Assert.Null(Session().EntryProblem()); - /// N1MM's Alt+W: a wipe keeps what was in the boxes and Alt+W puts it back. + /// N1MM's Alt+W goes both ways: it wipes the boxes, and pressed again on + /// empty boxes it puts back what it wiped. + [Fact] + public void AltWWipesAndThenPutsTheBoxesBack() + { + OperatingPosition session = Session(); + Type(session, "JA1XYZ", "25"); + + session.WipeOrRestore(); + Assert.Equal("", session.Entry.Call); + + session.WipeOrRestore(); + Assert.Equal("JA1XYZ", session.Entry.Call); + Assert.Equal("25", session.Entry.ValueOf(ExchangeSlot.Zone)); + } + + /// A wipe keeps what was in the boxes and Alt+W puts it back. [Fact] public void WhatAWipeClearedComesBack() {