Shrink autocomplete list while typing

52 views
Skip to first unread message

Charly Dante

unread,
Jan 11, 2017, 5:40:52 PM1/11/17
to scintilla-interest
Hi,

I really would like to have the feature that while typing code, the autocomplete list dynamically shrinks to only list matching keywords.

Unfortunatly it seems that this feature isn't inbuilt into Scintilla? If the autocomplete list string is updated using a second call with SCI_AUTOCSHOW, the current list closes and reopens instead of shrinking which causes flickering of the list.

Question: Wouldn't it be a reasonable approach just define a new Scintilla message to update the autocomplete list string? On the message, Scintilla would just call ac.SetList((const char *)(lParam));

After a first try this seems to work. However, I worry that this might introduce problems... can someone maybe comment whether this approach is reasonable or if it might crash Scintilla at some point?

Best
CD

Lex Trotman

unread,
Jan 11, 2017, 7:44:44 PM1/11/17
to scintilla...@googlegroups.com
On 12 January 2017 at 08:40, Charly Dante <dante...@gmail.com> wrote:
> Hi,
>
> I really would like to have the feature that while typing code, the
> autocomplete list dynamically shrinks to only list matching keywords.

An alternative, which Geany uses, is to move the selection as you type
to always select the first match to the typed prefix.

>
> Unfortunatly it seems that this feature isn't inbuilt into Scintilla? If the
> autocomplete list string is updated using a second call with SCI_AUTOCSHOW,
> the current list closes and reopens instead of shrinking which causes
> flickering of the list.
>
> Question: Wouldn't it be a reasonable approach just define a new Scintilla
> message to update the autocomplete list string? On the message, Scintilla
> would just call ac.SetList((const char *)(lParam));
>
> After a first try this seems to work. However, I worry that this might
> introduce problems... can someone maybe comment whether this approach is
> reasonable or if it might crash Scintilla at some point?
>
> Best
> CD
>
> --
> You received this message because you are subscribed to the Google Groups
> "scintilla-interest" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scintilla-inter...@googlegroups.com.
> To post to this group, send email to scintilla...@googlegroups.com.
> Visit this group at https://groups.google.com/group/scintilla-interest.
> For more options, visit https://groups.google.com/d/optout.

Neil Hodgson

unread,
Jan 11, 2017, 8:44:57 PM1/11/17
to scintilla...@googlegroups.com
Charly Dante:

> I really would like to have the feature that while typing code, the autocomplete list dynamically shrinks to only list matching keywords.

My personal preference is to maintain the extra context of the full list but it would be reasonable to have an option or call for this.

> Unfortunatly it seems that this feature isn't inbuilt into Scintilla? If the autocomplete list string is updated using a second call with SCI_AUTOCSHOW, the current list closes and reopens instead of shrinking which causes flickering of the list.

There are various things occurring here which may or may not be needed. The list is being sized and positioned and these may still be needed. There is also the ‘choose single’ option and whether it should be reevaluated when the list is changed and there is only one remaining option.

> Question: Wouldn't it be a reasonable approach just define a new Scintilla message to update the autocomplete list string? On the message, Scintilla would just call ac.SetList((const char *)(lParam));

We would need to choose which parts of ScintillaBase::AutoCompleteStart are also needed for this API.

Perhaps it would be better to try to eliminate the close and reopen caused by SCI_AUTOCSHOW if possible.

Neil

Mike Lischke

unread,
Jan 12, 2017, 4:00:56 AM1/12/17
to scintilla...@googlegroups.com
>
>> Question: Wouldn't it be a reasonable approach just define a new Scintilla message to update the autocomplete list string? On the message, Scintilla would just call ac.SetList((const char *)(lParam));
>
> We would need to choose which parts of ScintillaBase::AutoCompleteStart are also needed for this API.
>
> Perhaps it would be better to try to eliminate the close and reopen caused by SCI_AUTOCSHOW if possible.


I use this message since a long time to update the CS list while typing and I have never seen flickering with it (e.g. a visible close and reopen action) once the list was on screen. The update is very smooth on all platforms I have (Linux, OSX, Win).

Mike
--
www.soft-gems.net

Charly Dante

unread,
Jan 12, 2017, 1:50:37 PM1/12/17
to scintilla-interest
> An alternative, which Geany uses, is to move the selection as you type
> to always select the first match to the typed prefix.

Hm but that only modifies the selection then without changing the autocomplete list items? That would be quite different behavior I guess?

> There are various things occurring here which may or may not be needed. The list is being sized and positioned and these may still be needed. There is also the ‘choose single’ option and whether it should be reevaluated when the list is changed and there is only one remaining option.

Yes, thats right. Actually I just copy/pasted all the position calculating stuff from ScintillaBase::AutoCompleteStart to the custom message and it seems to work well.
Additionally I defined a  message which toggles a flag whether the list is shrinkable or not.
If it is shrinkable, in ScintillaBase::AutoCompleteCharacterAdded, the AutoCompleteMoveToCurrentWord must not be executed but rather just the the first remaining item in the list be selected.
With catching SCN_AUTOCCHARDELETED in the application its then even possible to re-expand the list when the user deletes charakters. Choose single is ignored if shrinking is enabled.

I was just woundering whether there might be any critical problems with this approach which I'm currently not aware of because I don't know the whole source code of Scintilla yet...


> We would need to choose which parts of ScintillaBase::AutoCompleteStart are also needed for this API.
> Perhaps it would be better to try to eliminate the close and reopen caused by SCI_AUTOCSHOW if possible.

I just took everything from line 259 to 290 and after that everything from line 300 - 315.

> I use this message since a long time to update the CS list while typing and I have never seen flickering with it (e.g. a visible close and reopen action) once the list was on screen. The update is very smooth on all platforms I have (Linux, OSX, Win).

Really? I experience significant flickering if I don't check whether the autocomplete list is already open before showing it. If I just send a SCI_AUOCSHOW on SCN_CHARADDED, the list flickers very strong.

Mike Lischke

unread,
Jan 12, 2017, 2:16:04 PM1/12/17
to scintilla...@googlegroups.com

> I use this message since a long time to update the CS list while typing and I have never seen flickering with it (e.g. a visible close and reopen action) once the list was on screen. The update is very smooth on all platforms I have (Linux, OSX, Win). 

Really? I experience significant flickering if I don't check whether the autocomplete list is already open before showing it. If I just send a SCI_AUOCSHOW on SCN_CHARADDED, the list flickers very strong.

Strange that the behavior is so different, especially since I see no flickering on all major platforms. Here's what I do:


that is where I update the list on each keypress and here the call to scintilla:


Reply all
Reply to author
Forward
0 new messages