Add IRCDefault to colors enum

weechat-hashes
Curtis McEnroe 2018-09-13 15:17:41 -04:00
parent 311795bf41
commit 9a69869d39
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
3 changed files with 12 additions and 11 deletions

5
chat.h
View File

@ -56,7 +56,7 @@ const struct Tag TagVerbose;
struct Tag tagFind(const char *name);
struct Tag tagFor(const char *name);
enum {
enum IRCColor {
IRCWhite,
IRCBlack,
IRCBlue,
@ -73,6 +73,7 @@ enum {
IRCPink,
IRCGray,
IRCLightGray,
IRCDefault = 99,
};
enum {
IRCBold = 002,
@ -88,7 +89,7 @@ struct Format {
size_t len;
bool split;
bool bold, italic, underline, reverse;
int fg, bg;
enum IRCColor fg, bg;
};
void formatReset(struct Format *format);
bool formatParse(struct Format *format, const wchar_t *split);

View File

@ -25,15 +25,15 @@ void formatReset(struct Format *format) {
format->italic = false;
format->underline = false;
format->reverse = false;
format->fg = -1;
format->bg = -1;
format->fg = IRCDefault;
format->bg = IRCDefault;
}
static void parseColor(struct Format *format) {
size_t len = MIN(wcsspn(format->str, L"0123456789"), 2);
if (!len) {
format->fg = -1;
format->bg = -1;
format->fg = IRCDefault;
format->bg = IRCDefault;
return;
}
format->fg = 0;
@ -41,7 +41,7 @@ static void parseColor(struct Format *format) {
format->fg *= 10;
format->fg += format->str[i] - L'0';
}
if (format->fg > IRCLightGray) format->fg = -1;
if (format->fg > IRCLightGray) format->fg = IRCDefault;
format->str = &format->str[len];
len = 0;
@ -54,7 +54,7 @@ static void parseColor(struct Format *format) {
format->bg *= 10;
format->bg += format->str[1 + i] - L'0';
}
if (format->bg > IRCLightGray) format->bg = -1;
if (format->bg > IRCLightGray) format->bg = IRCDefault;
format->str = &format->str[1 + len];
}

6
ui.c
View File

@ -160,7 +160,7 @@ void uiDraw(void) {
doupdate();
}
static const short IRCColors[] = {
static const short Colors[] = {
[IRCWhite] = 8 + COLOR_WHITE,
[IRCBlack] = 0 + COLOR_BLACK,
[IRCBlue] = 0 + COLOR_BLUE,
@ -187,8 +187,8 @@ static void addFormat(WINDOW *win, const struct Format *format) {
if (format->reverse) attr |= A_REVERSE;
short pair = -1;
if (format->fg >= 0) pair = IRCColors[format->fg];
if (format->bg >= 0) pair |= IRCColors[format->bg] << 4;
if (format->fg != IRCDefault) pair = Colors[format->fg];
if (format->bg != IRCDefault) pair |= Colors[format->bg] << 4;
wattr_set(win, attr | attr8(pair), 1 + pair8(pair), NULL);
waddnwstr(win, format->str, format->len);