hirc

IRC client
Log | Files | Refs

commit e74f2fd582878416286af3560d785762be4dd9b0
parent b089c0480250c7c90b0ee8cca2dfdbc068722cba
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 27 Mar 2022 13:33:17 +0100

Add HIST_UI shorthand

Diffstat:
Msrc/commands.c | 52++++++++++++++++++++++++++--------------------------
Msrc/config.c | 6+++---
Msrc/struct.h | 1+
Msrc/ui.c | 8++++----
4 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/src/commands.c b/src/commands.c @@ -1066,12 +1066,12 @@ command_server) { break; case opt_auto: if (!arg || !*arg) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_AUTOCMDS_START %s :Autocmds for %s:", + hist_format(selected.history, Activity_none, HIST_UI, "SELF_AUTOCMDS_START %s :Autocmds for %s:", nserver->name, nserver->name); for (acmds = nserver->autocmds; acmds && *acmds; acmds++) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_AUTOCMDS_LIST %s :%s", + hist_format(selected.history, Activity_none, HIST_UI, "SELF_AUTOCMDS_LIST %s :%s", nserver->name, *acmds); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_AUTOCMDS_END %s :End of autocmds for %s", + hist_format(selected.history, Activity_none, HIST_UI, "SELF_AUTOCMDS_END %s :End of autocmds for %s", nserver->name, nserver->name); } else { if (*arg == '/') { @@ -1295,16 +1295,16 @@ command_bind) { } if (!binding) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_KEYBIND_START :Keybindings:"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_KEYBIND_START :Keybindings:"); for (p = keybinds; p; p = p->next) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_KEYBIND_LIST %s :%s", ui_unctrl(p->binding), p->cmd); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_KEYBIND_END :End of keybindings"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_KEYBIND_LIST %s :%s", ui_unctrl(p->binding), p->cmd); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_KEYBIND_END :End of keybindings"); } else if (!cmd) { for (p = keybinds; p; p = p->next) { if (strcmp(p->binding, binding) == 0) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_KEYBIND_START :Keybindings:"); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_KEYBIND_LIST %s :%s", ui_unctrl(p->binding), p->cmd); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_KEYBIND_END :End of keybindings"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_KEYBIND_START :Keybindings:"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_KEYBIND_LIST %s :%s", ui_unctrl(p->binding), p->cmd); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_KEYBIND_END :End of keybindings"); return; } } @@ -1346,16 +1346,16 @@ command_alias) { } if (!alias) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_ALIAS_START :Aliases:"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_ALIAS_START :Aliases:"); for (p = aliases; p; p = p->next) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_ALIAS_LIST %s :%s", p->alias, p->cmd); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_ALIAS_END :End of aliases"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_ALIAS_LIST %s :%s", p->alias, p->cmd); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_ALIAS_END :End of aliases"); } else if (!cmd) { for (p = aliases; p; p = p->next) { if (strcmp(p->alias, alias) == 0) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_ALIAS_START :Aliases:"); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_ALIAS_LIST %s :%s", p->alias, p->cmd); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_ALIAS_END :End of aliases"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_ALIAS_START :Aliases:"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_ALIAS_LIST %s :%s", p->alias, p->cmd); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_ALIAS_END :End of aliases"); return; } } @@ -1379,18 +1379,18 @@ command_help) { } if (strcmp(str, "commands") == 0) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", str); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_START :%s", str); for (i=0; commands[i].name && commands[i].func; i++) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP : /%s", commands[i].name); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP : /%s", commands[i].name); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_END :end of help"); return; } if (strcmp(str, "variables") == 0) { - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", str); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_START :%s", str); for (i=0; config[i].name; i++) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_UI : %s", config[i].name); - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_UI : %s", config[i].name); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_END :end of help"); return; } @@ -1402,9 +1402,9 @@ command_help) { for (i=0; commands[i].name && commands[i].func; i++) { if (strncmp(commands[i].name, str, strlen(str)) == 0) { found = 1; - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", commands[i].name); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_START :%s", commands[i].name); for (j=0; commands[i].description[j]; j++) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP :%s", commands[i].description[j]); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP :%s", commands[i].description[j]); if (strcmp(commands[i].name, str) == 0) goto end; /* only print one for an exact match, i,e, /help format should only print the command, not all formats. */ } @@ -1414,9 +1414,9 @@ command_help) { for (i=0; config[i].name; i++) { if (strncmp(config[i].name, str, strlen(str)) == 0) { found = 1; - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_START :%s", config[i].name); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_START :%s", config[i].name); for (j=0; config[i].description[j]; j++) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP :%s", config[i].description[j]); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP :%s", config[i].description[j]); if (strcmp(config[i].name, str) == 0) goto end; } @@ -1425,7 +1425,7 @@ command_help) { end: if (found) - hist_format(selected.history, Activity_none, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_HELP_END :end of help"); + hist_format(selected.history, Activity_none, HIST_UI, "SELF_HELP_END :end of help"); else ui_error("no help on '%s'", str); } diff --git a/src/config.c b/src/config.c @@ -1273,13 +1273,13 @@ config_get_print(char *name) { for (i = found = 0; config[i].name; i++) { if (strncmp(config[i].name, name, strlen(name)) == 0) { if (config[i].valtype == Val_string) - hist_format(selected.history, Activity_status, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_UI :%s: %s", + hist_format(selected.history, Activity_status, HIST_UI, "SELF_UI :%s: %s", config[i].name, config[i].str); else if (config[i].valtype == Val_pair || config[i].valtype == Val_colourpair) - hist_format(selected.history, Activity_status, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_UI :%s: {%ld, %ld}", + hist_format(selected.history, Activity_status, HIST_UI, "SELF_UI :%s: {%ld, %ld}", config[i].name, config[i].pair[0], config[i].pair[1]); else - hist_format(selected.history, Activity_status, HIST_SHOW|HIST_TMP|HIST_MAIN, "SELF_UI :%s: %ld", + hist_format(selected.history, Activity_status, HIST_UI, "SELF_UI :%s: %ld", config[i].name, config[i].num); found = 1; } diff --git a/src/struct.h b/src/struct.h @@ -57,6 +57,7 @@ enum HistOpt { HIST_SERR = 128,/* generated by 400-599 numerics (which should be errors) */ HIST_RLOG = 256,/* messages read from log, useful for clearing the log */ HIST_DFL = HIST_SHOW|HIST_LOG, + HIST_UI = HIST_SHOW|HIST_TMP|HIST_MAIN, HIST_ALL = 0xFFFF }; diff --git a/src/ui.c b/src/ui.c @@ -284,14 +284,14 @@ ui_error_(char *file, int line, const char *func, char *format, ...) { vsnprintf(msg, sizeof(msg), format, ap); va_end(ap); - hist_format(selected.history, Activity_error, HIST_SHOW|HIST_TMP|HIST_MAIN|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, "SELF_ERROR %s %d %s :%s", file, line, func, msg); } void ui_perror_(char *file, int line, const char *func, char *str) { - hist_format(selected.history, Activity_error, HIST_SHOW|HIST_TMP|HIST_MAIN|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, "SELF_ERROR %s %d %s :%s: %s", file, line, func, str, strerror(errno)); } @@ -299,14 +299,14 @@ ui_perror_(char *file, int line, const char *func, char *str) { #ifdef TLS void ui_tls_config_error_(char *file, int line, const char *func, struct tls_config *config, char *str) { - hist_format(selected.history, Activity_error, HIST_SHOW|HIST_TMP|HIST_MAIN|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, "SELF_ERROR %s %d %s :%s: %s", file, line, func, str, tls_config_error(config)); } void ui_tls_error_(char *file, int line, const char *func, struct tls *ctx, char *str) { - hist_format(selected.history, Activity_error, HIST_SHOW|HIST_TMP|HIST_MAIN|HIST_ERR, + hist_format(selected.history, Activity_error, HIST_UI|HIST_ERR, "SELF_ERROR %s %d %s :%s: %s", file, line, func, str, tls_error(ctx)); }