Hi All,
I'm writing a plugin and right now I'm struggling with the following, so maybe you can help me. :-)
Based on a file selected on the project pane, I want to discover the HighlightLanguage for it, but I can't get it to work. What I'm doing is
...
EditorColourSet* theme = ed->GetColourSet();
HighlightLanguage lang = theme->GetLanguageForFilename(prjFile->file.GetFullName());
which returns "CC" for a .cpp file.
However, it should be "C/C++", as confirmed by
wxArrayString langs = theme->GetAllHighlightLanguages();
In the langs array, there is no "CC", but "C/C++" indeed.
What am I missing here? What's the catch?
BTW, the first code returns an empty string for a .h file. :o
This one returns the string you expected (at least on my system):
Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageName(ed->GetLanguage() );
Thanks for the answer danselmi.
I haven't tested it yet, but one thing I forgot to mention is that the file is not necessarily opened on an editor, so I cannot rely on "ed->GetLanguage()". I was just using "ed" to get to "EditorColourSet* theme". BTW, if there's a clever or better way to do it, I'd like to hear it...
Edit: top answer my question above, I just realized that I can simply do
Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageForFilename(...)
without going through the "theme" variable, but I still have the problem, of course.
Ok, following danselmi post, I found a solution (or should I say workaround) to my problem.
The way I'm doing it right now is
HighlightLanguage langWrong = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageForFilename( _T(".")+prjFile->file.GetExt() );
HighlightLanguage lang = Manager::Get()->GetEditorManager()->GetColourSet()->GetLanguageName(langWrong);
What I have, for example is:
langWrong = "CC" , lang = "C/C++"
langWrong = "MASM_Assembly", lang = "MASM Assembly"
Nonetheless, I'd like to understand what's the difference between both highlight language names and why do we have two. I suspect it has something to do with the lexers name and syntax highlighting, but I don't understand the C::B sources good enough to figure it out, so any explanation or clarification would be pretty much appreciated.
Thx!