Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Semantic highlight

(1/16) > >>

mistar:
Hi guys.

I'm working on C::B plugin for semantic highlight based on clang.
For a long time I've used Eclipse CDT but its support for the new c++11 standard (which I'm using extensively) is quite poor...

Currently I'm designing a framework for SemanticHighlight plugin and have following problems:

1. The member function CodeBlocksEvent::GetEditor() returns a pointer to EditorBase, not to cbEditor; hence the static_cast in the code below;
2. when I handle cbEVT_EDITOR_OPEN event:

--- Code: ---void SemanticHighlight::OnEditorOpen(CodeBlocksEvent & evt)
{
    cbEditor * ed = static_cast<cbEditor *>(evt.GetEditor());
    ProjectFile * pf = ed->GetProjectFile();
    wxString projTitle = pf ? pf->GetParentProject()->GetTitle() : wxT("[None]");
    Manager::Get()->GetLogManager()->Log(wxT("\tSH: processing cbEVT_EDITOR_OPEN: ")+evt.GetEditor()->GetTitle()+wxT("@")+projTitle);
}

--- End code ---
the variable 'ed' is always set to null pointer regardless of whether the opened file has parent project or not.

Isn't it a bug?

EDIT: I'm using the latest nightly build on Gentoo Linux

oBFusCATed:
Sorry to disappoint you but currently you won't be able to implement such plugin.
And the reason is that the editor control we are using doesn't support it.
We are using Scintilla (wxScintilla to be exact).
If you look at their mailing list you'll find info of other people trying to do it and you'll be able to read about their failures.

Here is the link to the discussion: http://groups.google.com/group/scintilla-interest/browse_thread/thread/35a1ba3c99488d8f/b7365d210b6aca39?hl=en&lnk=gst&q=semantic+highlight#

For the cast, you can test the EditorBase if it is a built in editor, then the cast is safe.

mistar:

--- Quote from: oBFusCATed on April 25, 2012, 08:45:03 pm ---Sorry to disappoint you but currently you won't be able to implement such plugin.
And the reason is that the editor control we are using doesn't support it.
We are using Scintilla (wxScintilla to be exact).
If you look at their mailing list you'll find info of other people trying to do it and you'll be able to read about their failures.

Here is the link to the discussion: http://groups.google.com/group/scintilla-interest/browse_thread/thread/35a1ba3c99488d8f/b7365d210b6aca39?hl=en&lnk=gst&q=semantic+highlight#

For the cast, you can test the EditorBase if it is a built in editor, then the cast is safe.

--- End quote ---

I know you are using Scintilla. I believe it has ability to manually set styles (without use of any lexer),
so the only thing is to correctly assign semantic information to tokens.
It is by no means the cleanest way to do it but the effect can be even better than that of SH in Eclipse CDT.
Nota bene, semantic highlighting _cannot_ use lexers as a token might have different semantics in different contexts (e.g., namespaces).

What about cbEVT_EDITOR_OPEN? In cbEVT_EDITOR_CLOSE everything is ok...
Besides, why is cbEVT_EDITOR_OPEN posted before cbEVT_PROJECT_OPEN when loading recently-opened files? This is really weird...

Thanks for pointing out EditorBase::IsBuiltinEditor :)

mistar:
OK, I've found the reason...

Why is cbEVT_EDITOR_OPEN event posted in EditorManager::New instead of EditorManager::Open (after cbEditor::SetProjectFile is called)?
BTW, can someone explain why are cbEVT_EDITOR_* events to be posted for non-builtin editors?
Thanks in advance!

ollydbg:
Your work is very promising. Great! I'm also interest on this. I see there are some document of scintilla about writing custom lexers which can set colors of the text by clients. Maybe I'm wrong.  :)

Here are some resources/links you may interest:
1, Clang code completion: ClangComplete plugin
2, Display Events: DisplayEvents plugin - CodeBlocks

Navigation

[0] Message Index

[#] Next page

Go to full version