wxStyleTextCtrl::SetLexer not setting lexer Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
PaulR
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Mar 22, 2019 9:05 pm

wxStyleTextCtrl::SetLexer not setting lexer

Post by PaulR » Sat Jul 27, 2019 10:55 pm

I am wondering if this rings a bell with anybody. GetLexer returns '0' after SetLexer(3) and there is no syntax highlighting after these steps:

Code: Select all

m_stc->SetLexer(wxSTC_LEX_CPP);
m_stc->StyleSetForeground(wxSTC_C_DEFAULT, wxColour(20, 20, 200));
m_stc->StyleSetForeground(wxSTC_C_COMMENT, wxColour(150, 150, 150));
m_stc->SetKeyWords(0, 
    wxT(
        "alignas alignof and and_eq asm atomic_cancel atomic_commit "
    )
);

…

m_stc->Connect(wxEVT_STC_MODIFIED, 
    wxStyledTextEventHandler(MainWindow::onStcModified), NULL, this
);

…

void onStcModified(wxStyledTextEvent& event)
{
    m_stc->SetLexer(wxSTC_LEX_CPP);
    uint64_t start_pos = m_stc->GetEndStyled(); // <- this is always zero too
    uint64_t end_pos = m_stc->GetLineEndPosition(m_stc->LineFromPosition(m_stc->GetCurrentPos()));
    m_stc->Colourise(0, end_pos);
    auto lex = m_stc->GetLexer();
}
Using wxWidgets 3.1.2 on Windows, installed via vcpkg.

Have I missed out on a vital config option or something?

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: wxStyleTextCtrl::SetLexer not setting lexer

Post by New Pagodi » Sat Jul 27, 2019 11:46 pm

There was a problem with the CMake files that left out compiling the lexers. It was fixed a while back, but vcpkg must still be using the old CMake files. i can't think of any way to fix this after the library has been build, so if you need the lexers, you'll probably need to build the wxWidgets libraries yourself.

PaulR
In need of some credit
In need of some credit
Posts: 3
Joined: Fri Mar 22, 2019 9:05 pm

Re: wxStyleTextCtrl::SetLexer not setting lexer

Post by PaulR » Sat Jul 27, 2019 11:49 pm

Ah okay that's good news I can sort it out, thanks for the reply!

Post Reply