Closed Garash2k closed 1 year ago
Interesting 🤔I need to investigate this a bit deeper, might take a while - I'm getting exactly same results, but the Scintilla control should be able to display ANSI escape sequences with colors, see: https://sourceforge.net/p/scintilla/bugs/2161/.
Hi, The Lexer must be styled as by default the styles are nowhere. The code:
scintilla.StyleClearAll();
var text = File.ReadAllText(@"C:\Users\Petteri Kautonen\Downloads\git.diff.--color.always.txt");
scintilla.LexerName = "errorlist";
var errorBackground = Color.FromArgb(0xFF, 0xF7,0xE7);
// Default
scintilla.Styles[0].ForeColor = Color.Black;
// python Error
scintilla.Styles[1].ForeColor = Color.FromArgb(0xff, 0x00, 0x00);
// gcc Error
scintilla.Styles[2].ForeColor = Color.FromArgb(0x80, 0x00, 0x80);
// Microsoft Error
scintilla.Styles[3].ForeColor = Color.FromArgb(0x80, 0x80, 0x00);
// command or return status
scintilla.Styles[4].ForeColor = Color.FromArgb(0x00, 0x00, 0xFF);
// Borland error and warning messages
scintilla.Styles[5].ForeColor = Color.FromArgb(0xB0, 0x60, 0x00);
// perl error and warning messages
scintilla.Styles[6].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// .NET tracebacks
scintilla.Styles[7].ForeColor = Color.FromArgb(0x00, 0x00,0x00);
// Lua error and warning messages
scintilla.Styles[8].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// ctags
scintilla.Styles[9].ForeColor = Color.FromArgb(0xFF, 0x00,0xFF);
// diff changed !
scintilla.Styles[10].ForeColor = Color.FromArgb(0x00, 0x7F,0x00);
// diff addition +
scintilla.Styles[11].ForeColor = Color.FromArgb(0x00, 0x00,0x7F);
// diff deletion -
scintilla.Styles[12].ForeColor = Color.FromArgb(0x00, 0x7F,0x7F);
// diff message ---
scintilla.Styles[13].ForeColor = Color.FromArgb(0x7F, 0x00,0x00);
// PHP error
scintilla.Styles[14].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// Essential Lahey Fortran 90 error
scintilla.Styles[15].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// Intel Fortran Compiler error
scintilla.Styles[16].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// Intel Fortran Compiler v8.0 error/warning
scintilla.Styles[17].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// Absoft Pro Fortran 90/95 v8.2 error or warning
scintilla.Styles[18].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// HTML Tidy
scintilla.Styles[19].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// Java runtime stack trace
scintilla.Styles[20].ForeColor = Color.FromArgb(0xFF, 0x00,0x00);
// Text matched with find in files and message part of GCC errors
scintilla.Styles[21].ForeColor = Color.FromArgb(0x00, 0x00,0x00);
// GCC showing include path to following error
scintilla.Styles[22].ForeColor = Color.FromArgb(0x80, 0x00,0x80);
// Escape sequence
scintilla.Styles[23].ForeColor = Color.FromArgb(0x00, 0x00,0x00);
scintilla.Styles[23].BackColor = errorBackground;
scintilla.Styles[23].FillLine = true;
scintilla.Styles[23].Visible = false;
// Escape sequence unknown
scintilla.Styles[24].BackColor = Color.FromArgb(0xFF, 0xE0,0xA0);
// GCC showing excerpt of code with pointer
scintilla.Styles[25].ForeColor = Color.FromArgb(0xCF, 0x00,0x8F);
// ???
scintilla.Styles[32].ForeColor = Color.FromArgb(0xB0, 0x60,0x00);
// Basic colors
scintilla.Styles[40].ForeColor = Color.FromArgb(0x00, 0x00,0x00);
scintilla.Styles[41].ForeColor = Color.FromArgb(0x80, 0x00,0x00);
scintilla.Styles[41].BackColor = errorBackground;
scintilla.Styles[42].ForeColor = Color.FromArgb(0x00, 0x80,0x00);
scintilla.Styles[42].BackColor = errorBackground;
scintilla.Styles[43].ForeColor = Color.FromArgb(0x80, 0x80,0x00);
scintilla.Styles[43].BackColor = errorBackground;
scintilla.Styles[44].ForeColor = Color.FromArgb(0x00, 0x00,0x80);
scintilla.Styles[44].BackColor = errorBackground;
scintilla.Styles[45].ForeColor = Color.FromArgb(0x80, 0x00,0x80);
scintilla.Styles[45].BackColor = errorBackground;
scintilla.Styles[46].ForeColor = Color.FromArgb(0x00, 0x80,0x80);
scintilla.Styles[46].BackColor = errorBackground;
scintilla.Styles[47].ForeColor = Color.FromArgb(0xA0, 0xA0,0xA0);
scintilla.Styles[47].BackColor = errorBackground;
// Intense colors
scintilla.Styles[48].ForeColor = Color.FromArgb(0x00, 0x00,0x00);
scintilla.Styles[48].BackColor = errorBackground;
scintilla.Styles[48].Bold = true;
scintilla.Styles[49].ForeColor = Color.FromArgb(0x80, 0x00,0x00);
scintilla.Styles[49].BackColor = errorBackground;
scintilla.Styles[49].Bold = true;
scintilla.Styles[50].ForeColor = Color.FromArgb(0x00, 0x80,0x00);
scintilla.Styles[50].BackColor = errorBackground;
scintilla.Styles[50].Bold = true;
scintilla.Styles[51].ForeColor = Color.FromArgb(0x80, 0x80,0x00);
scintilla.Styles[51].BackColor = errorBackground;
scintilla.Styles[51].Bold = true;
scintilla.Styles[52].ForeColor = Color.FromArgb(0x00, 0x00,0x80);
scintilla.Styles[52].BackColor = errorBackground;
scintilla.Styles[52].Bold = true;
scintilla.Styles[53].ForeColor = Color.FromArgb(0x80, 0x00,0x80);
scintilla.Styles[53].BackColor = errorBackground;
scintilla.Styles[53].Bold = true;
scintilla.Styles[54].ForeColor = Color.FromArgb(0x00, 0x80,0x80);
scintilla.Styles[54].BackColor = errorBackground;
scintilla.Styles[54].Bold = true;
scintilla.Styles[55].ForeColor = Color.FromArgb(0xA0, 0xA0,0xA0);
scintilla.Styles[55].BackColor = errorBackground;
scintilla.Styles[55].Bold = true;
scintilla.SetProperty("lexer.errorlist.escape.sequences", "1");
scintilla.SetProperty("lexer.errorlist.value.separate", "1");
scintilla.Text = text;
The code piece that hides the escape symbol in the above is:
scintilla.Styles[23].Visible = false;
I read this from the Scintilla source code, see others.properties
file in the SciTe source code:
...
# Error list styles
style.errorlist.32=fore:#B06000,$(font.small)
# Default
style.errorlist.0=fore:#000000
# python Error
style.errorlist.1=fore:#FF0000
# gcc Error
style.errorlist.2=fore:#800080
# Microsoft Error
style.errorlist.3=fore:#808000
# command or return status
style.errorlist.4=fore:#0000FF
# Borland error and warning messages
style.errorlist.5=fore:#B06000
# perl error and warning messages
style.errorlist.6=fore:#FF0000
# .NET tracebacks
style.errorlist.7=fore:#FF0000
# Lua error and warning messages
style.errorlist.8=fore:#FF0000
# ctags
style.errorlist.9=fore:#FF00FF
# diff changed !
style.errorlist.10=fore:#007F00
# diff addition +
style.errorlist.11=fore:#00007F
# diff deletion -
style.errorlist.12=fore:#007F7F
# diff message ---
style.errorlist.13=fore:#7F0000
# PHP error
style.errorlist.14=fore:#FF0000
# Essential Lahey Fortran 90 error
style.errorlist.15=fore:#FF0000
# Intel Fortran Compiler error
style.errorlist.16=fore:#FF0000
# Intel Fortran Compiler v8.0 error/warning
style.errorlist.17=fore:#FF0000
# Absoft Pro Fortran 90/95 v8.2 error or warning
style.errorlist.18=fore:#FF0000
# HTML Tidy
style.errorlist.19=fore:#FF0000
# Java runtime stack trace
style.errorlist.20=fore:#FF0000
# Text matched with find in files and message part of GCC errors
style.errorlist.21=fore:#000000
# GCC showing include path to following error
style.errorlist.22=fore:#800080
# GCC showing excerpt of code with pointer
style.errorlist.25=fore:#CF008F,$(font.monospace.small)
# Escape sequence
style.errorlist.23=fore:#000000,notvisible,back:#FFFFFF,$(error.background)
# Escape sequence unknown
style.errorlist.24=back:#FFE0A0
# Ensures that spacing is not affected by line number styles
style.errorlist.33=$(font.small)
# Basic colours
style.errorlist.40=fore:#000000
style.errorlist.41=fore:#800000,$(error.background)
style.errorlist.42=fore:#008000,$(error.background)
style.errorlist.43=fore:#808000,$(error.background)
style.errorlist.44=fore:#000080,$(error.background)
style.errorlist.45=fore:#800080,$(error.background)
style.errorlist.46=fore:#008080,$(error.background)
style.errorlist.47=fore:#A0A0A0,$(error.background)
# Intense colours
style.errorlist.48=fore:#000000,bold,$(error.background)
style.errorlist.49=fore:#800000,bold,$(error.background)
style.errorlist.50=fore:#008000,bold,$(error.background)
style.errorlist.51=fore:#808000,bold,$(error.background)
style.errorlist.52=fore:#000080,bold,$(error.background)
style.errorlist.53=fore:#800080,bold,$(error.background)
style.errorlist.54=fore:#008080,bold,$(error.background)
style.errorlist.55=fore:#A0A0A0,bold,$(error.background)
error.background=back:#FFF7E7,eolfilled
lexer.errorlist.value.separate=1
#lexer.errorlist.escape.sequences=1
...
As a result I get this:
NOTE: The provided C# code doesn't include font family changes. Let me know if this answered your question 🙂
Closed due inactivity.
Hi! I'd like to use Scintilla.NET to be able to show colored
git diff
results. TortoiseGit uses scintilla to that effort so it should be possible in theory.In SciTE, after adding a
lexer.errorlist.escape.sequences=1
property in an options file, and setting the lexer to Errorlist via the Language menu, the escape codes are parsed fine. git diff --color=always.txtHowever, despite setting the property to 1 and using errorlist as our lexer, the escape codes are still shown as is, instead of being interpreted.
Am I missing something or is there something that could be improved to make them work?