Skip to content

Commit

Permalink
attempting to publish v2 docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Dec 1, 2023
1 parent c9465a0 commit 59dcec1
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 151 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and publish API docs

on:
push:
branches: [main]
branches: [main, develop, v2_develop]

jobs:
generate-docs:
Expand Down Expand Up @@ -30,6 +30,8 @@ jobs:
# https://stackoverflow.com/questions/56726429/how-to-run-multiple-commands-in-one-github-actions-docker
run: |
rm ../docs -Recurse -Force -ErrorAction SilentlyContinue
rm ../api -Recurse -Force -ErrorAction SilentlyContinue
$env:DOCFX_SOURCE_BRANCH_NAME="${{ github.ref_name }}""
docfx docfx.json
continue-on-error: false

Expand Down
20 changes: 10 additions & 10 deletions Terminal.Gui/Text/TextFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -929,15 +929,15 @@ public static Rect CalcRect (int x, int y, string text, TextDirection direction
}

/// <summary>
/// Finds the hotkey and its location in text.
/// Finds the hot key and its location in text.
/// </summary>
/// <param name="text">The text to look in.</param>
/// <param name="hotKeySpecifier">The hotkey specifier (e.g. '_') to look for.</param>
/// <param name="firstUpperCase">If <c>true</c> the legacy behavior of identifying the first upper case character as the hotkey will be enabled.
/// <param name="hotKeySpecifier">The hot key specifier (e.g. '_') to look for.</param>
/// <param name="firstUpperCase">If <c>true</c> the legacy behavior of identifying the first upper case character as the hot key will be enabled.
/// Regardless of the value of this parameter, <c>hotKeySpecifier</c> takes precedence.</param>
/// <param name="hotPos">Outputs the Rune index into <c>text</c>.</param>
/// <param name="hotKey">Outputs the hotKey.</param>
/// <returns><c>true</c> if a hotkey was found; <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if a hot key was found; <c>false</c> otherwise.</returns>
public static bool FindHotKey (string text, Rune hotKeySpecifier, bool firstUpperCase, out int hotPos, out Key hotKey)
{
if (string.IsNullOrEmpty (text) || hotKeySpecifier == (Rune)0xFFFF) {
Expand Down Expand Up @@ -996,11 +996,11 @@ public static bool FindHotKey (string text, Rune hotKeySpecifier, bool firstUppe

/// <summary>
/// Replaces the Rune at the index specified by the <c>hotPos</c> parameter with a tag identifying
/// it as the hotkey.
/// it as the hot key.
/// </summary>
/// <param name="text">The text to tag the hotkey in.</param>
/// <param name="hotPos">The Rune index of the hotkey in <c>text</c>.</param>
/// <returns>The text with the hotkey tagged.</returns>
/// <param name="text">The text to tag the hot key in.</param>
/// <param name="hotPos">The Rune index of the hot key in <c>text</c>.</param>
/// <returns>The text with the hot key tagged.</returns>
/// <remarks>
/// The returned string will not render correctly without first un-doing the tag. To undo the tag, search for
/// </remarks>
Expand All @@ -1015,12 +1015,12 @@ public string ReplaceHotKeyWithTag (string text, int hotPos)
}

/// <summary>
/// Removes the hotkey specifier from text.
/// Removes the hot key specifier from text.
/// </summary>
/// <param name="text">The text to manipulate.</param>
/// <param name="hotKeySpecifier">The hot-key specifier (e.g. '_') to look for.</param>
/// <param name="hotPos">Returns the position of the hot-key in the text. -1 if not found.</param>
/// <returns>The input text with the hotkey specifier ('_') removed.</returns>
/// <returns>The input text with the hot key specifier ('_') removed.</returns>
public static string RemoveHotKeySpecifier (string text, int hotPos, Rune hotKeySpecifier)
{
if (string.IsNullOrEmpty (text)) {
Expand Down
15 changes: 15 additions & 0 deletions Terminal.Gui/View/ViewKeyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ public bool TabStop {
/// <para>
/// Overrides must call into the base and return <see langword="true"/> if the base returns <see langword="true"/>.
/// </para>
/// <para>
/// See <see href="/articles/keyboard.html">for an overview of Terminal.Gui keyboard APIs.</see>
/// </para>
/// </remarks>
/// </summary>
/// <param name="keyEvent">Contains the details about the key that produced the event.</param>
Expand Down Expand Up @@ -230,6 +233,9 @@ public virtual bool OnKeyDown (KeyEventArgs keyEvent)
/// <para>
/// Overrides must call into the base and return <see langword="true"/> if the base returns <see langword="true"/>.
/// </para>
/// <para>
/// See <see href="/articles/keyboard.html">for an overview of Terminal.Gui keyboard APIs.</see>
/// </para>
/// </remarks>
/// </summary>
/// <param name="keyEvent">Contains the details about the key that produced the event.</param>
Expand Down Expand Up @@ -268,6 +274,9 @@ public virtual bool OnKeyUp (KeyEventArgs keyEvent)
/// If the view is enabled, processes a key pressed event and returns <see langword="true"/> if the event was handled.
/// <remarks>
/// <para>Calls <see cref="OnKeyPressed(KeyEventArgs)"/> and <see cref="OnInvokeKeyBindings(KeyEventArgs)"/>.</para>
/// <para>
/// See <see href="/articles/keyboard.html">for an overview of Terminal.Gui keyboard APIs.</see>
/// </para>
/// </remarks>
/// </summary>
/// <param name="keyEvent"></param>
Expand Down Expand Up @@ -310,6 +319,9 @@ public bool ProcessKeyPressed (KeyEventArgs keyEvent)
/// Not all terminals support key distinct down/up notifications, Applications should avoid
/// depending on distinct KeyDown and KeyUp events and instead should use <see cref="KeyPressed"/>.
/// </para>
/// <para>
/// See <see href="/articles/keyboard.html">for an overview of Terminal.Gui keyboard APIs.</see>
/// </para>
/// </remarks>
/// </summary>
/// <param name="keyEvent">Contains the details about the key that produced the event.</param>
Expand Down Expand Up @@ -349,6 +361,9 @@ public virtual bool OnKeyPressed (KeyEventArgs keyEvent)
/// <para>
/// Fires the <see cref="InvokingKeyBindings"/> event.
/// </para>
/// <para>
/// See <see href="/articles/keyboard.html">for an overview of Terminal.Gui keyboard APIs.</see>
/// </para>
/// </remarks>
/// </summary>
/// <param name="keyEvent">Contains the details about the key that produced the event.</param>
Expand Down
21 changes: 0 additions & 21 deletions Terminal.Gui/Views/FileDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,27 +485,6 @@ private IFileSystemInfo [] GetFocusedFiles ()
.ToArray ();
}


// /// <inheritdoc/>
// public override bool OnHotKey (KeyEventArgs keyEvent)
// {
//#if BROKE_IN_2927
// // BUGBUG: Ctrl-F is forward in a TextField.
// if (this.NavigateIf (keyEvent, Key.Alt | Key.F, this.tbFind)) {
// return true;
// }
//#endif

// ClearFeedback ();

// if (allowedTypeMenuBar != null &&
// keyEvent.Key == Key.Tab &&
// allowedTypeMenuBar.IsMenuOpen) {
// allowedTypeMenuBar.CloseMenu (false, false, false);
// }

// return base.OnHotKey (keyEvent);
// }
private void RestartSearch ()
{
if (disposed || State?.Directory == null) {
Expand Down
43 changes: 2 additions & 41 deletions Terminal.Gui/Views/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,40 +2079,7 @@ private void ProcessMenu (int i, MenuBarItem mi)
}
SetNeedsDisplay ();
}

/////<inheritdoc/>
//public override bool OnHotKey (KeyEventArgs a)
//{
// if (a.Key == Key) {
// if (Visible && !IsMenuOpen) {
// OpenMenu ();
// } else {
// CloseAllMenus ();
// }
// return true;
// }

// a.Key
// // To ncurses simulate a AltMask key pressing Alt+Space because
// // it can't detect an alone special key down was pressed.
// if (a.Key == Key.AltMask && _openMenu == null) {
// OnKeyDown (a);
// OnKeyUp (a);
// return true;
// } else if (((a.Key & Key.AltMask) != 0) || a.IsAlt && !a.IsCtrl && !a.IsShift) {
// // BUGBUG: Note the test for BOTH AltMask and a.IsAlt above. This is because the
// // unit test Separators_Does_Not_Throws_Pressing_Menu_Shortcut calls
// // menu.OnHotKey(new KeyEventArgs (Key.AltMask | Key.Q))) which does not
// // cause a.IsAlt to be set.
// if (FindAndOpenMenuByHotkey (a)) {
// return true;
// }
// }
// //var kc = a.KeyValue;

// return base.OnHotKey (a);
//}


///<inheritdoc/>
public override bool OnKeyPressed (KeyEventArgs a)
{
Expand Down Expand Up @@ -2232,13 +2199,7 @@ void MoveLeft ()
OpenMenu (_selected);
SetNeedsDisplay ();
}

/////<inheritdoc/>
//public override bool OnColdKey (KeyEventArgs a)
//{
// return FindAndOpenMenuByShortcut (a);
//}


///<inheritdoc/>
public override bool MouseEvent (MouseEvent me)
{
Expand Down
15 changes: 1 addition & 14 deletions Terminal.Gui/Views/Toplevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,20 +468,7 @@ private void QuitToplevel ()
Application.RequestStop ();
}
}

/////<inheritdoc/>
//public override bool OnColdKey (KeyEventArgs keyEvent)
//{
// if (base.OnColdKey (keyEvent)) {
// return true;
// }

// if (ShortcutHelper.FindAndOpenByShortcut (keyEvent, this)) {
// return true;
// }
// return false;
//}


View GetDeepestFocusedSubview (View view)
{
if (view == null) {
Expand Down
108 changes: 54 additions & 54 deletions UnitTests/ConsoleDrivers/ConsoleDriverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,62 +125,62 @@ public void FakeDriver_MockKeyPresses (Type driverType)
Application.Shutdown ();
}

//[Theory]
//[InlineData (typeof (FakeDriver))]
//public void FakeDriver_MockKeyPresses_Press_AfterTimeOut (Type driverType)
//{
// var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
// Application.Init (driver);

// // Simulating pressing of QuitKey after a short period of time
// uint quitTime = 100;
// Func<MainLoop, bool> closeCallback = (MainLoop loop) => {
// // Prove the scenario is using Application.QuitKey correctly
// output.WriteLine ($" {quitTime}ms elapsed; Simulating keypresses...");
// FakeConsole.PushMockKeyPress (Key.F);
// FakeConsole.PushMockKeyPress (Key.U);
// FakeConsole.PushMockKeyPress (Key.C);
// FakeConsole.PushMockKeyPress (Key.K);
// return false;
// };
// output.WriteLine ($"Add timeout to simulate key presses after {quitTime}ms");
// _ = Application.AddTimeout (TimeSpan.FromMilliseconds (quitTime), closeCallback);

// // If Top doesn't quit within abortTime * 5 (500ms), this will force it
// uint abortTime = quitTime * 5;
// Func<MainLoop, bool> forceCloseCallback = (MainLoop loop) => {
// Application.RequestStop ();
// Assert.Fail ($" failed to Quit after {abortTime}ms. Force quit.");
// return false;
// };
// output.WriteLine ($"Add timeout to force quit after {abortTime}ms");
// _ = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), forceCloseCallback);

// Key key = Key.Unknown;

// Application.Top.KeyPress += (e) => {
// key = e.Key;
// output.WriteLine ($" Application.Top.KeyPress: {key}");
// e.Handled = true;

// };

// int iterations = 0;
// Application.Iteration += (s, a) => {
// output.WriteLine ($" iteration {++iterations}");

// if (Console.MockKeyPresses.Count == 0) {
// output.WriteLine ($" No more MockKeyPresses; RequestStop");
// Application.RequestStop ();
// }
// };
[Theory]
[InlineData (typeof (FakeDriver))]
public void FakeDriver_MockKeyPresses_Press_AfterTimeOut (Type driverType)
{
var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
Application.Init (driver);

// Simulating pressing of QuitKey after a short period of time
uint quitTime = 100;
Func<bool> closeCallback = () => {
// Prove the scenario is using Application.QuitKey correctly
output.WriteLine ($" {quitTime}ms elapsed; Simulating keypresses...");
FakeConsole.PushMockKeyPress (Key.F);
FakeConsole.PushMockKeyPress (Key.U);
FakeConsole.PushMockKeyPress (Key.C);
FakeConsole.PushMockKeyPress (Key.K);
return false;
};
output.WriteLine ($"Add timeout to simulate key presses after {quitTime}ms");
_ = Application.AddTimeout (TimeSpan.FromMilliseconds (quitTime), closeCallback);

// If Top doesn't quit within abortTime * 5 (500ms), this will force it
uint abortTime = quitTime * 5;
Func<bool> forceCloseCallback = () => {
Application.RequestStop ();
Assert.Fail ($" failed to Quit after {abortTime}ms. Force quit.");
return false;
};
output.WriteLine ($"Add timeout to force quit after {abortTime}ms");
_ = Application.AddTimeout (TimeSpan.FromMilliseconds (abortTime), forceCloseCallback);

Key key = Key.Unknown;

Application.Top.KeyPressed += (s, e) => {
key = e.Key;
output.WriteLine ($" Application.Top.KeyPressed: {key}");
e.Handled = true;
};

int iterations = 0;
Application.Iteration += (s, a) => {
output.WriteLine ($" iteration {++iterations}");
if (Console.MockKeyPresses.Count == 0) {
output.WriteLine ($" No more MockKeyPresses; RequestStop");
Application.RequestStop ();
}
};

Application.Run ();

// Application.Run ();
// Shutdown must be called to safely clean up Application if Init has been called
Application.Shutdown ();
}

// // Shutdown must be called to safely clean up Application if Init has been called
// Application.Shutdown ();
//}

[Theory]
[InlineData (typeof (FakeDriver))]
[InlineData (typeof (NetDriver))]
Expand Down
9 changes: 1 addition & 8 deletions UnitTests/UICatalog/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,11 @@ public void Run_All_Scenarios ()

// Press QuitKey
Assert.Empty (FakeConsole.MockKeyPresses);
// BUGBUG: (#2474) For some reason ReadKey is not returning the QuitKey for some Scenarios
// by adding this Space it seems to work.
//FakeConsole.PushMockKeyPress (Key.Space);
FakeConsole.PushMockKeyPress (Application.QuitKey);

// The only key we care about is the QuitKey
Application.Top.KeyPressed += (object sender, KeyEventArgs args) => {
output.WriteLine ($" Keypress: {args.Key}");
// BUGBUG: (#2474) For some reason ReadKey is not returning the QuitKey for some Scenarios
// by adding this Space it seems to work.
// See #2474 for why this is commented out
output.WriteLine ($" Keypressed: {args.Key}");
Assert.Equal (Application.QuitKey, args.Key);
};

Expand All @@ -82,7 +76,6 @@ public void Run_All_Scenarios ()
Func<bool> forceCloseCallback = () => {
if (Application.Top.Running && FakeConsole.MockKeyPresses.Count == 0) {
Application.RequestStop ();
// See #2474 for why this is commented out
Assert.Fail ($"'{scenario.GetName ()}' failed to Quit with {Application.QuitKey} after {abortTime}ms. Force quit.");
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/View/NavigationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ public void CanFocus_Sets_To_False_On_Toplevel_Focus_View_On_Another_Toplevel ()

[Fact]
[AutoInitShutdown]
public void ProcessHotKey_Will_Invoke_ProcessKey_Only_For_The_MostFocused_With_Top_KeyPress_Event ()
public void ProcessKeyPressed_Will_Invoke_KeyPressed_Only_For_The_MostFocused_With_Top_KeyPressed_Event ()
{
var sbQuiting = false;
var tfQuiting = false;
Expand Down Expand Up @@ -955,7 +955,7 @@ void Top_KeyPress (object sender, KeyEventArgs obj)

[Fact]
[AutoInitShutdown]
public void ProcessHotKey_Will_Invoke_ProcessKey_Only_For_The_MostFocused_Without_Top_KeyPress_Event ()
public void ProcessKeyPressed_Will_Invoke_KeyPressed_Only_For_The_MostFocused_Without_Top_KeyPressed_Event ()
{
var sbQuiting = false;
var tfQuiting = false;
Expand Down

0 comments on commit 59dcec1

Please sign in to comment.