Moving SnippetCompletionItem to language/completion

Milian Wolff mail at milianw.de
Sun Sep 13 20:11:50 UTC 2009


David Nolden, 13.09.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)

Here I have a problem with the way kate treats the range. I have a SmartRange 
and set it also as selection and place the cursor in front of it. When I now 
type something, it's not the range contents that gets changed, but instead I 
type something _in front of the range_ and the range contents (the selection) 
gets truncated. So after typing I have an empty range (which still works as a 
jump-position)... I don't know how to fix that. Will ask the Kate devels.

> - ALT+left and ALT+right are a bit non-standard for input controls, better
> would be "TAB" and "shift+TAB"

Was my first approach as well.

The problem here was that even though I ate pretty much anything KeyRelated in 
my eventfilter, kate persisted to indent the lines. I don't know why that 
happens. I think the code that does the "tab pressed when we have a selection 
indents the line" is doing something wrong?

So if someone comes up with a fix for that, I'd really like to see it use TAB 
as well.

> - It should stop as soon as a newline is inserted, or when TAB is pressed
> while in the last range

Stop on newline is great. I'll implement that right away. But the latter I'm 
not sure of... I mean when I hit TAB accidentally and want to go back, I'd 
like to be able to hit TAB and have it "wrap" (that's the current behavior).

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

Also a very good idea. Will add it as well, but it would require the first 
issue to be solved.

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

Ok, thanks for the ideas!

-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20090913/340fbca6/attachment.sig>


More information about the KDevelop-devel mailing list