Fixes #4050. Rename Command.Select and Selecting to Activate/Activating (#4470)

* Initial plan

* Rename Command.Select to Command.Activate and Selecting to Activating

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Add Activating event propagation to SuperView

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Update all comments and docs referencing Select to Activate

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix event log messages in examples to use Activating/Activate

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Revert automatic Activating event propagation that broke tests

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Update docfx documentation to use Activate/Activating terminology

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* renames

* Revert "Add Activating event propagation to SuperView"

This reverts commit 6d82bee9ad.

* added command diagrams

* mermaid

* updated level 3

* again

* Select->Activate in MouseTests.cs

* Update Terminal.Gui/Views/Selectors/FlagSelector.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor: Rename Selecting to Activating in View APIs

Renamed the `Selecting` event and `OnSelecting` method to
`Activating` and `OnActivating` to better reflect their purpose.
Updated all related comments, test method names, variables,
and assertions in `View` and `ViewCommandTests` to align with
the new terminology.

Improved code clarity by using `_` for unused parameters in
lambda expressions. Renamed properties like `HandleSelecting`
to `HandleActivating` and adjusted naming conventions for
consistency (e.g., `OnactivatingCount` to `OnActivatingCount`).

These changes enhance readability, maintainability, and
terminology consistency across the codebase.

* Update Terminal.Gui/Views/Selectors/OptionSelector.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Typos

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot
2025-12-09 12:42:34 -07:00
committed by GitHub
parent b2cf674e0b
commit e7a4df492d
57 changed files with 512 additions and 390 deletions

View File

@@ -106,7 +106,7 @@ public class MouseTests : TestsAllViews
[InlineData (MouseFlags.Button2Clicked)]
[InlineData (MouseFlags.Button3Clicked)]
[InlineData (MouseFlags.Button4Clicked)]
public void WantContinuousButtonPressed_True_Button_Clicked_Raises_Selecting (MouseFlags clicked)
public void WantContinuousButtonPressed_True_Button_Clicked_Raises_Activating (MouseFlags clicked)
{
MouseEventArgs me = new ();
@@ -117,13 +117,13 @@ public class MouseTests : TestsAllViews
WantContinuousButtonPressed = true
};
var selectingCount = 0;
var activatingCount = 0;
view.Selecting += (s, e) => selectingCount++;
view.Activating += (s, e) => activatingCount++;
me.Flags = clicked;
view.NewMouseEvent (me);
Assert.Equal (1, selectingCount);
Assert.Equal (1, activatingCount);
view.Dispose ();

View File

@@ -285,9 +285,9 @@ public class ButtonTests (ITestOutputHelper output)
WantContinuousButtonPressed = true
};
var selectingCount = 0;
var activatingCount = 0;
button.Selecting += (s, e) => selectingCount++;
button.Activating += (s, e) => activatingCount++;
var acceptedCount = 0;
button.Accepting += (s, e) =>
@@ -299,19 +299,19 @@ public class ButtonTests (ITestOutputHelper output)
me = new ();
me.Flags = pressed;
button.NewMouseEvent (me);
Assert.Equal (0, selectingCount);
Assert.Equal (0, activatingCount);
Assert.Equal (0, acceptedCount);
me = new ();
me.Flags = released;
button.NewMouseEvent (me);
Assert.Equal (0, selectingCount);
Assert.Equal (0, activatingCount);
Assert.Equal (0, acceptedCount);
me = new ();
me.Flags = clicked;
button.NewMouseEvent (me);
Assert.Equal (1, selectingCount);
Assert.Equal (1, activatingCount);
Assert.Equal (1, acceptedCount);
button.Dispose ();
@@ -341,23 +341,23 @@ public class ButtonTests (ITestOutputHelper output)
e.Handled = true;
};
var selectingCount = 0;
var activatingCount = 0;
button.Selecting += (s, e) =>
button.Activating += (s, e) =>
{
selectingCount++;
activatingCount++;
e.Handled = true;
};
me.Flags = pressed;
button.NewMouseEvent (me);
Assert.Equal (0, acceptedCount);
Assert.Equal (0, selectingCount);
Assert.Equal (0, activatingCount);
me.Flags = released;
button.NewMouseEvent (me);
Assert.Equal (0, acceptedCount);
Assert.Equal (0, selectingCount);
Assert.Equal (0, activatingCount);
button.Dispose ();
}

View File

@@ -271,10 +271,10 @@ public class CheckBoxTests (ITestOutputHelper output)
ckb.CheckedState = initialState;
ckb.Selecting += OnActivating;
ckb.Activating += OnActivating;
Assert.Equal (initialState, ckb.CheckedState);
bool? ret = ckb.InvokeCommand (Command.Select);
bool? ret = ckb.InvokeCommand (Command.Activate);
Assert.True (ret);
Assert.True (checkedInvoked);
Assert.Equal (initialState, ckb.CheckedState);

View File

@@ -69,9 +69,9 @@ public class ShortcutTests
public void MouseClick_Default_CommandView_Raises_Accepted_Selected_Correctly (
int mouseX,
int expectedCommandViewAccepted,
int expectedCommandViewSelected,
int expectedCommandViewActivated,
int expectedShortcutAccepted,
int expectedShortcutSelected
int expectedShortcutActivated
)
{
Application.Begin (new Runnable<bool> ());
@@ -85,13 +85,13 @@ public class ShortcutTests
var commandViewAcceptCount = 0;
shortcut.CommandView.Accepting += (s, e) => { commandViewAcceptCount++; };
var commandViewSelectCount = 0;
shortcut.CommandView.Selecting += (s, e) => { commandViewSelectCount++; };
var commandViewActivatingCount = 0;
shortcut.CommandView.Activating += (s, e) => { commandViewActivatingCount++; };
var shortcutAcceptCount = 0;
shortcut.Accepting += (s, e) => { shortcutAcceptCount++; };
var shortcutSelectCount = 0;
shortcut.Selecting += (s, e) => { shortcutSelectCount++; };
shortcut.Activating += (s, e) => { shortcutSelectCount++; };
Application.TopRunnableView.Add (shortcut);
Application.TopRunnableView.SetRelativeLayout (new (100, 100));
@@ -105,9 +105,9 @@ public class ShortcutTests
});
Assert.Equal (expectedShortcutAccepted, shortcutAcceptCount);
Assert.Equal (expectedShortcutSelected, shortcutSelectCount);
Assert.Equal (expectedShortcutActivated, shortcutSelectCount);
Assert.Equal (expectedCommandViewAccepted, commandViewAcceptCount);
Assert.Equal (expectedCommandViewSelected, commandViewSelectCount);
Assert.Equal (expectedCommandViewActivated, commandViewActivatingCount);
Application.TopRunnableView.Dispose ();
Application.ResetState (true);
@@ -202,24 +202,24 @@ public class ShortcutTests
var checkboxAccepted = 0;
shortcut.CommandView.Accepting += (s, e) => { checkboxAccepted++; };
var checkboxSelected = 0;
shortcut.CommandView.Selecting += (s, e) =>
var checkboxActivated = 0;
shortcut.CommandView.Activating += (s, e) =>
{
if (e.Handled)
{
return;
}
checkboxSelected++;
checkboxActivated++;
};
Application.TopRunnableView.Add (shortcut);
Application.TopRunnableView.SetRelativeLayout (new (100, 100));
Application.TopRunnableView.LayoutSubViews ();
var selected = 0;
shortcut.Selecting += (s, e) =>
var activatingCount = 0;
shortcut.Activating += (s, e) =>
{
selected++;
activatingCount++;
};
var accepted = 0;
@@ -237,9 +237,9 @@ public class ShortcutTests
});
Assert.Equal (expectedAccepted, accepted);
Assert.Equal (expectedAccepted, selected);
Assert.Equal (expectedAccepted, activatingCount);
Assert.Equal (expectedCheckboxAccepted, checkboxAccepted);
Assert.Equal (expectedCheckboxAccepted, checkboxSelected);
Assert.Equal (expectedCheckboxAccepted, checkboxActivated);
Application.TopRunnableView.Dispose ();
Application.ResetState (true);
@@ -278,7 +278,7 @@ public class ShortcutTests
shortcut.Accepting += (s, e) => accepted++;
var selected = 0;
shortcut.Selecting += (s, e) => selected++;
shortcut.Activating += (s, e) => selected++;
Application.RaiseKeyDownEvent (key);

View File

@@ -3048,7 +3048,7 @@ A B C
dt.Rows.Add (1, 2, 3, 4, 5, 6);
tableView.MultiSelect = true;
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
Point selectedCell = tableView.GetAllSelectedCells ().Single ();
Assert.Equal (0, selectedCell.X);
@@ -3120,7 +3120,7 @@ A B C
dt.Rows.Add (1, 2, 3, 4, 5, 6);
tableView.FullRowSelect = true;
tableView.MultiSelect = true;
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
// Toggle Select Cell 0,0
tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.Space });
@@ -3160,7 +3160,7 @@ A B C
dt.Rows.Add (1, 2, 3, 4, 5, 6);
dt.Rows.Add (1, 2, 3, 4, 5, 6);
tableView.MultiSelect = true;
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
// Make a square selection
tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.ShiftMask | KeyCode.CursorDown });
@@ -3201,7 +3201,7 @@ A B C
dt.Rows.Add (1, 2, 3, 4, 5, 6);
dt.Rows.Add (1, 2, 3, 4, 5, 6);
tableView.MultiSelect = true;
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Select);
tableView.KeyBindings.ReplaceCommands (Key.Space, Command.Activate);
// Make first square selection (0,0 to 1,1)
tableView.NewKeyDownEvent (new () { KeyCode = KeyCode.ShiftMask | KeyCode.CursorDown });