Просмотр исходного кода

fix: with status_string on utf-8 char

Ilia Maslakov 16 лет назад
Родитель
Сommit
13986ea0af
2 измененных файлов с 17 добавлено и 7 удалено
  1. 1 2
      edit/edit.c
  2. 16 5
      edit/editdraw.c

+ 1 - 2
edit/edit.c

@@ -164,12 +164,11 @@ int edit_get_utf (WEdit * edit, long byte_index, int *char_width)
     int width = 0;
     int width = 0;
 
 
     if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) {
     if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) {
-        *char_width = 1;
+        *char_width = 0;
         return '\n';
         return '\n';
     }
     }
 
 
     str = edit_get_byte_ptr (edit, byte_index);
     str = edit_get_byte_ptr (edit, byte_index);
-
     res = g_utf8_get_char_validated (str, -1);
     res = g_utf8_get_char_validated (str, -1);
 
 
     if ( res < 0 ) {
     if ( res < 0 ) {

+ 16 - 5
edit/editdraw.c

@@ -73,11 +73,22 @@ static void status_string (WEdit * edit, char *s, int w)
      * as decimal and as hex.
      * as decimal and as hex.
      */
      */
     if (edit->curs1 < edit->last_byte) {
     if (edit->curs1 < edit->last_byte) {
-	unsigned char cur_byte = edit_get_byte (edit, edit->curs1);
-	g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
-		    is_printable (cur_byte) ? cur_byte : '.',
-		    (int) cur_byte,
-		    (unsigned) cur_byte);
+        if ( !edit->utf8 ) {
+	    unsigned char cur_byte = edit_get_byte (edit, edit->curs1);
+	    g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
+		        is_printable (cur_byte) ? cur_byte : '.',
+		        (int) cur_byte,
+		        (unsigned) cur_byte);
+	} else {
+	    int cw = 1;
+	    unsigned int cur_utf = edit_get_utf (edit, edit->curs1, &cw);
+	    if ( cw > 0 ) {
+	        g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
+		            (unsigned) cur_utf,
+		            (unsigned) cur_utf);
+	    }
+	
+	}
     } else {
     } else {
 	strcpy (byte_str, "<EOF>");
 	strcpy (byte_str, "<EOF>");
     }
     }