On Sun, 30 Jul 2006 00:58:16 +0200
Jonas Fonseca <[EMAIL PROTECTED]> wrote:
> Kalle Olavi Niemitalo <[EMAIL PROTECTED]> wrote Fri, Jul 28, 2006:
> > diff --git a/src/config/kbdbind.c b/src/config/kbdbind.c
> > index 09c7ceb..a90a3d7 100644
> > --- a/src/config/kbdbind.c
> > +++ b/src/config/kbdbind.c
> > @@ -369,34 +369,41 @@ read_key(unsigned char *key_str)
> > return -1;
> > }
> >
> > +struct modifier {
> > + const unsigned char *name_and_dash;
> > + size_t name_len; /* does not include the dash */
> > + int bitmask;
> > +};
>
> Ok, I didn't see the funny string name and the comment in my first run
> through the patch. Below a simpler idea for doing this which is more
> obvious or clean, at least to me.
>
> > +static const struct modifier modifiers[] = {
> > + { "Shift-", 5, KBD_MOD_SHIFT },
> > + { "Ctrl-", 4, KBD_MOD_CTRL },
> > + { "Alt-", 3, KBD_MOD_ALT },
> > + { NULL }
> > +};
>
> Leave out the '-'s at the end here ...
>
> > @@ -408,15 +415,14 @@ add_keystroke_to_string(struct string *s
> > unsigned char key_buffer[3] = "\\x";
> > unsigned char *key_string = NULL;
> > struct key *key;
> > + const struct modifier *modp;
> >
> > if (kbd->key < 0) return;
> >
> > - if (kbd->modifier & KBD_MOD_SHIFT)
> > - add_to_string(str, "Shift-");
> > - if (kbd->modifier & KBD_MOD_CTRL)
> > - add_to_string(str, "Ctrl-");
> > - if (kbd->modifier & KBD_MOD_ALT)
> > - add_to_string(str, "Alt-");
> > + for (modp = modifiers; modp->name_and_dash != NULL; ++modp) {
> > + if (kbd->modifier & modp->bitmask)
> > + add_to_string(str, modp->name_and_dash);
>
> ... and use
>
> add_format_to_string(str, "%s-", ...);
>
> here.
>
> (Sorry for nitpicking. ;)
or just add add_char_to_string(str, '-');
--
Zas
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev