Moving SnippetCompletionItem to language/completion

David Nolden zwabel at googlemail.com
Sun Sep 13 19:56:43 UTC 2009


Am Sonntag 13 September 2009 21:04:04 schrieb Milian Wolff:
> Would it be OK to move the SnippetCompletionItem + the SelectionJumper to
> language/completion?
> 
> I'd like to reuse that code in PHP and I think others could leverage it as
> well. Especially the SelectionJumper should/could be used in quite a few
>  more places.
> 
> Try it out, create a snippet and put this into it:
> 
> for ( int i = 0; i < $max$; ++i ) {
>   $//code$
> }
> 
> When you execute it, the following text will be inserted / completed:
> 
> for ( int i = 0; i < max; ++i ) {
>   //code
> }
> 
> max and //code have a colored background. max is preselected, typing will
> replace its contents. use Alt Left/Right for navigation. Esc will close the
> selection jumper.
> 
> I think nearly _every_ code completion item would benefit from the
>  selection jumper:
> 
> function completion for example:
> ~~
> void someFunc(type1 arg1, typ2 arg2);
> // completion could e.g. lead to:
> someFunc($type1 arg1$, $type2 arg2$)$$
> ~~
> 
> I'd appreciate reviews. Also I think it should be somehow made clearer that
>  a selection jumper is running - ideas?
Sounds very good. I have no time for review, but some more ideas:
- The selection-jumper could be indicated by blinking the current range, 
similar to a cursor (Should be fairly easy using dynamic smart-range 
attributes)
- ALT+left and ALT+right are a bit non-standard for input controls, better 
would be "TAB" and "shift+TAB"
- It should stop as soon as a newline is inserted, or when TAB is pressed 
while in the last range
- Ideally it should be possible to jump from one range to the next using just 
the normal left/right cursor navigation (For example, one could just listen 
the text-editor whether the cursor leaves the range, and if yes, jump it to 
the next one)

When that would be sorted out, this would really be a good option also for 
other code-completion stuff like functions, and should then be moved into 
kdevplatform/language.

Greetigns, David




More information about the KDevelop-devel mailing list