|
@@ -61,7 +61,7 @@ internal class TextModel
|
|
|
|
|
|
public bool CloseFile ()
|
|
|
{
|
|
|
- if (FilePath == null)
|
|
|
+ if (FilePath is null)
|
|
|
{
|
|
|
throw new ArgumentNullException (nameof (FilePath));
|
|
|
}
|
|
@@ -148,7 +148,7 @@ internal class TextModel
|
|
|
|
|
|
public void LoadStream (Stream input)
|
|
|
{
|
|
|
- if (input == null)
|
|
|
+ if (input is null)
|
|
|
{
|
|
|
throw new ArgumentNullException (nameof (input));
|
|
|
}
|
|
@@ -296,7 +296,7 @@ internal class TextModel
|
|
|
RuneCell? cell = RuneAt (col, row);
|
|
|
Rune rune;
|
|
|
|
|
|
- if (cell != null)
|
|
|
+ if (cell is { })
|
|
|
{
|
|
|
rune = cell.Rune;
|
|
|
}
|
|
@@ -565,7 +565,7 @@ internal class TextModel
|
|
|
// Returns the left column in a range of the string.
|
|
|
internal static int CalculateLeftColumn (List<Rune> t, int start, int end, int width, int tabWidth = 0)
|
|
|
{
|
|
|
- if (t == null || t.Count == 0)
|
|
|
+ if (t is null || t.Count == 0)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
@@ -632,7 +632,7 @@ internal class TextModel
|
|
|
int tabWidth = 0
|
|
|
)
|
|
|
{
|
|
|
- if (t == null || t.Count == 0)
|
|
|
+ if (t is null || t.Count == 0)
|
|
|
{
|
|
|
return (0, 0);
|
|
|
}
|
|
@@ -687,7 +687,7 @@ internal class TextModel
|
|
|
bool matchWholeWord = false
|
|
|
)
|
|
|
{
|
|
|
- if (text == null || _lines.Count == 0)
|
|
|
+ if (text is null || _lines.Count == 0)
|
|
|
{
|
|
|
gaveFullTurn = false;
|
|
|
|
|
@@ -730,7 +730,7 @@ internal class TextModel
|
|
|
bool matchWholeWord = false
|
|
|
)
|
|
|
{
|
|
|
- if (text == null || _lines.Count == 0)
|
|
|
+ if (text is null || _lines.Count == 0)
|
|
|
{
|
|
|
gaveFullTurn = false;
|
|
|
|
|
@@ -1328,7 +1328,7 @@ internal partial class HistoryText
|
|
|
{
|
|
|
HistoryTextItem? found = _historyTextItems.FindLast (x => x.LineStatus == lineStatus);
|
|
|
|
|
|
- if (found != null)
|
|
|
+ if (found is { })
|
|
|
{
|
|
|
found.Lines = lines;
|
|
|
found.CursorPosition = curPos;
|
|
@@ -2744,7 +2744,7 @@ public class TextView : View
|
|
|
|
|
|
SetNeedsDisplay ();
|
|
|
}
|
|
|
- else if (_multiline && _savedHeight != null)
|
|
|
+ else if (_multiline && _savedHeight is { })
|
|
|
{
|
|
|
//var lyout = LayoutStyle;
|
|
|
//if (LayoutStyle == LayoutStyle.Computed) {
|
|
@@ -2932,7 +2932,7 @@ public class TextView : View
|
|
|
_wrapManager = new WordWrapManager (_model);
|
|
|
_model = _wrapManager.WrapModel (_frameWidth, out _, out _, out _, out _);
|
|
|
}
|
|
|
- else if (!_wordWrap && _wrapManager != null)
|
|
|
+ else if (!_wordWrap && _wrapManager is { })
|
|
|
{
|
|
|
_model = _wrapManager.Model;
|
|
|
}
|
|
@@ -3218,7 +3218,7 @@ public class TextView : View
|
|
|
{
|
|
|
ColorScheme? cs = ColorScheme;
|
|
|
|
|
|
- if (ColorScheme == null)
|
|
|
+ if (ColorScheme is null)
|
|
|
{
|
|
|
cs = new ColorScheme ();
|
|
|
}
|
|
@@ -3485,7 +3485,7 @@ public class TextView : View
|
|
|
_lastWasKill = false;
|
|
|
_columnTrack = CurrentColumn;
|
|
|
|
|
|
- if (Application.MouseGrabView == null)
|
|
|
+ if (Application.MouseGrabView is null)
|
|
|
{
|
|
|
Application.GrabMouse (this);
|
|
|
}
|
|
@@ -3529,7 +3529,7 @@ public class TextView : View
|
|
|
|
|
|
newPos = _model.WordForward (CurrentColumn, CurrentRow);
|
|
|
|
|
|
- if (newPos != null && newPos.HasValue)
|
|
|
+ if (newPos is { } && newPos.HasValue)
|
|
|
{
|
|
|
CurrentColumn = CurrentRow == newPos.Value.row ? newPos.Value.col : line.Count;
|
|
|
}
|
|
@@ -3737,7 +3737,7 @@ public class TextView : View
|
|
|
/// <inheritdoc/>
|
|
|
public override bool OnLeave (View view)
|
|
|
{
|
|
|
- if (Application.MouseGrabView != null && Application.MouseGrabView == this)
|
|
|
+ if (Application.MouseGrabView is { } && Application.MouseGrabView == this)
|
|
|
{
|
|
|
Application.UngrabMouse ();
|
|
|
}
|
|
@@ -3770,10 +3770,10 @@ public class TextView : View
|
|
|
/// <summary>Invoke the <see cref="UnwrappedCursorPosition"/> event with the unwrapped <see cref="CursorPosition"/>.</summary>
|
|
|
public virtual void OnUnwrappedCursorPosition (int? cRow = null, int? cCol = null)
|
|
|
{
|
|
|
- int? row = cRow == null ? CurrentRow : cRow;
|
|
|
- int? col = cCol == null ? CurrentColumn : cCol;
|
|
|
+ int? row = cRow is null ? CurrentRow : cRow;
|
|
|
+ int? col = cCol is null ? CurrentColumn : cCol;
|
|
|
|
|
|
- if (cRow == null && cCol == null && _wordWrap)
|
|
|
+ if (cRow is null && cCol is null && _wordWrap)
|
|
|
{
|
|
|
row = _wrapManager!.GetModelLineFromWrappedLines (CurrentRow);
|
|
|
col = _wrapManager.GetModelColFromWrappedLines (CurrentRow, CurrentColumn);
|
|
@@ -3795,7 +3795,7 @@ public class TextView : View
|
|
|
|
|
|
if (_copyWithoutSelection && contents.FirstOrDefault (x => x == '\n' || x == '\r') == 0)
|
|
|
{
|
|
|
- List<RuneCell> runeList = contents == null ? new List<RuneCell> () : TextModel.ToRuneCellList (contents);
|
|
|
+ List<RuneCell> runeList = contents is null ? new List<RuneCell> () : TextModel.ToRuneCellList (contents);
|
|
|
List<RuneCell> currentLine = GetCurrentLine ();
|
|
|
|
|
|
_historyText.Add (new List<List<RuneCell>> { new (currentLine) }, CursorPosition);
|
|
@@ -3852,7 +3852,7 @@ public class TextView : View
|
|
|
{
|
|
|
ProcessAutocomplete ();
|
|
|
|
|
|
- if (!CanFocus || !Enabled || Application.Driver == null)
|
|
|
+ if (!CanFocus || !Enabled || Application.Driver is null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -4028,7 +4028,7 @@ public class TextView : View
|
|
|
var ev = new RuneCellEventArgs (line, idxCol, unwrappedPos);
|
|
|
DrawNormalColor?.Invoke (this, ev);
|
|
|
|
|
|
- if (line [idxCol].ColorScheme != null)
|
|
|
+ if (line [idxCol].ColorScheme is { })
|
|
|
{
|
|
|
ColorScheme? colorScheme = line [idxCol].ColorScheme;
|
|
|
Driver.SetAttribute (Enabled ? colorScheme!.Focus : colorScheme!.Disabled);
|
|
@@ -4054,7 +4054,7 @@ public class TextView : View
|
|
|
var ev = new RuneCellEventArgs (line, idxCol, unwrappedPos);
|
|
|
DrawReadOnlyColor?.Invoke (this, ev);
|
|
|
|
|
|
- ColorScheme? colorScheme = line [idxCol].ColorScheme != null ? line [idxCol].ColorScheme : ColorScheme;
|
|
|
+ ColorScheme? colorScheme = line [idxCol].ColorScheme is { } ? line [idxCol].ColorScheme : ColorScheme;
|
|
|
Attribute attribute;
|
|
|
|
|
|
if (colorScheme!.Disabled.Foreground == colorScheme.Focus.Background)
|
|
@@ -4084,7 +4084,7 @@ public class TextView : View
|
|
|
var ev = new RuneCellEventArgs (line, idxCol, unwrappedPos);
|
|
|
DrawSelectionColor?.Invoke (this, ev);
|
|
|
|
|
|
- if (line [idxCol].ColorScheme != null)
|
|
|
+ if (line [idxCol].ColorScheme is { })
|
|
|
{
|
|
|
ColorScheme? colorScheme = line [idxCol].ColorScheme;
|
|
|
|
|
@@ -4118,7 +4118,7 @@ public class TextView : View
|
|
|
var ev = new RuneCellEventArgs (line, idxCol, unwrappedPos);
|
|
|
DrawUsedColor?.Invoke (this, ev);
|
|
|
|
|
|
- if (line [idxCol].ColorScheme != null)
|
|
|
+ if (line [idxCol].ColorScheme is { })
|
|
|
{
|
|
|
ColorScheme? colorScheme = line [idxCol].ColorScheme;
|
|
|
SetValidUsedColor (colorScheme!);
|
|
@@ -4628,7 +4628,7 @@ public class TextView : View
|
|
|
long selection;
|
|
|
long point;
|
|
|
|
|
|
- if (startRow == null || startCol == null || cRow == null || cCol == null)
|
|
|
+ if (startRow is null || startCol is null || cRow is null || cCol is null)
|
|
|
{
|
|
|
selection = ((long)(uint)_selectionStartRow << 32) | (uint)_selectionStartColumn;
|
|
|
point = ((long)(uint)CurrentRow << 32) | (uint)CurrentColumn;
|
|
@@ -4675,7 +4675,7 @@ public class TextView : View
|
|
|
var maxrow = (int)(end >> 32);
|
|
|
var startCol = (int)(start & 0xffffffff);
|
|
|
var endCol = (int)(end & 0xffffffff);
|
|
|
- List<RuneCell> line = model == null ? _model.GetLine (startRow) : model.GetLine (startRow);
|
|
|
+ List<RuneCell> line = model is null ? _model.GetLine (startRow) : model.GetLine (startRow);
|
|
|
|
|
|
if (startRow == maxrow)
|
|
|
{
|
|
@@ -4695,7 +4695,7 @@ public class TextView : View
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- line = model == null ? _model.GetLine (maxrow) : model.GetLine (maxrow);
|
|
|
+ line = model is null ? _model.GetLine (maxrow) : model.GetLine (maxrow);
|
|
|
res = res + Environment.NewLine + StringFromRunes (line.GetRange (0, endCol));
|
|
|
|
|
|
return res;
|
|
@@ -4742,11 +4742,11 @@ public class TextView : View
|
|
|
{
|
|
|
SetWrapModel ();
|
|
|
|
|
|
- if (obj != null)
|
|
|
+ if (obj is { })
|
|
|
{
|
|
|
int startLine = obj.CursorPosition.Y;
|
|
|
|
|
|
- if (obj.RemovedOnAdded != null)
|
|
|
+ if (obj.RemovedOnAdded is { })
|
|
|
{
|
|
|
int offset;
|
|
|
|
|
@@ -4908,7 +4908,7 @@ public class TextView : View
|
|
|
addedLines.Add (new List<RuneCell> (lines [i]));
|
|
|
}
|
|
|
|
|
|
- if (rest != null)
|
|
|
+ if (rest is { })
|
|
|
{
|
|
|
List<RuneCell> last = _model.GetLine (CurrentRow + lines.Count - 1);
|
|
|
lastp = last.Count;
|
|
@@ -4921,7 +4921,7 @@ public class TextView : View
|
|
|
|
|
|
// Now adjust column and row positions
|
|
|
CurrentRow += lines.Count - 1;
|
|
|
- CurrentColumn = rest != null ? lastp : lines [lines.Count - 1].Count;
|
|
|
+ CurrentColumn = rest is { } ? lastp : lines [lines.Count - 1].Count;
|
|
|
Adjust ();
|
|
|
|
|
|
_historyText.Add (
|
|
@@ -5424,7 +5424,7 @@ public class TextView : View
|
|
|
|
|
|
private bool MoveNextView ()
|
|
|
{
|
|
|
- if (Application.OverlappedTop != null)
|
|
|
+ if (Application.OverlappedTop is { })
|
|
|
{
|
|
|
return SuperView?.FocusNext () == true;
|
|
|
}
|
|
@@ -5490,7 +5490,7 @@ public class TextView : View
|
|
|
|
|
|
private bool MovePreviousView ()
|
|
|
{
|
|
|
- if (Application.OverlappedTop != null)
|
|
|
+ if (Application.OverlappedTop is { })
|
|
|
{
|
|
|
return SuperView?.FocusPrev () == true;
|
|
|
}
|
|
@@ -5760,7 +5760,7 @@ public class TextView : View
|
|
|
RuneCell cell = line [colWithColor];
|
|
|
int colWithoutColor = Math.Max (col - 1, 0);
|
|
|
|
|
|
- if (cell.ColorScheme != null && colWithColor == 0 && lineToSet [colWithoutColor].ColorScheme != null)
|
|
|
+ if (cell.ColorScheme is { } && colWithColor == 0 && lineToSet [colWithoutColor].ColorScheme is { })
|
|
|
{
|
|
|
for (int r = row - 1; r > -1; r--)
|
|
|
{
|
|
@@ -5768,7 +5768,7 @@ public class TextView : View
|
|
|
|
|
|
for (int c = l.Count - 1; c > -1; c--)
|
|
|
{
|
|
|
- if (l [c].ColorScheme == null)
|
|
|
+ if (l [c].ColorScheme is null)
|
|
|
{
|
|
|
l [c].ColorScheme = cell.ColorScheme;
|
|
|
}
|
|
@@ -5782,7 +5782,7 @@ public class TextView : View
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (cell.ColorScheme == null)
|
|
|
+ if (cell.ColorScheme is null)
|
|
|
{
|
|
|
for (int r = row; r > -1; r--)
|
|
|
{
|
|
@@ -5793,7 +5793,7 @@ public class TextView : View
|
|
|
rc => rc.ColorScheme != null
|
|
|
);
|
|
|
|
|
|
- if (colWithColor > -1 && l [colWithColor].ColorScheme != null)
|
|
|
+ if (colWithColor > -1 && l [colWithColor].ColorScheme is { })
|
|
|
{
|
|
|
cell = l [colWithColor];
|
|
|
|
|
@@ -5805,9 +5805,9 @@ public class TextView : View
|
|
|
{
|
|
|
int cRow = row;
|
|
|
|
|
|
- while (cell.ColorScheme == null)
|
|
|
+ while (cell.ColorScheme is null)
|
|
|
{
|
|
|
- if ((colWithColor == 0 || cell.ColorScheme == null) && cRow > 0)
|
|
|
+ if ((colWithColor == 0 || cell.ColorScheme is null) && cRow > 0)
|
|
|
{
|
|
|
line = GetLine (--cRow);
|
|
|
colWithColor = line.Count - 1;
|
|
@@ -5820,9 +5820,9 @@ public class TextView : View
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (cell.ColorScheme != null && colWithColor > -1 && colWithoutColor < lineToSet.Count && lineToSet [colWithoutColor].ColorScheme == null)
|
|
|
+ if (cell.ColorScheme is { } && colWithColor > -1 && colWithoutColor < lineToSet.Count && lineToSet [colWithoutColor].ColorScheme is null)
|
|
|
{
|
|
|
- while (lineToSet [colWithoutColor].ColorScheme == null)
|
|
|
+ while (lineToSet [colWithoutColor].ColorScheme is null)
|
|
|
{
|
|
|
lineToSet [colWithoutColor].ColorScheme = cell.ColorScheme;
|
|
|
colWithoutColor--;
|
|
@@ -6288,7 +6288,7 @@ public class TextView : View
|
|
|
|
|
|
private void SetClipboard (string text)
|
|
|
{
|
|
|
- if (text != null)
|
|
|
+ if (text is { })
|
|
|
{
|
|
|
Clipboard.Contents = text;
|
|
|
}
|
|
@@ -6362,7 +6362,7 @@ public class TextView : View
|
|
|
/// <summary>Restore from original model.</summary>
|
|
|
private void SetWrapModel ([CallerMemberName] string? caller = null)
|
|
|
{
|
|
|
- if (_currentCaller != null)
|
|
|
+ if (_currentCaller is { })
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -6415,7 +6415,7 @@ public class TextView : View
|
|
|
|
|
|
private string StringFromRunes (List<RuneCell> cells)
|
|
|
{
|
|
|
- if (cells == null)
|
|
|
+ if (cells is null)
|
|
|
{
|
|
|
throw new ArgumentNullException (nameof (cells));
|
|
|
}
|
|
@@ -6442,7 +6442,7 @@ public class TextView : View
|
|
|
{
|
|
|
Autocomplete.HostControl = this;
|
|
|
|
|
|
- if (Application.Top != null)
|
|
|
+ if (Application.Top is { })
|
|
|
{
|
|
|
Application.Top.AlternateForwardKeyChanged += Top_AlternateForwardKeyChanged!;
|
|
|
Application.Top.AlternateBackwardKeyChanged += Top_AlternateBackwardKeyChanged!;
|
|
@@ -6493,7 +6493,7 @@ public class TextView : View
|
|
|
/// <summary>Update the original model.</summary>
|
|
|
private void UpdateWrapModel ([CallerMemberName] string? caller = null)
|
|
|
{
|
|
|
- if (_currentCaller != null && _currentCaller != caller)
|
|
|
+ if (_currentCaller is { } && _currentCaller != caller)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -6523,7 +6523,7 @@ public class TextView : View
|
|
|
SetNeedsDisplay ();
|
|
|
}
|
|
|
|
|
|
- if (_currentCaller != null)
|
|
|
+ if (_currentCaller is { })
|
|
|
{
|
|
|
throw new InvalidOperationException (
|
|
|
$"WordWrap settings was changed after the {_currentCaller} call."
|
|
@@ -6533,7 +6533,7 @@ public class TextView : View
|
|
|
|
|
|
private void WrapTextModel ()
|
|
|
{
|
|
|
- if (_wordWrap && _wrapManager != null)
|
|
|
+ if (_wordWrap && _wrapManager is { })
|
|
|
{
|
|
|
_model = _wrapManager.WrapModel (
|
|
|
_frameWidth,
|