case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
{
- int num = atoi(s);
- if (num >= 0 && num <= 129)
+ char *num_delimiter;
+ int num;
+ int other_num;
+
+ if ((num_delimiter = strchr(s, ',')))
+ {
+ *num_delimiter = '\0';
+ num = atoi(s);
+ s = num_delimiter + 1;
+ other_num = atoi(s);
+
+ if (other_num >= 0 && other_num <= 7)
+ {
+ // If there's a valid background color, set that, overriding whatever
+ // came from the first number (but leaving the foreground in place)
+ num &= 15;
+ num |= other_num << 4;
+ }
+
+ }
+ else // no ',' delimiter
+ num = atoi(s);
+
+ if (num >= -1 && num <= 128)
attr |= COLOR_PAIR(num+1);
}
break;
void drawbanner(struct dg_banner *ban)
{
unsigned int i;
- char *edit_cursor, *special_end, *next_delimiter;
+ char *edit_cursor, *second_cursor, *next_delimiter;
int attr = 0, oattr = 0;
if (!ban)
do
{ // while (line_incomplete)
line_incomplete = 0;
- if ((edit_cursor = strstr(output_cursor, "$ATTR(")))
+ if (!(edit_cursor = strstr(output_cursor, "$ATTR(")))
{
- if ((special_end = strstr(edit_cursor, ")")))
- {
- int delimited = 0;
- char *next_attr_char;
- line_incomplete = 1;
- oattr = attr;
- attr = A_NORMAL;
- *edit_cursor = *special_end = '\0';
- edit_cursor += 6;
- next_attr_char = edit_cursor;
- do // while(delimited)
- {
- delimited = 0;
- next_delimiter = strchr(edit_cursor, ';');
- if (next_delimiter && *next_delimiter)
- {
- delimited = 1;
- next_attr_char = next_delimiter;
- *next_attr_char = '\0';
- next_attr_char++;
- }
- attr |= remap_attr_string(edit_cursor);
- edit_cursor = next_attr_char;
- } while (delimited);
-
- mvaddstr(1 + i, x, output_cursor);
- if (oattr)
- attroff(oattr);
- if (attr)
- attron(attr);
- x += strlen(output_cursor);
- special_end++;
- output_cursor = special_end;
- }
- else
- mvaddstr(1 + i, x, output_cursor);
+ mvaddstr(1 + i, x, output_cursor);
+ break;
}
- else
+ if (!(second_cursor = strstr(edit_cursor, ")")))
+ {
mvaddstr(1 + i, x, output_cursor);
-// elif ((edit_cursor = strstr(output_cursor, "$ATT2(")))
-// {
-// if ((special_end = strstr(edit_cursor, ")")))
-// {
-// }
-// }
+ break;
+ }
+ int delimited = 0;
+ char *next_attr_char;
+ line_incomplete = 1;
+ oattr = attr;
+ attr = A_NORMAL;
+ *edit_cursor = *second_cursor = '\0';
+ edit_cursor += 6;
+ next_attr_char = edit_cursor;
+ do // while(delimited)
+ {
+ delimited = 0;
+ next_delimiter = strchr(edit_cursor, ';');
+ if (next_delimiter && *next_delimiter)
+ {
+ delimited = 1;
+ next_attr_char = next_delimiter;
+ *next_attr_char = '\0';
+ next_attr_char++;
+ }
+ attr |= remap_attr_string(edit_cursor);
+ edit_cursor = next_attr_char;
+ } while (delimited);
+
+ mvaddstr(1 + i, x, output_cursor);
+ if (oattr)
+ attroff(oattr);
+ if (attr)
+ attron(attr);
+ x += strlen(output_cursor);
+ second_cursor++;
+ output_cursor = second_cursor;
} while (line_incomplete);
free(banner_line);
}
clear();
refresh();
}
+/* ************************************************************* */
+#ifdef USE_NCURSES_COLOR
int color_pair_idx(int fg, int bg)
{
int bgbits = (((1 & bg) << 2) | (2 & bg) | ((4 & bg) >> 2)) << 4;
int fgbits = (8 & fg) | ((1 & fg) << 2) | (2 & fg) | ((4 & fg) >> 2);
return (bgbits | fgbits) + 1;
}
-
+#endif
/* ************************************************************* */
void
# String substitutions defined in bannervars-section above.
# $VERSION = dgamelaunch version
# $USERNAME = user name (or [Anonymous] if not logged in)
-# $ATTR(params) = change text color and attributes.
-# params can be either number (to set the text color),
-# one, or any of "b" (bold), "s" (standout), "u" (underline),
-# "r" (reverse) or "d" (dim),
-# or both color number and attribute characters, separated by semicolon.
-# Empty param resets color and attributes to default.
+# $ATTR(params) = change text color and attributes. | 0 = Black
+# params can be either number (to set the text color), | 1 = Blue
+# one, or any of "b" (bold), "s" (standout), "u" (underline), | 2 = Green
+# "r" (reverse) or "d" (dim), | 3 = Cyan
+# or both color number and attribute characters, separated by semicolon.| 4 = Red
+# Empty param resets color and attributes to default. | 5 = Purple
+# Color number can be from -1 to 128. Two color numbers can be provided,| 6 = Yellow
+# separated by a comma (eg: $ATTR(14,1;b;f)) -- the second number must | 7 = White
+# be from 0-7, and will be used as the background colour. | 8-15 = bright-bit set
+# If no background color is given, and the provided foreground is >15, | 16-127 = setting background bits
+# the higher 3 bits will be used as a background color.
bannerfile = "(:menudir:)/dgl_menu_main_user.txt"
# after which cursor is moved to this location
# if cursor-definition is missing, the cursor is put