変愚蛮怒のメインリポジトリです
Revision | 1ee5945960f7203771cf34da886bff726f06edfd (tree) |
---|---|
Time | 2003-10-24 03:57:43 |
Author | mogami <mogami@0568...> |
Commiter | mogami |
show_file()の中で画面をスクロールすると文字化けが起る事があるバグ修正。
Revision 1.139 で画面がチラチラしないように、全画面消去をしないで画面
のアップデートをするように変更したが、そのような場合に漢字を含む文字列
を表示する為に1byteずつz-term.cの関数を呼んではいけない。
つまり、Term_addstr()、Term_queue_chars()、prt()等は使って良いが、
Term_addch()、Term_draw()、Term_queue_char()等は使ってはいけない。
@@ -5044,6 +5044,81 @@ msg_print(" | ||
5044 | 5044 | |
5045 | 5045 | |
5046 | 5046 | /* |
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 | +/* | |
5047 | 5122 | * Recursive file perusal. |
5048 | 5123 | * |
5049 | 5124 | * Return FALSE on 'Q', otherwise TRUE. |
@@ -5338,7 +5413,6 @@ msg_format("'%s' | ||
5338 | 5413 | /* Dump the next 20, or rows, lines of the file */ |
5339 | 5414 | for (i = 0; i < rows; ) |
5340 | 5415 | { |
5341 | - int print_x, x; | |
5342 | 5416 | cptr str = buf; |
5343 | 5417 | |
5344 | 5418 | /* Hack -- track the "first" line */ |
@@ -5388,42 +5462,7 @@ msg_format("'%s' | ||
5388 | 5462 | find = NULL; |
5389 | 5463 | |
5390 | 5464 | /* 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); | |
5427 | 5466 | |
5428 | 5467 | /* Hilite "shower" */ |
5429 | 5468 | if (shower[0]) |