diff --git a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs
new file mode 100644
index 000000000..9c95d2389
--- /dev/null
+++ b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs
@@ -0,0 +1,49 @@
+#nullable enable
+namespace Terminal.Gui;
+
+///
+/// Describes an Ansi escape sequence. This is a 'blueprint'. If you
+/// want to send the sequence you should instead use
+///
+public class AnsiEscapeSequence
+{
+ ///
+ /// Request to send e.g. see
+ ///
+ /// EscSeqUtils.CSI_SendDeviceAttributes.Request
+ ///
+ ///
+ public required string Request { get; init; }
+
+ ///
+ ///
+ /// The terminator that uniquely identifies the type of response as responded
+ /// by the console. e.g. for
+ ///
+ /// EscSeqUtils.CSI_SendDeviceAttributes.Request
+ ///
+ /// the terminator is
+ ///
+ /// EscSeqUtils.CSI_SendDeviceAttributes.Terminator
+ ///
+ /// .
+ ///
+ ///
+ /// After sending a request, the first response with matching terminator will be matched
+ /// to the oldest outstanding request.
+ ///
+ ///
+ public required string Terminator { get; init; }
+
+
+
+ ///
+ /// The value expected in the response e.g.
+ ///
+ /// EscSeqUtils.CSI_ReportTerminalSizeInChars.Value
+ ///
+ /// which will have a 't' as terminator but also other different request may return the same terminator with a
+ /// different value.
+ ///
+ public string? Value { get; init; }
+}
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
index 9b1f6b29e..d2e70ae28 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
@@ -6,47 +6,19 @@ namespace Terminal.Gui;
/// Use to handle the response
/// when console answers the request.
///
-public class AnsiEscapeSequenceRequest
+public class AnsiEscapeSequenceRequest : AnsiEscapeSequence
{
- ///
- /// Request to send e.g. see
- ///
- /// EscSeqUtils.CSI_SendDeviceAttributes.Request
- ///
- ///
- public required string Request { get; init; }
-
- // BUGBUG: Nullable issue
///
/// Invoked when the console responds with an ANSI response code that matches the
- ///
+ ///
///
- public Action ResponseReceived;
+ public required Action ResponseReceived { get; init; }
///
/// Invoked if the console fails to responds to the ANSI response code
///
- public Action? Abandoned;
+ public Action? Abandoned { get; init; }
- ///
- ///
- /// The terminator that uniquely identifies the type of response as responded
- /// by the console. e.g. for
- ///
- /// EscSeqUtils.CSI_SendDeviceAttributes.Request
- ///
- /// the terminator is
- ///
- /// EscSeqUtils.CSI_SendDeviceAttributes.Terminator
- ///
- /// .
- ///
- ///
- /// After sending a request, the first response with matching terminator will be matched
- /// to the oldest outstanding request.
- ///
- ///
- public required string Terminator { get; init; }
///
/// Sends the to the raw output stream of the current .
@@ -55,14 +27,4 @@ public class AnsiEscapeSequenceRequest
///
public void Send () { Application.Driver?.WriteRaw (Request); }
-
- ///
- /// The value expected in the response e.g.
- ///
- /// EscSeqUtils.CSI_ReportTerminalSizeInChars.Value
- ///
- /// which will have a 't' as terminator but also other different request may return the same terminator with a
- /// different value.
- ///
- public string? Value { get; init; }
}
diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
index 43236fa75..38530ff22 100644
--- a/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
+++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
@@ -581,8 +581,7 @@ internal class CursesDriver : ConsoleDriver
private Curses.Window? _window;
private UnixMainLoop? _mainLoopDriver;
- // BUGBUG: Fix this nullable issue.
- private object _processInputToken;
+ private object? _processInputToken;
public override MainLoop Init ()
{
@@ -1111,7 +1110,7 @@ internal class CursesDriver : ConsoleDriver
StopReportingMouseMoves ();
SetCursorVisibility (CursorVisibility.Default);
- if (_mainLoopDriver is { })
+ if (_mainLoopDriver is { } && _processInputToken != null)
{
_mainLoopDriver.RemoveWatch (_processInputToken);
}
diff --git a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs
index 9d145b7a7..5ce2af939 100644
--- a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs
+++ b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs
@@ -1799,7 +1799,7 @@ public static class EscSeqUtils
/// https://terminalguide.namepad.de/seq/csi_sn__p-6/
/// The terminal reply to . ESC [ ? (y) ; (x) ; 1 R
///
- public static readonly AnsiEscapeSequenceRequest CSI_RequestCursorPositionReport = new () { Request = CSI + "?6n", Terminator = "R" };
+ public static readonly AnsiEscapeSequence CSI_RequestCursorPositionReport = new () { Request = CSI + "?6n", Terminator = "R" };
///
/// The terminal reply to . ESC [ ? (y) ; (x) R
@@ -1826,30 +1826,30 @@ public static class EscSeqUtils
/// The terminator indicating a reply to or
///
///
- public static readonly AnsiEscapeSequenceRequest CSI_SendDeviceAttributes = new () { Request = CSI + "0c", Terminator = "c" };
+ public static readonly AnsiEscapeSequence CSI_SendDeviceAttributes = new () { Request = CSI + "0c", Terminator = "c" };
///
/// ESC [ > 0 c - Send Device Attributes (Secondary DA)
/// Windows Terminal v1.18+ emits: "\x1b[>0;10;1c" (vt100, firmware version 1.0, vt220)
///
- public static readonly AnsiEscapeSequenceRequest CSI_SendDeviceAttributes2 = new () { Request = CSI + ">0c", Terminator = "c" };
+ public static readonly AnsiEscapeSequence CSI_SendDeviceAttributes2 = new () { Request = CSI + ">0c", Terminator = "c" };
///
/// CSI 16 t - Request sixel resolution (width and height in pixels)
///
- public static readonly AnsiEscapeSequenceRequest CSI_RequestSixelResolution = new () { Request = CSI + "16t", Terminator = "t" };
+ public static readonly AnsiEscapeSequence CSI_RequestSixelResolution = new () { Request = CSI + "16t", Terminator = "t" };
///
/// CSI 14 t - Request window size in pixels (width x height)
///
- public static readonly AnsiEscapeSequenceRequest CSI_RequestWindowSizeInPixels = new () { Request = CSI + "14t", Terminator = "t" };
+ public static readonly AnsiEscapeSequence CSI_RequestWindowSizeInPixels = new () { Request = CSI + "14t", Terminator = "t" };
///
/// CSI 1 8 t | yes | yes | yes | report window size in chars
/// https://terminalguide.namepad.de/seq/csi_st-18/
/// The terminator indicating a reply to : ESC [ 8 ; height ; width t
///
- public static readonly AnsiEscapeSequenceRequest CSI_ReportTerminalSizeInChars = new () { Request = CSI + "18t", Terminator = "t", Value = "8" };
+ public static readonly AnsiEscapeSequence CSI_ReportTerminalSizeInChars = new () { Request = CSI + "18t", Terminator = "t", Value = "8" };
///
diff --git a/Terminal.Gui/Drawing/Sixel/SixelSupportDetector.cs b/Terminal.Gui/Drawing/Sixel/SixelSupportDetector.cs
index 3a784ce98..d0135fcde 100644
--- a/Terminal.Gui/Drawing/Sixel/SixelSupportDetector.cs
+++ b/Terminal.Gui/Drawing/Sixel/SixelSupportDetector.cs
@@ -127,7 +127,7 @@ public class SixelSupportDetector
() => resultCallback (result));
}
- private static void QueueRequest (AnsiEscapeSequenceRequest req, Action responseCallback, Action abandoned)
+ private static void QueueRequest (AnsiEscapeSequence req, Action responseCallback, Action abandoned)
{
var newRequest = new AnsiEscapeSequenceRequest
{
diff --git a/UICatalog/Scenarios/AnsiRequestsScenario.cs b/UICatalog/Scenarios/AnsiRequestsScenario.cs
index 723a0c6e3..7c98282f6 100644
--- a/UICatalog/Scenarios/AnsiRequestsScenario.cs
+++ b/UICatalog/Scenarios/AnsiRequestsScenario.cs
@@ -104,7 +104,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
}
var selAnsiEscapeSequenceRequestName = scrRequests [cbRequests.SelectedItem];
- AnsiEscapeSequenceRequest selAnsiEscapeSequenceRequest = null;
+ AnsiEscapeSequence selAnsiEscapeSequenceRequest = null;
switch (selAnsiEscapeSequenceRequestName)
{
@@ -157,7 +157,7 @@ public sealed class AnsiEscapeSequenceRequests : Scenario
btnResponse.Accepting += (s, e) =>
{
- var ansiEscapeSequenceRequest = new AnsiEscapeSequenceRequest
+ var ansiEscapeSequenceRequest = new AnsiEscapeSequence
{
Request = tfRequest.Text,
Terminator = tfTerminator.Text,