Browse Source

Code cleanup.

BDisp 8 months ago
parent
commit
f0b2474b6f

+ 4 - 4
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -46,7 +46,7 @@ public abstract class ConsoleDriver
                     {
                         lock (ansiRequest._responseLock)
                         {
-                            AnsiEscapeSequenceRequest? request = ansiRequest;
+                            AnsiEscapeSequenceRequest request = ansiRequest;
 
                             ansiRequest.ResponseFromInput += (s, e) =>
                                                              {
@@ -179,7 +179,7 @@ public abstract class ConsoleDriver
     /// <summary>Gets the location and size of the terminal screen.</summary>
     internal Rectangle Screen => new (0, 0, Cols, Rows);
 
-    private Region? _clip = null;
+    private Region? _clip;
 
     /// <summary>
     ///     Gets or sets the clip rectangle that <see cref="AddRune(Rune)"/> and <see cref="AddStr(string)"/> are subject
@@ -248,7 +248,7 @@ public abstract class ConsoleDriver
     ///     <see langword="false"/> if the coordinate is outside the screen bounds or outside of <see cref="Clip"/>.
     ///     <see langword="true"/> otherwise.
     /// </returns>
-    public bool IsValidLocation (int col, int row) { return col >= 0 && row >= 0 && col < Cols && row < Rows && Clip.Contains (col, row); }
+    public bool IsValidLocation (int col, int row) { return col >= 0 && row >= 0 && col < Cols && row < Rows && Clip!.Contains (col, row); }
 
     /// <summary>
     ///     Updates <see cref="Col"/> and <see cref="Row"/> to the specified column and row in <see cref="Contents"/>.
@@ -523,7 +523,7 @@ public abstract class ConsoleDriver
                     }
                     Contents [r, c] = new Cell
                     {
-                        Rune = (rune != default ? rune : (Rune)' '),
+                        Rune = rune != default ? rune : (Rune)' ',
                         Attribute = CurrentAttribute, IsDirty = true
                     };
                     _dirtyLines! [r] = true;

+ 2 - 4
Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

@@ -3,7 +3,6 @@
 // Driver.cs: Curses-based Driver
 //
 
-using System.Diagnostics;
 using System.Runtime.InteropServices;
 using Terminal.Gui.ConsoleDrivers;
 using Unix.Terminal;
@@ -58,12 +57,11 @@ internal class CursesDriver : ConsoleDriver
         {
             // Not a valid location (outside screen or clip region)
             // Move within the clip region, then AddRune will actually move to Col, Row
-            Rectangle clipRect = Clip.GetBounds ();
+            Rectangle clipRect = Clip!.GetBounds ();
             Curses.move (clipRect.Y, clipRect.X);
         }
     }
 
-    
     public override void SendKeys (char keyChar, ConsoleKey consoleKey, bool shift, bool alt, bool control)
     {
         KeyCode key;
@@ -580,7 +578,7 @@ internal class CursesDriver : ConsoleDriver
 
     #region Init/End/MainLoop
 
-    public Curses.Window? _window;
+    private Curses.Window? _window;
     private UnixMainLoop? _mainLoopDriver;
 
     internal override MainLoop Init ()

+ 1 - 1
Terminal.Gui/ConsoleDrivers/NetDriver/NetEvents.cs

@@ -208,7 +208,7 @@ internal class NetEvents : IDisposable
                                 continue;
                             }
 
-                            ProcessRequestResponse (ref newConsoleKeyInfo, ref key, _cki, ref mod);
+                            ProcessRequestResponse (ref newConsoleKeyInfo, ref key, _cki!, ref mod);
                             _cki = null;
                             _isEscSeq = false;
                             ProcessResponse ();

+ 2 - 2
Terminal.Gui/ConsoleDrivers/NetDriver/NetMainLoop.cs

@@ -149,13 +149,13 @@ internal class NetMainLoop : IMainLoopDriver
 
     private void ProcessInputQueue ()
     {
-        if (_resultQueue?.Count == 0 || ((IMainLoopDriver)this).ForceRead)
+        if (_resultQueue.Count == 0 || ((IMainLoopDriver)this).ForceRead)
         {
             NetEvents.InputResult? result = _netEvents!.DequeueInput ();
 
             if (result.HasValue)
             {
-                _resultQueue?.Enqueue (result.Value);
+                _resultQueue.Enqueue (result.Value);
 
                 _eventReady.Set ();
             }