[Geany-devel] Geany multicursors patch

Davide Andreoli dave at xxxxx
Tue May 22 18:40:48 UTC 2012


2012/5/21 Dimitar Zhekov <dimitar.zhekov at gmail.com>

> On Sun, 20 May 2012 12:30:12 +0200
> Davide Andreoli <dave at gurumeditation.it> wrote:
>
> > Hi all!
>
> Hi.
>
> > I implemented this in editor.c (and not as an external plugin) because I
> > have plans to also extend the snippets to support multi editing.
> >
> > Actually the patch is really simple but is just a first test, it is not
> > ready as there are 3 open issue:
> >
> > 1. do you like the feature? :)
>
> Yes, but would prefer it as a plugin. Extending it to snippets, well...
> doesn't seem useful to me.
>

Please, give a look at the last mail (the one I replayed) in the geany ml,
it seems I'm not the only one searching for snippets that can insert the
same typed word in different position inside the snip.

This is my use case:
I'm writing some python binding for a library, its a really repetitive task
that
will end to use this snippet again, again and again:

property XXX:
        def __get__(self):
                return self.XXX_get()

        def __set__(self, value):
                self.XXX_set(value)

where XXX is always the same word. so I type "prop+TAB", I got a super
usefull
spippets expansion, but then I need to write the same word 3 times and this
destroy
all of the snippet magic :(


>
> > 2. atm the multimode end when you press up/down/left/right....i don't
> like
> > it too much, some other idea?
>
> Prefferably on the same events that cancel the rectangle multi line
> character insertion.
>
> > 3. is there a way to really show multiple carets?
>
> No easy way AFAIK.
>

hey! you are wrong :P

I found the easy way (that also solve the issue 2). I just enabled
scintilla
multiple selections ! in fact scintilla is able to do exactly what I was
searching for :)
(thank go to elextr that point me to the right direction in IRC)

...and now the patch is just a 3 liner:

+++ b/src/editor.c
@@ -4677,6 +4677,11 @@ static ScintillaObject *create_new_sci(GeanyEditor
*editor)
     /* virtual space */
     SSM(sci, SCI_SETVIRTUALSPACEOPTIONS, editor_prefs.show_virtual_space,
0);

+    /* multiple selection */
+    SSM(sci, SCI_SETMULTIPLESELECTION, 1, 0);
+    SSM(sci, SCI_SETADDITIONALSELECTIONTYPING, 1, 0);
+    SSM(sci, SCI_SETRECTANGULARSELECTIONMODIFIER, SCMOD_SUPER, 0);


In real they should be just 2 line, the last one is there to solve a
scintilla issue (also found in scite):
The multiple selection hard-coded binding (Ctrl+Alt) is "shadowed" by the
rectangular selection
binding (Ctrl). So the only way I found to make multiple selection +
rectangular selection to work
is to change the binding for the rect selection.

With the patch applied you can make rectangular selection with "Super" and
multiple selections with "Ctrl+Alt".

Probably you will not like the binding change (I don't like to change it,
I'm quite used to use Ctr for rect selections)  so I'm searching another
way to solve the binding conflict... suggestions are welcome


NOTE: I switched to github (as requested). Now you can find the new (and
the old) patch
into 2 branch I have done at:
https://github.com/DaveMDS/geany/tree/enable-multiselection ( the new one)
https://github.com/DaveMDS/geany/tree/multicursor ( the old one )


feedbacks welcome :)
davemds


>
> If you position the cursor on the first of several lines with leading
> tabs, switch to overwrite and mark the tabs as rectangle, there will be
> several cursors, each with tab width. So scintilla is actually pretty
> capable - if you want to get your hands dirty, open it's sources and
> see how it's done.
>
> > note: this is my first geany patch... plese be kind :P
>
> :)
>
> --
> E-gards: Jimmy
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geany.org/pipermail/devel/attachments/20120522/4095cb1d/attachment.html>


More information about the Devel mailing list