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

Semantic highlight

<< < (2/16) > >>

mistar:
For semantic highlight one cannot use lexers, but there is an option to style a given text manually in Scintilla.
I don't suspect it to be efficient but it should be anyway more efficient than semantic highlight in Eclipse CDT.

BTW, C::B is great IDE but its sources are messy... It lacks a good framework (design).
Some examples I've mentioned above and another one I encountered when I wanted to get a project's active build target:
GetActiveBuildTarget returns a wxString and there is no option to get an index or pointer...
IHMO, the right way is to get a pointer to a build target object and then to obtain a wxString just call one of the BT methods...

So... Did you, C::B guys, consider redesigning C::B SDK API and then redesigning plugins? ;)

More complaints to come ;P

oBFusCATed:
If you want to invest the time and do it and you show us that your changes improve the API,
why not, but don't expect anyone to take the job.

p.s. You can get a target by name, I think, if think there is a better way, post a patch :)

mistar:
Ok, guys.
If you are interested, in two or three weeks I'll be done with SemanticHighlight plugin provided the problem with cbEVT_EDITOR_OPEN will be solved.
To finish SH plugin, I _really_ need to get the project a file belongs to because I need to get all the project's include directories and defines to get SH plugin work properly.
Since I am new to C::B sdk, I'd like someone to take a look at this proposal of change in the file editormanager.cpp:

remove these lines from EditorManager::New():

--- Code: ---CodeBlocksEvent evt(cbEVT_EDITOR_OPEN, -1, 0, ed);
Manager::Get()->GetPluginManager()->NotifyPlugins(evt);

--- End code ---
and insert these lines to EditorManager::Open(LoaderBase*, const wxString &, int, ProjectFile *):

--- Code: ---if (!eb) // was not open
{
  CodeBlocksEvent evt(cbEVT_EDITOR_OPEN, -1, 0, ed);
  Manager::Get()->GetPluginManager()->NotifyPlugins(evt);
}

--- End code ---
just before "s_CanShutdown = true". This way, cbEVT_EDITOR_OPEN is posted after all editor's data is initialized.

MortenMacFly:

--- Quote from: mistar on April 27, 2012, 10:19:28 am ---Why is cbEVT_EDITOR_OPEN event posted in EditorManager::New instead of EditorManager::Open (after cbEditor::SetProjectFile is called)?

--- End quote ---
Because it is defined as "about to be opened" if you like and plugins can intercept and interrupt this event in case they handle the file itself. So this won't change.

If you need another event after the file has been opened and added to the project, you would need another (new) SDK event, like cbEVT_EDITOR_OPENED. Implement this and provide a patch and it may make it into C::B's core.

mistar:
Thanks for your reply.

Since I've never participate in a big project like C::B, please guide me what to do to post a patch (I've searched the forum but dodn't find anything),
or point to some description.

My proposal:
1. insert the code below to EditorManager::Open(LoaderBase*, const wxString &, int, ProjectFile *) in editormanager.cpp:

--- Code: ---if (!eb) // was not open
{
  CodeBlocksEvent evt(cbEVT_EDITOR_OPENED, -1, 0, ed);
  Manager::Get()->GetPluginManager()->NotifyPlugins(evt);
}

--- End code ---
just before

--- Code: ---s_CanShutdown = true;

--- End code ---
2. Declare new sdk editor event cbEVT_EDITOR_OPENED (or maybe _LOADED?) in sdk_events.h:

--- Code: ---extern EVTIMPORT const wxEventType cbEVT_EDITOR_OPENED;
#define EVT_EDITOR_OPENED(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_EDITOR_OPENED, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),

--- End code ---
3. Define cbEVT_EDITOR_OPENED in sdk_events.cpp

--- Code: ---const wxEventType cbEVT_EDITOR_OPENED = wxNewEventType();

--- End code ---
4. Add

--- Code: ---NotifyPlugins(cbEVT_EDITOR_OPENED);
--- End code ---
to cbEditor::Open() in cbeditor.cpp.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version