Quantcast
Channel: ScintillaNET Forum Rss Feed
Viewing all articles
Browse latest Browse all 296

New Post: New Feature: Auto Launch AutoComplete

$
0
0
By default, we have to manually run 'AutoComplete.Show()' in the 'CharAdded' event.

However, I would like to suggest it to be auto-launch.

Default behaviour:
  • If the AutoComplete.List is empty, AutoComplete will not launch.
  • If the AutoComplete.List is not empty, it will launch for matched character enter by user.
  • If the developer want to implement different behaviour, he/she can override the methods or turn it off.
This is the sample codes patch that I can come out with:

This is the original codes of the method of OnCharAdded() in ScintillaNET.Scintilla
///<summary>///     Raises the <see cref="CharAdded"/> event.///</summary>///<param name="e">An <see cref="CharAddedEventArgs"/> that contains the event data.</param>protectedvirtualvoid OnCharAdded(CharAddedEventArgs e)
{
    EventHandler<CharAddedEventArgs> handler = Events[_charAddedEventKey] as EventHandler<CharAddedEventArgs>;
    if (handler != null)
        handler(this, e);

    if (_indentation.SmartIndentType != SmartIndent.None)
        _indentation.CheckSmartIndent(e.Ch);
}
Patches:
private Bool _autoLaunchAutoComplete = true;

public Bool AutoLaunchAutoComplete 
{ 
    get { return _autoLaunchAutoComplete; } 
    set { _autoLaunchAutoComplete = value; } 
}

///<summary>///     Raises the <see cref="CharAdded"/> event.///</summary>///<param name="e">An <see cref="CharAddedEventArgs"/> that contains the event data.</param>protectedvirtualvoid OnCharAdded(CharAddedEventArgs e)
{
    EventHandler<CharAddedEventArgs> handler = Events[_charAddedEventKey] as EventHandler<CharAddedEventArgs>;
    if (handler != null)
        handler(this, e);

    if (_indentation.SmartIndentType != SmartIndent.None)
        _indentation.CheckSmartIndent(e.Ch);

    if (_autoLaunchAutoComplete)
        LaunchAutoComplete();
}

publicvirtualvoid LaunchAutoComplete()
{
    if (this.AutoComplete.List.Count == 0)
        return;

    int pos = this.NativeInterface.GetCurrentPos();
    int length = pos - this.NativeInterface.WordStartPosition(pos, true);
    if (length == 0)
        return;

    this.AutoComplete.Show(length);
}
If the developer don't want automatic launch AutoComplete or he/she want to implement different behaviour, he/she may do this to suspend default behaviour:
ScintillaNET.Scintilla scintilla1 = new ScintillaNET.Scintilla();
scintilla1.AutoLaunchAutoComplete = false;

Viewing all articles
Browse latest Browse all 296


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>