Re: Keychains

From: Robert <ro....at.web.de>
Date: Sun, 11 Apr 2010 12:11:18 -0700 (PDT)

On Apr 11, 6:26 pm, mitchell <mforal.n....at.gmail.com> wrote:
> Robert,
>
> On Apr 11, 12:05 pm, Robert <ro....at.web.de> wrote:
>
>
>
> > On Apr 10, 5:18 pm, mitchell <mforal.n....at.gmail.com> wrote:
>
> > > Robert,
>
> > > On Apr 10, 8:23 am, Robert <ro....at.web.de> wrote:
>
> > > > Hi!
>
> > > > Is it possible to have keychains behave like the other modifier keys?
> > > > E.g. with
> > > > keys.cf = keys.cf   = { 'char_right', b }
> > > > I can keep ctrl pressed and I can press "f" many times to move the
> > > > caret one char forward.
>
> > > > I would like to have something like
> > > > keys.ar = {
> > > >    f = { 'char_right_rect_extend', b },
> > > >    b = { 'char_left_rect_extend',  b },
> > > >    n = { 'line_down_rect_extend',  b },
> > > >    p = { 'line_up_rect_extend',    b },
> > > >    a = { 'vc_home_rect_extend',    b },
> > > >   e = { 'line_end_rect_extend',   b },}
>
> > > > So, press alt and r, then hold down alt and press "f", "n", etc. to
> > > > make my rectangular selection.
>
> > > > Is this possible? Currently, I would have to press alt+r, pause, then
> > > > f and then repeat the complete keychain.
>
> > > I don't think this is possible. Maybe playing around in core/ext/
> > > keys.lua will get you somewhere, but I cannot think how.
>
> > > Mitchell
>
> > I looked there, but would agree... Would it be possible to have a
> > function that would listen to all keypress events (overriding the
> > default keypress event listener), do some rect_extend for f, b, n, p
> > or the arrow keys and return when any other key is pressed? I tried
> > but it wasn't really succesful.
>
> You could try textadept.events.add_handler('keypress', your_func, 1).
> I'm not exactly sure if that's what you're looking for, but it will be
> run before the standard key handler.
>
> Mitchell
>
>
>
> > Robert

Thanks a lot! This got me in the right direction, I have a working
"prototype" now. It took me a while to figure out how to remove an
event as there is no remove_handler function, but
table.remove(textadept.events['keypresss'], 1) did it.

Robert
Received on Sun 11 Apr 2010 - 15:11:18 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:43:17 EST