/* 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, "***** "))
{
/* 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 */
/* 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;
for (i = 0; i < rows; )
{
int print_x, x;
- cptr str;
+ cptr str = buf;
/* Hack -- track the "first" line */
if (!i) line = next;
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 */
/* 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])
{