Hi,
when I integrated Scintilla in CrypTool (http://www.cryptool.org/), I
noticed that the *complete document* gets lexed initially, which can cause
a delay for large documents (actually the lexer gets called twice, once
with the first few 100 bytes, then again with the rest of the document;
later, when the document is changed, the lexer is called only for the
displayed part of the document).
This is not what I expected from the documentation, which states that
lexers need not be coded effiently, because only the displayed portion of
a document gets lexed at a time.
Is this normal or did I make a mistake with the Scintilla integration?
Here is the code, which activates/deactivates the lexer:
void CScintillaWnd::SetShowAlphabet(BOOL show)
{
// we do not check if show == m_bShowAlphabet, because this method is
// also used to refresh the alphabet after changes to the text options
if (show) {
SendMessage(SCI_STYLESETFORE, atoi(STYLE_NONEALPHABET),
RGB(192,192,192));
SendMessage(SCI_SETPROPERTY,
(WPARAM)_T("cryptool.nonalphabetstyle"),
(LPARAM)STYLE_NONEALPHABET);
SendMessage(SCI_SETPROPERTY, (WPARAM)_T("cryptool.alphabet"),
(LPARAM)(LPCTSTR)theApp.TextOptions.m_alphabet);
SendMessage(SCI_SETSTYLEBITS, 5, 0);
SendMessage(SCI_SETLEXERLANGUAGE,0,(LPARAM)CT_LEXER_LANGUAGE );
if (SCLEX_NULL == SendMessage(SCI_GETLEXER)) {
SendMessage(SCI_LOADLEXERLIBRARY,0,(LPARAM)CT_LEXER_LIB);
SendMessage(SCI_SETLEXERLANGUAGE,0,(LPARAM)CT_LEXER_LANGUAGE );
if (SCLEX_NULL == SendMessage(SCI_GETLEXER)) {
show = false;
CString msg;
msg.Format(IDS_SCINTILLA_LEXER_LOAD_ERROR,CT_LEXER_LIB);
MessageBox(msg);
}
}
SendMessage(SCI_CLEARDOCUMENTSTYLE, 0, 0);
SendMessage(SCI_COLOURISE,0,(LPARAM)1); // trigger re-lexing
// without this lexing is done only on the first update
} else {
SendMessage(SCI_SETLEXER, SCLEX_NULL);
SendMessage(SCI_CLEARDOCUMENTSTYLE, 0, 0);
}
m_bShowAlphabet = show;
}
Cheers,
Jörg
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest