nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit bf406ffc6f3bceec95ccf63a14d9d34b8404c410
parent 2e46cc11e5268303d690a39ae49dcaed0bca833b
Author: Chris Allegretta <chrisa@asty.org>
Date:   Fri, 14 Jun 2013 02:44:54 +0000

2013-06-13  David Lawrence Ramsey <pooka109@gmail.com>
        * 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

Diffstat:
MChangeLog | 4++++
Msrc/global.c | 35+++++++++++++++++++++++++----------
2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +2013-06-13 David Lawrence Ramsey <pooka109@gmail.com> + * 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 <kdudka@redhat.com> * doc/man/nano.1 - Actually document the -P (--poslog) option. diff --git 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