From: Chris Allegretta Date: Sat, 13 Jan 2001 17:22:54 +0000 (+0000) Subject: Added function ABCD(), better support for default settings X-Git-Tag: v0.9.99pre1~13 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=1748cd1d0f48468197c727fe188c4015824cf487;p=nano.git 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 --- 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;