diff --git a/Terminal.Gui/Application/Application.Initialization.cs b/Terminal.Gui/Application/Application.Initialization.cs
index d23f4f49c8..923b1534d5 100644
--- a/Terminal.Gui/Application/Application.Initialization.cs
+++ b/Terminal.Gui/Application/Application.Initialization.cs
@@ -7,7 +7,7 @@ namespace Terminal.Gui;
public static partial class Application // Initialization (Init/Shutdown)
{
- /// Initializes a new instance of Application.
+ /// Initializes a new instance of a Terminal.Gui Application. must be called when the application is closing.
/// Call this method once per instance (or after has been called).
///
/// This function loads the right for the platform, Creates a . and
diff --git a/Terminal.Gui/Application/Application.Run.cs b/Terminal.Gui/Application/Application.Run.cs
index 5bfa5f2cc6..b929cce4ad 100644
--- a/Terminal.Gui/Application/Application.Run.cs
+++ b/Terminal.Gui/Application/Application.Run.cs
@@ -71,7 +71,7 @@ public static Key ArrangeKey
/// The to prepare execution for.
///
/// This method prepares the provided for running with the focus, it adds this to the list
- /// of s, lays out the Subviews, focuses the first element, and draws the
+ /// of s, lays out the SubViews, focuses the first element, and draws the
/// in the screen. This is usually followed by executing the method, and then the
/// method upon termination which will undo these changes.
///
diff --git a/Terminal.Gui/Application/ApplicationNavigation.cs b/Terminal.Gui/Application/ApplicationNavigation.cs
index 1fe6972eae..f351b515d6 100644
--- a/Terminal.Gui/Application/ApplicationNavigation.cs
+++ b/Terminal.Gui/Application/ApplicationNavigation.cs
@@ -33,7 +33,7 @@ public ApplicationNavigation ()
}
///
- /// Gets whether is in the Subview hierarchy of .
+ /// Gets whether is in the SubView hierarchy of .
///
///
///
@@ -50,7 +50,7 @@ public static bool IsInHierarchy (View? start, View? view)
return true;
}
- foreach (View subView in start.Subviews)
+ foreach (View subView in start.SubViews)
{
if (view == subView)
{
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs
index 9c95d23896..40b891c73d 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequence.cs
@@ -33,7 +33,7 @@ public class AnsiEscapeSequence
/// to the oldest outstanding request.
///
///
- public required string Terminator { get; init; }
+ public required string? Terminator { get; init; }
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
index 4b872ab626..3bffbbb7c7 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiEscapeSequenceRequest.cs
@@ -12,7 +12,7 @@ public class AnsiEscapeSequenceRequest : AnsiEscapeSequence
/// Invoked when the console responds with an ANSI response code that matches the
///
///
- public required Action ResponseReceived { get; init; }
+ public required Action ResponseReceived { get; init; }
///
/// Invoked if the console fails to responds to the ANSI response code
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs
index 5ae29060bf..83c6c41817 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiMouseParser.cs
@@ -17,11 +17,11 @@ public class AnsiMouseParser
///
///
///
- public bool IsMouse (string cur)
+ public bool IsMouse (string? cur)
{
// Typically in this format
// ESC [ < {button_code};{x_pos};{y_pos}{final_byte}
- return cur.EndsWith ('M') || cur.EndsWith ('m');
+ return cur!.EndsWith ('M') || cur.EndsWith ('m');
}
///
@@ -30,10 +30,10 @@ public bool IsMouse (string cur)
///
///
///
- public MouseEventArgs? ProcessMouseInput (string input)
+ public MouseEventArgs? ProcessMouseInput (string? input)
{
// Match mouse wheel events first
- Match match = _mouseEventPattern.Match (input);
+ Match match = _mouseEventPattern.Match (input!);
if (match.Success)
{
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs
index aec693de55..6b30b3d10e 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs
@@ -108,7 +108,7 @@ private bool SendOrSchedule (AnsiEscapeSequenceRequest request, bool addToQueue)
private void EvictStaleRequests ()
{
- foreach (string stale in _lastSend.Where (v => IsStale (v.Value)).Select (k => k.Key))
+ foreach (string? stale in _lastSend.Where (v => IsStale (v.Value)).Select (k => k.Key))
{
EvictStaleRequests (stale);
}
@@ -123,9 +123,9 @@ private void EvictStaleRequests ()
///
///
///
- private bool EvictStaleRequests (string withTerminator)
+ private bool EvictStaleRequests (string? withTerminator)
{
- if (_lastSend.TryGetValue (withTerminator, out DateTime dt))
+ if (_lastSend.TryGetValue (withTerminator!, out DateTime dt))
{
if (IsStale (dt))
{
@@ -178,7 +178,7 @@ public bool RunSchedule (bool force = false)
private void Send (AnsiEscapeSequenceRequest r)
{
- _lastSend.AddOrUpdate (r.Terminator, _ => Now (), (_, _) => Now ());
+ _lastSend.AddOrUpdate (r.Terminator!, _ => Now (), (_, _) => Now ());
_parser.ExpectResponse (r.Terminator, r.ResponseReceived, r.Abandoned, false);
r.Send ();
}
@@ -206,7 +206,7 @@ private bool CanSend (AnsiEscapeSequenceRequest r, out ReasonCannotSend reason)
private bool ShouldThrottle (AnsiEscapeSequenceRequest r)
{
- if (_lastSend.TryGetValue (r.Terminator, out DateTime value))
+ if (_lastSend.TryGetValue (r.Terminator!, out DateTime value))
{
return Now () - value < _throttle;
}
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseExpectation.cs b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseExpectation.cs
index 00aa1a9512..c66f111839 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseExpectation.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseExpectation.cs
@@ -1,7 +1,7 @@
#nullable enable
namespace Terminal.Gui;
-internal record AnsiResponseExpectation (string Terminator, Action Response, Action? Abandoned)
+internal record AnsiResponseExpectation (string? Terminator, Action Response, Action? Abandoned)
{
- public bool Matches (string cur) { return cur.EndsWith (Terminator); }
+ public bool Matches (string? cur) { return cur!.EndsWith (Terminator!); }
}
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs
index 93d2bbeb9a..4c6656de85 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs
@@ -6,12 +6,32 @@ namespace Terminal.Gui;
internal abstract class AnsiResponseParserBase : IAnsiResponseParser
{
- private const char Escape = '\x1B';
+ private const char ESCAPE = '\x1B';
private readonly AnsiMouseParser _mouseParser = new ();
+#pragma warning disable IDE1006 // Naming Styles
protected readonly AnsiKeyboardParser _keyboardParser = new ();
protected object _lockExpectedResponses = new ();
protected object _lockState = new ();
+ protected readonly IHeld _heldContent;
+
+ ///
+ /// Responses we are expecting to come in.
+ ///
+ protected readonly List _expectedResponses = [];
+
+ ///
+ /// Collection of responses that we .
+ ///
+ protected readonly List _lateResponses = [];
+
+ ///
+ /// Responses that you want to look out for that will come in continuously e.g. mouse events.
+ /// Key is the terminator.
+ ///
+ protected readonly List _persistentExpectations = [];
+
+#pragma warning restore IDE1006 // Naming Styles
///
/// Event raised when mouse events are detected - requires setting to true
@@ -35,22 +55,6 @@ internal abstract class AnsiResponseParserBase : IAnsiResponseParser
///
public bool HandleKeyboard { get; set; } = false;
- ///
- /// Responses we are expecting to come in.
- ///
- protected readonly List _expectedResponses = [];
-
- ///
- /// Collection of responses that we .
- ///
- protected readonly List _lateResponses = [];
-
- ///
- /// Responses that you want to look out for that will come in continuously e.g. mouse events.
- /// Key is the terminator.
- ///
- protected readonly List _persistentExpectations = [];
-
private AnsiResponseParserState _state = AnsiResponseParserState.Normal;
///
@@ -64,8 +68,6 @@ protected set
}
}
- protected readonly IHeld _heldContent;
-
///
/// When was last changed.
///
@@ -74,17 +76,17 @@ protected set
// These all are valid terminators on ansi responses,
// see CSI in https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s
// No - N or O
- protected readonly HashSet _knownTerminators = new (
- [
- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
-
- // No - N or O
- 'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Z',
- '^', '`', '~',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
- 'l', 'm', 'n',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
- ]);
+ protected readonly HashSet _knownTerminators =
+ [
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+
+ // No - N or O
+ 'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Z',
+ '^', '`', '~',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
+ 'l', 'm', 'n',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
+ ];
protected AnsiResponseParserBase (IHeld heldContent) { _heldContent = heldContent; }
@@ -137,7 +139,7 @@ int inputLength
char currentChar = getCharAtIndex (index);
object currentObj = getObjectAtIndex (index);
- bool isEscape = currentChar == Escape;
+ bool isEscape = currentChar == ESCAPE;
switch (State)
{
@@ -233,7 +235,7 @@ protected void TryLastMinuteSequences ()
{
lock (_lockState)
{
- string cur = _heldContent.HeldToString ();
+ string? cur = _heldContent.HeldToString ();
if (HandleKeyboard)
{
@@ -250,7 +252,7 @@ protected void TryLastMinuteSequences ()
// We have something totally unexpected, not a CSI and
// still Esc+. So give last minute swallow chance
- if (cur.Length >= 2 && cur [0] == Escape)
+ if (cur!.Length >= 2 && cur [0] == ESCAPE)
{
// Maybe swallow anyway if user has custom delegate
bool swallow = ShouldSwallowUnexpectedResponse ();
@@ -270,7 +272,7 @@ protected bool ShouldReleaseHeldContent ()
{
lock (_lockState)
{
- string cur = _heldContent.HeldToString ();
+ string? cur = _heldContent.HeldToString ();
if (HandleMouse && IsMouse (cur))
{
@@ -328,7 +330,7 @@ protected bool ShouldReleaseHeldContent ()
// Finally if it is a valid ansi response but not one we are expect (e.g. its mouse activity)
// then we can release it back to input processing stream
- if (_knownTerminators.Contains (cur.Last ()) && cur.StartsWith (EscSeqUtils.CSI))
+ if (_knownTerminators.Contains (cur!.Last ()) && cur!.StartsWith (EscSeqUtils.CSI))
{
// We have found a terminator so bail
State = AnsiResponseParserState.Normal;
@@ -354,7 +356,7 @@ protected bool ShouldReleaseHeldContent ()
return false; // Continue accumulating
}
- private void RaiseMouseEvent (string cur)
+ private void RaiseMouseEvent (string? cur)
{
MouseEventArgs? ev = _mouseParser.ProcessMouseInput (cur);
@@ -364,9 +366,9 @@ private void RaiseMouseEvent (string cur)
}
}
- private bool IsMouse (string cur) { return _mouseParser.IsMouse (cur); }
+ private bool IsMouse (string? cur) { return _mouseParser.IsMouse (cur); }
- protected void RaiseKeyboardEvent (AnsiKeyboardParserPattern pattern, string cur)
+ protected void RaiseKeyboardEvent (AnsiKeyboardParserPattern pattern, string? cur)
{
Key? k = pattern.GetKey (cur);
@@ -394,7 +396,7 @@ protected void RaiseKeyboardEvent (AnsiKeyboardParserPattern pattern, string cur
///
protected abstract bool ShouldSwallowUnexpectedResponse ();
- private bool MatchResponse (string cur, List collection, bool invokeCallback, bool removeExpectation)
+ private bool MatchResponse (string? cur, List collection, bool invokeCallback, bool removeExpectation)
{
// Check for expected responses
AnsiResponseExpectation? matchingResponse = collection.FirstOrDefault (r => r.Matches (cur));
@@ -422,7 +424,7 @@ private bool MatchResponse (string cur, List collection
}
///
- public void ExpectResponse (string terminator, Action response, Action? abandoned, bool persistent)
+ public void ExpectResponse (string? terminator, Action response, Action? abandoned, bool persistent)
{
lock (_lockExpectedResponses)
{
@@ -438,17 +440,17 @@ public void ExpectResponse (string terminator, Action response, Action?
}
///
- public bool IsExpecting (string terminator)
+ public bool IsExpecting (string? terminator)
{
lock (_lockExpectedResponses)
{
// If any of the new terminator matches any existing terminators characters it's a collision so true.
- return _expectedResponses.Any (r => r.Terminator.Intersect (terminator).Any ());
+ return _expectedResponses.Any (r => r.Terminator!.Intersect (terminator!).Any ());
}
}
///
- public void StopExpecting (string terminator, bool persistent)
+ public void StopExpecting (string? terminator, bool persistent)
{
lock (_lockExpectedResponses)
{
@@ -530,7 +532,7 @@ public Tuple [] Release ()
///
///
///
- public void ExpectResponseT (string terminator, Action>> response, Action? abandoned, bool persistent)
+ public void ExpectResponseT (string? terminator, Action>> response, Action? abandoned, bool persistent)
{
lock (_lockExpectedResponses)
{
@@ -562,7 +564,7 @@ internal class AnsiResponseParser () : AnsiResponseParserBase (new StringHeld ()
/// keystrokes 'swallowed' (i.e. not returned to input stream).
///
///
- public Func UnknownResponseHandler { get; set; } = _ => false;
+ public Func UnknownResponseHandler { get; set; } = _ => false;
public string ProcessInput (string input)
{
@@ -583,13 +585,13 @@ private void AppendOutput (StringBuilder output, char c)
output.Append (c);
}
- public string Release ()
+ public string? Release ()
{
lock (_lockState)
{
TryLastMinuteSequences ();
- string output = _heldContent.HeldToString ();
+ string? output = _heldContent.HeldToString ();
ResetState ();
return output;
diff --git a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/GenericHeld.cs b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/GenericHeld.cs
index 8a5955da40..a898088038 100644
--- a/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/GenericHeld.cs
+++ b/Terminal.Gui/ConsoleDrivers/AnsiResponseParser/GenericHeld.cs
@@ -11,7 +11,7 @@ internal class GenericHeld : IHeld
public void ClearHeld () { held.Clear (); }
- public string HeldToString () { return new (held.Select (h => h.Item1).ToArray ()); }
+ public string? HeldToString () { return new (held.Select (h => h.Item1).ToArray ()); }
public IEnumerable