• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision1ee5945960f7203771cf34da886bff726f06edfd (tree)
Time2003-10-24 03:57:43
Authormogami <mogami@0568...>
Commitermogami

Log Message

show_file()の中で画面をスクロールすると文字化けが起る事があるバグ修正。

Revision 1.139 で画面がチラチラしないように、全画面消去をしないで画面
のアップデートをするように変更したが、そのような場合に漢字を含む文字列
を表示する為に1byteずつz-term.cの関数を呼んではいけない。

つまり、Term_addstr()、Term_queue_chars()、prt()等は使って良いが、
Term_addch()、Term_draw()、Term_queue_char()等は使ってはいけない。

Change Summary

Incremental Difference

--- a/src/files.c
+++ b/src/files.c
@@ -5044,6 +5044,81 @@ msg_print("
50445044
50455045
50465046 /*
5047+ * Display single line of on-line help file
5048+ */
5049+static void show_file_aux_line(cptr str, int cy, byte color)
5050+{
5051+ int cx = 0;
5052+
5053+ /* Initial cursor position */
5054+ Term_gotoxy(cx, cy);
5055+
5056+
5057+ while (*str)
5058+ {
5059+ cptr leftb = my_strchr(str, '[');
5060+ int len;
5061+
5062+ /* Get length of white text */
5063+ if (NULL == leftb)
5064+ {
5065+ len = strlen(str);
5066+ }
5067+ else
5068+ {
5069+ len = (int)(leftb - str);
5070+ }
5071+
5072+ /* Print a white (actually default colored) text */
5073+ Term_addstr(len, color, str);
5074+ cx += len;
5075+ str += len;
5076+
5077+ /* Colored segment? */
5078+ if (prefix(str, "[[[[["))
5079+ {
5080+ cptr rightb;
5081+ byte attr;
5082+
5083+ str += 5;
5084+
5085+ /* Illigal end of line */
5086+ if (!isalpha((int)((unsigned char)*str))) break;
5087+
5088+ /* Get color attr */
5089+ attr = color_char_to_attr(*str);
5090+
5091+ str++;
5092+
5093+ rightb = my_strchr(str, ']');
5094+
5095+ /* No close-bracket? */
5096+ if (NULL == rightb) break;
5097+
5098+ len = (int)(rightb - str);
5099+
5100+ /* Ok print a colored text */
5101+ Term_addstr(len, attr, str);
5102+ cx += len;
5103+ str = rightb + 1;
5104+ }
5105+
5106+ /* This '[' was not a part of color tag */
5107+ else if (*str == '[')
5108+ {
5109+ /* Print the '[' */
5110+ Term_addstr(1, color, str);
5111+ cx++;
5112+ str++;
5113+ }
5114+ }
5115+
5116+ /* Clear rest of line */
5117+ Term_erase(cx, cy, 255);
5118+}
5119+
5120+
5121+/*
50475122 * Recursive file perusal.
50485123 *
50495124 * Return FALSE on 'Q', otherwise TRUE.
@@ -5338,7 +5413,6 @@ msg_format("'%s'
53385413 /* Dump the next 20, or rows, lines of the file */
53395414 for (i = 0; i < rows; )
53405415 {
5341- int print_x, x;
53425416 cptr str = buf;
53435417
53445418 /* Hack -- track the "first" line */
@@ -5388,42 +5462,7 @@ msg_format("'%s'
53885462 find = NULL;
53895463
53905464 /* Dump the line */
5391- x = 0;
5392- print_x = 0;
5393- while (str[x])
5394- {
5395- /* Color ? */
5396- if (prefix(str + x, "[[[[["))
5397- {
5398- byte c;
5399- x += 5;
5400-
5401- /* Illigal end of line */
5402- if (!str[x]) break;
5403-
5404- /* Get color attr */
5405- c = color_char_to_attr(str[x++]);
5406-
5407- /* Ok print a colored text */
5408- while (str[x] && str[x] != ']')
5409- {
5410- Term_putch(print_x, i + 2, c, str[x]);
5411- x++;
5412- print_x++;
5413- }
5414-
5415- if (str[x] == ']') x++;
5416- }
5417- else
5418- {
5419- Term_putch(print_x, i + 2, color, str[x]);
5420- x++;
5421- print_x++;
5422- }
5423- }
5424-
5425- /* Clear rest of line */
5426- Term_erase(print_x, i + 2, 255);
5465+ show_file_aux_line(str, i + 2, color);
54275466
54285467 /* Hilite "shower" */
54295468 if (shower[0])
Show on old repository browser