changeset 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
files mcabber/src/screen.c
diffstat 1 files changed, 27 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/screen.c	Sat Jul 08 09:40:05 2006 +0200
+++ b/mcabber/src/screen.c	Sat Jul 08 09:43:01 2006 +0200
@@ -2449,6 +2449,7 @@
 int process_key(keycode kcode)
 {
   int key = kcode.value;
+  int display_char = FALSE;
 
   switch (kcode.mcode) {
     case 0:
@@ -2473,6 +2474,12 @@
         key = ERR; // Do not process any further
   }
 
+  if (kcode.utf8) {
+    if (key != ERR && !kcode.mcode)
+      display_char = TRUE;
+    goto display;
+  }
+
   switch (key) {
     case 0:
     case ERR:
@@ -2640,23 +2647,28 @@
         update_panels();
         break;
     default:
-        if (iswprint(key) && (!utf8_mode || kcode.utf8 || key < 128)) {
-          char tmpLine[INPUTLINE_LENGTH+1];
+        display_char = TRUE;
+  } // switch
 
-          // Check the line isn't too long
-          if (strlen(inputLine) + 4 > INPUTLINE_LENGTH)
-            return 0;
+display:
+  if (display_char) {
+    if (iswprint(key) && (!utf8_mode || kcode.utf8 || key < 128)) {
+      char tmpLine[INPUTLINE_LENGTH+1];
 
-          // Insert char
-          strcpy(tmpLine, ptr_inputline);
-          ptr_inputline = put_char(ptr_inputline, key);
-          strcpy(ptr_inputline, tmpLine);
-          check_offset(1);
-        } else {
-          // Look for a key binding.
-          if (bindcommand(kcode) == 255)
-            return 255;
-        }
+      // Check the line isn't too long
+      if (strlen(inputLine) + 4 > INPUTLINE_LENGTH)
+        return 0;
+
+      // Insert char
+      strcpy(tmpLine, ptr_inputline);
+      ptr_inputline = put_char(ptr_inputline, key);
+      strcpy(ptr_inputline, tmpLine);
+      check_offset(1);
+    } else {
+      // Look for a key binding.
+      if (!kcode.utf8 && (bindcommand(kcode) == 255))
+        return 255;
+    }
   }
 
   if (completion_started && key != 9 && key != KEY_RESIZE)