mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02:00
Added time, size and level setting types. Breaks some settings - I'll add
automatic converter to these settings later. Meanwhile you CVS users can fix your config files yourself :) Time settings allow using "days", "hours", "minutes", "seconds" and "milliseconds" or several of their abbreviations. For example "5d 4h 5msecs". Size settings allow using "gbytes", "mbytes", "kbytes" and "bytes" or their abbrevations. For example "5MB". Level settings are currently handled pretty much the way they were before. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3080 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
9c18cb00e7
commit
bd6fe052bc
35 changed files with 526 additions and 186 deletions
|
|
@ -153,11 +153,11 @@ void fe_common_core_init(void)
|
|||
args_register(options);
|
||||
|
||||
settings_add_bool("lookandfeel", "timestamps", TRUE);
|
||||
settings_add_str("lookandfeel", "timestamp_level", "ALL");
|
||||
settings_add_int("lookandfeel", "timestamp_timeout", 0);
|
||||
settings_add_level("lookandfeel", "timestamp_level", "ALL");
|
||||
settings_add_time("lookandfeel", "timestamp_timeout", 0);
|
||||
|
||||
settings_add_bool("lookandfeel", "bell_beeps", FALSE);
|
||||
settings_add_str("lookandfeel", "beep_msg_level", "");
|
||||
settings_add_level("lookandfeel", "beep_msg_level", "");
|
||||
settings_add_bool("lookandfeel", "beep_when_window_active", TRUE);
|
||||
settings_add_bool("lookandfeel", "beep_when_away", TRUE);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ static int ret_texts[] = {
|
|||
TXT_CHAN_NOT_FOUND,
|
||||
TXT_CHAN_NOT_SYNCED,
|
||||
TXT_ILLEGAL_PROTO,
|
||||
TXT_NOT_GOOD_IDEA
|
||||
TXT_NOT_GOOD_IDEA,
|
||||
CMDERR_INVALID_TIME
|
||||
};
|
||||
|
||||
int command_hide_output;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ static void cmd_ignore(const char *data)
|
|||
char *patternarg, *chanarg, *mask, *levels, *timestr;
|
||||
char **channels;
|
||||
void *free_arg;
|
||||
int new_ignore;
|
||||
int new_ignore, msecs;
|
||||
|
||||
if (*data == '\0') {
|
||||
cmd_ignore_show();
|
||||
|
|
@ -132,6 +132,13 @@ static void cmd_ignore(const char *data)
|
|||
if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
if (*levels == '\0') levels = "ALL";
|
||||
|
||||
msecs = 0;
|
||||
timestr = g_hash_table_lookup(optlist, "time");
|
||||
if (timestr != NULL) {
|
||||
if (!parse_time_interval(timestr, &msecs))
|
||||
cmd_return_error(CMDERR_INVALID_TIME);
|
||||
}
|
||||
|
||||
if (active_win->active_server != NULL &&
|
||||
server_ischannel(active_win->active_server, mask)) {
|
||||
chanarg = mask;
|
||||
|
|
@ -173,9 +180,8 @@ static void cmd_ignore(const char *data)
|
|||
rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
|
||||
rec->fullword = g_hash_table_lookup(optlist, "full") != NULL;
|
||||
rec->replies = g_hash_table_lookup(optlist, "replies") != NULL;
|
||||
timestr = g_hash_table_lookup(optlist, "time");
|
||||
if (timestr != NULL)
|
||||
rec->unignore_time = time(NULL)+atoi(timestr);
|
||||
if (msecs != 0)
|
||||
rec->unignore_time = time(NULL)+msecs/1000;
|
||||
|
||||
if (new_ignore)
|
||||
ignore_add_rec(rec);
|
||||
|
|
|
|||
|
|
@ -671,7 +671,7 @@ static void read_settings(void)
|
|||
|
||||
autolog_path = settings_get_str("autolog_path");
|
||||
autolog_level = !settings_get_bool("autolog") ? 0 :
|
||||
level2bits(settings_get_str("autolog_level"));
|
||||
settings_get_level("autolog_level");
|
||||
|
||||
if (old_autolog && !autolog_level)
|
||||
autologs_close_all();
|
||||
|
|
@ -704,7 +704,7 @@ void fe_log_init(void)
|
|||
settings_add_bool("log", "autolog", FALSE);
|
||||
settings_add_bool("log", "autolog_colors", FALSE);
|
||||
settings_add_str("log", "autolog_path", "~/irclogs/$tag/$0.log");
|
||||
settings_add_str("log", "autolog_level", "all -crap -clientcrap -ctcps");
|
||||
settings_add_level("log", "autolog_level", "all -crap -clientcrap -ctcps");
|
||||
settings_add_str("log", "log_theme", "");
|
||||
|
||||
autolog_level = 0;
|
||||
|
|
|
|||
|
|
@ -340,8 +340,8 @@ static void sig_message_private(SERVER_REC *server, const char *msg,
|
|||
|
||||
static void read_settings(void)
|
||||
{
|
||||
querycreate_level = level2bits(settings_get_str("autocreate_query_level"));
|
||||
query_auto_close = settings_get_int("autoclose_query");
|
||||
querycreate_level = settings_get_level("autocreate_query_level");
|
||||
query_auto_close = settings_get_time("autoclose_query")/1000;
|
||||
if (query_auto_close > 0 && queryclose_tag == -1)
|
||||
queryclose_tag = g_timeout_add(5000, (GSourceFunc) sig_query_autoclose, NULL);
|
||||
else if (query_auto_close <= 0 && queryclose_tag != -1) {
|
||||
|
|
@ -352,9 +352,9 @@ static void read_settings(void)
|
|||
|
||||
void fe_queries_init(void)
|
||||
{
|
||||
settings_add_str("lookandfeel", "autocreate_query_level", "MSGS DCCMSGS");
|
||||
settings_add_level("lookandfeel", "autocreate_query_level", "MSGS DCCMSGS");
|
||||
settings_add_bool("lookandfeel", "autocreate_own_query", TRUE);
|
||||
settings_add_int("lookandfeel", "autoclose_query", 0);
|
||||
settings_add_time("lookandfeel", "autoclose_query", "0");
|
||||
|
||||
queryclose_tag = -1;
|
||||
read_settings();
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ static void set_print(SETTINGS_REC *rec)
|
|||
value = value_int;
|
||||
break;
|
||||
case SETTING_TYPE_STRING:
|
||||
case SETTING_TYPE_TIME:
|
||||
case SETTING_TYPE_LEVEL:
|
||||
case SETTING_TYPE_SIZE:
|
||||
value = settings_get_str(rec->key);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -106,20 +109,38 @@ static void cmd_set(char *data)
|
|||
if (clear)
|
||||
settings_set_bool(key, FALSE);
|
||||
else if (set_default)
|
||||
settings_set_bool(key, GPOINTER_TO_INT(rec->def));
|
||||
settings_set_bool(key, rec->default_value.v_bool);
|
||||
else
|
||||
set_boolean(key, value);
|
||||
break;
|
||||
case SETTING_TYPE_INT:
|
||||
settings_set_int(key, clear ? 0 :
|
||||
set_default ? GPOINTER_TO_INT(rec->def) :
|
||||
set_default ? rec->default_value.v_int :
|
||||
atoi(value));
|
||||
break;
|
||||
case SETTING_TYPE_STRING:
|
||||
settings_set_str(key, clear ? "" :
|
||||
set_default ? rec->def :
|
||||
set_default ? rec->default_value.v_string :
|
||||
value);
|
||||
break;
|
||||
case SETTING_TYPE_TIME:
|
||||
if (!settings_set_time(key, clear ? "0" :
|
||||
set_default ? rec->default_value.v_string : value))
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_INVALID_TIME);
|
||||
break;
|
||||
case SETTING_TYPE_LEVEL:
|
||||
if (!settings_set_level(key, clear ? "" :
|
||||
set_default ? rec->default_value.v_string : value))
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_INVALID_LEVEL);
|
||||
break;
|
||||
case SETTING_TYPE_SIZE:
|
||||
if (!settings_set_size(key, clear ? "0" :
|
||||
set_default ? rec->default_value.v_string : value))
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||
TXT_INVALID_SIZE);
|
||||
break;
|
||||
}
|
||||
signal_emit("setup changed", 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
|
|||
|
||||
rec = g_new0(WINDOW_REC, 1);
|
||||
rec->refnum = window_get_new_refnum();
|
||||
rec->level = level2bits(settings_get_str("window_default_level"));
|
||||
rec->level = settings_get_level("window_default_level");
|
||||
|
||||
windows = g_slist_prepend(windows, rec);
|
||||
signal_emit("window created", 2, rec, GINT_TO_POINTER(automatic));
|
||||
|
|
@ -646,7 +646,7 @@ void windows_init(void)
|
|||
settings_add_bool("lookandfeel", "window_auto_change", FALSE);
|
||||
settings_add_bool("lookandfeel", "windows_auto_renumber", TRUE);
|
||||
settings_add_bool("lookandfeel", "window_check_level_first", FALSE);
|
||||
settings_add_str("lookandfeel", "window_default_level", "NONE");
|
||||
settings_add_level("lookandfeel", "window_default_level", "NONE");
|
||||
|
||||
read_settings();
|
||||
signal_add("server looking", (SIGNAL_FUNC) sig_server_connected);
|
||||
|
|
|
|||
|
|
@ -1091,11 +1091,9 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
|
|||
static void read_settings(void)
|
||||
{
|
||||
timestamp_level = settings_get_bool("timestamps") ? MSGLEVEL_ALL : 0;
|
||||
if (timestamp_level > 0) {
|
||||
timestamp_level =
|
||||
level2bits(settings_get_str("timestamp_level"));
|
||||
}
|
||||
timestamp_timeout = settings_get_int("timestamp_timeout");
|
||||
if (timestamp_level > 0)
|
||||
timestamp_level = settings_get_level("timestamp_level");
|
||||
timestamp_timeout = settings_get_time("timestamp_timeout")/1000;
|
||||
|
||||
hide_server_tags = settings_get_bool("hide_server_tags");
|
||||
hide_text_style = settings_get_bool("hide_text_style");
|
||||
|
|
|
|||
|
|
@ -676,14 +676,14 @@ static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
|||
|
||||
static void read_settings(void)
|
||||
{
|
||||
default_hilight_level = level2bits(settings_get_str("hilight_level"));
|
||||
default_hilight_level = settings_get_level("hilight_level");
|
||||
}
|
||||
|
||||
void hilight_text_init(void)
|
||||
{
|
||||
settings_add_str("lookandfeel", "hilight_color", "%Y");
|
||||
settings_add_str("lookandfeel", "hilight_act_color", "%M");
|
||||
settings_add_str("lookandfeel", "hilight_level", "PUBLIC DCCMSGS");
|
||||
settings_add_level("lookandfeel", "hilight_level", "PUBLIC DCCMSGS");
|
||||
|
||||
read_settings();
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,9 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||
{ "chan_not_synced", "Channel not fully synchronized yet, try again after a while", 0 },
|
||||
{ "illegal_proto", "Command isn't designed for the chat protocol of the active server", 0 },
|
||||
{ "not_good_idea", "Doing this is not a good idea. Add -YES option to command if you really mean it", 0 },
|
||||
{ "invalid_time", "Invalid timestamp", 0 },
|
||||
{ "invalid_level", "Invalid message level", 0 },
|
||||
{ "invalid_size", "Invalid size", 0 },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Themes", 0 },
|
||||
|
|
|
|||
|
|
@ -183,6 +183,9 @@ enum {
|
|||
TXT_CHAN_NOT_SYNCED,
|
||||
TXT_ILLEGAL_PROTO,
|
||||
TXT_NOT_GOOD_IDEA,
|
||||
TXT_INVALID_TIME,
|
||||
TXT_INVALID_LEVEL,
|
||||
TXT_INVALID_SIZE,
|
||||
|
||||
TXT_FILL_11,
|
||||
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ static void sig_gui_dialog(const char *type, const char *text)
|
|||
|
||||
static void read_settings(void)
|
||||
{
|
||||
beep_msg_level = level2bits(settings_get_str("beep_msg_level"));
|
||||
beep_msg_level = settings_get_level("beep_msg_level");
|
||||
beep_when_away = settings_get_bool("beep_when_away");
|
||||
beep_when_window_active = settings_get_bool("beep_when_window_active");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,18 +138,18 @@ static void read_settings(void)
|
|||
g_strsplit(targets, " ", -1);
|
||||
|
||||
hide_level = MSGLEVEL_NEVER | MSGLEVEL_NO_ACT |
|
||||
level2bits(settings_get_str("activity_hide_level"));
|
||||
msg_level = level2bits(settings_get_str("activity_msg_level"));
|
||||
settings_get_level("activity_hide_level");
|
||||
msg_level = settings_get_level("activity_msg_level");
|
||||
hilight_level = MSGLEVEL_HILIGHT |
|
||||
level2bits(settings_get_str("activity_hilight_level"));
|
||||
settings_get_level("activity_hilight_level");
|
||||
}
|
||||
|
||||
void window_activity_init(void)
|
||||
{
|
||||
settings_add_str("lookandfeel", "activity_hide_targets", "");
|
||||
settings_add_str("lookandfeel", "activity_hide_level", "");
|
||||
settings_add_str("lookandfeel", "activity_msg_level", "PUBLIC");
|
||||
settings_add_str("lookandfeel", "activity_hilight_level", "MSGS DCCMSGS");
|
||||
settings_add_level("lookandfeel", "activity_hide_level", "");
|
||||
settings_add_level("lookandfeel", "activity_msg_level", "PUBLIC");
|
||||
settings_add_level("lookandfeel", "activity_hilight_level", "MSGS DCCMSGS");
|
||||
|
||||
read_settings();
|
||||
signal_add("print text", (SIGNAL_FUNC) sig_hilight_text);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue