Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
SmartIndent after CodeCompletion
(1/1)
danselmi:
I'd like to improve the SmartIndentHDL plugin.
The following case:
--- Code: ---process begin
...
end pro|
--- End code ---
After typing "pro" CC pops up and I choose "process".
Normally the SmartIndent plugin chatches the wxEVT_SCI_CHARADDED event.
I tried additional with wxEVT_SCI_AUTOCOMP_SELECTION but at this time the completion is not done yet so the
line only contains "end pro" and the plugin can't decide how to unindent.
Any ideas?
Alpha:
Hooking into the modified event should notify you at the right time (but it will also give many other notifications, so watch out for double handling events).
--- Code: ---if (evtType == wxEVT_SCI_MODIFIED && (event.GetModificationType() & wxSCI_MOD_INSERTTEXT))
{
// handle changes...
if (!didJustAutocomplete()) // might need to try a filter or something (wxSCI_PERFORMED_USER might help)
return; // ignore
}
--- End code ---
Alternatively, you could add an API call into sdk/ccmanager.cpp line 742, so SmartIndent plugins get called at when necessary.
danselmi:
I tried alphas suggestion without success:
From Scintilla documentation:
"No modifications may be performed while in a SCN_MODIFIED event...".
I have a possible solution where i "take" the first wxEVT_SCI_UPDATEUI event after the wxEVT_SCI_AUTOCOMP_SELECTION event (Patch is attached).
Any better proposals?
regards danselmi
Alpha:
Oops, sorry about that. I guess I did not read the docs closely enough.
Reading through your patch, it seems like it relies too much on a specific order of events (which *might* be interrupted/altered someday in the future). I think a cleaner way is to:
--- Quote from: Alpha on July 24, 2014, 03:46:47 am ---[...] add an API call into sdk/ccmanager.cpp line 742, so SmartIndent plugins get called at when necessary.
--- End quote ---
Have CCManager either broadcast a CC_Done event (which SmartIndent plugins could pick up), or iterate through all SmartIndent plugins and execute plugin->OnCCDone(ed).
danselmi:
just commited rev9853
It implements the approach where CCManager calls SmartIndentPlugin->OnCCDone(ed).
Kudos to alpha for support and reviewing!
regards danselmi
Navigation
[0] Message Index
Go to full version