On Fri, Jan 08, 2010 at 10:20:13PM +0300, Lime wrote:
> Hi all,
> 
> I saw interesting trick in one config (it's for slightly different thing,
> but may be helpful).
> Author implemented emacs-like double keybindings: when special combination
> (like "C-x") was pressed, ordinary shortcuts were replaced with different
> ones and then, after processing second stroke, everything was restored.
> 
> Adopting this technique with some modifications (e.g. leaving new bindings
> rather than restoring defaults after the first stroke) should help you.
> 
> Regards,
> Anton.
> 
> 
> On Fri, Jan 8, 2010 at 9:27 PM, Gregor Best <[email protected]> wrote:
> 
> > On Fri, Jan 08, 2010 at 07:24:09PM +0100, Dieter Plaetinck wrote:
> > > On Fri, 8 Jan 2010 23:52:41 +0530
> > > Anurag Priyam <[email protected]> wrote:
> > >
> > > > I also want to implement the same. From a previous mail it seems that
> > > > Gregor Best seems to have a solution.
> > > >
> > > > @Gregor Please do help us in implementing modal keybindings. We could
> > > > contact you off the list if desired.
> > >
> > > off-list? are you crazy?
> > > share the wisdom!
> > > [...]
> >
> > I'd favor doing this on list, however, I have plans for tonight, so all
> > I can leave you with is this message for today. I can give some basic
> > points though, which should at least spark some Ideas.
> >
> > Basically, it'd boil down to having the usual keybindings as they are
> > and adding one which starts a keygrabber, performing whatever acts one
> > wants at keypress (or accumulating keypresses).
> >
> > --
> > GCS/IT/M d- s+:- a-- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o--
> > K- w--- ?O M-- ?V PS++ PE- Y++ PGP+++ t+ 5 X+ R tv b+++ DI+++
> > D+++ G+ e h! r y+
> >
> >    Gregor Best
> >

Thanks for the help...
This is how I did it..

I still use the globalkeys table for keys that work in both modes
now I have 2 more tables insertkeys and commandkeys:

insertkeys = awful.util.table.join(
    awful.key({}, "F30",     function () CommandMode(1)         end)
)

commandkeys = awful.util.table.join(
    awful.key({},'Return',function () awful.util.spawn(terminal) EndCommand() 
end),
    awful.key({},   'F30',function () exitCmdMode = 0    end),
    awful.key({},     'i',function () InsertMode()         end)
)

and these functions:


exitCmdMode = nil

function InsertMode ()
    keymap = {}
    table.foreach(globalkeys,function(i,v)
        table.insert(keymap,v)
    end)
    table.foreach(insertkeys,function(i,v)
        table.insert(keymap,v)
    end)
    root.keys(keymap)
end


function CommandMode (leave)
    exitCmdMode = leave
    keymap = {}
    table.foreach(globalkeys,function(i,v)
        table.insert(keymap,v)
    end)
    table.foreach(commandkeys,function(i,v)
        table.insert(keymap,v)
    end)
    root.keys(keymap)
end

function EndCommand ()
    if(exitCmdMode ~= 0) then
        InsertMode()
    end
end

so all insert mode key functions need to call the EndCommand function at the 
end.
If I just want to type one key in in insert mode I just type F30 once.
If I want to be in insert mode until I press i I type F30 twice...

-Brian

-- 
To unsubscribe, send mail to [email protected].

Reply via email to