Sfoglia il codice sorgente

Change all RuneCell to Cell and move methods to the Cell record struct.

BDisp 10 mesi fa
parent
commit
ccf2daa024

+ 131 - 6
Terminal.Gui/Drawing/Cell.cs

@@ -4,19 +4,18 @@
 ///     Represents a single row/column in a Terminal.Gui rendering surface (e.g. <see cref="LineCanvas"/> and
 ///     Represents a single row/column in a Terminal.Gui rendering surface (e.g. <see cref="LineCanvas"/> and
 ///     <see cref="ConsoleDriver"/>).
 ///     <see cref="ConsoleDriver"/>).
 /// </summary>
 /// </summary>
-public record struct Cell ()
+public record struct Cell (Attribute? Attribute = null, bool IsDirty = false, Rune Rune = default)
 {
 {
-
     /// <summary>The attributes to use when drawing the Glyph.</summary>
     /// <summary>The attributes to use when drawing the Glyph.</summary>
-    public Attribute? Attribute { get; set; } = null;
+    public Attribute? Attribute { get; set; } = Attribute;
 
 
     /// <summary>
     /// <summary>
     ///     Gets or sets a value indicating whether this <see cref="T:Terminal.Gui.Cell"/> has been modified since the
     ///     Gets or sets a value indicating whether this <see cref="T:Terminal.Gui.Cell"/> has been modified since the
     ///     last time it was drawn.
     ///     last time it was drawn.
     /// </summary>
     /// </summary>
-    public bool IsDirty { get; set; } = false;
+    public bool IsDirty { get; set; } = IsDirty;
 
 
-    private Rune _rune = default;
+    private Rune _rune = Rune;
 
 
     /// <summary>The character to display. If <see cref="Rune"/> is <see langword="null"/>, then <see cref="Rune"/> is ignored.</summary>
     /// <summary>The character to display. If <see cref="Rune"/> is <see langword="null"/>, then <see cref="Rune"/> is ignored.</summary>
     public Rune Rune
     public Rune Rune
@@ -29,6 +28,8 @@ public record struct Cell ()
         }
         }
     }
     }
 
 
+    private List<Rune> _combiningMarks;
+
     /// <summary>
     /// <summary>
     ///     The combining marks for <see cref="Rune"/> that when combined makes this Cell a combining sequence. If
     ///     The combining marks for <see cref="Rune"/> that when combined makes this Cell a combining sequence. If
     ///     <see cref="CombiningMarks"/> empty, then <see cref="CombiningMarks"/> is ignored.
     ///     <see cref="CombiningMarks"/> empty, then <see cref="CombiningMarks"/> is ignored.
@@ -37,8 +38,132 @@ public record struct Cell ()
     ///     Only valid in the rare case where <see cref="Rune"/> is a combining sequence that could not be normalized to a
     ///     Only valid in the rare case where <see cref="Rune"/> is a combining sequence that could not be normalized to a
     ///     single Rune.
     ///     single Rune.
     /// </remarks>
     /// </remarks>
-    internal List<Rune> CombiningMarks { get; } = new ();
+    internal List<Rune> CombiningMarks
+    {
+        get => _combiningMarks ?? [];
+        private set => _combiningMarks = value ?? [];
+    }
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
     public override string ToString () { return $"[{Rune}, {Attribute}]"; }
     public override string ToString () { return $"[{Rune}, {Attribute}]"; }
+
+    /// <summary>Converts the string into a <see cref="List{Cell}"/>.</summary>
+    /// <param name="str">The string to convert.</param>
+    /// <param name="attribute">The <see cref="Gui.ColorScheme"/> to use.</param>
+    /// <returns></returns>
+    public static List<Cell> ToCellList (string str, Attribute? attribute = null)
+    {
+        List<Cell> cells = new ();
+
+        foreach (Rune rune in str.EnumerateRunes ())
+        {
+            cells.Add (new () { Rune = rune, Attribute = attribute });
+        }
+
+        return cells;
+    }
+
+    /// <summary>
+    ///     Splits a string into a List that will contain a <see cref="List{Cell}"/> for each line.
+    /// </summary>
+    /// <param name="content">The string content.</param>
+    /// <param name="attribute">The color scheme.</param>
+    /// <returns>A <see cref="List{Cell}"/> for each line.</returns>
+    public static List<List<Cell>> StringToLinesOfCells (string content, Attribute? attribute = null)
+    {
+        List<Cell> cells = content.EnumerateRunes ()
+                                      .Select (x => new Cell { Rune = x, Attribute = attribute })
+                                      .ToList ();
+
+        return SplitNewLines (cells);
+    }
+
+    /// <summary>Converts a <see cref="Cell"/> generic collection into a string.</summary>
+    /// <param name="cells">The enumerable cell to convert.</param>
+    /// <returns></returns>
+    public static string ToString (IEnumerable<Cell> cells)
+    {
+        var str = string.Empty;
+
+        foreach (Cell cell in cells)
+        {
+            str += cell.Rune.ToString ();
+        }
+
+        return str;
+    }
+
+    // Turns the string into cells, this does not split the contents on a newline if it is present.
+
+    internal static List<Cell> StringToCells (string str, Attribute? attribute = null)
+    {
+        List<Cell> cells = [];
+
+        foreach (Rune rune in str.ToRunes ())
+        {
+            cells.Add (new () { Rune = rune, Attribute = attribute });
+        }
+
+        return cells;
+    }
+
+    internal static List<Cell> ToCells (IEnumerable<Rune> runes, Attribute? attribute = null)
+    {
+        List<Cell> cells = new ();
+
+        foreach (Rune rune in runes)
+        {
+            cells.Add (new () { Rune = rune, Attribute = attribute });
+        }
+
+        return cells;
+    }
+
+    private static List<List<Cell>> SplitNewLines (List<Cell> cells)
+    {
+        List<List<Cell>> lines = [];
+        int start = 0, i = 0;
+        var hasCR = false;
+
+        // ASCII code 13 = Carriage Return.
+        // ASCII code 10 = Line Feed.
+        for (; i < cells.Count; i++)
+        {
+            if (cells [i].Rune.Value == 13)
+            {
+                hasCR = true;
+
+                continue;
+            }
+
+            if (cells [i].Rune.Value == 10)
+            {
+                if (i - start > 0)
+                {
+                    lines.Add (cells.GetRange (start, hasCR ? i - 1 - start : i - start));
+                }
+                else
+                {
+                    lines.Add (StringToCells (string.Empty));
+                }
+
+                start = i + 1;
+                hasCR = false;
+            }
+        }
+
+        if (i - start >= 0)
+        {
+            lines.Add (cells.GetRange (start, i - start));
+        }
+
+        return lines;
+    }
+
+    /// <summary>
+    ///     Splits a rune cell list into a List that will contain a <see cref="List{Cell}"/> for each line.
+    /// </summary>
+    /// <param name="cells">The cells list.</param>
+    /// <returns></returns>
+    public static List<List<Cell>> ToCells (List<Cell> cells) { return SplitNewLines (cells); }
 }
 }

+ 8 - 8
Terminal.Gui/Views/RuneCellEventArgs.cs → Terminal.Gui/Drawing/CellEventArgs.cs

@@ -1,27 +1,27 @@
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
-/// <summary>Args for events that relate to a specific <see cref="RuneCell"/>.</summary>
-public class RuneCellEventArgs
+/// <summary>Args for events that relate to a specific <see cref="Cell"/>.</summary>
+public class CellEventArgs
 {
 {
-    /// <summary>Creates a new instance of the <see cref="RuneCellEventArgs"/> class.</summary>
+    /// <summary>Creates a new instance of the <see cref="CellEventArgs"/> class.</summary>
     /// <param name="line">The line.</param>
     /// <param name="line">The line.</param>
     /// <param name="col">The col index.</param>
     /// <param name="col">The col index.</param>
     /// <param name="unwrappedPosition">The unwrapped row and col index.</param>
     /// <param name="unwrappedPosition">The unwrapped row and col index.</param>
-    public RuneCellEventArgs (List<RuneCell> line, int col, (int Row, int Col) unwrappedPosition)
+    public CellEventArgs (List<Cell> line, int col, (int Row, int Col) unwrappedPosition)
     {
     {
         Line = line;
         Line = line;
         Col = col;
         Col = col;
         UnwrappedPosition = unwrappedPosition;
         UnwrappedPosition = unwrappedPosition;
     }
     }
 
 
-    /// <summary>The index of the RuneCell in the line.</summary>
+    /// <summary>The index of the Cell in the line.</summary>
     public int Col { get; }
     public int Col { get; }
 
 
-    /// <summary>The list of runes the RuneCell is part of.</summary>
-    public List<RuneCell> Line { get; }
+    /// <summary>The list of runes the Cell is part of.</summary>
+    public List<Cell> Line { get; }
 
 
     /// <summary>
     /// <summary>
-    ///     The unwrapped row and column index into the text containing the RuneCell. Unwrapped means the text without
+    ///     The unwrapped row and column index into the text containing the Cell. Unwrapped means the text without
     ///     word wrapping or other visual formatting having been applied.
     ///     word wrapping or other visual formatting having been applied.
     /// </summary>
     /// </summary>
     public (int Row, int Col) UnwrappedPosition { get; }
     public (int Row, int Col) UnwrappedPosition { get; }

+ 1 - 1
Terminal.Gui/Drawing/LineCanvas.cs

@@ -138,7 +138,7 @@ public class LineCanvas : IDisposable
         int length,
         int length,
         Orientation orientation,
         Orientation orientation,
         LineStyle style,
         LineStyle style,
-        Attribute? attribute = default
+        Attribute? attribute = null
     )
     )
     {
     {
         _cachedViewport = Rectangle.Empty;
         _cachedViewport = Rectangle.Empty;

+ 1 - 1
Terminal.Gui/Drawing/StraightLine.cs

@@ -16,7 +16,7 @@ public class StraightLine
         int length,
         int length,
         Orientation orientation,
         Orientation orientation,
         LineStyle style,
         LineStyle style,
-        Attribute? attribute = default
+        Attribute? attribute = null
     )
     )
     {
     {
         Start = start;
         Start = start;

+ 2 - 2
Terminal.Gui/Text/Autocomplete/AutocompleteContext.cs

@@ -7,7 +7,7 @@ namespace Terminal.Gui;
 public class AutocompleteContext
 public class AutocompleteContext
 {
 {
     /// <summary>Creates a new instance of the <see cref="AutocompleteContext"/> class</summary>
     /// <summary>Creates a new instance of the <see cref="AutocompleteContext"/> class</summary>
-    public AutocompleteContext (List<RuneCell> currentLine, int cursorPosition, bool canceled = false)
+    public AutocompleteContext (List<Cell> currentLine, int cursorPosition, bool canceled = false)
     {
     {
         CurrentLine = currentLine;
         CurrentLine = currentLine;
         CursorPosition = cursorPosition;
         CursorPosition = cursorPosition;
@@ -18,7 +18,7 @@ public class AutocompleteContext
     public bool Canceled { get; set; }
     public bool Canceled { get; set; }
 
 
     /// <summary>The text on the current line.</summary>
     /// <summary>The text on the current line.</summary>
-    public List<RuneCell> CurrentLine { get; set; }
+    public List<Cell> CurrentLine { get; set; }
 
 
     /// <summary>The position of the input cursor within the <see cref="CurrentLine"/>.</summary>
     /// <summary>The position of the input cursor within the <see cref="CurrentLine"/>.</summary>
     public int CursorPosition { get; set; }
     public int CursorPosition { get; set; }

+ 2 - 2
Terminal.Gui/Views/AutocompleteFilepathContext.cs

@@ -6,7 +6,7 @@ namespace Terminal.Gui;
 internal class AutocompleteFilepathContext : AutocompleteContext
 internal class AutocompleteFilepathContext : AutocompleteContext
 {
 {
     public AutocompleteFilepathContext (string currentLine, int cursorPosition, FileDialogState state)
     public AutocompleteFilepathContext (string currentLine, int cursorPosition, FileDialogState state)
-        : base (RuneCell.ToRuneCellList (currentLine), cursorPosition)
+        : base (Cell.ToCellList (currentLine), cursorPosition)
     {
     {
         State = state;
         State = state;
     }
     }
@@ -30,7 +30,7 @@ internal class FilepathSuggestionGenerator : ISuggestionGenerator
             return Enumerable.Empty<Suggestion> ();
             return Enumerable.Empty<Suggestion> ();
         }
         }
 
 
-        var path = RuneCell.ToString (context.CurrentLine);
+        var path = Cell.ToString (context.CurrentLine);
         int last = path.LastIndexOfAny (FileDialog.Separators);
         int last = path.LastIndexOfAny (FileDialog.Separators);
 
 
         if (string.IsNullOrWhiteSpace (path) || !Path.IsPathRooted (path))
         if (string.IsNullOrWhiteSpace (path) || !Path.IsPathRooted (path))

+ 3 - 3
Terminal.Gui/Views/HistoryTextItemEventArgs.cs

@@ -9,11 +9,11 @@ internal partial class HistoryText
         public Point CursorPosition;
         public Point CursorPosition;
         public Point FinalCursorPosition;
         public Point FinalCursorPosition;
         public bool IsUndoing;
         public bool IsUndoing;
-        public List<List<RuneCell>> Lines;
+        public List<List<Cell>> Lines;
         public LineStatus LineStatus;
         public LineStatus LineStatus;
         public HistoryTextItemEventArgs RemovedOnAdded;
         public HistoryTextItemEventArgs RemovedOnAdded;
 
 
-        public HistoryTextItemEventArgs (List<List<RuneCell>> lines, Point curPos, LineStatus linesStatus)
+        public HistoryTextItemEventArgs (List<List<Cell>> lines, Point curPos, LineStatus linesStatus)
         {
         {
             Lines = lines;
             Lines = lines;
             CursorPosition = curPos;
             CursorPosition = curPos;
@@ -22,7 +22,7 @@ internal partial class HistoryText
 
 
         public HistoryTextItemEventArgs (HistoryTextItemEventArgs historyTextItem)
         public HistoryTextItemEventArgs (HistoryTextItemEventArgs historyTextItem)
         {
         {
-            Lines = new List<List<RuneCell>> (historyTextItem.Lines);
+            Lines = new List<List<Cell>> (historyTextItem.Lines);
             CursorPosition = new Point (historyTextItem.CursorPosition.X, historyTextItem.CursorPosition.Y);
             CursorPosition = new Point (historyTextItem.CursorPosition.X, historyTextItem.CursorPosition.Y);
             LineStatus = historyTextItem.LineStatus;
             LineStatus = historyTextItem.LineStatus;
         }
         }

+ 7 - 7
Terminal.Gui/Views/TextField.cs

@@ -546,12 +546,12 @@ public class TextField : View
             if (!Secret && !_historyText.IsFromHistory)
             if (!Secret && !_historyText.IsFromHistory)
             {
             {
                 _historyText.Add (
                 _historyText.Add (
-                                  new List<List<RuneCell>> { RuneCell.ToRuneCellList (oldText) },
+                                  new List<List<Cell>> { Cell.ToCellList (oldText) },
                                   new Point (_cursorPosition, 0)
                                   new Point (_cursorPosition, 0)
                                  );
                                  );
 
 
                 _historyText.Add (
                 _historyText.Add (
-                                  new List<List<RuneCell>> { RuneCell.ToRuneCells (_text) },
+                                  new List<List<Cell>> { Cell.ToCells (_text) },
                                   new Point (_cursorPosition, 0),
                                   new Point (_cursorPosition, 0),
                                   HistoryText.LineStatus.Replaced
                                   HistoryText.LineStatus.Replaced
                                  );
                                  );
@@ -648,7 +648,7 @@ public class TextField : View
         }
         }
 
 
         _historyText.Add (
         _historyText.Add (
-                          new List<List<RuneCell>> { RuneCell.ToRuneCells (_text) },
+                          new List<List<Cell>> { Cell.ToCells (_text) },
                           new Point (_cursorPosition, 0)
                           new Point (_cursorPosition, 0)
                          );
                          );
 
 
@@ -702,7 +702,7 @@ public class TextField : View
         }
         }
 
 
         _historyText.Add (
         _historyText.Add (
-                          new List<List<RuneCell>> { RuneCell.ToRuneCells (_text) },
+                          new List<List<Cell>> { Cell.ToCells (_text) },
                           new Point (_cursorPosition, 0)
                           new Point (_cursorPosition, 0)
                          );
                          );
 
 
@@ -1342,7 +1342,7 @@ public class TextField : View
 
 
     private void GenerateSuggestions ()
     private void GenerateSuggestions ()
     {
     {
-        List<RuneCell> currentLine = RuneCell.ToRuneCellList (Text);
+        List<Cell> currentLine = Cell.ToCellList (Text);
         int cursorPosition = Math.Min (CursorPosition, currentLine.Count);
         int cursorPosition = Math.Min (CursorPosition, currentLine.Count);
 
 
         Autocomplete.Context = new AutocompleteContext (
         Autocomplete.Context = new AutocompleteContext (
@@ -1390,7 +1390,7 @@ public class TextField : View
             return;
             return;
         }
         }
 
 
-        Text = RuneCell.ToString (obj?.Lines [obj.CursorPosition.Y]);
+        Text = Cell.ToString (obj?.Lines [obj.CursorPosition.Y]);
         CursorPosition = obj.CursorPosition.X;
         CursorPosition = obj.CursorPosition.X;
         Adjust ();
         Adjust ();
     }
     }
@@ -1398,7 +1398,7 @@ public class TextField : View
     private void InsertText (Key a, bool usePreTextChangedCursorPos)
     private void InsertText (Key a, bool usePreTextChangedCursorPos)
     {
     {
         _historyText.Add (
         _historyText.Add (
-                          new List<List<RuneCell>> { RuneCell.ToRuneCells (_text) },
+                          new List<List<Cell>> { Cell.ToCells (_text) },
                           new Point (_cursorPosition, 0)
                           new Point (_cursorPosition, 0)
                          );
                          );
 
 

File diff suppressed because it is too large
+ 133 - 283
Terminal.Gui/Views/TextView.cs


+ 9 - 9
Terminal.Gui/Views/TreeView/Branch.cs

@@ -75,7 +75,7 @@ internal class Branch<T> where T : class
     /// <param name="availableWidth"></param>
     /// <param name="availableWidth"></param>
     public virtual void Draw (ConsoleDriver driver, ColorScheme colorScheme, int y, int availableWidth)
     public virtual void Draw (ConsoleDriver driver, ColorScheme colorScheme, int y, int availableWidth)
     {
     {
-        List<RuneCell> cells = new ();
+        List<Cell> cells = new ();
         int? indexOfExpandCollapseSymbol = null;
         int? indexOfExpandCollapseSymbol = null;
         int indexOfModelText;
         int indexOfModelText;
 
 
@@ -106,7 +106,7 @@ internal class Branch<T> where T : class
             }
             }
             else
             else
             {
             {
-                cells.Add (NewRuneCell (attr, r));
+                cells.Add (NewCell (attr, r));
                 availableWidth -= r.GetColumns ();
                 availableWidth -= r.GetColumns ();
             }
             }
         }
         }
@@ -148,7 +148,7 @@ internal class Branch<T> where T : class
         else
         else
         {
         {
             indexOfExpandCollapseSymbol = cells.Count;
             indexOfExpandCollapseSymbol = cells.Count;
-            cells.Add (NewRuneCell (attr, expansion));
+            cells.Add (NewCell (attr, expansion));
             availableWidth -= expansion.GetColumns ();
             availableWidth -= expansion.GetColumns ();
         }
         }
 
 
@@ -211,7 +211,7 @@ internal class Branch<T> where T : class
         }
         }
 
 
         attr = modelColor;
         attr = modelColor;
-        cells.AddRange (lineBody.Select (r => NewRuneCell (attr, new Rune (r))));
+        cells.AddRange (lineBody.Select (r => NewCell (attr, new Rune (r))));
 
 
         if (availableWidth > 0)
         if (availableWidth > 0)
         {
         {
@@ -219,7 +219,7 @@ internal class Branch<T> where T : class
 
 
             cells.AddRange (
             cells.AddRange (
                             Enumerable.Repeat (
                             Enumerable.Repeat (
-                                               NewRuneCell (attr, new Rune (' ')),
+                                               NewCell (attr, new Rune (' ')),
                                                availableWidth
                                                availableWidth
                                               )
                                               )
                            );
                            );
@@ -229,7 +229,7 @@ internal class Branch<T> where T : class
         {
         {
             Model = Model,
             Model = Model,
             Y = y,
             Y = y,
-            RuneCells = cells,
+            Cells = cells,
             Tree = tree,
             Tree = tree,
             IndexOfExpandCollapseSymbol =
             IndexOfExpandCollapseSymbol =
                 indexOfExpandCollapseSymbol,
                 indexOfExpandCollapseSymbol,
@@ -239,9 +239,9 @@ internal class Branch<T> where T : class
 
 
         if (!e.Handled)
         if (!e.Handled)
         {
         {
-            foreach (RuneCell cell in cells)
+            foreach (Cell cell in cells)
             {
             {
-                driver.SetAttribute (cell.ColorScheme.Normal);
+                driver.SetAttribute ((Attribute)cell.Attribute!);
                 driver.AddRune (cell.Rune);
                 driver.AddRune (cell.Rune);
             }
             }
         }
         }
@@ -529,5 +529,5 @@ internal class Branch<T> where T : class
         return Parent.ChildBranches.Values.LastOrDefault () == this;
         return Parent.ChildBranches.Values.LastOrDefault () == this;
     }
     }
 
 
-    private static RuneCell NewRuneCell (Attribute attr, Rune r) { return new RuneCell { Rune = r, ColorScheme = new ColorScheme (attr) }; }
+    private static Cell NewCell (Attribute attr, Rune r) { return new Cell { Rune = r, Attribute = new (attr) }; }
 }
 }

+ 4 - 4
Terminal.Gui/Views/TreeView/DrawTreeViewLineEventArgs.cs

@@ -12,16 +12,16 @@ public class DrawTreeViewLineEventArgs<T> where T : class
     public bool Handled { get; set; }
     public bool Handled { get; set; }
 
 
     /// <summary>
     /// <summary>
-    ///     If line contains a branch that can be expanded/collapsed then this is the index in <see cref="RuneCells"/> at
+    ///     If line contains a branch that can be expanded/collapsed then this is the index in <see cref="Cells"/> at
     ///     which the symbol is (or null for leaf elements).
     ///     which the symbol is (or null for leaf elements).
     /// </summary>
     /// </summary>
     public int? IndexOfExpandCollapseSymbol { get; init; }
     public int? IndexOfExpandCollapseSymbol { get; init; }
 
 
     /// <summary>
     /// <summary>
-    ///     The notional index in <see cref="RuneCells"/> which contains the first character of the
+    ///     The notional index in <see cref="Cells"/> which contains the first character of the
     ///     <see cref="TreeView{T}.AspectGetter"/> text (i.e. after all branch lines and expansion/collapse symbols).
     ///     <see cref="TreeView{T}.AspectGetter"/> text (i.e. after all branch lines and expansion/collapse symbols).
     /// </summary>
     /// </summary>
-    /// <remarks>May be negative or outside of bounds of <see cref="RuneCells"/> if the view has been scrolled horizontally.</remarks>
+    /// <remarks>May be negative or outside of bounds of <see cref="Cells"/> if the view has been scrolled horizontally.</remarks>
     public int IndexOfModelText { get; init; }
     public int IndexOfModelText { get; init; }
 
 
     /// <summary>The object at this line in the tree</summary>
     /// <summary>The object at this line in the tree</summary>
@@ -32,7 +32,7 @@ public class DrawTreeViewLineEventArgs<T> where T : class
     ///     respected.  You can modify these to change what is rendered.
     ///     respected.  You can modify these to change what is rendered.
     /// </summary>
     /// </summary>
     /// <remarks>Changing the length of this collection may result in corrupt rendering</remarks>
     /// <remarks>Changing the length of this collection may result in corrupt rendering</remarks>
-    public List<RuneCell> RuneCells { get; init; }
+    public List<Cell> Cells { get; init; }
 
 
     /// <summary>The <see cref="TreeView{T}"/> that is performing the rendering.</summary>
     /// <summary>The <see cref="TreeView{T}"/> that is performing the rendering.</summary>
     public TreeView<T> Tree { get; init; }
     public TreeView<T> Tree { get; init; }

+ 15 - 17
UICatalog/Scenarios/Editor.cs

@@ -210,22 +210,18 @@ public class Editor : Scenario
                                        {
                                        {
                                            if (!PromptForColor (
                                            if (!PromptForColor (
                                                                 "Colors",
                                                                 "Colors",
-                                                                GetSelectedRuneCellAttribute (),
+                                                                GetSelectedCellAttribute (),
                                                                 out Attribute newAttribute
                                                                 out Attribute newAttribute
                                                                ))
                                                                ))
                                            {
                                            {
                                                return;
                                                return;
                                            }
                                            }
 
 
-                                           var cs = new ColorScheme (_textView.ColorScheme)
-                                           {
-                                               Focus = new (
-                                                                          newAttribute.Foreground,
+                                           var attribute = new Attribute (newAttribute.Foreground,
                                                                           newAttribute.Background
                                                                           newAttribute.Background
-                                                                         )
-                                           };
+                                                                         );
 
 
-                                           ApplyRuneCellAttribute (cs);
+                                           ApplyCellAttribute (attribute);
                                        })
                                        })
                      }
                      }
                     ),
                     ),
@@ -341,7 +337,7 @@ public class Editor : Scenario
 
 
     }
     }
 
 
-    private void ApplyRuneCellAttribute (ColorScheme cs)
+    private void ApplyCellAttribute (Attribute attribute)
     {
     {
         if (!_textView.ReadOnly && _textView.SelectedLength > 0)
         if (!_textView.ReadOnly && _textView.SelectedLength > 0)
         {
         {
@@ -352,29 +348,31 @@ public class Editor : Scenario
 
 
             for (int r = startRow; r <= endRow; r++)
             for (int r = startRow; r <= endRow; r++)
             {
             {
-                List<RuneCell> line = _textView.GetLine (r);
+                List<Cell> line = _textView.GetLine (r);
 
 
                 for (int c = r == startRow ? startCol : 0;
                 for (int c = r == startRow ? startCol : 0;
                      c < (r == endRow ? endCol : line.Count);
                      c < (r == endRow ? endCol : line.Count);
                      c++)
                      c++)
                 {
                 {
-                    line [c].ColorScheme = cs;
+                    Cell cell = line [c]; // Copy value to a new variable
+                    cell.Attribute = attribute; // Modify the copy
+                    line [c] = cell; // Assign the modified copy back
                 }
                 }
             }
             }
         }
         }
     }
     }
 
 
-    private Attribute? GetSelectedRuneCellAttribute ()
+    private Attribute? GetSelectedCellAttribute ()
     {
     {
-        List<RuneCell> line;
+        List<Cell> line;
 
 
         if (_textView.SelectedLength > 0)
         if (_textView.SelectedLength > 0)
         {
         {
             line = _textView.GetLine (_textView.SelectionStartRow);
             line = _textView.GetLine (_textView.SelectionStartRow);
 
 
-            if (line [Math.Min (_textView.SelectionStartColumn, line.Count - 1)].ColorScheme is { } csSel)
+            if (line [Math.Min (_textView.SelectionStartColumn, line.Count - 1)].Attribute is { } attributeSel)
             {
             {
-                return new (csSel.Focus);
+                return new (attributeSel);
             }
             }
 
 
             return new (_textView.ColorScheme!.Focus);
             return new (_textView.ColorScheme!.Focus);
@@ -382,9 +380,9 @@ public class Editor : Scenario
 
 
         line = _textView.GetCurrentLine ();
         line = _textView.GetCurrentLine ();
 
 
-        if (line [Math.Min (_textView.CurrentColumn, line.Count - 1)].ColorScheme is { } cs)
+        if (line [Math.Min (_textView.CurrentColumn, line.Count - 1)].Attribute is { } attribute)
         {
         {
-            return new (cs!.Focus);
+            return new (attribute);
         }
         }
 
 
         return new (_textView.ColorScheme!.Focus);
         return new (_textView.ColorScheme!.Focus);

+ 31 - 28
UICatalog/Scenarios/SyntaxHighlighting.cs

@@ -85,13 +85,13 @@ public class SyntaxHighlighting : Scenario
         "exists"
         "exists"
     };
     };
 
 
-    private readonly string _path = "RuneCells.rce";
-    private ColorScheme _blue;
-    private ColorScheme _green;
-    private ColorScheme _magenta;
+    private readonly string _path = "Cells.rce";
+    private Attribute _blue;
+    private Attribute _green;
+    private Attribute _magenta;
     private MenuItem _miWrap;
     private MenuItem _miWrap;
     private TextView _textView;
     private TextView _textView;
-    private ColorScheme _white;
+    private Attribute _white;
 
 
     /// <summary>
     /// <summary>
     ///     Reads an object instance from an Json file.
     ///     Reads an object instance from an Json file.
@@ -155,12 +155,12 @@ public class SyntaxHighlighting : Scenario
                          new (
                          new (
                               "_Load Rune Cells",
                               "_Load Rune Cells",
                               "",
                               "",
-                              () => ApplyLoadRuneCells ()
+                              () => ApplyLoadCells ()
                              ),
                              ),
                          new (
                          new (
                               "_Save Rune Cells",
                               "_Save Rune Cells",
                               "",
                               "",
-                              () => SaveRuneCells ()
+                              () => SaveCells ()
                              ),
                              ),
                          null,
                          null,
                          new ("_Quit", "", () => Quit ())
                          new ("_Quit", "", () => Quit ())
@@ -231,11 +231,11 @@ public class SyntaxHighlighting : Scenario
         }
         }
     }
     }
 
 
-    private void ApplyLoadRuneCells ()
+    private void ApplyLoadCells ()
     {
     {
         ClearAllEvents ();
         ClearAllEvents ();
 
 
-        List<RuneCell> runeCells = new ();
+        List<Cell> cells = new ();
 
 
         foreach (KeyValuePair<string, ColorScheme> color in Colors.ColorSchemes)
         foreach (KeyValuePair<string, ColorScheme> color in Colors.ColorSchemes)
         {
         {
@@ -243,21 +243,21 @@ public class SyntaxHighlighting : Scenario
 
 
             foreach (Rune rune in csName.EnumerateRunes ())
             foreach (Rune rune in csName.EnumerateRunes ())
             {
             {
-                runeCells.Add (new() { Rune = rune, ColorScheme = color.Value });
+                cells.Add (new() { Rune = rune, Attribute = color.Value.Normal });
             }
             }
 
 
-            runeCells.Add (new() { Rune = (Rune)'\n', ColorScheme = color.Value });
+            cells.Add (new() { Rune = (Rune)'\n', Attribute = color.Value.Focus });
         }
         }
 
 
         if (File.Exists (_path))
         if (File.Exists (_path))
         {
         {
-            //Reading the file  
-            List<List<RuneCell>> cells = ReadFromJsonFile<List<List<RuneCell>>> (_path);
-            _textView.Load (cells);
+            //Reading the file
+            List<List<Cell>> fileCells = ReadFromJsonFile<List<List<Cell>>> (_path);
+            _textView.Load (fileCells);
         }
         }
         else
         else
         {
         {
-            _textView.Load (runeCells);
+            _textView.Load (cells);
         }
         }
 
 
         _textView.Autocomplete.SuggestionGenerator = new SingleWordSuggestionGenerator ();
         _textView.Autocomplete.SuggestionGenerator = new SingleWordSuggestionGenerator ();
@@ -267,11 +267,11 @@ public class SyntaxHighlighting : Scenario
     {
     {
         ClearAllEvents ();
         ClearAllEvents ();
 
 
-        _green = new (new Attribute (Color.Green, Color.Black));
-        _blue = new (new Attribute (Color.Blue, Color.Black));
-        _magenta = new (new Attribute (Color.Magenta, Color.Black));
-        _white = new (new Attribute (Color.White, Color.Black));
-        _textView.ColorScheme = _white;
+        _green = new Attribute (Color.Green, Color.Black);
+        _blue = new Attribute (Color.Blue, Color.Black);
+        _magenta = new Attribute (Color.Magenta, Color.Black);
+        _white = new Attribute (Color.White, Color.Black);
+        _textView.ColorScheme = new () { Focus = _white };
 
 
         _textView.Text =
         _textView.Text =
             "/*Query to select:\nLots of data*/\nSELECT TOP 100 * \nfrom\n MyDb.dbo.Biochemistry where TestCode = 'blah';";
             "/*Query to select:\nLots of data*/\nSELECT TOP 100 * \nfrom\n MyDb.dbo.Biochemistry where TestCode = 'blah';";
@@ -292,7 +292,7 @@ public class SyntaxHighlighting : Scenario
         _textView.ClearEventHandlers ("DrawContent");
         _textView.ClearEventHandlers ("DrawContent");
         _textView.ClearEventHandlers ("DrawContentComplete");
         _textView.ClearEventHandlers ("DrawContentComplete");
 
 
-        _textView.InheritsPreviousColorScheme = false;
+        _textView.InheritsPreviousAttribute = false;
     }
     }
 
 
     private bool ContainsPosition (Match m, int pos) { return pos >= m.Index && pos < m.Index + m.Length; }
     private bool ContainsPosition (Match m, int pos) { return pos >= m.Index && pos < m.Index + m.Length; }
@@ -317,27 +317,30 @@ public class SyntaxHighlighting : Scenario
 
 
         for (var y = 0; y < _textView.Lines; y++)
         for (var y = 0; y < _textView.Lines; y++)
         {
         {
-            List<RuneCell> line = _textView.GetLine (y);
+            List<Cell> line = _textView.GetLine (y);
 
 
             for (var x = 0; x < line.Count; x++)
             for (var x = 0; x < line.Count; x++)
             {
             {
+                Cell cell = line [x];
+
                 if (commentMatches.Any (m => ContainsPosition (m, pos)))
                 if (commentMatches.Any (m => ContainsPosition (m, pos)))
                 {
                 {
-                    line [x].ColorScheme = _green;
+                    cell.Attribute = _green;
                 }
                 }
                 else if (singleQuoteMatches.Any (m => ContainsPosition (m, pos)))
                 else if (singleQuoteMatches.Any (m => ContainsPosition (m, pos)))
                 {
                 {
-                    line [x].ColorScheme = _magenta;
+                    cell.Attribute = _magenta;
                 }
                 }
                 else if (keywordMatches.Any (m => ContainsPosition (m, pos)))
                 else if (keywordMatches.Any (m => ContainsPosition (m, pos)))
                 {
                 {
-                    line [x].ColorScheme = _blue;
+                    cell.Attribute = _blue;
                 }
                 }
                 else
                 else
                 {
                 {
-                    line [x].ColorScheme = _white;
+                    cell.Attribute = _white;
                 }
                 }
 
 
+                line [x] = cell;
                 pos++;
                 pos++;
             }
             }
 
 
@@ -384,10 +387,10 @@ public class SyntaxHighlighting : Scenario
 
 
     private void Quit () { Application.RequestStop (); }
     private void Quit () { Application.RequestStop (); }
 
 
-    private void SaveRuneCells ()
+    private void SaveCells ()
     {
     {
         //Writing to file  
         //Writing to file  
-        List<List<RuneCell>> cells = _textView.GetAllLines ();
+        List<List<Cell>> cells = _textView.GetAllLines ();
         WriteToJsonFile (_path, cells);
         WriteToJsonFile (_path, cells);
     }
     }
 
 

+ 7 - 9
UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -441,16 +441,14 @@ public class TreeViewFileSystem : Scenario
         {
         {
             if (_iconProvider.UseNerdIcons || _iconProvider.UseUnicodeCharacters)
             if (_iconProvider.UseNerdIcons || _iconProvider.UseUnicodeCharacters)
             {
             {
-                if (e.IndexOfModelText > 0 && e.IndexOfModelText < e.RuneCells.Count)
+                if (e.IndexOfModelText > 0 && e.IndexOfModelText < e.Cells.Count)
                 {
                 {
-                    RuneCell cell = e.RuneCells [e.IndexOfModelText];
-
-                    cell.ColorScheme = new ColorScheme (
-                                                        new Attribute (
-                                                                       Color.BrightYellow,
-                                                                       cell.ColorScheme.Normal.Background
-                                                                      )
-                                                       );
+                    Cell cell = e.Cells [e.IndexOfModelText];
+
+                    cell.Attribute = new Attribute (
+                                                    Color.BrightYellow,
+                                                    cell.Attribute!.Value.Background
+                                                   );
                 }
                 }
             }
             }
         }
         }

+ 1 - 0
UnitTests/Configuration/ThemeTests.cs

@@ -10,6 +10,7 @@ public class ThemeTests
         Converters = { new AttributeJsonConverter (), new ColorJsonConverter () }
         Converters = { new AttributeJsonConverter (), new ColorJsonConverter () }
     };
     };
 
 
+    [Fact]
     [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
     [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
     public void TestApply ()
     public void TestApply ()
     {
     {

+ 86 - 82
UnitTests/Views/RuneCellTests.cs → UnitTests/Drawing/CellTests.cs

@@ -1,59 +1,59 @@
 using System.Text;
 using System.Text;
 using Xunit.Abstractions;
 using Xunit.Abstractions;
 
 
-namespace Terminal.Gui.ViewsTests;
+namespace Terminal.Gui.DrawingTests;
 
 
-public class RuneCellTests (ITestOutputHelper output)
+public class CellTests (ITestOutputHelper output)
 {
 {
     [Fact]
     [Fact]
     public void Constructor_Defaults ()
     public void Constructor_Defaults ()
     {
     {
-        var rc = new RuneCell ();
-        Assert.NotNull (rc);
-        Assert.Equal (0, rc.Rune.Value);
-        Assert.Null (rc.ColorScheme);
+        var c = new Cell ();
+        Assert.True (c is { });
+        Assert.Equal (0, c.Rune.Value);
+        Assert.Null (c.Attribute);
     }
     }
 
 
     [Fact]
     [Fact]
     public void Equals_False ()
     public void Equals_False ()
     {
     {
-        var rc1 = new RuneCell ();
+        var c1 = new Cell ();
 
 
-        var rc2 = new RuneCell
+        var c2 = new Cell
         {
         {
-            Rune = new ('a'), ColorScheme = new() { Normal = new (Color.Red) }
+            Rune = new ('a'), Attribute = new (Color.Red)
         };
         };
-        Assert.False (rc1.Equals (rc2));
-        Assert.False (rc2.Equals (rc1));
-
-        rc1.Rune = new ('a');
-        rc1.ColorScheme = new ();
-        Assert.Equal (rc1.Rune, rc2.Rune);
-        Assert.False (rc1.Equals (rc2));
-        Assert.False (rc2.Equals (rc1));
+        Assert.False (c1.Equals (c2));
+        Assert.False (c2.Equals (c1));
+
+        c1.Rune = new ('a');
+        c1.Attribute = new ();
+        Assert.Equal (c1.Rune, c2.Rune);
+        Assert.False (c1.Equals (c2));
+        Assert.False (c2.Equals (c1));
     }
     }
 
 
     [Fact]
     [Fact]
     public void Equals_True ()
     public void Equals_True ()
     {
     {
-        var rc1 = new RuneCell ();
-        var rc2 = new RuneCell ();
-        Assert.True (rc1.Equals (rc2));
-        Assert.True (rc2.Equals (rc1));
-
-        rc1.Rune = new ('a');
-        rc1.ColorScheme = new ();
-        rc2.Rune = new ('a');
-        rc2.ColorScheme = new ();
-        Assert.True (rc1.Equals (rc2));
-        Assert.True (rc2.Equals (rc1));
+        var c1 = new Cell ();
+        var c2 = new Cell ();
+        Assert.True (c1.Equals (c2));
+        Assert.True (c2.Equals (c1));
+
+        c1.Rune = new ('a');
+        c1.Attribute = new ();
+        c2.Rune = new ('a');
+        c2.Attribute = new ();
+        Assert.True (c1.Equals (c2));
+        Assert.True (c2.Equals (c1));
     }
     }
 
 
     [Fact]
     [Fact]
     [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
     [AutoInitShutdown (configLocation: ConfigurationManager.ConfigLocations.DefaultOnly)]
-    public void RuneCell_LoadRuneCells_InheritsPreviousColorScheme ()
+    public void Cell_LoadCells_InheritsPreviousAttribute ()
     {
     {
-        List<RuneCell> runeCells = new ();
+        List<Cell> cells = [];
 
 
         foreach (KeyValuePair<string, ColorScheme> color in Colors.ColorSchemes)
         foreach (KeyValuePair<string, ColorScheme> color in Colors.ColorSchemes)
         {
         {
@@ -61,18 +61,18 @@ public class RuneCellTests (ITestOutputHelper output)
 
 
             foreach (Rune rune in csName.EnumerateRunes ())
             foreach (Rune rune in csName.EnumerateRunes ())
             {
             {
-                runeCells.Add (new() { Rune = rune, ColorScheme = color.Value });
+                cells.Add (new() { Rune = rune, Attribute = color.Value.Normal });
             }
             }
 
 
-            runeCells.Add (new() { Rune = (Rune)'\n', ColorScheme = color.Value });
+            cells.Add (new() { Rune = (Rune)'\n', Attribute = color.Value.Focus });
         }
         }
 
 
         TextView tv = CreateTextView ();
         TextView tv = CreateTextView ();
-        tv.Load (runeCells);
+        tv.Load (cells);
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (tv);
         top.Add (tv);
         RunState rs = Application.Begin (top);
         RunState rs = Application.Begin (top);
-        Assert.True (tv.InheritsPreviousColorScheme);
+        Assert.True (tv.InheritsPreviousAttribute);
 
 
         var expectedText = @"
         var expectedText = @"
 TopLevel
 TopLevel
@@ -85,27 +85,30 @@ Error   ";
         Attribute [] attributes =
         Attribute [] attributes =
         {
         {
             // 0
             // 0
-            Colors.ColorSchemes ["TopLevel"].Focus,
+            Colors.ColorSchemes ["TopLevel"].Normal,
 
 
             // 1
             // 1
-            Colors.ColorSchemes ["Base"].Focus,
+            Colors.ColorSchemes ["Base"].Normal,
 
 
             // 2
             // 2
-            Colors.ColorSchemes ["Dialog"].Focus,
+            Colors.ColorSchemes ["Dialog"].Normal,
 
 
             // 3
             // 3
-            Colors.ColorSchemes ["Menu"].Focus,
+            Colors.ColorSchemes ["Menu"].Normal,
 
 
             // 4
             // 4
-            Colors.ColorSchemes ["Error"].Focus
+            Colors.ColorSchemes ["Error"].Normal,
+
+            // 5
+            tv.ColorScheme!.Focus
         };
         };
 
 
         var expectedColor = @"
         var expectedColor = @"
-0000000000
-1111000000
-2222220000
-3333000000
-4444400000";
+0000000055
+1111555555
+2222225555
+3333555555
+4444455555";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
 
         tv.WordWrap = true;
         tv.WordWrap = true;
@@ -134,13 +137,13 @@ Dialogror ";
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
 
         expectedColor = @"
         expectedColor = @"
-0000000000
-1111000000
-2222220000
-3333000000
-4444444444
-4444000000
-4444444440";
+0000000055
+1111555555
+2222225555
+3333555555
+4455555555
+5555555555
+5555544445";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
 
         tv.Undo ();
         tv.Undo ();
@@ -170,14 +173,14 @@ ror       ";
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
         TestHelpers.AssertDriverContentsWithFrameAre (expectedText, output);
 
 
         expectedColor = @"
         expectedColor = @"
-0000000000
-1111000000
-2222220000
-3333000000
+0000000055
+1111555555
+2222225555
+3333555555
 4444444444
 4444444444
-4444000000
-4444440000
-4440000000";
+4444555555
+4444445555
+4445555555";
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
         TestHelpers.AssertDriverAttributesAre (expectedColor, Application.Driver, attributes);
 
 
         Application.End (rs);
         Application.End (rs);
@@ -185,9 +188,9 @@ ror       ";
     }
     }
 
 
     [Fact]
     [Fact]
-    public void RuneCell_LoadRuneCells_Without_ColorScheme_Is_Never_Null ()
+    public void Cell_LoadCells_Without_ColorScheme_Is_Never_Null ()
     {
     {
-        List<RuneCell> cells = new ()
+        List<Cell> cells = new ()
         {
         {
             new() { Rune = new ('T') },
             new() { Rune = new ('T') },
             new() { Rune = new ('e') },
             new() { Rune = new ('e') },
@@ -201,43 +204,44 @@ ror       ";
 
 
         for (var i = 0; i < tv.Lines; i++)
         for (var i = 0; i < tv.Lines; i++)
         {
         {
-            List<RuneCell> line = tv.GetLine (i);
+            List<Cell> line = tv.GetLine (i);
 
 
-            foreach (RuneCell rc in line)
+            foreach (Cell c in line)
             {
             {
-                Assert.NotNull (rc.ColorScheme);
+                Assert.NotNull (c.Attribute);
             }
             }
         }
         }
     }
     }
 
 
     [Fact]
     [Fact]
     [AutoInitShutdown]
     [AutoInitShutdown]
-    public void RuneCellEventArgs_WordWrap_True ()
+    public void CellEventArgs_WordWrap_True ()
     {
     {
         var eventCount = 0;
         var eventCount = 0;
 
 
-        List<List<RuneCell>> text = new ()
-        {
-            RuneCell.ToRuneCells (
-                                   "This is the first line.".ToRunes ()
-                                  ),
-            RuneCell.ToRuneCells (
-                                   "This is the second line.".ToRunes ()
-                                  )
-        };
+        List<List<Cell>> text =
+        [
+            Cell.ToCells (
+                          "This is the first line.".ToRunes ()
+                         ),
+
+            Cell.ToCells (
+                          "This is the second line.".ToRunes ()
+                         )
+        ];
         TextView tv = CreateTextView ();
         TextView tv = CreateTextView ();
         tv.DrawNormalColor += _textView_DrawColor;
         tv.DrawNormalColor += _textView_DrawColor;
         tv.DrawReadOnlyColor += _textView_DrawColor;
         tv.DrawReadOnlyColor += _textView_DrawColor;
         tv.DrawSelectionColor += _textView_DrawColor;
         tv.DrawSelectionColor += _textView_DrawColor;
         tv.DrawUsedColor += _textView_DrawColor;
         tv.DrawUsedColor += _textView_DrawColor;
 
 
-        void _textView_DrawColor (object sender, RuneCellEventArgs e)
+        void _textView_DrawColor (object sender, CellEventArgs e)
         {
         {
             Assert.Equal (e.Line [e.Col], text [e.UnwrappedPosition.Row] [e.UnwrappedPosition.Col]);
             Assert.Equal (e.Line [e.Col], text [e.UnwrappedPosition.Row] [e.UnwrappedPosition.Col]);
             eventCount++;
             eventCount++;
         }
         }
 
 
-        tv.Text = $"{RuneCell.ToString (text [0])}\n{RuneCell.ToString (text [1])}\n";
+        tv.Text = $"{Cell.ToString (text [0])}\n{Cell.ToString (text [1])}\n";
         Assert.False (tv.WordWrap);
         Assert.False (tv.WordWrap);
         var top = new Toplevel ();
         var top = new Toplevel ();
         top.Add (tv);
         top.Add (tv);
@@ -275,20 +279,20 @@ line.  ",
     [Fact]
     [Fact]
     public void ToString_Override ()
     public void ToString_Override ()
     {
     {
-        var rc1 = new RuneCell ();
+        var c1 = new Cell ();
 
 
-        var rc2 = new RuneCell
+        var c2 = new Cell
         {
         {
-            Rune = new ('a'), ColorScheme = new() { Normal = new (Color.Red) }
+            Rune = new ('a'), Attribute = new (Color.Red)
         };
         };
-        Assert.Equal ("U+0000 '\0'; null", rc1.ToString ());
+        Assert.Equal ("[\0, ]", c1.ToString ());
 
 
         Assert.Equal (
         Assert.Equal (
-                      "U+0061 'a'; Normal: [Red,Red]; Focus: [White,Black]; HotNormal: [White,Black]; HotFocus: [White,Black]; Disabled: [White,Black]",
-                      rc2.ToString ()
+                      "[a, [Red,Red]]",
+                      c2.ToString ()
                      );
                      );
     }
     }
 
 
-    // TODO: Move the tests below to View or Color - they test ColorScheme, not RuneCell primitives.
+    // TODO: Move the tests below to View or Color - they test ColorScheme, not Cell primitives.
     private TextView CreateTextView () { return new() { Width = 30, Height = 10 }; }
     private TextView CreateTextView () { return new() { Width = 30, Height = 10 }; }
 }
 }

+ 1 - 1
UnitTests/Text/AutocompleteTests.cs

@@ -254,7 +254,7 @@ This an long line and against TextView.",
 
 
         ac.GenerateSuggestions (
         ac.GenerateSuggestions (
                                 new (
                                 new (
-                                     RuneCell.ToRuneCellList (tv.Text),
+                                     Cell.ToCellList (tv.Text),
                                      2
                                      2
                                     )
                                     )
                                );
                                );

+ 11 - 11
UnitTests/Views/TextViewTests.cs

@@ -1160,7 +1160,7 @@ This is the second line.
             {
             {
                 Assert.Throws<ArgumentException> (
                 Assert.Throws<ArgumentException> (
                                                   () => ht.Add (
                                                   () => ht.Add (
-                                                                new List<List<RuneCell>> { new () },
+                                                                new List<List<Cell>> { new () },
                                                                 Point.Empty,
                                                                 Point.Empty,
                                                                 (HistoryText.LineStatus)ls
                                                                 (HistoryText.LineStatus)ls
                                                                )
                                                                )
@@ -1168,7 +1168,7 @@ This is the second line.
             }
             }
         }
         }
 
 
-        Assert.Null (Record.Exception (() => ht.Add (new List<List<RuneCell>> { new () }, Point.Empty)));
+        Assert.Null (Record.Exception (() => ht.Add (new List<List<Cell>> { new () }, Point.Empty)));
     }
     }
 
 
     [Fact]
     [Fact]
@@ -4717,7 +4717,7 @@ This is the second line.
     public void Internal_Tests ()
     public void Internal_Tests ()
     {
     {
         var txt = "This is a text.";
         var txt = "This is a text.";
-        List<RuneCell> txtRunes = RuneCell.StringToRuneCells (txt);
+        List<Cell> txtRunes = Cell.StringToCells (txt);
         Assert.Equal (txt.Length, txtRunes.Count);
         Assert.Equal (txt.Length, txtRunes.Count);
         Assert.Equal ('T', txtRunes [0].Rune.Value);
         Assert.Equal ('T', txtRunes [0].Rune.Value);
         Assert.Equal ('h', txtRunes [1].Rune.Value);
         Assert.Equal ('h', txtRunes [1].Rune.Value);
@@ -4757,8 +4757,8 @@ This is the second line.
         Assert.Equal (2, TextModel.CalculateLeftColumn (txtRunes, 0, 9, 8));
         Assert.Equal (2, TextModel.CalculateLeftColumn (txtRunes, 0, 9, 8));
 
 
         var tm = new TextModel ();
         var tm = new TextModel ();
-        tm.AddLine (0, RuneCell.StringToRuneCells ("This is first line."));
-        tm.AddLine (1, RuneCell.StringToRuneCells ("This is last line."));
+        tm.AddLine (0, Cell.StringToCells ("This is first line."));
+        tm.AddLine (1, Cell.StringToCells ("This is last line."));
         Assert.Equal ((new Point (2, 0), true), tm.FindNextText ("is", out bool gaveFullTurn));
         Assert.Equal ((new Point (2, 0), true), tm.FindNextText ("is", out bool gaveFullTurn));
         Assert.False (gaveFullTurn);
         Assert.False (gaveFullTurn);
         Assert.Equal ((new Point (5, 0), true), tm.FindNextText ("is", out gaveFullTurn));
         Assert.Equal ((new Point (5, 0), true), tm.FindNextText ("is", out gaveFullTurn));
@@ -4782,14 +4782,14 @@ This is the second line.
         Assert.True (gaveFullTurn);
         Assert.True (gaveFullTurn);
 
 
         Assert.Equal ((new Point (9, 1), true), tm.ReplaceAllText ("is", false, false, "really"));
         Assert.Equal ((new Point (9, 1), true), tm.ReplaceAllText ("is", false, false, "really"));
-        Assert.Equal (RuneCell.StringToRuneCells ("Threally really first line."), tm.GetLine (0));
-        Assert.Equal (RuneCell.StringToRuneCells ("Threally really last line."), tm.GetLine (1));
+        Assert.Equal (Cell.StringToCells ("Threally really first line."), tm.GetLine (0));
+        Assert.Equal (Cell.StringToCells ("Threally really last line."), tm.GetLine (1));
         tm = new TextModel ();
         tm = new TextModel ();
-        tm.AddLine (0, RuneCell.StringToRuneCells ("This is first line."));
-        tm.AddLine (1, RuneCell.StringToRuneCells ("This is last line."));
+        tm.AddLine (0, Cell.StringToCells ("This is first line."));
+        tm.AddLine (1, Cell.StringToCells ("This is last line."));
         Assert.Equal ((new Point (5, 1), true), tm.ReplaceAllText ("is", false, true, "really"));
         Assert.Equal ((new Point (5, 1), true), tm.ReplaceAllText ("is", false, true, "really"));
-        Assert.Equal (RuneCell.StringToRuneCells ("This really first line."), tm.GetLine (0));
-        Assert.Equal (RuneCell.StringToRuneCells ("This really last line."), tm.GetLine (1));
+        Assert.Equal (Cell.StringToCells ("This really first line."), tm.GetLine (0));
+        Assert.Equal (Cell.StringToCells ("This really last line."), tm.GetLine (1));
     }
     }
 
 
     [Fact]
     [Fact]

+ 7 - 7
UnitTests/Views/TreeViewTests.cs

@@ -970,10 +970,10 @@ public class TreeViewTests
         Assert.All (eventArgs, ea => Assert.Equal (ea.Tree, tv));
         Assert.All (eventArgs, ea => Assert.Equal (ea.Tree, tv));
         Assert.All (eventArgs, ea => Assert.False (ea.Handled));
         Assert.All (eventArgs, ea => Assert.False (ea.Handled));
 
 
-        Assert.Equal ("├-root one", eventArgs [0].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
-        Assert.Equal ("│ ├─leaf 1", eventArgs [1].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
-        Assert.Equal ("│ └─leaf 2", eventArgs [2].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
-        Assert.Equal ("└─root two", eventArgs [3].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("├-root one", eventArgs [0].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("│ ├─leaf 1", eventArgs [1].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("│ └─leaf 2", eventArgs [2].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("└─root two", eventArgs [3].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
 
 
         Assert.Equal (1, eventArgs [0].IndexOfExpandCollapseSymbol);
         Assert.Equal (1, eventArgs [0].IndexOfExpandCollapseSymbol);
         Assert.Equal (3, eventArgs [1].IndexOfExpandCollapseSymbol);
         Assert.Equal (3, eventArgs [1].IndexOfExpandCollapseSymbol);
@@ -1083,9 +1083,9 @@ oot two
         Assert.All (eventArgs, ea => Assert.Equal (ea.Tree, tv));
         Assert.All (eventArgs, ea => Assert.Equal (ea.Tree, tv));
         Assert.All (eventArgs, ea => Assert.False (ea.Handled));
         Assert.All (eventArgs, ea => Assert.False (ea.Handled));
 
 
-        Assert.Equal ("─leaf 1", eventArgs [0].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
-        Assert.Equal ("─leaf 2", eventArgs [1].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
-        Assert.Equal ("oot two", eventArgs [2].RuneCells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("─leaf 1", eventArgs [0].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("─leaf 2", eventArgs [1].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
+        Assert.Equal ("oot two", eventArgs [2].Cells.Aggregate ("", (s, n) => s += n.Rune).TrimEnd ());
 
 
         Assert.Equal (0, eventArgs [0].IndexOfExpandCollapseSymbol);
         Assert.Equal (0, eventArgs [0].IndexOfExpandCollapseSymbol);
         Assert.Equal (0, eventArgs [1].IndexOfExpandCollapseSymbol);
         Assert.Equal (0, eventArgs [1].IndexOfExpandCollapseSymbol);

Some files were not shown because too many files changed in this diff