Cannot Style ScintillaNet Text after or before syntax coloring

2.6k views Asked by At
var scin = new Scintilla();
ScintillaHotspotStyle = scin.Styles.LastPredefined.Index + 1;
scin.Margins[0].Width = 20;
scin.Caret.HighlightCurrentLine = true;

scin.Styles[ScintillaHotspotStyle].IsHotspot = true;
scin.Styles[ScintillaHotspotStyle].Underline = true;
scin.Styles[ScintillaHotspotStyle].ForeColor = System.Drawing.Color.Blue;

var contents = File.ReadAllText(file);
scin.Text = contents;

//scin.ConfigurationManager.Language = "cpp";
//scin.ConfigurationManager.Configure();

scin.GetRange(2, 5).SetStyle(ScintillaHotspotStyle);

//scin.ConfigurationManager.Language = "cpp";
//scin.ConfigurationManager.Configure();

It doesn't matter which order of the commented lines, nor if the call to .Configure() is performed - the outcome is the same: Not working

If however, I do not apply the syntax highlighting, it does work: Working

Scintilla is pretty confusing, so I'm probably doing something wrong - but I'm not sure what...

1

There are 1 answers

0
VGE On

I think that the syntax hiliting is applied after your job. Or like if you read the scintilla documentation it seems than hotspot style have restricted feature.

""" Caret, selection, and hotspot styles

The selection is shown by changing the foreground and/or background colours. If one of these is not set then that attribute is not changed for the selection. The default is to show the selection by changing the background to light gray and leaving the foreground the same as when it was not selected. When there is no selection, the current insertion point is marked by the text caret. This is a vertical line that is normally blinking on and off to attract the users attention. """

Did you try to force the style hiliting in an area which are not syntactically hilited ? Near main or print as an example.

And try it by setting a background color.