[Geany-Devel] Move question from Scintilla list
Lex Trotman
elextr at xxxxx
Fri Jun 26 09:40:32 UTC 2015
Jiri,
I have pasted the questions and Neils answers below with my comments
and I'm sure others may have more info.
> Jiří Techet:
>
> > I have a question regarding the use of SCI_COLOURISE. It is used in Geany at several places and it's call is rather expensive so I'd like to avoid it as much as possible.
>
> Most of the time all of the buffer you see should be styled automatically by Scintilla in a lazy way. That means that Scintilla does not normally style much beyond the portion currently visible. There are times when you want the whole file to be styled, such as when exporting the file as HTML/PDF/RTF. There may also be workarounds to problems in Scintilla and its possible some of these workarounds are no longer needed.
>
> > 1. After SCI_SETKEYWORDS - this basically happens after every keystroke because we colorize typenames using keywords (we've already talked about that if you remember).
>
> Possibly Geany wants the document styled up to some point immediately so it can use the style information.
As best I can tell this one is extraneous, it would just change names
from/to type colourising which AFAICT doesn't affect anything else,
they are both code type styles etc. So long as the visible area is
colorised by Scintilla so when a newly typed name matches a keyword it
will highlight, then it doesn't look like doing it manually is useful.
>
> > 2. Immediately after SCI_SETTEXT when loading (or reloading) file.
>
> This may or may not be needed depending on Geany’s features. One reason for doing this is if you want to perform a global fold operation since folding depends on fold information and thus on styling.
This one is more likely useful, since lots of features need to know
the styles of things outside the visible area, for example to avoid
considering characters in comments and strings when counting braces
for scopes.
>
> > I tried to remove SCI_COLOURISE in all these cases and interestingly everything seems to work. In particular, I'm most interested in optimizing the case (1) above and after looking at the code, it seems that LexState::SetWordList() sets the Document::ModifiedAt() to 0 if something changes and in Editor::Paint() the document gets colored if needed. Am I right this case is already handled by Scintilla and doesn't require the explicit SCI_COLOURISE call?
It of course depends on what features you use, you would have to check
nearly everything.
>
> Its going to depend on when and how Geany uses style information.
>
> > Is the SCI_COLOURISE call needed in the other cases above (or maybe in other words, is there any Scintilla API call that requires SCI_COLOURISE to be called explicitly)?
>
> The application may need more text to be styled than Scintilla will perform automatically. For example, when performing brace matching and the corresponding brace is below the visible area then you may want to call SCI_COLOURISE over each line before checking it for braces.
This sort of thing is used in several places in Geany, styles are used
to avoid considering braces parens etc in strings and comments (see
highlighting_is_code_style()).
>
> > Is it possible that Scintilla behaved differently in the past in this respect? This would explain the SCI_COLOURISE calls in Geany.
>
> This is why we have source control: go looking for changes in Geany involving SCI_COLOURISE and see why they occurred.
I'm sure Colomban has a better understanding as well.
Cheers
Lex
More information about the Devel
mailing list