Skip to content

Commit ea037e1

Browse files
chore(keysequences): organize docs and tests
1 parent 6249f8d commit ea037e1

13 files changed

Lines changed: 718 additions & 499 deletions

Examples/UICatalog/Scenarios/KeySequencesDemo.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,16 @@ public override void Main ()
6767
ConfigurationManager.Enable (ConfigLocations.All);
6868
using IApplication app = Application.Create ();
6969
app.Init ();
70+
app.Keyboard.KeyBindings.Remove (Key.Esc);
7071

7172
using Window window = new ()
7273
{
73-
Title = GetQuitKeyAndName ()
74+
Title = "Key Sequences - :q to Quit"
7475
};
7576

7677
Label title = new ()
7778
{
78-
Text = "Command mode: ; enters, i exits",
79+
Text = "Command mode: Esc enters, i exits, :q quits",
7980
X = 0,
8081
Y = 0
8182
};
@@ -115,23 +116,24 @@ public override void Main ()
115116
window.Add (title, commands, editor, logView);
116117

117118
AddLog ("Focus is on the editor.");
118-
AddLog ("Press ; once to enter command mode.");
119+
AddLog ("Press Esc once to enter command mode.");
119120
AddLog ("Motions: h/j/k/l, 4 j, w, b, 0, $, g g, G, Ctrl+B/F");
120121
AddLog ("Selection: v h/j/k/l/w/b/0/$/g g/G/Ctrl+B/Ctrl+F");
121122
AddLog ("Edit: d d, 3 d d, y y, v y, v c, p, x, X, u, Ctrl+R");
122-
AddLog ("Press i to return to normal editing.");
123+
AddLog ("Press i to return to normal editing. Press : q to quit.");
123124

124125
using IDisposable registration = editor.UseKeySequences (
125126
bindings =>
126127
{
127128
bindings.Mode = KeySequenceMode.Persistent;
128-
bindings.EnterModeKey = ';';
129+
bindings.EnterModeKey = Key.Esc;
129130
bindings.ExitModeKey = 'i';
130131
bindings.Timeout = TimeSpan.FromSeconds (5);
131132

132133
AddMotionBindings (bindings, editor);
133134
AddSelectionBindings (bindings, editor);
134135
AddEditingBindings (bindings, editor);
136+
AddQuitBinding (bindings, app);
135137

136138
bindings.StateChanged += (_, e) =>
137139
{
@@ -224,6 +226,16 @@ private void AddEditingBindings (KeySequenceBindings bindings, Editor editor)
224226
AddCountedLineCommand (bindings, editor, "<count> y y", Command.Copy, "y y");
225227
}
226228

229+
private void AddQuitBinding (KeySequenceBindings bindings, IApplication app)
230+
{
231+
bindings.AddMode (": q", context =>
232+
{
233+
AddLog ($"{FormatSequence (context)} -> quit");
234+
app.RequestStop ();
235+
return true;
236+
});
237+
}
238+
227239
private void AddRepeatedCommand (KeySequenceBindings bindings, Editor editor, string pattern, Command command, string display)
228240
{
229241
bindings.AddMode (pattern, context =>

Terminal.Gui.KeySequences/README.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

Terminal.Gui.KeySequences/Terminal.Gui.KeySequences.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121
<ItemGroup>
2222
<ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
2323
</ItemGroup>
24+
25+
<ItemGroup>
26+
<Compile Remove="Tests\**\*.cs" />
27+
</ItemGroup>
2428
</Project>

Terminal.Gui.KeySequences.Tests/KeySequenceBindingsTests.cs renamed to Terminal.Gui.KeySequences/Tests/KeySequenceBindingsTests.cs

File renamed without changes.

Terminal.Gui.KeySequences.Tests/KeySequenceParserTests.cs renamed to Terminal.Gui.KeySequences/Tests/KeySequenceParserTests.cs

File renamed without changes.

Terminal.Gui.KeySequences.Tests/Terminal.Gui.KeySequences.Tests.csproj renamed to Terminal.Gui.KeySequences/Tests/Terminal.Gui.KeySequences.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\Terminal.Gui.KeySequences\Terminal.Gui.KeySequences.csproj" />
21-
<ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
20+
<ProjectReference Include="..\Terminal.Gui.KeySequences.csproj" />
21+
<ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />
2222
</ItemGroup>
2323

2424
<ItemGroup>

Terminal.Gui.KeySequences.Tests/ViewKeySequenceExtensionTests.cs renamed to Terminal.Gui.KeySequences/Tests/ViewKeySequenceExtensionTests.cs

File renamed without changes.

0 commit comments

Comments
 (0)