From 13f13c1fb0001b1762acf57a2d525cdca393661a Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Mon, 13 Apr 2009 09:28:07 +0000 Subject: [PATCH] fix incorrect edit_draw_this_line, edit_get_utf. utf-8 text now showed correct --- edit/edit.c | 4 ++-- edit/editdraw.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/edit/edit.c b/edit/edit.c index dc13078ca..500f696ea 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -130,8 +130,8 @@ int edit_get_utf (WEdit * edit, long byte_index, int *char_width) int width = 0; if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) { - *char_width = 0; - return 0; + *char_width = 1; + return '\n'; } if (byte_index >= edit->curs1) { diff --git a/edit/editdraw.c b/edit/editdraw.c index f28869b48..96ebdea44 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -296,6 +296,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, unsigned int c; int color; int i; + int utf8lag = 0; edit_get_syntax_color (edit, b - 1, &color); q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0); @@ -318,7 +319,6 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, } while (col <= end_col - edit->start_col) { - mc_log("col=%i, end_col = %i, edit->start_col = %i, end_col - edit->start_col = %i\n",col, end_col, edit->start_col,end_col - edit->start_col ); p->ch = 0; p->style = 0; if (q == edit->curs1) @@ -342,14 +342,13 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, c = edit_get_byte (edit, q); } else { c = edit_get_utf (edit, q, &cw); - mc_log("c:%04x, w:%i\n", c, cw); } /* we don't use bg for mc - fg contains both */ edit_get_syntax_color (edit, q, &color); p->style |= color << 16; switch (c) { case '\n': - col = end_col - edit->start_col + 1; /* quit */ + col = (end_col + utf8lag) - edit->start_col + 1; /* quit */ p->ch = ' '; p++; break; @@ -449,12 +448,14 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, p++; } } else { - p->ch = c; - p++; - if ( cw > 1) { - col += cw - 1; - mc_log("col+ : %i\n", cw-1); - } + if ( g_unichar_isprint (c) ) { + p->ch = c; + p++; + } else { + p->ch = '.'; + p->style = MOD_ABNORMAL; + p++; + } } col++; break;