Under Linux, the Home, Del, and End keys don't work correctly in con- sole and/or XTerm sessions. This patch tries to fix these three keys for both modes. --- ncftp-3.2.5.old/ncftp/gl_getline.c +++ ncftp-3.2.5/ncftp/gl_getline.c @@ -909,6 +909,7 @@ search_term(); /* terminate and handle char */ } } +chtop: switch (c) { case '\n': case '\r': /* newline */ gl_newline(); @@ -989,10 +990,15 @@ case '\031': gl_yank(); /* ^Y */ break; case '\033': /* ansi arrow keys */ + c = gl_getcx(3); if ((c == '[') || (c == 'O')) { + int q; ansi: - switch(c = gl_getc()) { + c = gl_getc(); + q = c; + + switch(c) { case 'A': /* up */ strcpy(gl_buf, hist_prev()); if (gl_in_hook) @@ -1021,8 +1027,39 @@ if (gl_getc() == '~') gl_del(0, -1); /* del */ break; + +//-------------------------------------------------------------------- +// Fix some keys. + +// This code fixes the Home, End, and Del keys for XTerm and/or Linux +// console sessions. + +// Note: For the Linux console: +// +// Home key = ESC [ 1 ~ Del key = ESC [ 3 ~ +// End key = ESC [ 4 ~ + +// Additionally, for XTerm: +// +// Home key = ESC [ H Del key = ESC [ 3 +// End key = ESC [ F + + case '1': // Linux console Home key + case '4': // Linux console End key +// case 'H': // XTerm Home key +// case 'F': // XTerm End key +// case '3': // Del key for XTerm or Linux console + + gl_getcx (0); // Skip tilde, if present + c = '.'; + if ((q == '1') || (q == 'H')) c = 1; + if ((q == '4') || (q == 'F')) c = 5; + if (q == '3') c = 4; + goto chtop; + +//-------------------------------------------------------------------- + case '0': - case '1': goto ansi; default: gl_beep(); /* who knows */ break;