Add -NOOVERRIDE flag to GUI COLOR. (#2644)

This commit is contained in:
Nolan Lum 2021-10-14 07:44:11 -07:00 committed by GitHub
parent aabe3438fa
commit 9039a5d75b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 16 deletions

View File

@ -69,7 +69,16 @@ int fe_input_add (int sok, int flags, void *func, void *data);
void fe_input_remove (int tag);
void fe_idle_add (void *func, void *data);
void fe_set_topic (struct session *sess, char *topic, char *stripped_topic);
void fe_set_tab_color (struct session *sess, int col);
typedef enum
{
FE_COLOR_NONE = 0,
FE_COLOR_NEW_DATA = 1,
FE_COLOR_NEW_MSG = 2,
FE_COLOR_NEW_HILIGHT = 3,
FE_COLOR_FLAG_NOOVERRIDE = 8,
} tabcolor;
#define FE_COLOR_ALLFLAGS (FE_COLOR_FLAG_NOOVERRIDE)
void fe_set_tab_color (struct session *sess, tabcolor col);
void fe_flash_window (struct session *sess);
void fe_update_mode_buttons (struct session *sess, char mode, char sign);
void fe_update_channel_key (struct session *sess);

View File

@ -2152,7 +2152,6 @@ cmd_gui (struct session *sess, char *tbuf, char *word[], char *word_eol[])
{
case 0x058b836e: fe_ctrl_gui (sess, 8, 0); break; /* APPLY */
case 0xac1eee45: fe_ctrl_gui (sess, 7, 2); break; /* ATTACH */
case 0x05a72f63: fe_ctrl_gui (sess, 4, atoi (word[3])); break; /* COLOR */
case 0xb06a1793: fe_ctrl_gui (sess, 7, 1); break; /* DETACH */
case 0x05cfeff0: fe_ctrl_gui (sess, 3, 0); break; /* FLASH */
case 0x05d154d8: fe_ctrl_gui (sess, 2, 0); break; /* FOCUS */
@ -2166,6 +2165,12 @@ cmd_gui (struct session *sess, char *tbuf, char *word[], char *word_eol[])
else
return FALSE;
break;
case 0x05a72f63: /* COLOR */
if (!g_ascii_strcasecmp (word[4], "-NOOVERRIDE"))
fe_ctrl_gui (sess, 4, FE_COLOR_FLAG_NOOVERRIDE | atoi (word[3]));
else
fe_ctrl_gui (sess, 4, atoi (word[3]));
break;
default:
return FALSE;
}
@ -4015,8 +4020,9 @@ const struct commands xc_cmds[] = {
{"GETINT", cmd_getint, 0, 0, 1, "GETINT <default> <command> <prompt>"},
{"GETSTR", cmd_getstr, 0, 0, 1, "GETSTR <default> <command> <prompt>"},
{"GHOST", cmd_ghost, 1, 0, 1, N_("GHOST <nick> [password], Kills a ghosted nickname")},
{"GUI", cmd_gui, 0, 0, 1, "GUI [APPLY|ATTACH|DETACH|SHOW|HIDE|FOCUS|FLASH|ICONIFY|COLOR <n>]\n"
" GUI [MSGBOX <text>|MENU TOGGLE]"},
{"GUI", cmd_gui, 0, 0, 1, "GUI [APPLY|ATTACH|DETACH|SHOW|HIDE|FOCUS|FLASH|ICONIFY]\n"
" GUI [MSGBOX <text>|MENU TOGGLE]\n"
" GUI COLOR <n> [-NOOVERRIDE]"},
{"HELP", cmd_help, 0, 0, 1, 0},
{"HOP", cmd_hop, 1, 1, 1,
N_("HOP <nick>, gives chanhalf-op status to the nick (needs chanop)")},

View File

@ -664,13 +664,13 @@ fe_print_text (struct session *sess, char *text, time_t stamp,
return;
if (sess == current_tab)
fe_set_tab_color (sess, 0);
fe_set_tab_color (sess, FE_COLOR_NONE);
else if (sess->tab_state & TAB_STATE_NEW_HILIGHT)
fe_set_tab_color (sess, 3);
fe_set_tab_color (sess, FE_COLOR_NEW_HILIGHT);
else if (sess->tab_state & TAB_STATE_NEW_MSG)
fe_set_tab_color (sess, 2);
fe_set_tab_color (sess, FE_COLOR_NEW_MSG);
else
fe_set_tab_color (sess, 1);
fe_set_tab_color (sess, FE_COLOR_NEW_DATA);
}
void

View File

@ -175,20 +175,26 @@ fe_flash_window (session *sess)
/* set a tab plain, red, light-red, or blue */
void
fe_set_tab_color (struct session *sess, int col)
fe_set_tab_color (struct session *sess, tabcolor col)
{
struct session *server_sess = sess->server->server_session;
int col_noflags = (col & ~FE_COLOR_ALLFLAGS);
int col_shouldoverride = !(col & FE_COLOR_FLAG_NOOVERRIDE);
if (sess->res->tab && sess->gui->is_tab && (col == 0 || sess != current_tab))
{
switch (col)
switch (col_noflags)
{
case 0: /* no particular color (theme default) */
sess->tab_state = TAB_STATE_NONE;
chan_set_color (sess->res->tab, plain_list);
break;
case 1: /* new data has been displayed (dark red) */
sess->tab_state = TAB_STATE_NEW_DATA;
chan_set_color (sess->res->tab, newdata_list);
if (col_shouldoverride || !((sess->tab_state & TAB_STATE_NEW_MSG)
|| (sess->tab_state & TAB_STATE_NEW_HILIGHT))) {
sess->tab_state = TAB_STATE_NEW_DATA;
chan_set_color (sess->res->tab, newdata_list);
}
if (chan_is_collapsed (sess->res->tab)
&& !((server_sess->tab_state & TAB_STATE_NEW_MSG)
@ -201,8 +207,10 @@ fe_set_tab_color (struct session *sess, int col)
break;
case 2: /* new message arrived in channel (light red) */
sess->tab_state = TAB_STATE_NEW_MSG;
chan_set_color (sess->res->tab, newmsg_list);
if (col_shouldoverride || !(sess->tab_state & TAB_STATE_NEW_HILIGHT)) {
sess->tab_state = TAB_STATE_NEW_MSG;
chan_set_color (sess->res->tab, newmsg_list);
}
if (chan_is_collapsed (sess->res->tab)
&& !(server_sess->tab_state & TAB_STATE_NEW_HILIGHT)
@ -540,7 +548,7 @@ mg_focus (session *sess)
/* when called via mg_changui_new, is_tab might be true, but
sess->res->tab is still NULL. */
if (sess->res->tab)
fe_set_tab_color (sess, 0);
fe_set_tab_color (sess, FE_COLOR_NONE);
}
static int

View File

@ -623,7 +623,7 @@ fe_cleanup (void)
{
}
void
fe_set_tab_color (struct session *sess, int col)
fe_set_tab_color (struct session *sess, tabcolor col)
{
}
void