News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

SmartIndent after CodeCompletion

Started by danselmi, July 23, 2014, 10:17:39 PM

Previous topic - Next topic

danselmi

I'd like to improve the SmartIndentHDL plugin.

The following case:

process begin
    ...
    end pro|

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?
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

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).

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
}


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
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]

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.
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
spell checker plugin: [url="http://developer.berlios.de/projects/spellchecker/"]http://developer.berlios.de/projects/spellchecker/[/url]
nassi shneiderman plugin: [url="http://developer.berlios.de/projects/nassiplugin"]http://developer.berlios.de/projects/nassiplugin[/url]