Mercurial > hg
comparison mcabber/src/screen.c @ 931:1cd6d694ac3c
Fix display of some UTF-8 chars
There was a conflict between the keycode and ncurses special keys. This
patch should fix it.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 08 Jul 2006 09:43:01 +0200 |
parents | a75f7a13df7b |
children | fc6aaa223650 |
comparison
equal
deleted
inserted
replaced
930:a75f7a13df7b | 931:1cd6d694ac3c |
---|---|
2447 // process_key(key) | 2447 // process_key(key) |
2448 // Handle the pressed key, in the command line (bottom). | 2448 // Handle the pressed key, in the command line (bottom). |
2449 int process_key(keycode kcode) | 2449 int process_key(keycode kcode) |
2450 { | 2450 { |
2451 int key = kcode.value; | 2451 int key = kcode.value; |
2452 int display_char = FALSE; | |
2452 | 2453 |
2453 switch (kcode.mcode) { | 2454 switch (kcode.mcode) { |
2454 case 0: | 2455 case 0: |
2455 break; | 2456 break; |
2456 case MKEY_EQUIV: | 2457 case MKEY_EQUIV: |
2469 break; | 2470 break; |
2470 default: | 2471 default: |
2471 if (bindcommand(kcode) == 255) | 2472 if (bindcommand(kcode) == 255) |
2472 return 255; | 2473 return 255; |
2473 key = ERR; // Do not process any further | 2474 key = ERR; // Do not process any further |
2475 } | |
2476 | |
2477 if (kcode.utf8) { | |
2478 if (key != ERR && !kcode.mcode) | |
2479 display_char = TRUE; | |
2480 goto display; | |
2474 } | 2481 } |
2475 | 2482 |
2476 switch (key) { | 2483 switch (key) { |
2477 case 0: | 2484 case 0: |
2478 case ERR: | 2485 case ERR: |
2638 top_panel(chatPanel); | 2645 top_panel(chatPanel); |
2639 top_panel(inputPanel); | 2646 top_panel(inputPanel); |
2640 update_panels(); | 2647 update_panels(); |
2641 break; | 2648 break; |
2642 default: | 2649 default: |
2643 if (iswprint(key) && (!utf8_mode || kcode.utf8 || key < 128)) { | 2650 display_char = TRUE; |
2644 char tmpLine[INPUTLINE_LENGTH+1]; | 2651 } // switch |
2645 | 2652 |
2646 // Check the line isn't too long | 2653 display: |
2647 if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) | 2654 if (display_char) { |
2648 return 0; | 2655 if (iswprint(key) && (!utf8_mode || kcode.utf8 || key < 128)) { |
2649 | 2656 char tmpLine[INPUTLINE_LENGTH+1]; |
2650 // Insert char | 2657 |
2651 strcpy(tmpLine, ptr_inputline); | 2658 // Check the line isn't too long |
2652 ptr_inputline = put_char(ptr_inputline, key); | 2659 if (strlen(inputLine) + 4 > INPUTLINE_LENGTH) |
2653 strcpy(ptr_inputline, tmpLine); | 2660 return 0; |
2654 check_offset(1); | 2661 |
2655 } else { | 2662 // Insert char |
2656 // Look for a key binding. | 2663 strcpy(tmpLine, ptr_inputline); |
2657 if (bindcommand(kcode) == 255) | 2664 ptr_inputline = put_char(ptr_inputline, key); |
2658 return 255; | 2665 strcpy(ptr_inputline, tmpLine); |
2659 } | 2666 check_offset(1); |
2667 } else { | |
2668 // Look for a key binding. | |
2669 if (!kcode.utf8 && (bindcommand(kcode) == 255)) | |
2670 return 255; | |
2671 } | |
2660 } | 2672 } |
2661 | 2673 |
2662 if (completion_started && key != 9 && key != KEY_RESIZE) | 2674 if (completion_started && key != 9 && key != KEY_RESIZE) |
2663 scr_end_current_completion(); | 2675 scr_end_current_completion(); |
2664 refresh_inputline(); | 2676 refresh_inputline(); |