From: Chris Allegretta Date: Fri, 14 Jun 2013 02:44:54 +0000 (+0000) Subject: 2013-06-13 David Lawrence Ramsey X-Git-Tag: v2.3.3~351 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=bf406ffc6f3bceec95ccf63a14d9d34b8404c410;p=nano.git 2013-06-13 David Lawrence Ramsey * src/global.c (first_sc_for) - try and more consistently display keystrokes, useful when the user has re-binded a bunch of them. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4579 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 9f8c15e0..6ac3de68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-06-13 David Lawrence Ramsey + * src/global.c (first_sc_for) - try and more consistently display keystrokes, + useful when the user has re-binded a bunch of them. + 2013-06-13 Kamil Dudka * doc/man/nano.1 - Actually document the -P (--poslog) option. diff --git a/src/global.c b/src/global.c index 566a8163..46bad8d7 100644 --- a/src/global.c +++ b/src/global.c @@ -308,26 +308,41 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h #endif } -const sc *first_sc_for(int menu, void (*func)(void)) { +const sc *first_sc_for(int menu, void (*func)(void)) +{ const sc *s; + const sc *fkeysc = NULL; const sc *metasc = NULL; for (s = sclist; s != NULL; s = s->next) { if ((s->menu & menu) && s->scfunc == func) { - /* try to use a meta sequence as a last resort. Otherwise - we will run into problems when we try and handle things like - the arrow keys, home, etc, if for some reason the user bound - them to a meta sequence first *shrug* */ - if (s->type == META) { - metasc = s; + /* Try to use function keys and meta sequences as last + * resorts. Otherwise, we will run into problems when we + * try and handle things like the arrow keys, Home, etc., if + * for some reason the user bound them to a function key or + * meta sequence first *shrug*. */ + if (s->type == FKEY) { + if (!fkeysc) + fkeysc = s; + continue; + } else if (s->type == META) { + if (!metasc) + metasc = s; continue; - } /* otherwise it was something else, use it */ + } + + /* Otherwise, it was something else, so use it. */ return s; } } - /* If we're here we may have found only meta sequences, if so use one */ - if (metasc) + /* If we're here, we may have found only function keys or meta + * sequences. If so, use one, with the same priority as in the + * help browser: function keys come first, unless meta sequences are + * available, in which case meta sequences come first. */ + if (fkeysc && !metasc) + return fkeysc; + else if (metasc) return metasc; #ifdef DEBUG