Skip to content

Commit

Permalink
Merge pull request #172 from tznind/ansi-parser-net-driver
Browse files Browse the repository at this point in the history
Ansi parser net driver
  • Loading branch information
tznind authored Oct 28, 2024
2 parents 2fa855f + d7183f6 commit 9aff491
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 217 deletions.
6 changes: 6 additions & 0 deletions Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ namespace Terminal.Gui;
/// </remarks>
public abstract class ConsoleDriver
{

/// <summary>
/// How long after Esc has been pressed before we give up on getting an Ansi escape sequence
/// </summary>
internal TimeSpan EscTimeout = TimeSpan.FromMilliseconds (50);

// As performance is a concern, we keep track of the dirty lines and only refresh those.
// This is in addition to the dirty flag on each cell.
internal bool []? _dirtyLines;
Expand Down
12 changes: 12 additions & 0 deletions Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,18 @@ public static ConsoleKeyInfo MapConsoleKeyInfo (ConsoleKeyInfo consoleKeyInfo)

break;
case uint n when n > 0 && n <= KeyEsc:
if (n == KeyEsc)
{
key= ConsoleKey.Escape;

newConsoleKeyInfo = new ConsoleKeyInfo (
consoleKeyInfo.KeyChar,
key,
(consoleKeyInfo.Modifiers & ConsoleModifiers.Shift) != 0,
(consoleKeyInfo.Modifiers & ConsoleModifiers.Alt) != 0,
(consoleKeyInfo.Modifiers & ConsoleModifiers.Control) != 0);
}
else
if (consoleKeyInfo.Key == 0 && consoleKeyInfo.KeyChar == '\r')
{
key = ConsoleKey.Enter;
Expand Down
Loading

0 comments on commit 9aff491

Please sign in to comment.