# HG changeset patch # User Mikael Berthe # Date 1181313302 -7200 # Node ID e9ea1497ac9d4e233bd836e1be10686e043e39d8 # Parent 9a68fe4515dcc48a6be9cf581e81cda5db00d2a7 Fix a key binding issue on FreeBSD The problem is that on FreeBSD with wide ncurses support, isprint() returns TRUE for special key codes like Fn, KEY_PPAGE, etc. This (ugly) patch makes possible for these special keys to be bound anyway. diff -r 9a68fe4515dc -r e9ea1497ac9d mcabber/src/screen.c --- a/mcabber/src/screen.c Sun May 20 22:01:20 2007 +0200 +++ b/mcabber/src/screen.c Fri Jun 08 16:35:02 2007 +0200 @@ -395,6 +395,41 @@ g_string_free(sbuf, TRUE); } +// is_speckey(key) +// Return TRUE if key is a special code, i.e. no char should be displayed on +// the screen. It's not very nice, it's a workaround for the systems where +// isprint(KEY_PPAGE) returns TRUE... +static int is_speckey(int key) +{ + switch (key) { + case 127: + case 393: + case 402: + case KEY_BACKSPACE: + case KEY_DC: + case KEY_LEFT: + case KEY_RIGHT: + case KEY_UP: + case KEY_DOWN: + case KEY_PPAGE: + case KEY_NPAGE: + case KEY_HOME: + case KEY_END: + case KEY_EOL: + return TRUE; + } + + // Fn keys + if (key >= 265 && key < 265+12) + return TRUE; + + // Special key combinations + if (key >= 513 && key <= 521) + return TRUE; + + return FALSE; +} + void scr_InitLocaleCharSet(void) { setlocale(LC_CTYPE, ""); @@ -3239,7 +3274,7 @@ display: if (display_char) { - if (kcode.utf8 ? iswprint(key) : isprint(key)) { + if (kcode.utf8 ? iswprint(key) : (isprint(key) && !is_speckey(key))) { char tmpLine[INPUTLINE_LENGTH+1]; // Check the line isn't too long