From 5803543f57ecac1e53f971e5a4514b9a8e61f78d Mon Sep 17 00:00:00 2001 From: mogami Date: Mon, 13 Oct 2003 06:01:12 +0000 Subject: [PATCH] =?utf8?q?=E3=83=98=E3=83=AB=E3=83=97=E8=A1=A8=E7=A4=BA?= =?utf8?q?=E4=B8=AD=E3=81=AB=E3=82=AB=E3=83=BC=E3=82=BD=E3=83=AB=E3=81=A7?= =?utf8?q?=E3=82=B9=E3=82=AF=E3=83=AD=E3=83=BC=E3=83=AB=E3=81=99=E3=82=8B?= =?utf8?q?=E3=81=A8=E7=94=BB=E9=9D=A2=E3=81=8C=E3=83=81=E3=83=A9=E3=83=81?= =?utf8?q?=E3=83=A9=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92?= =?utf8?q?=E4=BF=AE=E6=AD=A3=E3=80=82=E3=81=BE=E3=81=9F=E3=80=81=E8=89=B2?= =?utf8?q?=E4=BB=98=E3=81=8D=E6=96=87=E5=AD=97=E3=82=92=E8=A1=A8=E7=A4=BA?= =?utf8?q?=E3=81=99=E3=82=8B=E3=82=BF=E3=82=B0=E3=81=8C=E4=B8=8D=E6=AD=A3?= =?utf8?q?=E3=81=A0=E3=81=A3=E3=81=9F=E6=99=82=E3=81=AB=E9=85=8D=E5=88=97?= =?utf8?q?=E5=A4=96=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E3=82=92=E3=81=97?= =?utf8?q?=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E3=83=90=E3=82=B0=E3=82=92?= =?utf8?q?=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/files.c | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/files.c b/src/files.c index cfa9715c2..6e0371ed6 100644 --- a/src/files.c +++ b/src/files.c @@ -5044,15 +5044,11 @@ msg_format("'%s' /* Pre-Parse the file */ while (TRUE) { - char *str; + char *str = buf; /* Read a line or stop */ if (my_fgets(fff, buf, sizeof(buf))) break; - /* Get a color */ - if (prefix(buf, "#####")) str = &buf[6]; - else str = buf; - /* XXX Parse "menu" items */ if (prefix(str, "***** ")) { @@ -5077,8 +5073,13 @@ msg_format("'%s' /* Notice "tag" requests */ else if (str[6] == '<') { - str[strlen(str) - 1] = '\0'; - if (tag && streq(str + 7, tag)) line = next; + size_t len = strlen(str); + + if (str[len - 1] == '>') + { + str[len - 1] = '\0'; + if (tag && streq(str + 7, tag)) line = next; + } } /* Skip this */ @@ -5095,12 +5096,12 @@ msg_format("'%s' /* start from bottom when reverse mode */ if (line == -1) line = ((size-1)/rows)*rows; + /* Clear screen */ + Term_clear(); + /* Display the file */ while (TRUE) { - /* Clear screen */ - Term_clear(); - /* Restart when necessary */ if (line >= size - rows) line = size - rows; if (line < 0) line = 0; @@ -5138,7 +5139,7 @@ msg_format("'%s' for (i = 0; i < rows; ) { int print_x, x; - cptr str; + cptr str = buf; /* Hack -- track the "first" line */ if (!i) line = next; @@ -5150,15 +5151,18 @@ msg_format("'%s' if (prefix(buf, "***** ")) continue; /* Get a color */ - if (prefix(buf, "#####")) + if (prefix(str, "#####")) { - color = color_char_to_attr(buf[5]); - str = &buf[6]; + str += 5; + if (*str) + { + color = color_char_to_attr(*str); + str++; + } } else { color = TERM_WHITE; - str = buf; } /* Count the "real" lines */ @@ -5191,26 +5195,36 @@ msg_format("'%s' /* Color ? */ if (prefix(str + x, "[[[[[")) { - byte c = color_char_to_attr(str[x + 5]); - x += 6; + byte c; + x += 5; + + /* Illigal end of line */ + if (!str[x]) break; - /* Ok print the link name */ - while (str[x] != ']') + /* 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++; } - - x++; } + /* Clear rest of line */ + Term_erase(print_x, i + 2, 255); + /* Hilite "shower" */ if (shower[0]) { -- 2.11.0