|
@@ -1,10 +1,8 @@
|
|
#nullable enable
|
|
#nullable enable
|
|
|
|
|
|
// TextView.cs: multi-line text editing
|
|
// TextView.cs: multi-line text editing
|
|
-using System.Diagnostics;
|
|
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.CompilerServices;
|
|
-using System.Text.Json.Serialization;
|
|
|
|
using Terminal.Gui.Resources;
|
|
using Terminal.Gui.Resources;
|
|
|
|
|
|
namespace Terminal.Gui;
|
|
namespace Terminal.Gui;
|
|
@@ -106,7 +104,7 @@ internal class TextModel
|
|
|
|
|
|
public void LoadCells (List<Cell> cells, Attribute? attribute)
|
|
public void LoadCells (List<Cell> cells, Attribute? attribute)
|
|
{
|
|
{
|
|
- _lines = Cell.ToCells ((List<Cell>)cells);
|
|
|
|
|
|
+ _lines = Cell.ToCells (cells);
|
|
SetAttributes (attribute);
|
|
SetAttributes (attribute);
|
|
OnLinesLoaded ();
|
|
OnLinesLoaded ();
|
|
}
|
|
}
|
|
@@ -180,7 +178,7 @@ internal class TextModel
|
|
{
|
|
{
|
|
if (_lines.Count > 0 && pos < _lines.Count)
|
|
if (_lines.Count > 0 && pos < _lines.Count)
|
|
{
|
|
{
|
|
- _lines [pos] = [..runes];
|
|
|
|
|
|
+ _lines [pos] = [.. runes];
|
|
}
|
|
}
|
|
else if (_lines.Count == 0 || (_lines.Count > 0 && pos >= _lines.Count))
|
|
else if (_lines.Count == 0 || (_lines.Count > 0 && pos >= _lines.Count))
|
|
{
|
|
{
|
|
@@ -188,8 +186,6 @@ internal class TextModel
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public override string ToString ()
|
|
public override string ToString ()
|
|
{
|
|
{
|
|
var sb = new StringBuilder ();
|
|
var sb = new StringBuilder ();
|
|
@@ -608,8 +604,7 @@ internal class TextModel
|
|
|
|
|
|
internal Size GetDisplaySize ()
|
|
internal Size GetDisplaySize ()
|
|
{
|
|
{
|
|
- Size size = Size.Empty;
|
|
|
|
-
|
|
|
|
|
|
+ var size = Size.Empty;
|
|
|
|
|
|
return size;
|
|
return size;
|
|
}
|
|
}
|
|
@@ -799,7 +794,7 @@ internal class TextModel
|
|
|
|
|
|
string GetText (List<Cell> x)
|
|
string GetText (List<Cell> x)
|
|
{
|
|
{
|
|
- string txt = Cell.ToString (x);
|
|
|
|
|
|
+ var txt = Cell.ToString (x);
|
|
|
|
|
|
if (!matchCase)
|
|
if (!matchCase)
|
|
{
|
|
{
|
|
@@ -872,7 +867,7 @@ internal class TextModel
|
|
for (int i = start.Y; i < linesCount; i++)
|
|
for (int i = start.Y; i < linesCount; i++)
|
|
{
|
|
{
|
|
List<Cell> x = _lines [i];
|
|
List<Cell> x = _lines [i];
|
|
- string txt = Cell.ToString (x);
|
|
|
|
|
|
+ var txt = Cell.ToString (x);
|
|
|
|
|
|
if (!matchCase)
|
|
if (!matchCase)
|
|
{
|
|
{
|
|
@@ -912,7 +907,7 @@ internal class TextModel
|
|
for (int i = linesCount; i >= 0; i--)
|
|
for (int i = linesCount; i >= 0; i--)
|
|
{
|
|
{
|
|
List<Cell> x = _lines [i];
|
|
List<Cell> x = _lines [i];
|
|
- string txt = Cell.ToString (x);
|
|
|
|
|
|
+ var txt = Cell.ToString (x);
|
|
|
|
|
|
if (!matchCase)
|
|
if (!matchCase)
|
|
{
|
|
{
|
|
@@ -1075,7 +1070,7 @@ internal class TextModel
|
|
|
|
|
|
private string ReplaceText (List<Cell> source, string textToReplace, string matchText, int col)
|
|
private string ReplaceText (List<Cell> source, string textToReplace, string matchText, int col)
|
|
{
|
|
{
|
|
- string origTxt = Cell.ToString (source);
|
|
|
|
|
|
+ var origTxt = Cell.ToString (source);
|
|
(_, int len) = DisplaySize (source, 0, col, false);
|
|
(_, int len) = DisplaySize (source, 0, col, false);
|
|
(_, int len2) = DisplaySize (source, col, col + matchText.Length, false);
|
|
(_, int len2) = DisplaySize (source, col, col + matchText.Length, false);
|
|
(_, int len3) = DisplaySize (source, col + matchText.Length, origTxt.GetRuneCount (), false);
|
|
(_, int len3) = DisplaySize (source, col + matchText.Length, origTxt.GetRuneCount (), false);
|
|
@@ -1171,10 +1166,11 @@ internal partial class HistoryText
|
|
_historyTextItems.Clear ();
|
|
_historyTextItems.Clear ();
|
|
_idxHistoryText = -1;
|
|
_idxHistoryText = -1;
|
|
_originalCellsList.Clear ();
|
|
_originalCellsList.Clear ();
|
|
|
|
+
|
|
// Save a copy of the original, not the reference
|
|
// Save a copy of the original, not the reference
|
|
foreach (List<Cell> cells in cellsList)
|
|
foreach (List<Cell> cells in cellsList)
|
|
{
|
|
{
|
|
- _originalCellsList.Add ([..cells]);
|
|
|
|
|
|
+ _originalCellsList.Add ([.. cells]);
|
|
}
|
|
}
|
|
|
|
|
|
OnChangeText (null);
|
|
OnChangeText (null);
|
|
@@ -1678,15 +1674,15 @@ internal class WordWrapManager
|
|
List<Cell> line = Model.GetLine (i);
|
|
List<Cell> line = Model.GetLine (i);
|
|
|
|
|
|
List<List<Cell>> wrappedLines = ToListRune (
|
|
List<List<Cell>> wrappedLines = ToListRune (
|
|
- TextFormatter.Format (
|
|
|
|
- Cell.ToString (line),
|
|
|
|
- width,
|
|
|
|
- Alignment.Start,
|
|
|
|
- true,
|
|
|
|
- preserveTrailingSpaces,
|
|
|
|
- tabWidth
|
|
|
|
- )
|
|
|
|
- );
|
|
|
|
|
|
+ TextFormatter.Format (
|
|
|
|
+ Cell.ToString (line),
|
|
|
|
+ width,
|
|
|
|
+ Alignment.Start,
|
|
|
|
+ true,
|
|
|
|
+ preserveTrailingSpaces,
|
|
|
|
+ tabWidth
|
|
|
|
+ )
|
|
|
|
+ );
|
|
var sumColWidth = 0;
|
|
var sumColWidth = 0;
|
|
|
|
|
|
for (var j = 0; j < wrappedLines.Count; j++)
|
|
for (var j = 0; j < wrappedLines.Count; j++)
|
|
@@ -1885,7 +1881,6 @@ public class TextView : View
|
|
private WordWrapManager? _wrapManager;
|
|
private WordWrapManager? _wrapManager;
|
|
private bool _wrapNeeded;
|
|
private bool _wrapNeeded;
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Initializes a <see cref="TextView"/> on the specified area, with dimensions controlled with the X, Y, Width
|
|
/// Initializes a <see cref="TextView"/> on the specified area, with dimensions controlled with the X, Y, Width
|
|
/// and Height properties.
|
|
/// and Height properties.
|
|
@@ -1911,7 +1906,7 @@ public class TextView : View
|
|
// Things this view knows how to do
|
|
// Things this view knows how to do
|
|
|
|
|
|
// Note - NewLine is only bound to Enter if Multiline is true
|
|
// Note - NewLine is only bound to Enter if Multiline is true
|
|
- AddCommand (Command.NewLine, (ctx) => ProcessEnterKey (ctx));
|
|
|
|
|
|
+ AddCommand (Command.NewLine, ctx => ProcessEnterKey (ctx));
|
|
|
|
|
|
AddCommand (
|
|
AddCommand (
|
|
Command.PageDown,
|
|
Command.PageDown,
|
|
@@ -2376,7 +2371,7 @@ public class TextView : View
|
|
KeyBindings.Add (Key.C.WithCtrl, Command.Copy);
|
|
KeyBindings.Add (Key.C.WithCtrl, Command.Copy);
|
|
|
|
|
|
KeyBindings.Add (Key.W.WithCtrl, Command.Cut); // Move to Unix?
|
|
KeyBindings.Add (Key.W.WithCtrl, Command.Cut); // Move to Unix?
|
|
- KeyBindings.Add (Key.X.WithCtrl, Command.Cut);
|
|
|
|
|
|
+ KeyBindings.Add (Key.X.WithCtrl, Command.Cut);
|
|
|
|
|
|
KeyBindings.Add (Key.CursorLeft.WithCtrl, Command.WordLeft);
|
|
KeyBindings.Add (Key.CursorLeft.WithCtrl, Command.WordLeft);
|
|
|
|
|
|
@@ -2422,10 +2417,7 @@ public class TextView : View
|
|
KeyBindings.Add ((KeyCode)ContextMenu.Key, KeyBindingScope.HotKey, Command.Context);
|
|
KeyBindings.Add ((KeyCode)ContextMenu.Key, KeyBindingScope.HotKey, Command.Context);
|
|
}
|
|
}
|
|
|
|
|
|
- private void TextView_Added1 (object? sender, SuperViewChangedEventArgs e)
|
|
|
|
- {
|
|
|
|
- throw new NotImplementedException ();
|
|
|
|
- }
|
|
|
|
|
|
+ private void TextView_Added1 (object? sender, SuperViewChangedEventArgs e) { throw new NotImplementedException (); }
|
|
|
|
|
|
// BUGBUG: AllowsReturn is mis-named. It should be EnterKeyAccepts.
|
|
// BUGBUG: AllowsReturn is mis-named. It should be EnterKeyAccepts.
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -2435,11 +2427,13 @@ public class TextView : View
|
|
/// <remarks>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// <para>
|
|
/// Setting this property alters <see cref="Multiline"/>.
|
|
/// Setting this property alters <see cref="Multiline"/>.
|
|
- /// If <see cref="AllowsReturn"/> is set to <see langword="true"/>, then <see cref="Multiline"/> is also set to `true` and
|
|
|
|
|
|
+ /// If <see cref="AllowsReturn"/> is set to <see langword="true"/>, then <see cref="Multiline"/> is also set to
|
|
|
|
+ /// `true` and
|
|
/// vice-versa.
|
|
/// vice-versa.
|
|
/// </para>
|
|
/// </para>
|
|
/// <para>
|
|
/// <para>
|
|
- /// If <see cref="AllowsReturn"/> is set to <see langword="false"/>, then <see cref="AllowsTab"/> gets set to <see langword="false"/>.
|
|
|
|
|
|
+ /// If <see cref="AllowsReturn"/> is set to <see langword="false"/>, then <see cref="AllowsTab"/> gets set to
|
|
|
|
+ /// <see langword="false"/>.
|
|
/// </para>
|
|
/// </para>
|
|
/// </remarks>
|
|
/// </remarks>
|
|
public bool AllowsReturn
|
|
public bool AllowsReturn
|
|
@@ -2458,6 +2452,7 @@ public class TextView : View
|
|
if (!_allowsReturn && _multiline)
|
|
if (!_allowsReturn && _multiline)
|
|
{
|
|
{
|
|
Multiline = false;
|
|
Multiline = false;
|
|
|
|
+
|
|
// BUGBUG: Setting properties should not have side-effects like this. Multiline and AllowsTab should be independent.
|
|
// BUGBUG: Setting properties should not have side-effects like this. Multiline and AllowsTab should be independent.
|
|
AllowsTab = false;
|
|
AllowsTab = false;
|
|
}
|
|
}
|
|
@@ -2532,7 +2527,6 @@ public class TextView : View
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Indicates whatever the text has history changes or not. <see langword="true"/> if the text has history changes
|
|
/// Indicates whatever the text has history changes or not. <see langword="true"/> if the text has history changes
|
|
/// <see langword="false"/> otherwise.
|
|
/// <see langword="false"/> otherwise.
|
|
@@ -2604,7 +2598,7 @@ public class TextView : View
|
|
CurrentRow = 0;
|
|
CurrentRow = 0;
|
|
_savedHeight = Height;
|
|
_savedHeight = Height;
|
|
|
|
|
|
- Height = Dim.Auto (DimAutoStyle.Text, minimumContentDim: 1);
|
|
|
|
|
|
+ Height = Dim.Auto (DimAutoStyle.Text, 1);
|
|
|
|
|
|
if (!IsInitialized)
|
|
if (!IsInitialized)
|
|
{
|
|
{
|
|
@@ -2805,7 +2799,6 @@ public class TextView : View
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>Allows clearing the <see cref="HistoryText.HistoryTextItemEventArgs"/> items updating the original text.</summary>
|
|
/// <summary>Allows clearing the <see cref="HistoryText.HistoryTextItemEventArgs"/> items updating the original text.</summary>
|
|
public void ClearHistoryChanges () { _historyText?.Clear (_model.GetAllLines ()); }
|
|
public void ClearHistoryChanges () { _historyText?.Clear (_model.GetAllLines ()); }
|
|
|
|
|
|
@@ -2855,7 +2848,7 @@ public class TextView : View
|
|
line [c] = cell; // Assign the modified copy back
|
|
line [c] = cell; // Assign the modified copy back
|
|
}
|
|
}
|
|
|
|
|
|
- selectedCellsChanged.Add ([..GetLine (r)]);
|
|
|
|
|
|
+ selectedCellsChanged.Add ([.. GetLine (r)]);
|
|
}
|
|
}
|
|
|
|
|
|
GetSelectedRegion ();
|
|
GetSelectedRegion ();
|
|
@@ -2906,10 +2899,10 @@ public class TextView : View
|
|
public void PromptForColors ()
|
|
public void PromptForColors ()
|
|
{
|
|
{
|
|
if (!ColorPicker.Prompt (
|
|
if (!ColorPicker.Prompt (
|
|
- "Colors",
|
|
|
|
- GetSelectedCellAttribute (),
|
|
|
|
- out Attribute newAttribute
|
|
|
|
- ))
|
|
|
|
|
|
+ "Colors",
|
|
|
|
+ GetSelectedCellAttribute (),
|
|
|
|
+ out Attribute newAttribute
|
|
|
|
+ ))
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -3177,10 +3170,7 @@ public class TextView : View
|
|
public List<Cell> GetLine (int line) { return _model.GetLine (line); }
|
|
public List<Cell> GetLine (int line) { return _model.GetLine (line); }
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override Attribute GetNormalColor ()
|
|
|
|
- {
|
|
|
|
- return GetFocusColor ();
|
|
|
|
- }
|
|
|
|
|
|
+ public override Attribute GetNormalColor () { return GetFocusColor (); }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Inserts the given <paramref name="toAdd"/> text at the current cursor position exactly as if the user had just
|
|
/// Inserts the given <paramref name="toAdd"/> text at the current cursor position exactly as if the user had just
|
|
@@ -3563,7 +3553,6 @@ public class TextView : View
|
|
|
|
|
|
ProcessInheritsPreviousColorScheme (CurrentRow, CurrentColumn);
|
|
ProcessInheritsPreviousColorScheme (CurrentRow, CurrentColumn);
|
|
ProcessAutocomplete ();
|
|
ProcessAutocomplete ();
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
@@ -3628,6 +3617,7 @@ public class TextView : View
|
|
else
|
|
else
|
|
{
|
|
{
|
|
AddRune (col, row, rune);
|
|
AddRune (col, row, rune);
|
|
|
|
+
|
|
// Ensures that cols less than 0 to be 1 because it will be converted to a printable rune
|
|
// Ensures that cols less than 0 to be 1 because it will be converted to a printable rune
|
|
cols = Math.Max (cols, 1);
|
|
cols = Math.Max (cols, 1);
|
|
}
|
|
}
|
|
@@ -3664,42 +3654,29 @@ public class TextView : View
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- protected override bool OnInvokingKeyBindings (Key a, KeyBindingScope scope)
|
|
|
|
|
|
+ protected override void OnHasFocusChanged (bool newHasFocus, View? previousFocusedView, View? view)
|
|
{
|
|
{
|
|
- if (!a.IsValid)
|
|
|
|
- {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Give autocomplete first opportunity to respond to key presses
|
|
|
|
- if (SelectedLength == 0 && Autocomplete.Suggestions.Count > 0 && Autocomplete.ProcessKey (a))
|
|
|
|
|
|
+ if (Application.MouseGrabView is { } && Application.MouseGrabView == this)
|
|
{
|
|
{
|
|
- return true;
|
|
|
|
|
|
+ Application.UngrabMouse ();
|
|
}
|
|
}
|
|
-
|
|
|
|
- return base.OnInvokingKeyBindings (a, scope);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
- public override bool OnKeyUp (Key key)
|
|
|
|
|
|
+ protected override bool OnKeyDown (Key key)
|
|
{
|
|
{
|
|
- if (key == Key.Space.WithCtrl)
|
|
|
|
|
|
+ if (!key.IsValid)
|
|
{
|
|
{
|
|
- return true;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <inheritdoc/>
|
|
|
|
- protected override void OnHasFocusChanged (bool newHasFocus, View? previousFocusedView, View? view)
|
|
|
|
- {
|
|
|
|
- if (Application.MouseGrabView is { } && Application.MouseGrabView == this)
|
|
|
|
|
|
+ // Give autocomplete first opportunity to respond to key presses
|
|
|
|
+ if (SelectedLength == 0 && Autocomplete.Suggestions.Count > 0 && Autocomplete.ProcessKey (key))
|
|
{
|
|
{
|
|
- Application.UngrabMouse ();
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- return;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <inheritdoc/>
|
|
/// <inheritdoc/>
|
|
@@ -3724,6 +3701,17 @@ public class TextView : View
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <inheritdoc/>
|
|
|
|
+ public override bool OnKeyUp (Key key)
|
|
|
|
+ {
|
|
|
|
+ if (key == Key.Space.WithCtrl)
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>Invoke the <see cref="UnwrappedCursorPosition"/> event with the unwrapped <see cref="CursorPosition"/>.</summary>
|
|
/// <summary>Invoke the <see cref="UnwrappedCursorPosition"/> event with the unwrapped <see cref="CursorPosition"/>.</summary>
|
|
public virtual void OnUnwrappedCursorPosition (int? cRow = null, int? cCol = null)
|
|
public virtual void OnUnwrappedCursorPosition (int? cRow = null, int? cCol = null)
|
|
{
|
|
{
|
|
@@ -3760,7 +3748,7 @@ public class TextView : View
|
|
List<List<Cell>> addedLine = [new (currentLine), runeList];
|
|
List<List<Cell>> addedLine = [new (currentLine), runeList];
|
|
|
|
|
|
_historyText.Add (
|
|
_historyText.Add (
|
|
- [..addedLine],
|
|
|
|
|
|
+ [.. addedLine],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Added
|
|
HistoryText.LineStatus.Added
|
|
);
|
|
);
|
|
@@ -3862,6 +3850,7 @@ public class TextView : View
|
|
if (posX > -1 && col >= posX && posX < Viewport.Width && _topRow <= CurrentRow && posY < Viewport.Height)
|
|
if (posX > -1 && col >= posX && posX < Viewport.Width && _topRow <= CurrentRow && posY < Viewport.Height)
|
|
{
|
|
{
|
|
Move (col, CurrentRow - _topRow);
|
|
Move (col, CurrentRow - _topRow);
|
|
|
|
+
|
|
return new (col, CurrentRow - _topRow);
|
|
return new (col, CurrentRow - _topRow);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4481,12 +4470,12 @@ public class TextView : View
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- _historyText.Add ([ [.. currentLine]], CursorPosition);
|
|
|
|
|
|
+ _historyText.Add ([[.. currentLine]], CursorPosition);
|
|
|
|
|
|
currentLine.RemoveAt (CurrentColumn);
|
|
currentLine.RemoveAt (CurrentColumn);
|
|
|
|
|
|
_historyText.Add (
|
|
_historyText.Add (
|
|
- [ [.. currentLine]],
|
|
|
|
|
|
+ [[.. currentLine]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -4656,6 +4645,7 @@ public class TextView : View
|
|
{
|
|
{
|
|
cells = line.GetRange (startCol, endCol - startCol);
|
|
cells = line.GetRange (startCol, endCol - startCol);
|
|
cellsList.Add (cells);
|
|
cellsList.Add (cells);
|
|
|
|
+
|
|
return StringFromRunes (cells);
|
|
return StringFromRunes (cells);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4668,6 +4658,7 @@ public class TextView : View
|
|
cellsList.AddRange ([]);
|
|
cellsList.AddRange ([]);
|
|
cells = model == null ? _model.GetLine (row) : model.GetLine (row);
|
|
cells = model == null ? _model.GetLine (row) : model.GetLine (row);
|
|
cellsList.Add (cells);
|
|
cellsList.Add (cells);
|
|
|
|
+
|
|
res = res
|
|
res = res
|
|
+ Environment.NewLine
|
|
+ Environment.NewLine
|
|
+ StringFromRunes (cells);
|
|
+ StringFromRunes (cells);
|
|
@@ -4703,7 +4694,7 @@ public class TextView : View
|
|
|
|
|
|
OnUnwrappedCursorPosition (cRow, cCol);
|
|
OnUnwrappedCursorPosition (cRow, cCol);
|
|
|
|
|
|
- return GetRegion (out _, sRow: startRow, sCol: startCol, cRow: cRow, cCol: cCol, model: model);
|
|
|
|
|
|
+ return GetRegion (out _, startRow, startCol, cRow, cCol, model);
|
|
}
|
|
}
|
|
|
|
|
|
private (int Row, int Col) GetUnwrappedPosition (int line, int col)
|
|
private (int Row, int Col) GetUnwrappedPosition (int line, int col)
|
|
@@ -4897,7 +4888,7 @@ public class TextView : View
|
|
{
|
|
{
|
|
_model.AddLine (CurrentRow + i, lines [i]);
|
|
_model.AddLine (CurrentRow + i, lines [i]);
|
|
|
|
|
|
- addedLines.Add ([..lines [i]]);
|
|
|
|
|
|
+ addedLines.Add ([.. lines [i]]);
|
|
}
|
|
}
|
|
|
|
|
|
if (rest is { })
|
|
if (rest is { })
|
|
@@ -5071,7 +5062,7 @@ public class TextView : View
|
|
}
|
|
}
|
|
|
|
|
|
_historyText.Add (
|
|
_historyText.Add (
|
|
- [ [.. GetCurrentLine ()]],
|
|
|
|
|
|
+ [[.. GetCurrentLine ()]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -5111,7 +5102,7 @@ public class TextView : View
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- _historyText.Add ([ [.. currentLine]], CursorPosition);
|
|
|
|
|
|
+ _historyText.Add ([[.. currentLine]], CursorPosition);
|
|
|
|
|
|
if (currentLine.Count == 0)
|
|
if (currentLine.Count == 0)
|
|
{
|
|
{
|
|
@@ -5178,7 +5169,7 @@ public class TextView : View
|
|
}
|
|
}
|
|
|
|
|
|
_historyText.Add (
|
|
_historyText.Add (
|
|
- [ [.. GetCurrentLine ()]],
|
|
|
|
|
|
+ [[.. GetCurrentLine ()]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -5202,14 +5193,14 @@ public class TextView : View
|
|
|
|
|
|
List<Cell> currentLine = GetCurrentLine ();
|
|
List<Cell> currentLine = GetCurrentLine ();
|
|
|
|
|
|
- _historyText.Add ([ [.. GetCurrentLine ()]], CursorPosition);
|
|
|
|
|
|
+ _historyText.Add ([[.. GetCurrentLine ()]], CursorPosition);
|
|
|
|
|
|
if (CurrentColumn == 0)
|
|
if (CurrentColumn == 0)
|
|
{
|
|
{
|
|
DeleteTextBackwards ();
|
|
DeleteTextBackwards ();
|
|
|
|
|
|
_historyText.ReplaceLast (
|
|
_historyText.ReplaceLast (
|
|
- [ [.. GetCurrentLine ()]],
|
|
|
|
|
|
+ [[.. GetCurrentLine ()]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -5248,7 +5239,7 @@ public class TextView : View
|
|
}
|
|
}
|
|
|
|
|
|
_historyText.Add (
|
|
_historyText.Add (
|
|
- [ [.. GetCurrentLine ()]],
|
|
|
|
|
|
+ [[.. GetCurrentLine ()]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -5270,14 +5261,14 @@ public class TextView : View
|
|
|
|
|
|
List<Cell> currentLine = GetCurrentLine ();
|
|
List<Cell> currentLine = GetCurrentLine ();
|
|
|
|
|
|
- _historyText.Add ([ [.. GetCurrentLine ()]], CursorPosition);
|
|
|
|
|
|
+ _historyText.Add ([[.. GetCurrentLine ()]], CursorPosition);
|
|
|
|
|
|
if (currentLine.Count == 0 || CurrentColumn == currentLine.Count)
|
|
if (currentLine.Count == 0 || CurrentColumn == currentLine.Count)
|
|
{
|
|
{
|
|
DeleteTextForwards ();
|
|
DeleteTextForwards ();
|
|
|
|
|
|
_historyText.ReplaceLast (
|
|
_historyText.ReplaceLast (
|
|
- [ [.. GetCurrentLine ()]],
|
|
|
|
|
|
+ [[.. GetCurrentLine ()]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -5307,7 +5298,7 @@ public class TextView : View
|
|
}
|
|
}
|
|
|
|
|
|
_historyText.Add (
|
|
_historyText.Add (
|
|
- [ [.. GetCurrentLine ()]],
|
|
|
|
|
|
+ [[.. GetCurrentLine ()]],
|
|
CursorPosition,
|
|
CursorPosition,
|
|
HistoryText.LineStatus.Replaced
|
|
HistoryText.LineStatus.Replaced
|
|
);
|
|
);
|
|
@@ -5579,6 +5570,7 @@ public class TextView : View
|
|
}
|
|
}
|
|
|
|
|
|
DoNeededAction ();
|
|
DoNeededAction ();
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5919,6 +5911,7 @@ public class TextView : View
|
|
private bool ProcessMoveDown ()
|
|
private bool ProcessMoveDown ()
|
|
{
|
|
{
|
|
ResetContinuousFindTrack ();
|
|
ResetContinuousFindTrack ();
|
|
|
|
+
|
|
if (_shiftSelecting && IsSelecting)
|
|
if (_shiftSelecting && IsSelecting)
|
|
{
|
|
{
|
|
StopSelecting ();
|
|
StopSelecting ();
|
|
@@ -5961,8 +5954,10 @@ public class TextView : View
|
|
if (IsSelecting)
|
|
if (IsSelecting)
|
|
{
|
|
{
|
|
StopSelecting ();
|
|
StopSelecting ();
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
// do not respond (this lets the key press fall through to navigation system - which usually changes focus backward)
|
|
// do not respond (this lets the key press fall through to navigation system - which usually changes focus backward)
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -6001,8 +5996,10 @@ public class TextView : View
|
|
{
|
|
{
|
|
// In which case clear
|
|
// In which case clear
|
|
StopSelecting ();
|
|
StopSelecting ();
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -6296,7 +6293,6 @@ public class TextView : View
|
|
_continuousFind = false;
|
|
_continuousFind = false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void ResetPosition ()
|
|
private void ResetPosition ()
|
|
{
|
|
{
|
|
_topRow = _leftColumn = CurrentRow = CurrentColumn = 0;
|
|
_topRow = _leftColumn = CurrentRow = CurrentColumn = 0;
|
|
@@ -6461,13 +6457,13 @@ public class TextView : View
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private void TextView_Initialized (object sender, EventArgs e)
|
|
private void TextView_Initialized (object sender, EventArgs e)
|
|
{
|
|
{
|
|
if (Autocomplete.HostControl is null)
|
|
if (Autocomplete.HostControl is null)
|
|
{
|
|
{
|
|
Autocomplete.HostControl = this;
|
|
Autocomplete.HostControl = this;
|
|
}
|
|
}
|
|
|
|
+
|
|
OnContentsChanged ();
|
|
OnContentsChanged ();
|
|
}
|
|
}
|
|
|
|
|