Keyboard customizations

140 views
Skip to first unread message

Patrick Anderson

unread,
Feb 12, 2014, 4:36:38 PM2/12/14
to cgdb...@googlegroups.com
Hi all,

I tried customizing the key bindings but found some cannot be changed.

I'm an Emacs kind of guy <ducks>, and really want it closer to that feel...

I've been looking through the code a bit and have some ideas about how to change it, but wanted to consult with you all to see if there are already plans I might be conflicting with.

Thanks,
Patrick

Åke Forslund

unread,
Mar 6, 2014, 3:52:03 PM3/6/14
to cgdb...@googlegroups.com
Hi,

I am not the responsible dev but I think the project is in a pretty calm period, there are very few new patches and not much is happening in the git repository.

I'm (now and then about once every odd couple of months) trying to resolve the utf-8/wide char issues and I don't think there will be any clash with my work should I ever figure out how to get my code not to crash cgdb =)

I say go for it, send a pull-request and see if the maintainer likes the work.

/Åke

Bob Rossi

unread,
Mar 6, 2014, 5:10:55 PM3/6/14
to cgdb...@googlegroups.com
> Den onsdagen den 12:e februari 2014 kl. 22:36:38 UTC+1 skrev Patrick
> Anderson:

> > I tried customizing the key bindings but found some cannot be changed.

Which ones?

> > I'm an Emacs kind of guy <ducks>, and really want it closer to that feel...

That's fine, we haven't precluded that hopefully.

> > I've been looking through the code a bit and have some ideas about how to
> > change it, but wanted to consult with you all to see if there are already
> > plans I might be conflicting with.

What did you have in mind?

On Thu, Mar 06, 2014 at 12:52:03PM -0800, Åke Forslund wrote:
> I say go for it, send a pull-request and see if the maintainer likes the
> work.
>
> /Åke

I agree completely.

Bob Rossi

Patrick Anderson

unread,
Mar 10, 2014, 1:36:45 PM3/10/14
to cgdb...@googlegroups.com
On Thu, Mar 6, 2014 at 3:10 PM, Bob Rossi <b...@brasko.net> wrote:
> Den onsdagen den 12:e februari 2014 kl. 22:36:38 UTC+1 skrev Patrick
> Anderson:

> > I tried customizing the key bindings but found some cannot be changed.

Which ones?

While it is possible to add keys that are not already in use, none of the default
bindings can be changed except for the cgdb mode key (ESC by default).
 


> > I'm an Emacs kind of guy <ducks>, and really want it closer to that feel...

That's fine, we haven't precluded that hopefully.

Well, with every default key being hard-coded, this is very difficult.



> > I've been looking through the code a bit and have some ideas about how to
> > change it, but wanted to consult with you all to see if there are already
> > plans I might be conflicting with.

What did you have in mind?

I want to replace all of the default bindings in interface.c and filedlg.c with variables
that are set at startup.

This means we won't be able to use a switch statement.

So instead of

----
    switch (key) {
        case CGDB_KEY_DOWN:
        case 'j':
----

It will be more like

----
else if(key == cgdb_down)
{ }
----

Then in cgdbrc.c we will set all the defaults as they currently are, so someone
with no config file gets the same keybindings as cgdb currently has.

And then, after setting the defaults, cgdbrc.c reads the config file to override
any of those default bindings.


Later, a more advanced improvement would allow key 'sequences' to bind
a series of keys to a single command.


Bob Rossi

unread,
Apr 9, 2014, 6:38:20 PM4/9/14
to cgdb...@googlegroups.com
On Mon, Mar 10, 2014 at 11:36:45AM -0600, Patrick Anderson wrote:
> On Thu, Mar 6, 2014 at 3:10 PM, Bob Rossi <b...@brasko.net> wrote:
>
> > > Den onsdagen den 12:e februari 2014 kl. 22:36:38 UTC+1 skrev Patrick
> > > Anderson:
> >
> > > > I tried customizing the key bindings but found some cannot be changed.
> >
> > Which ones?
> >
>
> While it is possible to add keys that are not already in use, none of the
> default
> bindings can be changed except for the cgdb mode key (ESC by default).

I'm sorry for the long delay.

Right, a decision was made to allow the user to map keys at the keyboard
level. This means arbitrary keys can be mapped to other arbitrary keys.

However, at some point, keys are provided to CGDB. CGDB currently has in
it hardcoded what those keys mean. I thought about this extensively
years ago. Basically we can either

1) Map keys to commands after the macros are expanded. In this mode any
combination of keys can be configured to mean anything. That's powerful
but it misses one key feature of vim:

2) Have the application understand the context of certain keys being
entered to allow certain commands to be interactive. For example, think
of how vim handles searching. When you type '/He' it is searching for
any string that starts with He. You can then type 'l' and the screen
will update looking for Hel.

This interactive functionality is not available with choice 1. One day
I'll be working on this again, and I think I currently favor 2. I
haven't made my mind up yet specifically for people like yourself that
aren't vi users.

What do you think?

Bob Rossi
Reply all
Reply to author
Forward
0 new messages