Re: Changing to a different lexer in the same window
Andrew Truckle <[email protected]>
| Newsgroups | gmane.comp.lib.scintilla.devel |
|---|---|
| Message-ID | <[email protected]> |
I have reworked my code:
int CScintillaHelper::OnScintillaInit(const Lexer eLexer /*= Lexer::Xml*/)
{
if (eLexer == Lexer::Css)
{
#pragma warning(suppress: 26429)
m_pCLexer = theApp.m_pCreateLexer("css");
}
else if (eLexer == Lexer::Xml)
{
#pragma warning(suppress: 26429)
m_pCLexer = theApp.m_pCreateLexer("xml");
}
else if (eLexer == Lexer::Json)
{
#pragma warning(suppress: 26429)
m_pCLexer = theApp.m_pCreateLexer("json");
}
m_edit.SetILexer(m_pCLexer);
InitCtrl(eLexer);
return 0;
}
I call this function whenever I want to change the active lexer. It is
working correctly but it is still not clear to me if I should be caching
and re-using previously created lexers or not.
On Thursday 25 April 2024 at 17:59:03 UTC+1 Andrew Truckle wrote:
> I did some research and it implies this does not matter. But I want to be
> sure.
>
> At the moment I have:
>
> int CScintillaHelper::OnScintillaCreate()
> {
> #pragma warning(suppress: 26429)
> m_pCLexer = theApp.m_pCreateLexer("xml");
> // If I want to re-create the lexer with html ("hypertext") or json
> ("json"),
> // will I need to delete this one and create again?
>
> return 0;
> }
>
> I have a situation where I need to toggle between CSS and XML in the same
> window. Do I just re-create? Eg:
>
> int CScintillaHelper::OnScintillaCreate(const CString lexer)
> {
> if(lexer == L"xml")
> {
> #pragma warning(suppress: 26429)
> m_pCLexer = theApp.m_pCreateLexer("xml");
> }
> if(lexer == L"css")
> {
> #pragma warning(suppress: 26429)
> m_pCLexer = theApp.m_pCreateLexer("css");
> }
> return 0;
> }
>
> And then repeatedly call OnScintillaCreate as needed?
>
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scintilla-interest/191fb481-d46c-4836-ba29-badaad3da263n%40googlegroups.com.