Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 1229:e9ea1497ac9d
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.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 08 Jun 2007 16:35:02 +0200 |
parents | 9a68fe4515dc |
children | eb9fc5d6d085 |
comparison
equal
deleted
inserted
replaced
1228:9a68fe4515dc | 1229:e9ea1497ac9d |
---|---|
393 settings_set(SETTINGS_TYPE_BINDING, "265", "help"); // Bind F1 to help... | 393 settings_set(SETTINGS_TYPE_BINDING, "265", "help"); // Bind F1 to help... |
394 | 394 |
395 g_string_free(sbuf, TRUE); | 395 g_string_free(sbuf, TRUE); |
396 } | 396 } |
397 | 397 |
398 // is_speckey(key) | |
399 // Return TRUE if key is a special code, i.e. no char should be displayed on | |
400 // the screen. It's not very nice, it's a workaround for the systems where | |
401 // isprint(KEY_PPAGE) returns TRUE... | |
402 static int is_speckey(int key) | |
403 { | |
404 switch (key) { | |
405 case 127: | |
406 case 393: | |
407 case 402: | |
408 case KEY_BACKSPACE: | |
409 case KEY_DC: | |
410 case KEY_LEFT: | |
411 case KEY_RIGHT: | |
412 case KEY_UP: | |
413 case KEY_DOWN: | |
414 case KEY_PPAGE: | |
415 case KEY_NPAGE: | |
416 case KEY_HOME: | |
417 case KEY_END: | |
418 case KEY_EOL: | |
419 return TRUE; | |
420 } | |
421 | |
422 // Fn keys | |
423 if (key >= 265 && key < 265+12) | |
424 return TRUE; | |
425 | |
426 // Special key combinations | |
427 if (key >= 513 && key <= 521) | |
428 return TRUE; | |
429 | |
430 return FALSE; | |
431 } | |
432 | |
398 void scr_InitLocaleCharSet(void) | 433 void scr_InitLocaleCharSet(void) |
399 { | 434 { |
400 setlocale(LC_CTYPE, ""); | 435 setlocale(LC_CTYPE, ""); |
401 LocaleCharSet = nl_langinfo(CODESET); | 436 LocaleCharSet = nl_langinfo(CODESET); |
402 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); | 437 utf8_mode = (strcmp(LocaleCharSet, "UTF-8") == 0); |
3237 display_char = TRUE; | 3272 display_char = TRUE; |
3238 } // switch | 3273 } // switch |
3239 | 3274 |
3240 display: | 3275 display: |
3241 if (display_char) { | 3276 if (display_char) { |
3242 if (kcode.utf8 ? iswprint(key) : isprint(key)) { | 3277 if (kcode.utf8 ? iswprint(key) : (isprint(key) && !is_speckey(key))) { |
3243 char tmpLine[INPUTLINE_LENGTH+1]; | 3278 char tmpLine[INPUTLINE_LENGTH+1]; |
3244 | 3279 |
3245 // Check the line isn't too long | 3280 // Check the line isn't too long |
3246 if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) | 3281 if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) |
3247 return 0; | 3282 return 0; |