Skip to content

Fixes #4730. AnsiDriver will only capture Ctrl+Z if we move the mouse in Windows.#4731

Open
BDisp wants to merge 18 commits intogui-cs:v2_developfrom
BDisp:v2_4730_ansidriver-ctrl-z-fix
Open

Fixes #4730. AnsiDriver will only capture Ctrl+Z if we move the mouse in Windows.#4731
BDisp wants to merge 18 commits intogui-cs:v2_developfrom
BDisp:v2_4730_ansidriver-ctrl-z-fix

Conversation

@BDisp
Copy link
Collaborator

@BDisp BDisp commented Feb 19, 2026

Fixes

Proposed Changes/Todos

  • Use the native ReadConsoleInput instead of ReadFile
  • Still supports VT sequences for key and mouse
  • Removed any dotnet System.Console calls

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@BDisp BDisp requested a review from tig as a code owner February 19, 2026 21:50
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 17.96117% with 169 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.16%. Comparing base (bf59dbc) to head (4a21473).

Files with missing lines Patch % Lines
...minal.Gui/Drivers/UnixDriver/UnixTerminalHelper.cs 11.76% 73 Missing and 2 partials ⚠️
...minal.Gui/Drivers/AnsiDriver/AnsiTerminalHelper.cs 13.95% 36 Missing and 1 partial ⚠️
....Gui/Drivers/WindowsDriver/WindowsVTInputHelper.cs 0.00% 36 Missing ⚠️
Terminal.Gui/Drivers/DotNetDriver/NetOutput.cs 37.03% 15 Missing and 2 partials ⚠️
Terminal.Gui/Drivers/AnsiDriver/AnsiInput.cs 33.33% 1 Missing and 1 partial ⚠️
Terminal.Gui/Drivers/AnsiDriver/AnsiOutput.cs 50.00% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (17.96%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff               @@
##           v2_develop    #4731      +/-   ##
==============================================
- Coverage       77.62%   72.16%   -5.46%     
==============================================
  Files             461      463       +2     
  Lines           46088    46255     +167     
  Branches         6835     6856      +21     
==============================================
- Hits            35774    33381    -2393     
- Misses           8320    10817    +2497     
- Partials         1994     2057      +63     
Files with missing lines Coverage Δ
Terminal.Gui/App/Keyboard/KeyboardImpl.cs 83.75% <100.00%> (-1.53%) ⬇️
Terminal.Gui/Drivers/DriverImpl.cs 78.51% <100.00%> (+7.77%) ⬆️
Terminal.Gui/Drivers/UnixDriver/UnixOutput.cs 73.75% <100.00%> (+0.33%) ⬆️
...erminal.Gui/Drivers/WindowsDriver/WindowsOutput.cs 37.35% <100.00%> (+0.36%) ⬆️
Terminal.Gui/Drivers/AnsiDriver/AnsiInput.cs 20.58% <33.33%> (+1.03%) ⬆️
Terminal.Gui/Drivers/AnsiDriver/AnsiOutput.cs 40.25% <50.00%> (+0.39%) ⬆️
Terminal.Gui/Drivers/DotNetDriver/NetOutput.cs 49.57% <37.03%> (-3.77%) ⬇️
....Gui/Drivers/WindowsDriver/WindowsVTInputHelper.cs 0.00% <0.00%> (ø)
...minal.Gui/Drivers/AnsiDriver/AnsiTerminalHelper.cs 13.95% <13.95%> (ø)
...minal.Gui/Drivers/UnixDriver/UnixTerminalHelper.cs 11.76% <11.76%> (ø)

... and 108 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf59dbc...4a21473. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BDisp
Copy link
Collaborator Author

BDisp commented Feb 25, 2026

To test pressing Ctrl+Z to suspend the app using WSL, we have to open the respective distro first and run the app. Debugging WSL through the IDE doesn't work.

@BDisp
Copy link
Collaborator Author

BDisp commented Feb 25, 2026

Hey @tig, could you run the unit tests on your Mac? I've run them on an Intel Mac and didn't get any errors, but there might be some incompatibility with the ARM64. It could also just be a conditional failure, but I'd appreciate it if you could confirm that, just to be sure. Thanks.

@BDisp
Copy link
Collaborator Author

BDisp commented Mar 1, 2026

Should this glyph appear by default now? Isn't the idea to avoid displaying glyphs that might constantly change in unit tests?

 Expected:
 ┌────────────────────────────────────────────────────────────────────┐
 │   ╔═══════════════════════════════════════════════════════════╗    │
 │   ║UI Catalog: A comprehensive sample library and test app for║    │
 │   ║                                                           ║    │
 │   ║ _______                  _             _   _____       _  ║    │
 │   ║|__   __|                (_)           | | / ____|     (_) ║    │
 │   ║   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ║    │
 │   ║   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ║    │
 │   ║   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ║    │
 │   ║   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ║    │
 │   ║                                                           ║    │
 │   ║                      v2 - Pre-Alpha                       ║    │
 │   ║                                                           ║    │
 │   ║          https://github.com/gui-cs/Terminal.Gui?target=https://github.com           ║    │
 │   ║                                                           ║    │
 │   ║                                                   ⟦► OK ◄⟧║    │
 │   ╚═══════════════════════════════════════════════════════════╝    │
 └────────────────────────────────────────────────────────────────────┘
  But Was:
 ┌⡿───────────────────────────────────────────────────────────────────┐
 │   ╔⢿══════════════════════════════════════════════════════════╗    │
 │   ║UI Catalog: A comprehensive sample library and test app for║    │
 │   ║                                                           ║    │
 │   ║ _______                  _             _   _____       _  ║    │
 │   ║|__   __|                (_)           | | / ____|     (_) ║    │
 │   ║   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ║    │
 │   ║   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ║    │
 │   ║   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ║    │
 │   ║   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ║    │
 │   ║                                                           ║    │
 │   ║                      v2 - Pre-Alpha                       ║    │
 │   ║                                                           ║    │
 │   ║          https://github.com/gui-cs/Terminal.Gui?target=https://github.com           ║    │
 │   ║                                                           ║    │
 │   ║                                                   ⟦► OK ◄⟧║    │
 │   ╚═══════════════════════════════════════════════════════════╝    │
 └────────────────────────────────────────────────────────────────────┘

@tig
Copy link
Collaborator

tig commented Mar 1, 2026

Should this glyph appear by default now? Isn't the idea to avoid displaying glyphs that might constantly change in unit tests?

 Expected:
 ┌────────────────────────────────────────────────────────────────────┐
 │   ╔═══════════════════════════════════════════════════════════╗    │
 │   ║UI Catalog: A comprehensive sample library and test app for║    │
 │   ║                                                           ║    │
 │   ║ _______                  _             _   _____       _  ║    │
 │   ║|__   __|                (_)           | | / ____|     (_) ║    │
 │   ║   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ║    │
 │   ║   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ║    │
 │   ║   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ║    │
 │   ║   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ║    │
 │   ║                                                           ║    │
 │   ║                      v2 - Pre-Alpha                       ║    │
 │   ║                                                           ║    │
 │   ║          https://github.com/gui-cs/Terminal.Gui?target=https://github.com           ║    │
 │   ║                                                           ║    │
 │   ║                                                   ⟦► OK ◄⟧║    │
 │   ╚═══════════════════════════════════════════════════════════╝    │
 └────────────────────────────────────────────────────────────────────┘
  But Was:
 ┌⡿───────────────────────────────────────────────────────────────────┐
 │   ╔⢿══════════════════════════════════════════════════════════╗    │
 │   ║UI Catalog: A comprehensive sample library and test app for║    │
 │   ║                                                           ║    │
 │   ║ _______                  _             _   _____       _  ║    │
 │   ║|__   __|                (_)           | | / ____|     (_) ║    │
 │   ║   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _  ║    │
 │   ║   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | | ║    │
 │   ║   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | | ║    │
 │   ║   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_| ║    │
 │   ║                                                           ║    │
 │   ║                      v2 - Pre-Alpha                       ║    │
 │   ║                                                           ║    │
 │   ║          https://github.com/gui-cs/Terminal.Gui?target=https://github.com           ║    │
 │   ║                                                           ║    │
 │   ║                                                   ⟦► OK ◄⟧║    │
 │   ╚═══════════════════════════════════════════════════════════╝    │
 └────────────────────────────────────────────────────────────────────┘

SOme recent PR is somehow setting DrawIndicator in a unit test or something. This is the 2nd time i've seen this.

@BDisp
Copy link
Collaborator Author

BDisp commented Mar 1, 2026

Fixed in #4777.

@BDisp
Copy link
Collaborator Author

BDisp commented Mar 1, 2026

That's a good reason to remove System.Console from the other drivers, except for DotNetDriver which is based on it.

@BDisp
Copy link
Collaborator Author

BDisp commented Mar 1, 2026

I'm getting the same error related to the glyph. Could it be related to some static object that isn't reset in each unit test?

Actual:   "┌⣻┐\n│h│\n│ │\n│╭►\n│⣻ "
            ↑ (pos 1)
  Stack Trace:
     at UnitTests.DriverAssert.AssertDriverContentsWithFrameAre(String expectedLook, ITestOutputHelper output, IDriver driver) in /home/runner/work/Terminal.Gui/Terminal.Gui/Tests/UnitTests/DriverAssert.cs:line 459
   at UnitTests.ViewsTests.TabViewTests.ShowTopLine_False_TabsOnBottom_True_TestTabView_Width3() in /home/runner/work/Terminal.Gui/Terminal.Gui/Tests/UnitTests/Views/TabViewTests.cs:line 746
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  Standard Output Messages:
 Expected:
 ┌─┐
 │h│
 │ │
 │╭►
 ││ 
  But Was:
 ┌⣻┐
 │h│
 │ │
 │╭►
 │⣻ 

@BDisp
Copy link
Collaborator Author

BDisp commented Mar 1, 2026

I think we should make an effort to move and update all unit tests in the UnitTests project to the UnitTests.Parallelizable project. I suspect there's some static configuration that sporadically uses the spinner feature that isn't explicitly disabled, and some unit test is using it even if don't want it to.

@tig
Copy link
Collaborator

tig commented Mar 1, 2026

I think we should make an effort to move and update all unit tests in the UnitTests project to the UnitTests.Parallelizable project. I suspect there's some static configuration that sporadically uses the spinner feature that isn't explicitly disabled, and some unit test is using it even if don't want it to.

Do you have any idea how much time I've put into moving tests? Of course we should.

I noted above that glyph is the drawindicator. Some recent pr is somehow setting View.DrawIndicator or something else is corrupting it.

@tig
Copy link
Collaborator

tig commented Mar 2, 2026

Found it.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnsiDriver will only capture Ctrl+Z if we move the mouse in Windows.

2 participants