Neil Hodgson wrote:
Kein-Hong Man:
editor.Lexer = SCLEX_PERL;
...
My question is, shouldn't the green operator style appear
immediately, the first time test() is called? I have taken a
cursory look at the various calls involved, like RefreshStyleData,
InvalidateStyleRedraw and InvalidateStyleData, but so far I
haven't found out why this happens. Any ideas?
This behaviour is caused by refreshing settings from properties
after running the macro. A IDM_FINISHEDEXECUTE is sent after runing
the macro which checks the needReadProperties flag. This has been
reset by the call to set the WindowID in CheckEnvironment called from
the extension code upon opening the file. Its likely this could be
fixed by checking to see if the WindowID is the same before setting it
and thus changing needReadProperties.
Thanks, here is a follow-up. The following works for
CheckEnvironment (no longer flashes, green operators appears on
first call):
[scite/win32/DirectorExtension.cxx]
static void CheckEnvironment(ExtensionAPI *host) {
...
char number[32];
const char *oldNumber = host->Property("WindowID");
sprintf(number, "%0d", reinterpret_cast<int>(wReceiver));
if (strcmp(number, oldNumber)) {
host->SetProperty("WindowID", number);
}
...
However, various events (e.g. when we switch buffers) cause
properties to be reloaded again. Since ReadProperties resets based
on file extension, the lexer is changed back. When the document's
styling needs refreshing if we continue to edit, the custom
styling is lost as the display reverts back to the usual styling.
Setting custom lexer/properties during OnOpen/OnSwitchFile kinda
works (exception is when closing a window.) So ReadProperties
don't have to be changed. Using OnOpen/OnSwitchFile doesn't look
pretty, but I haven't given better solutions much thought yet. The
following example code uses extman.lua:
scite_OnOpen(function()
editor.Lexer = SCLEX_PERL
editor.StyleFore[10] = 255*256
end)
scite_OnSwitchFile(function()
editor.Lexer = SCLEX_PERL
editor.StyleFore[10] = 255*256
end)
So, it looks a bit tricky, but custom styles, or custom lexing
using SCLEX_CONTAINER in Lua seems feasible. There might be some
obscure applications for this thing. Ideally of course, the Lua
extension will need to have some kind of OnStyle() for this to
happen. SCLEX_CONTAINER appears to reset its styles on
ReadProperties, but this is no big loss if we are modifying styles
on a per-buffer basis anyway. There are probably better ways of
doing these things...
--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest