From 1ee5945960f7203771cf34da886bff726f06edfd Mon Sep 17 00:00:00 2001 From: mogami Date: Thu, 23 Oct 2003 18:57:43 +0000 Subject: [PATCH] =?utf8?q?show=5Ffile()=E3=81=AE=E4=B8=AD=E3=81=A7?= =?utf8?q?=E7=94=BB=E9=9D=A2=E3=82=92=E3=82=B9=E3=82=AF=E3=83=AD=E3=83=BC?= =?utf8?q?=E3=83=AB=E3=81=99=E3=82=8B=E3=81=A8=E6=96=87=E5=AD=97=E5=8C=96?= =?utf8?q?=E3=81=91=E3=81=8C=E8=B5=B7=E3=82=8B=E4=BA=8B=E3=81=8C=E3=81=82?= =?utf8?q?=E3=82=8B=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Revision 1.139 で画面がチラチラしないように、全画面消去をしないで画面 のアップデートをするように変更したが、そのような場合に漢字を含む文字列 を表示する為に1byteずつz-term.cの関数を呼んではいけない。 つまり、Term_addstr()、Term_queue_chars()、prt()等は使って良いが、 Term_addch()、Term_draw()、Term_queue_char()等は使ってはいけない。 --- src/files.c | 113 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 37 deletions(-) diff --git a/src/files.c b/src/files.c index 63a249d34..e10425973 100644 --- a/src/files.c +++ b/src/files.c @@ -5044,6 +5044,81 @@ msg_print(" /* + * Display single line of on-line help file + */ +static void show_file_aux_line(cptr str, int cy, byte color) +{ + int cx = 0; + + /* Initial cursor position */ + Term_gotoxy(cx, cy); + + + while (*str) + { + cptr leftb = my_strchr(str, '['); + int len; + + /* Get length of white text */ + if (NULL == leftb) + { + len = strlen(str); + } + else + { + len = (int)(leftb - str); + } + + /* Print a white (actually default colored) text */ + Term_addstr(len, color, str); + cx += len; + str += len; + + /* Colored segment? */ + if (prefix(str, "[[[[[")) + { + cptr rightb; + byte attr; + + str += 5; + + /* Illigal end of line */ + if (!isalpha((int)((unsigned char)*str))) break; + + /* Get color attr */ + attr = color_char_to_attr(*str); + + str++; + + rightb = my_strchr(str, ']'); + + /* No close-bracket? */ + if (NULL == rightb) break; + + len = (int)(rightb - str); + + /* Ok print a colored text */ + Term_addstr(len, attr, str); + cx += len; + str = rightb + 1; + } + + /* This '[' was not a part of color tag */ + else if (*str == '[') + { + /* Print the '[' */ + Term_addstr(1, color, str); + cx++; + str++; + } + } + + /* Clear rest of line */ + Term_erase(cx, cy, 255); +} + + +/* * Recursive file perusal. * * Return FALSE on 'Q', otherwise TRUE. @@ -5338,7 +5413,6 @@ msg_format("'%s' /* Dump the next 20, or rows, lines of the file */ for (i = 0; i < rows; ) { - int print_x, x; cptr str = buf; /* Hack -- track the "first" line */ @@ -5388,42 +5462,7 @@ msg_format("'%s' find = NULL; /* Dump the line */ - x = 0; - print_x = 0; - while (str[x]) - { - /* Color ? */ - if (prefix(str + x, "[[[[[")) - { - byte c; - x += 5; - - /* Illigal end of line */ - if (!str[x]) break; - - /* Get color attr */ - c = color_char_to_attr(str[x++]); - - /* Ok print a colored text */ - while (str[x] && str[x] != ']') - { - Term_putch(print_x, i + 2, c, str[x]); - x++; - print_x++; - } - - if (str[x] == ']') x++; - } - else - { - Term_putch(print_x, i + 2, color, str[x]); - x++; - print_x++; - } - } - - /* Clear rest of line */ - Term_erase(print_x, i + 2, 255); + show_file_aux_line(str, i + 2, color); /* Hilite "shower" */ if (shower[0]) -- 2.11.0