From 1748cd1d0f48468197c727fe188c4015824cf487 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sat, 13 Jan 2001 17:22:54 +0000 Subject: [PATCH] Added function ABCD(), better support for default settings git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 4 ++++ nano.c | 31 +++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd489635..feb4c889 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,10 @@ General do_browser() - Added space and - keys to do page up and down. - nano.c: + ABCD() + - New function, figures out what kbinput to return given + input common to several switch statements, allows us to + support the default Konsole key settings. main() - Alternate speller option no longer valid if DISABLE_SPELLER is active. (Rocco) diff --git a/nano.c b/nano.c index 853de0e8..7b3dcdfc 100644 --- a/nano.c +++ b/nano.c @@ -2028,6 +2028,26 @@ void do_toggle(int which) #endif } +/* This function returns the correct keystroke, given the A,B,C or D + input key. This is a common sequence of many terms which send + Esc-O-[A-D] or Esc-[-[A-D]. */ +int ABCD(int input) +{ + switch(input) + { + case 'A': + return(KEY_UP); + case 'B': + return(KEY_DOWN); + case 'C': + return(KEY_RIGHT); + case 'D': + return(KEY_LEFT); + default: + return 0; + } +} + int main(int argc, char *argv[]) { int optchr; @@ -2275,6 +2295,8 @@ int main(int argc, char *argv[]) /* Alt-O, suddenly very important ;) */ case 79: kbinput = wgetch(edit); + if (kbinput <= 'D' && kbinput >= 'A') + kbinput = ABCD(kbinput); if (kbinput <= 'S' && kbinput >= 'P') kbinput = KEY_F(kbinput - 79); #ifdef DEBUG @@ -2292,7 +2314,6 @@ int main(int argc, char *argv[]) keyhandled = 1; break; case 91: - switch (kbinput = wgetch(edit)) { case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */ kbinput = wgetch(edit); @@ -2369,16 +2390,10 @@ int main(int argc, char *argv[]) kbinput = KEY_F(kbinput - 64); break; case 'A': - kbinput = KEY_UP; - break; case 'B': - kbinput = KEY_DOWN; - break; case 'C': - kbinput = KEY_RIGHT; - break; case 'D': - kbinput = KEY_LEFT; + kbinput = ABCD(kbinput); break; case 'H': kbinput = KEY_HOME; -- 2.39.5