diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs
index 62d583c42..3d87d0666 100644
--- a/Terminal.Gui/Views/TextView.cs
+++ b/Terminal.Gui/Views/TextView.cs
@@ -1333,17 +1333,46 @@ namespace Terminal.Gui {
}
}
- void ColorNormal ()
+ ///
+ /// Sets the driver to the default color for the control where no text is being rendered. Defaults to .
+ ///
+ protected virtual void ColorNormal ()
{
Driver.SetAttribute (ColorScheme.Normal);
}
- void ColorSelection ()
+ ///
+ /// Sets the to an appropriate color for rendering the given of the
+ /// current . Override to provide custom coloring by calling
+ /// Defaults to .
+ ///
+ ///
+ ///
+ protected virtual void ColorNormal (List line, int idx)
+ {
+ Driver.SetAttribute (ColorScheme.Normal);
+ }
+
+ ///
+ /// Sets the to an appropriate color for rendering the given of the
+ /// current . Override to provide custom coloring by calling
+ /// Defaults to .
+ ///
+ ///
+ ///
+ protected virtual void ColorSelection (List line, int idx)
{
Driver.SetAttribute (ColorScheme.Focus);
}
- void ColorUsed ()
+ ///
+ /// Sets the to an appropriate color for rendering the given of the
+ /// current . Override to provide custom coloring by calling
+ /// Defaults to .
+ ///
+ ///
+ ///
+ protected virtual void ColorUsed (List line, int idx)
{
Driver.SetAttribute (ColorScheme.HotFocus);
}
@@ -1667,12 +1696,12 @@ namespace Terminal.Gui {
var rune = idxCol >= lineRuneCount ? ' ' : line [idxCol];
var cols = Rune.ColumnWidth (rune);
if (idxCol < line.Count && selecting && PointInSelection (idxCol, idxRow)) {
- ColorSelection ();
+ ColorSelection (line, idxCol);
} else if (idxCol == currentColumn && idxRow == currentRow && !selecting && !Used
&& HasFocus && idxCol < lineRuneCount) {
- ColorUsed ();
+ ColorUsed (line, idxCol);
} else {
- ColorNormal ();
+ ColorNormal (line,idxCol);
}
if (rune == '\t' && TabWidth > 0) {
diff --git a/UICatalog/Scenarios/SyntaxHighlighting.cs b/UICatalog/Scenarios/SyntaxHighlighting.cs
new file mode 100644
index 000000000..98234beca
--- /dev/null
+++ b/UICatalog/Scenarios/SyntaxHighlighting.cs
@@ -0,0 +1,66 @@
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Terminal.Gui;
+using static UICatalog.Scenario;
+
+
+namespace UICatalog.Scenarios {
+ [ScenarioMetadata (Name: "Syntax Highlighting", Description: "Text editor with keyword highlighting")]
+ [ScenarioCategory ("Controls")]
+ class SyntaxHighlighting : Scenario {
+
+ public override void Setup ()
+ {
+ Win.Title = this.GetName ();
+ Win.Y = 1; // menu
+ Win.Height = Dim.Fill (1); // status bar
+ Top.LayoutSubviews ();
+
+ var menu = new MenuBar (new MenuBarItem [] {
+ new MenuBarItem ("_File", new MenuItem [] {
+ new MenuItem ("_Quit", "", () => Quit()),
+ })
+ });
+ Top.Add (menu);
+
+ var textView = new SqlTextView () {
+ X = 0,
+ Y = 0,
+ Width = Dim.Fill (),
+ Height = Dim.Fill (1),
+ };
+
+
+ Win.Add (textView);
+
+ var statusBar = new StatusBar (new StatusItem [] {
+ new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
+
+ });
+
+
+ Top.Add (statusBar);
+ }
+
+
+ private void Quit ()
+ {
+ Application.RequestStop ();
+ }
+
+ private class SqlTextView : TextView{
+
+
+
+ protected override void ColorNormal (List line, int idx)
+ {
+ Driver.SetAttribute (Driver.MakeAttribute (Color.Green, Color.Black));
+ }
+ }
+ }
+}