diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2007-12-01 00:35:57 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2007-12-01 00:35:57 +0100 |
commit | 59fb878b77320844d7d2150c95ce22c253ffb4e6 (patch) | |
tree | dbb9ee486748b0c64fcf558732ae643474e33b3f | |
parent | 32cc6ae5d8a2c0753eb2ef8ecb7194f0afff4302 (diff) | |
download | weechat-59fb878b77320844d7d2150c95ce22c253ffb4e6.zip |
New config functions, almost entirely rewritten from scratch
45 files changed, 2590 insertions, 2732 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0e20941dc..f850d1948 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -16,10 +16,9 @@ SET(LIB_CORE_SRC weechat.c weechat.h wee-alias.c wee-alias.h wee-backtrace.c wee-backtrace.h wee-command.c wee-command.h wee-config.c wee-config.h -wee-config-file.c wee-config-file.h wee-config-option.c wee-config-option.h -wee-hook.c wee-hook.h wee-input.c wee-input.h wee-list.c wee-list.h wee-log.c -wee-log.h wee-string.c wee-string.h wee-upgrade.c wee-upgrade.h wee-utf8.c -wee-utf8.h wee-util.c wee-util.h) +wee-config-file.c wee-config-file.h wee-hook.c wee-hook.h wee-input.c +wee-input.h wee-list.c wee-list.h wee-log.c wee-log.h wee-string.c wee-string.h +wee-upgrade.c wee-upgrade.h wee-utf8.c wee-utf8.h wee-util.c wee-util.h) # Check for flock support INCLUDE(CheckSymbolExists) diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 043dba416..487c5693f 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -30,8 +30,6 @@ lib_weechat_core_a_SOURCES = weechat.c \ wee-config.h \ wee-config-file.c \ wee-config-file.h \ - wee-config-option.c \ - wee-config-option.h \ wee-hook.c \ wee-hook.h \ wee-input.c \ diff --git a/src/core/wee-alias.c b/src/core/wee-alias.c index d801c4ce8..992e30d5c 100644 --- a/src/core/wee-alias.c +++ b/src/core/wee-alias.c @@ -30,6 +30,7 @@ #include "wee-alias.h" #include "wee-config.h" #include "wee-string.h" +#include "../gui/gui-chat.h" struct alias *weechat_alias = NULL; diff --git a/src/core/wee-command.c b/src/core/wee-command.c index a8d458157..acaf8bbb2 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -40,6 +40,7 @@ #include "wee-utf8.h" #include "wee-list.h" #include "../gui/gui-chat.h" +#include "../gui/gui-color.h" #include "../gui/gui-history.h" #include "../gui/gui-input.h" #include "../gui/gui-keyboard.h" @@ -1011,7 +1012,7 @@ command_history (struct t_gui_buffer *buffer, /* make C compiler happy */ (void) argv_eol; - n_user = cfg_history_display_default; + n_user = CONFIG_INTEGER(config_history_display_default); if (argc == 1) { @@ -1529,7 +1530,7 @@ command_save (struct t_gui_buffer *buffer, (void) argv_eol; /* save WeeChat configuration */ - if (weechat_config_write () == 0) + if (config_weechat_write () == 0) gui_chat_printf (NULL, _("%sWeeChat configuration file saved"), gui_chat_prefix[GUI_CHAT_PREFIX_INFO]); @@ -1562,35 +1563,46 @@ command_set_display_option (struct t_config_option *option, char *prefix, switch (option->type) { - case OPTION_TYPE_BOOLEAN: + case CONFIG_OPTION_BOOLEAN: gui_chat_printf (NULL, "%s%s%s%s = %s%s", prefix, (message) ? message : " ", option->name, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT_HOST), - (*((int *)(option->ptr_int))) ? "ON" : "OFF"); + (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ? + "ON" : "OFF"); break; - case OPTION_TYPE_INT: - gui_chat_printf (NULL, "%s%s%s%s = %s%d", - prefix, - (message) ? message : " ", - option->name, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - *((int *)(option->ptr_int))); + case CONFIG_OPTION_INTEGER: + if (option->string_values) + gui_chat_printf (NULL, "%s%s%s%s = %s%s", + prefix, + (message) ? message : " ", + option->name, + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT_HOST), + option->string_values[CONFIG_INTEGER(option)]); + else + gui_chat_printf (NULL, "%s%s%s%s = %s%d", + prefix, + (message) ? message : " ", + option->name, + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT_HOST), + CONFIG_INTEGER(option)); break; - case OPTION_TYPE_INT_WITH_STRING: - gui_chat_printf (NULL, "%s%s%s%s = %s%s", + case CONFIG_OPTION_STRING: + gui_chat_printf (NULL, "%s%s%s%s = \"%s%s%s\"", prefix, (message) ? message : " ", option->name, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT_HOST), - option->array_values[*((int *)(option->ptr_int))]); + (option->value) ? CONFIG_STRING(option) : "", + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); break; - case OPTION_TYPE_COLOR: - color_name = gui_color_get_name (*((int *)(option->ptr_int))); + case CONFIG_OPTION_COLOR: + color_name = gui_color_get_name (CONFIG_COLOR(option)); gui_chat_printf (NULL, "%s%s%s%s = %s%s", prefix, (message) ? message : " ", @@ -1599,53 +1611,39 @@ command_set_display_option (struct t_config_option *option, char *prefix, GUI_COLOR(GUI_COLOR_CHAT_HOST), (color_name) ? color_name : _("(unknown)")); break; - case OPTION_TYPE_STRING: - if (*((char **)(option->ptr_string))) - gui_chat_printf (NULL, "%s%s%s%s = \"%s%s%s\"", - prefix, - (message) ? message : " ", - option->name, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT_HOST), - *(option->ptr_string), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); - else - gui_chat_printf (NULL, "%s%s%s%s = \"\"", - prefix, - (message) ? message : " ", - option->name, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); - break; } } /* * command_set_display_option_list: display list of options - * Return: number of options displayed + * return: number of options displayed */ int -command_set_display_option_list (char **config_sections, - struct t_config_option **config_options, +command_set_display_option_list (struct t_config_file *config_file, char *message, char *search) { - int i, j, number_found, section_displayed; + int number_found, section_displayed; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; - if (!config_sections || !config_options) + if (!config_file) return 0; number_found = 0; - for (i = 0; config_sections[i]; i++) + for (ptr_section = config_file->sections; ptr_section; + ptr_section = ptr_section->next_section) { - if (config_options[i]) + if (ptr_section->options) { section_displayed = 0; - for (j = 0; config_options[i][j].name; j++) + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) { if ((!search) || ((search) && (search[0]) - && (string_strcasestr (config_options[i][j].name, search)))) + && (string_strcasestr (ptr_option->name, search)))) { if (!section_displayed) { @@ -1653,12 +1651,11 @@ command_set_display_option_list (char **config_sections, gui_chat_printf (NULL, "%s[%s%s%s]", GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT_BUFFER), - config_sections[i], + ptr_section->name, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); section_displayed = 1; } - command_set_display_option (&config_options[i][j], - "", message); + command_set_display_option (ptr_option, "", message); number_found++; } } @@ -1688,10 +1685,10 @@ command_set (struct t_gui_buffer *buffer, { number_found = 0; - number_found += command_set_display_option_list (weechat_config_sections, - weechat_config_options, + number_found += command_set_display_option_list (weechat_config, NULL, - (argc == 1) ? argv[0] : NULL); + (argc == 1) ? + argv[0] : NULL); if (number_found == 0) { @@ -1728,9 +1725,7 @@ command_set (struct t_gui_buffer *buffer, /* set option value */ if ((argc >= 3) && (string_strcasecmp (argv[1], "=") == 0)) { - ptr_option = config_option_section_option_search (weechat_config_sections, - weechat_config_options, - argv[0]); + ptr_option = config_file_search_option (weechat_config, NULL, argv[0]); if (!ptr_option) { gui_chat_printf (NULL, @@ -1740,27 +1735,18 @@ command_set (struct t_gui_buffer *buffer, argv[0]); return -1; } - if (!ptr_option->handler_change) - { - gui_chat_printf (NULL, - _("%sError: option \"%s\" can not be " - "changed while WeeChat is " - "running"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - argv[0]); - return -1; - } value = string_remove_quotes (argv_eol[2], "'\""); - rc = config_option_set (ptr_option, - (value) ? value : argv_eol[2]); + rc = config_file_option_set (ptr_option, + (value) ? value : argv_eol[2]); if (value) free (value); - if (rc == 0) + if (rc > 0) { command_set_display_option (ptr_option, gui_chat_prefix[GUI_CHAT_PREFIX_INFO], _("Option changed: ")); - (void) (ptr_option->handler_change()); + if ((rc == 2) && (ptr_option->callback_change)) + (void) (ptr_option->callback_change) (); } else { @@ -1785,7 +1771,7 @@ command_setp (struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { char *pos, *ptr_name, *value; - struct t_plugin_option *ptr_option; + struct t_config_option *ptr_option; int number_found; /* make C compiler happy */ @@ -1808,7 +1794,7 @@ command_setp (struct t_gui_buffer *buffer, ptr_option->name, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT_HOST), - ptr_option->value, + (char *)ptr_option->value, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); number_found++; } @@ -2009,7 +1995,7 @@ command_upgrade (struct t_gui_buffer *buffer, /* unload plugins, save config, then upgrade */ plugin_end (); - /*if (cfg_look_save_on_exit) + /*if (CONFIG_BOOLEAN(config_look_save_on_exit)) (void) config_write (NULL); gui_main_end (); fifo_remove (); diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 5a0cc431e..a29e3ba97 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* wee-config-file.c: I/O functions to read/write options in a config file */ +/* wee-config-file.c: manages options in config files */ #ifdef HAVE_CONFIG_H @@ -25,64 +25,486 @@ #include <stdlib.h> #include <unistd.h> -#include <errno.h> -#include <stdio.h> #include <string.h> -#include <limits.h> -#include <time.h> -#include <pwd.h> -#include <sys/types.h> #include <sys/stat.h> #include "weechat.h" #include "wee-config-file.h" -#include "wee-config-option.h" #include "wee-log.h" #include "wee-string.h" -#include "wee-utf8.h" -#include "../gui/gui-chat.h" #include "../gui/gui-color.h" +#include "../gui/gui-chat.h" + + +struct t_config_file *config_files = NULL; +struct t_config_file *last_config_file = NULL; /* - * config_file_read_option: read an option for a section in config file - * This function is called when a new section begins - * or for an option of a section - * if options == NULL, then option is out of section - * if option_name == NULL, it's beginning of section - * otherwise it's an option for a section - * Return: 0 = successful - * -1 = option not found - * -2 = bad format/value + * config_file_new: create new config options structure */ -int -config_file_read_option (struct t_config_option *options, - char *option_name, char *value) +struct t_config_file * +config_file_new (char *filename) { - struct t_config_option *ptr_option; + struct t_config_file *new_config_file; + + if (!filename) + return NULL; - if (option_name) + new_config_file = (struct t_config_file *)malloc (sizeof (struct t_config_file)); + if (new_config_file) { - /* no option allowed outside a section by default */ - if (!options) - return -1; + new_config_file->filename = strdup (filename); + new_config_file->file = NULL; + new_config_file->sections = NULL; + new_config_file->last_section = NULL; - /* search option in list of options for section */ - ptr_option = config_option_search (options, option_name); - if (!ptr_option) - return -1; + new_config_file->prev_config = last_config_file; + new_config_file->next_config = NULL; + if (config_files) + last_config_file->next_config = new_config_file; + else + config_files = new_config_file; + last_config_file = new_config_file; + } + + return new_config_file; +} + +/* + * config_file_new_section: create a new section in a config + */ + +struct t_config_section * +config_file_new_section (struct t_config_file *config_file, char *name, + void (*callback_read)(struct t_config_file *, char *, char *), + void (*callback_write)(struct t_config_file *), + void (*callback_write_default)(struct t_config_file *)) +{ + struct t_config_section *new_section; + + if (!config_file || !name) + return NULL; + + new_section = (struct t_config_section *)malloc (sizeof (struct t_config_section)); + if (new_section) + { + new_section->name = strdup (name); + new_section->callback_read = callback_read; + new_section->callback_write = callback_write; + new_section->callback_write_default = callback_write_default; + new_section->options = NULL; + new_section->last_option = NULL; + + new_section->prev_section = config_file->last_section; + new_section->next_section = NULL; + if (config_file->sections) + config_file->last_section->next_section = new_section; + else + config_file->sections = new_section; + config_file->last_section = new_section; + } + + return new_section; +} + +/* + * config_file_search_section: search a section in a config structure + */ + +struct t_config_section * +config_file_search_section (struct t_config_file *config_file, + char *section_name) +{ + struct t_config_section *ptr_section; + + for (ptr_section = config_file->sections; ptr_section; + ptr_section = ptr_section->next_section) + { + if (string_strcasecmp (ptr_section->name, section_name) == 0) + return ptr_section; + } + + /* section not found */ + return NULL; +} + +/* + * config_file_new_option_boolean: create a new option, type "boolean" + * in a config section + */ + +struct t_config_option * +config_file_new_option_boolean (struct t_config_section *section, char *name, + char *description, int default_value, + void (*callback_change)()) +{ + struct t_config_option *new_option; + + if (!section || !name) + return NULL; + + new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); + if (new_option) + { + new_option->name = strdup (name); + new_option->type = CONFIG_OPTION_BOOLEAN; + new_option->description = (description) ? strdup (description) : NULL; + new_option->string_values = NULL; + new_option->min = CONFIG_BOOLEAN_FALSE; + new_option->max = CONFIG_BOOLEAN_TRUE; + default_value = (default_value) ? + CONFIG_BOOLEAN_TRUE : CONFIG_BOOLEAN_FALSE; + new_option->default_value = malloc (sizeof (char)); + *((char *)new_option->default_value) = default_value; + new_option->value = malloc (sizeof (char)); + *((char *)new_option->value) = default_value; + new_option->callback_change = callback_change; - /* set value for option found */ - if (config_option_set (ptr_option, value) < 0) - return -2; + new_option->prev_option = section->last_option; + new_option->next_option = NULL; + if (section->options) + section->last_option->next_option = new_option; + else + section->options = new_option; + section->last_option = new_option; } - else + + return new_option; +} + +/* + * config_file_new_option_integer: create a new option, type "integer" + * in a config section + */ + +struct t_config_option * +config_file_new_option_integer (struct t_config_section *section, char *name, + char *description, int min, int max, + int default_value, void (*callback_change)()) +{ + struct t_config_option *new_option; + + if (!section || !name) + return NULL; + + new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); + if (new_option) { - /* by default, does nothing for a new section */ + new_option->name = strdup (name); + new_option->type = CONFIG_OPTION_INTEGER; + new_option->description = (description) ? strdup (description) : NULL; + new_option->string_values = NULL; + new_option->min = min; + new_option->max = max; + new_option->default_value = malloc (sizeof (int)); + *((int *)new_option->default_value) = default_value; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = default_value; + new_option->callback_change = callback_change; + + new_option->prev_option = section->last_option; + new_option->next_option = NULL; + if (section->options) + section->last_option->next_option = new_option; + else + section->options = new_option; + section->last_option = new_option; + } + + return new_option; +} + +/* + * config_file_new_option_integer_with_string: create a new option, type "integer" + * (with string) in a config section + */ + +struct t_config_option * +config_file_new_option_integer_with_string (struct t_config_section *section, + char *name, char *description, + char *string_values, + int default_value, + void (*callback_change)()) +{ + struct t_config_option *new_option; + int argc; + + if (!section || !name || !string_values) + return NULL; + + new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); + if (new_option) + { + new_option->name = strdup (name); + new_option->type = CONFIG_OPTION_INTEGER; + new_option->description = (description) ? strdup (description) : NULL; + new_option->string_values = string_explode (string_values, "|", 0, 0, + &argc); + new_option->min = 0; + new_option->max = (argc == 0) ? 0 : argc - 1; + new_option->default_value = malloc (sizeof (int)); + *((int *)new_option->default_value) = default_value; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = default_value; + new_option->callback_change = callback_change; + + new_option->prev_option = section->last_option; + new_option->next_option = NULL; + if (section->options) + section->last_option->next_option = new_option; + else + section->options = new_option; + section->last_option = new_option; + } + + return new_option; +} + +/* + * config_file_new_option_string: create a new option, type "string" + * in a config section + */ + +struct t_config_option * +config_file_new_option_string (struct t_config_section *section, + char *name, char *description, + int min_length, int max_length, + char *default_value, void (*callback_change)()) +{ + struct t_config_option *new_option; + + if (!section || !name) + return NULL; + + new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); + if (new_option) + { + new_option->name = strdup (name); + new_option->type = CONFIG_OPTION_STRING; + new_option->description = (description) ? strdup (description) : NULL; + new_option->string_values = NULL; + new_option->min = min_length; + new_option->max = max_length; + new_option->default_value = (default_value) ? + strdup (default_value) : NULL; + new_option->value = strdup (default_value) ? + strdup (default_value) : NULL; + new_option->callback_change = callback_change; + + new_option->prev_option = section->last_option; + new_option->next_option = NULL; + if (section->options) + section->last_option->next_option = new_option; + else + section->options = new_option; + section->last_option = new_option; + } + + return new_option; +} + +/* + * config_file_new_option_color: create a new option, type "color" + * in a config section + */ + +struct t_config_option * +config_file_new_option_color (struct t_config_section *section, + char *name, char *description, int color_index, + char *default_value, void (*callback_change)()) +{ + struct t_config_option *new_option; + + if (!section || !name || !default_value) + return NULL; + + new_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); + if (new_option) + { + new_option->name = strdup (name); + new_option->type = CONFIG_OPTION_COLOR; + new_option->description = (description) ? strdup (description) : NULL; + new_option->string_values = NULL; + new_option->min = color_index; + new_option->max = color_index; + new_option->default_value = malloc (sizeof (int)); + if (!gui_color_assign (new_option->default_value, default_value)) + new_option->default_value = 0; + new_option->value = malloc (sizeof (int)); + *((int *)new_option->value) = *((int *)new_option->default_value); + new_option->callback_change = callback_change; + + new_option->prev_option = section->last_option; + new_option->next_option = NULL; + if (section->options) + section->last_option->next_option = new_option; + else + section->options = new_option; + section->last_option = new_option; + } + + return new_option; +} + +/* + * config_file_search_option: search an option in a config or section + */ + +struct t_config_option * +config_file_search_option (struct t_config_file *config_file, + struct t_config_section *section, + char *option_name) +{ + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + + if (section) + { + for (ptr_option = section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + if (string_strcasecmp (ptr_option->name, option_name) == 0) + return ptr_option; + } + } + else if (config_file) + { + for (ptr_section = config_file->sections; ptr_section; + ptr_section = ptr_section->next_section) + { + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + if (string_strcasecmp (ptr_option->name, option_name) == 0) + return ptr_option; + } + } + } + + /* option not found */ + return NULL; +} + +/* + * config_file_string_boolean_value: return boolean value of string + * return -1 if error + */ + +int +config_file_string_boolean_value (char *text) +{ + if ((string_strcasecmp (text, "on") == 0) + || (string_strcasecmp (text, "yes") == 0) + || (string_strcasecmp (text, "y") == 0) + || (string_strcasecmp (text, "true") == 0) + || (string_strcasecmp (text, "t") == 0) + || (string_strcasecmp (text, "1") == 0)) + return CONFIG_BOOLEAN_TRUE; + + if ((string_strcasecmp (text, "off") == 0) + || (string_strcasecmp (text, "no") == 0) + || (string_strcasecmp (text, "n") == 0) + || (string_strcasecmp (text, "false") == 0) + || (string_strcasecmp (text, "f") == 0) + || (string_strcasecmp (text, "0") == 0)) + return CONFIG_BOOLEAN_FALSE; + + /* invalid text */ + return -1; +} + +/* + * config_file_option_set: set value for an option + * return: 2 if ok (value changed) + * 1 if ok (value is the same) + * 0 if failed + */ + +int +config_file_option_set (struct t_config_option *option, char *new_value) +{ + int new_value_int, i, rc; + long number; + char *error; + + if (!option) + return 0; + + switch (option->type) + { + case CONFIG_OPTION_BOOLEAN: + if (!new_value) + return 0; + new_value_int = config_file_string_boolean_value (new_value); + if (new_value_int < 0) + return 0; + if (new_value_int == *((char *)option->value)) + return 1; + *((char *)option->value) = new_value_int; + return 2; + case CONFIG_OPTION_INTEGER: + if (!new_value) + return 0; + if (option->string_values) + { + new_value_int = -1; + for (i = 0; option->string_values[i]; i++) + { + if (string_strcasecmp (option->string_values[i], + new_value) == 0) + { + new_value_int = i; + break; + } + } + if (new_value_int < 0) + return 0; + if (new_value_int == *((int *)option->value)) + return 1; + *((int *)option->value) = new_value_int; + return 2; + } + else + { + error = NULL; + number = strtol (new_value, &error, 10); + if (error && (error[0] == '\0')) + { + if (number == *((int *)option->value)) + return 1; + *((int *)option->value) = number; + return 2; + } + } + break; + case CONFIG_OPTION_STRING: + rc = 1; + if ((!option->value && new_value) + || (option->value && !new_value) + || (strcmp ((char *)option->value, new_value) != 0)) + rc = 2; + if (option->value) + free (option->value); + if (new_value) + { + option->value = strdup (new_value); + if (!option->value) + return 0; + } + else + option->value = NULL; + return rc; + case CONFIG_OPTION_COLOR: + if (!gui_color_assign (&new_value_int, new_value)) + return 0; + if (new_value_int == *((int *)option->value)) + return 1; + *((int *)option->value) = new_value_int; + return 2; } - /* all ok */ return 0; } @@ -94,36 +516,27 @@ config_file_read_option (struct t_config_option *options, */ int -config_file_read (char **config_sections, struct t_config_option **options, - t_config_func_read_option **read_functions, - t_config_func_read_option *read_function_default, - t_config_func_write_options **write_default_functions, - char *config_filename) +config_file_read (struct t_config_file *config_file) { - int filename_length; + int filename_length, line_number, rc; char *filename; - FILE *file; - int section, line_number, rc; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; char line[1024], *ptr_line, *ptr_line2, *pos, *pos2; - filename_length = strlen (weechat_home) + strlen (config_filename) + 2; + if (!config_file) + return -1; + + filename_length = strlen (weechat_home) + strlen (config_file->filename) + 2; filename = (char *) malloc (filename_length * sizeof (char)); if (!filename) return -2; snprintf (filename, filename_length, "%s%s%s", - weechat_home, DIR_SEPARATOR, config_filename); - if ((file = fopen (filename, "r")) == NULL) + weechat_home, DIR_SEPARATOR, config_file->filename); + if ((config_file->file = fopen (filename, "r")) == NULL) { - /* if no default write functions provided and that config file - is not here, then return without doing anything */ - if (!write_default_functions) - return 0; - - /* create default config, then go on with reading */ - config_file_write_default (config_sections, options, - write_default_functions, - config_filename); - if ((file = fopen (filename, "r")) == NULL) + config_file_write (config_file, 1); + if ((config_file->file = fopen (filename, "r")) == NULL) { gui_chat_printf (NULL, _("Warning: config file \"%s\" not found.\n"), @@ -133,13 +546,11 @@ config_file_read (char **config_sections, struct t_config_option **options, } } - config_option_section_option_set_default_values (config_sections, options); - - section = -1; + ptr_section = NULL; line_number = 0; - while (!feof (file)) + while (!feof (config_file->file)) { - ptr_line = fgets (line, sizeof (line) - 1, file); + ptr_line = fgets (line, sizeof (line) - 1, config_file->file); line_number++; if (ptr_line) { @@ -164,29 +575,21 @@ config_file_read (char **config_sections, struct t_config_option **options, pos = strchr (line, ']'); if (pos == NULL) gui_chat_printf (NULL, - _("Warning: %s, line %d: invalid syntax, " - "missing \"]\"\n"), + _("Warning: %s, line %d: invalid " + "syntax, missing \"]\"\n"), filename, line_number); else { pos[0] = '\0'; pos = ptr_line + 1; - section = config_option_section_get_index (config_sections, pos); - if (section < 0) + ptr_section = config_file_search_section (config_file, + pos); + if (!ptr_section) gui_chat_printf (NULL, - _("Warning: %s, line %d: unknown section " - "identifier (\"%s\")\n"), + _("Warning: %s, line %d: unknown " + "section identifier " + "(\"%s\")\n"), filename, line_number, pos); - else - { - rc = ((int) (read_functions[section]) (options[section], - NULL, NULL)); - if (rc < 0) - gui_chat_printf (NULL, - _("Warning: %s, line %d: error " - "reading new section \"%s\"\n"), - filename, line_number, pos); - } } } else @@ -194,8 +597,8 @@ config_file_read (char **config_sections, struct t_config_option **options, pos = strchr (line, '='); if (pos == NULL) gui_chat_printf (NULL, - _("Warning: %s, line %d: invalid syntax, " - "missing \"=\"\n"), + _("Warning: %s, line %d: invalid " + "syntax, missing \"=\"\n"), filename, line_number); else { @@ -245,37 +648,54 @@ config_file_read (char **config_sections, struct t_config_option **options, } } - if (section < 0) - rc = ((int) (read_function_default) (NULL, line, pos)); + ptr_option = config_file_search_option (config_file, + ptr_section, + line); + if (ptr_option) + rc = config_file_option_set (ptr_option, pos); else - rc = ((int) (read_functions[section]) (options[section], - line, pos)); - if (rc < 0) { - switch (rc) + /* option not found: use read callback */ + if (ptr_section && ptr_section->callback_read) { - case -1: - if (section < 0) - gui_chat_printf (NULL, - _("Warning: %s, line %d: unknown " - "option \"%s\" " - "(outside a section)\n"), - filename, line_number, line); - else - gui_chat_printf (NULL, - _("Warning: %s, line %d: option " - "\"%s\" unknown for " - "section \"%s\"\n"), - filename, line_number, line, - config_sections[section]); - break; - case -2: - gui_chat_printf (NULL, - _("Warning: %s, line %d: invalid " - "value for option \"%s\"\n"), - filename, line_number, line); - break; + (void) (ptr_section->callback_read) (config_file, + line, pos); + rc = 1; } + else + rc = -1; + } + + switch (rc) + { + case -1: + if (ptr_section) + gui_chat_printf (NULL, + _("Warning: %s, line %d: " + "option \"%s\" " + "unknown for " + "section \"%s\"\n"), + filename, line_number, + line, ptr_section->name); + else + gui_chat_printf (NULL, + _("Warning: %s, line %d: " + "unknown option \"%s\" " + "(outside a section)\n"), + filename, line_number, + line); + break; + case 0: + gui_chat_printf (NULL, + _("Warning: %s, line %d: " + "invalid value for option " + "\"%s\"\n"), + filename, line_number, line); + break; + case 2: + if (ptr_option && ptr_option->callback_change) + (void) (ptr_option->callback_change) (); + break; } } } @@ -283,218 +703,99 @@ config_file_read (char **config_sections, struct t_config_option **options, } } - fclose (file); + fclose (config_file->file); + config_file->file = NULL; free (filename); return 0; } /* - * config_file_write_options: write a section with options in a config file - * This function is called when config is saved, - * for a section with standard options - * Return: 0 = successful - * -1 = write error + * config_file_write_option: write an option in a config file */ -int -config_file_write_options (FILE *file, char *section_name, - struct t_config_option *options) +void +config_file_write_option (struct t_config_file *config_file, + struct t_config_option *option, + int default_value) { - int i; - - string_iconv_fprintf (file, "\n[%s]\n", section_name); + void *value; - for (i = 0; options[i].name; i++) - { - switch (options[i].type) - { - case OPTION_TYPE_BOOLEAN: - string_iconv_fprintf (file, "%s = %s\n", - options[i].name, - (options[i].ptr_int && - *options[i].ptr_int) ? - "on" : "off"); - break; - case OPTION_TYPE_INT: - string_iconv_fprintf (file, "%s = %d\n", - options[i].name, - (options[i].ptr_int) ? - *options[i].ptr_int : - options[i].default_int); - break; - case OPTION_TYPE_INT_WITH_STRING: - string_iconv_fprintf (file, "%s = %s\n", - options[i].name, - (options[i].ptr_int) ? - options[i].array_values[*options[i].ptr_int] : - options[i].array_values[options[i].default_int]); - break; - case OPTION_TYPE_COLOR: - string_iconv_fprintf (file, "%s = %s\n", - options[i].name, - (options[i].ptr_int) ? - gui_color_get_name (*options[i].ptr_int) : - options[i].default_string); - break; - case OPTION_TYPE_STRING: - string_iconv_fprintf (file, "%s = \"%s\"\n", - options[i].name, - (options[i].ptr_string) ? - *options[i].ptr_string : - options[i].default_string); - break; - } - } - - /* all ok */ - return 0; -} - -/* - * config_file_write_options_default_values: write a section with options in a config file - * This function is called when new config file - * is created, with default values, for a - * section with standard options - * Return: 0 = successful - * -1 = write error - */ - -int -config_file_write_options_default_values (FILE *file, char *section_name, - struct t_config_option *options) -{ - int i; + if (!config_file || !config_file->file || !option) + return; - string_iconv_fprintf (file, "\n[%s]\n", section_name); + value = (default_value) ? option->default_value : option->value; - for (i = 0; options[i].name; i++) + switch (option->type) { - switch (options[i].type) - { - case OPTION_TYPE_BOOLEAN: - string_iconv_fprintf (file, "%s = %s\n", - options[i].name, - (options[i].default_int) ? - "on" : "off"); - break; - case OPTION_TYPE_INT: - string_iconv_fprintf (file, "%s = %d\n", - options[i].name, - options[i].default_int); - break; - case OPTION_TYPE_INT_WITH_STRING: - case OPTION_TYPE_COLOR: - string_iconv_fprintf (file, "%s = %s\n", - options[i].name, - options[i].default_string); - break; - case OPTION_TYPE_STRING: - string_iconv_fprintf (file, "%s = \"%s\"\n", - options[i].name, - options[i].default_string); - break; - } + case CONFIG_OPTION_BOOLEAN: + string_iconv_fprintf (config_file->file, "%s = %s\n", + option->name, + (*((int *)value)) == CONFIG_BOOLEAN_TRUE ? + "on" : "off"); + break; + case CONFIG_OPTION_INTEGER: + if (option->string_values) + string_iconv_fprintf (config_file->file, "%s = %s\n", + option->name, + option->string_values[*((int *)value)]); + else + string_iconv_fprintf (config_file->file, "%s = %d\n", + option->name, + *((int *)value)); + break; + case CONFIG_OPTION_STRING: + string_iconv_fprintf (config_file->file, "%s = \"%s\"\n", + option->name, + (char *)value); + break; + case CONFIG_OPTION_COLOR: + string_iconv_fprintf (config_file->file, "%s = %s\n", + option->name, + gui_color_get_name (*((int *)value))); + break; } - - /* all ok */ - return 0; } /* - * config_file_write_header: write header in a config file + * config_file_write_line: write a line in a config file */ void -config_file_write_header (FILE *file) +config_file_write_line (struct t_config_file *config_file, + char *option_name, char *value) { - time_t current_time; - - current_time = time (NULL); - string_iconv_fprintf (file, _("#\n# %s configuration file, created by " - "%s v%s on %s"), - PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION, - ctime (¤t_time)); - string_iconv_fprintf (file, _("# WARNING! Be careful when editing this file, " - "WeeChat may write it at any time.\n#\n")); + string_iconv_fprintf (config_file->file, "%s = %s\n", + option_name, value); } /* - * config_file_write_default: create a default configuration file - * return: 0 if ok - * < 0 if error - */ - -int -config_file_write_default (char **config_sections, struct t_config_option **options, - t_config_func_write_options **write_functions, - char *config_filename) -{ - int filename_length, i, rc; - char *filename; - FILE *file; - - filename_length = strlen (weechat_home) + - strlen (config_filename) + 2; - filename = - (char *) malloc (filename_length * sizeof (char)); - if (!filename) - return -2; - snprintf (filename, filename_length, "%s%s%s", - weechat_home, DIR_SEPARATOR, config_filename); - if ((file = fopen (filename, "w")) == NULL) - { - gui_chat_printf (NULL, - _("Error: cannot create file \"%s\"\n"), - filename); - free (filename); - return -1; - } - - string_iconv_fprintf (stdout, - _("%s: creating default config file \"%s\"...\n"), - PACKAGE_NAME, - config_filename); - log_printf (_("Creating default config file \"%s\"\n"), - config_filename); - - config_file_write_header (file); - - for (i = 0; config_sections[i]; i++) - { - rc = ((int) (write_functions[i]) (file, config_sections[i], - options[i])); - } - - fclose (file); - chmod (filename, 0600); - free (filename); - return 0; -} - -/* - * config_file_write: write a configurtion file + * config_file_write: write a configuration file * return: 0 if ok - * < 0 if error + * -1 if error writing file + * -2 if not enough memory */ int -config_file_write (char **config_sections, struct t_config_option **options, - t_config_func_write_options **write_functions, - char *config_filename) +config_file_write (struct t_config_file *config_file, int default_options) { - int filename_length, i, rc; + int filename_length, rc; char *filename, *filename2; - FILE *file; + time_t current_time; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + + if (!config_file) + return -1; filename_length = strlen (weechat_home) + - strlen (config_filename) + 2; + strlen (config_file->filename) + 2; filename = (char *) malloc (filename_length * sizeof (char)); if (!filename) return -2; snprintf (filename, filename_length, "%s%s%s", - weechat_home, DIR_SEPARATOR, config_filename); + weechat_home, DIR_SEPARATOR, config_file->filename); filename2 = (char *) malloc ((filename_length + 32) * sizeof (char)); if (!filename2) @@ -504,7 +805,7 @@ config_file_write (char **config_sections, struct t_config_option **options, } snprintf (filename2, filename_length + 32, "%s.weechattmp", filename); - if ((file = fopen (filename2, "w")) == NULL) + if ((config_file->file = fopen (filename2, "w")) == NULL) { gui_chat_printf (NULL, _("Error: cannot create file \"%s\"\n"), @@ -514,15 +815,46 @@ config_file_write (char **config_sections, struct t_config_option **options, return -1; } - config_file_write_header (file); - - for (i = 0; config_sections[i]; i++) + current_time = time (NULL); + string_iconv_fprintf (config_file->file, + _("#\n# %s configuration file, created by " + "%s v%s on %s"), + PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION, + ctime (¤t_time)); + string_iconv_fprintf (config_file->file, + _("# WARNING! Be careful when editing this file, " + "WeeChat may write it at any time.\n#\n")); + + for (ptr_section = config_file->sections; ptr_section; + ptr_section = ptr_section->next_section) { - rc = ((int) (write_functions[i]) (file, config_sections[i], - options[i])); + /* write section name in file */ + string_iconv_fprintf (config_file->file, + "\n[%s]\n", ptr_section->name); + + /* call write callback if defined for section */ + if (default_options) + { + if (ptr_section->callback_write_default) + (void) (ptr_section->callback_write_default) (config_file); + } + else + { + if (ptr_section->callback_write) + (void) (ptr_section->callback_write) (config_file); + } + + /* write all options for section */ + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + config_file_write_option (config_file, ptr_option, + default_options); + } } - fclose (file); + fclose (config_file->file); + config_file->file = NULL; chmod (filename2, 0600); unlink (filename); rc = rename (filename2, filename); @@ -532,3 +864,185 @@ config_file_write (char **config_sections, struct t_config_option **options, return -1; return 0; } + +/* + * config_file_print_stdout: print options on standard output + */ + +void +config_file_print_stdout (struct t_config_file *config_file) +{ + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + char *color_name; + int i; + + for (ptr_section = config_file->sections; ptr_section; + ptr_section = ptr_section->next_section) + { + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + string_iconv_fprintf (stdout, + "* %s:\n", + ptr_option->name); + switch (ptr_option->type) + { + case CONFIG_OPTION_BOOLEAN: + string_iconv_fprintf (stdout, _(" . type: boolean\n")); + string_iconv_fprintf (stdout, _(" . values: 'on' or 'off'\n")); + string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), + (CONFIG_BOOLEAN_DEFAULT(ptr_option) == CONFIG_BOOLEAN_TRUE) ? + "on" : "off"); + break; + case CONFIG_OPTION_INTEGER: + if (ptr_option->string_values) + { + string_iconv_fprintf (stdout, _(" . type: string\n")); + string_iconv_fprintf (stdout, _(" . values: ")); + i = 0; + while (ptr_option->string_values[i]) + { + string_iconv_fprintf (stdout, "'%s'", + ptr_option->string_values[i]); + if (ptr_option->string_values[i + 1]) + string_iconv_fprintf (stdout, ", "); + i++; + } + string_iconv_fprintf (stdout, "\n"); + string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), + ptr_option->string_values[CONFIG_INTEGER_DEFAULT(ptr_option)]); + } + else + { + string_iconv_fprintf (stdout, _(" . type: integer\n")); + string_iconv_fprintf (stdout, _(" . values: between %d and %d\n"), + ptr_option->min, + ptr_option->max); + string_iconv_fprintf (stdout, _(" . default value: %d\n"), + CONFIG_INTEGER_DEFAULT(ptr_option)); + } + break; + case CONFIG_OPTION_STRING: + switch (ptr_option->max) + { + case 0: + string_iconv_fprintf (stdout, _(" . type: string\n")); + string_iconv_fprintf (stdout, _(" . values: any string\n")); + break; + case 1: + string_iconv_fprintf (stdout, _(" . type: char\n")); + string_iconv_fprintf (stdout, _(" . values: any char\n")); + break; + default: + string_iconv_fprintf (stdout, _(" . type: string\n")); + string_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"), + ptr_option->max); + break; + } + string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), + CONFIG_STRING_DEFAULT(ptr_option)); + break; + case CONFIG_OPTION_COLOR: + color_name = gui_color_get_name (CONFIG_COLOR_DEFAULT(ptr_option)); + string_iconv_fprintf (stdout, _(" . type: color\n")); + string_iconv_fprintf (stdout, _(" . values: color (depends on GUI used)\n")); + string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), + color_name); + break; + } + string_iconv_fprintf (stdout, _(" . description: %s\n"), + _(ptr_option->description)); + string_iconv_fprintf (stdout, "\n"); + } + } +} + +/* + * config_file_print_log: print config in log (usually for crash dump) + */ + +void +config_file_print_log () +{ + struct t_config_file *ptr_config_file; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + + for (ptr_config_file = config_files; ptr_config_file; + ptr_config_file = ptr_config_file->next_config) + { + log_printf ("\n"); + log_printf ("[config (addr:0x%X)]\n", ptr_config_file); + log_printf (" filename . . . . . . . : '%s'\n", ptr_config_file->filename); + log_printf (" sections . . . . . . . : 0x%X\n", ptr_config_file->sections); + log_printf (" last_section . . . . . : 0x%X\n", ptr_config_file->last_section); + log_printf (" prev_config. . . . . . : 0x%X\n", ptr_config_file->prev_config); + log_printf (" next_config. . . . . . : 0x%X\n", ptr_config_file->next_config); + + for (ptr_section = ptr_config_file->sections; ptr_section; + ptr_section = ptr_section->next_section) + { + log_printf ("\n"); + log_printf (" [section (addr:0x%X)]\n", ptr_section); + log_printf (" name . . . . . . . . . : '%s'\n", ptr_section->name); + log_printf (" callback_read. . . . . : 0x%X\n", ptr_section->callback_read); + log_printf (" callback_write . . . . : 0x%X\n", ptr_section->callback_write); + log_printf (" options. . . . . . . . : 0x%X\n", ptr_section->options); + log_printf (" last_option. . . . . . : 0x%X\n", ptr_section->last_option); + log_printf (" prev_item. . . . . . . : 0x%X\n", ptr_section->prev_section); + log_printf (" next_item. . . . . . . : 0x%X\n", ptr_section->next_section); + + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + log_printf ("\n"); + log_printf (" [option (addr:0x%X)]\n", ptr_option); + log_printf (" name . . . . . . . . : '%s'\n", ptr_option->name); + log_printf (" type . . . . . . . . : %d\n", ptr_option->type); + log_printf (" string_values. . . . : 0x%X\n", ptr_option->string_values); + log_printf (" min. . . . . . . . . : %d\n", ptr_option->min); + log_printf (" max. . . . . . . . . : %d\n", ptr_option->max); + switch (ptr_option->type) + { + case CONFIG_OPTION_BOOLEAN: + log_printf (" value (boolean). . . : %s\n", + (*((int *)ptr_option->value) == CONFIG_BOOLEAN_TRUE) ? + "true" : "false"); + log_printf (" default value. . . . : %s\n", + (*((int *)ptr_option->default_value) == CONFIG_BOOLEAN_TRUE) ? + "true" : "false"); + break; + case CONFIG_OPTION_INTEGER: + if (ptr_option->string_values) + { + log_printf (" value (integer/str). : '%s'\n", + ptr_option->string_values[*((int *)ptr_option->value)]); + log_printf (" default value. . . . : '%s'\n", + ptr_option->string_values[*((int *)ptr_option->default_value)]); + } + else + { + log_printf (" value (integer). . . : %d\n", *((int *)ptr_option->value)); + log_printf (" default value. . . . : %d\n", *((int *)ptr_option->default_value)); + } + break; + case CONFIG_OPTION_STRING: + log_printf (" value (string) . . . : '%s'\n", (char *)ptr_option->value); + log_printf (" default value. . . . : '%s'\n", (char *)ptr_option->default_value); + break; + case CONFIG_OPTION_COLOR: + log_printf (" value (color). . . . : %d ('%s')\n", + *((int *)ptr_option->value), + gui_color_get_name (*((int *)ptr_option->value))); + log_printf (" default value. . . . : %d ('%s')\n", + *((int *)ptr_option->default_value), + gui_color_get_name (*((int *)ptr_option->default_value))); + break; + } + log_printf (" prev_option. . . . . : 0x%X\n", ptr_option->prev_option); + log_printf (" next_option. . . . . : 0x%X\n", ptr_option->next_option); + } + } + } +} diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index cde80def3..d7876b6d7 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -20,24 +20,108 @@ #ifndef __WEECHAT_CONFIG_FILE_H #define __WEECHAT_CONFIG_FILE_H 1 -#include "wee-config-option.h" - -typedef int (t_config_func_read_option) (struct t_config_option *, char *, char *); -typedef int (t_config_func_write_options) (FILE *, char *, struct t_config_option *); - -extern int config_file_read_option (struct t_config_option *, char *, char *); -extern int config_file_read (char **, struct t_config_option **, - t_config_func_read_option **, - t_config_func_read_option *, - t_config_func_write_options **, - char *); - -extern int config_file_write_options (FILE *, char *, struct t_config_option *); -extern int config_file_write_options_default_values (FILE *, char *, - struct t_config_option *); -extern int config_file_write_default (char **, struct t_config_option **, - t_config_func_write_options **, char *); -extern int config_file_write (char **, struct t_config_option **, - t_config_func_write_options **, char *); +#define CONFIG_BOOLEAN(option) (*((char *)((option)->value))) +#define CONFIG_BOOLEAN_DEFAULT(option) (*((char *)((option)->default_value))) + +#define CONFIG_INTEGER(option) (*((int *)((option)->value))) +#define CONFIG_INTEGER_DEFAULT(option) (*((int *)((option)->default_value))) + +#define CONFIG_STRING(option) ((char *)((option)->value)) +#define CONFIG_STRING_DEFAULT(option) ((char *)((option)->default_value)) + +#define CONFIG_COLOR(option) (*((int *)((option)->value))) +#define CONFIG_COLOR_DEFAULT(option) (*((int *)((option)->default_value))) + +#define CONFIG_BOOLEAN_FALSE 0 +#define CONFIG_BOOLEAN_TRUE 1 + +struct t_config_file +{ + char *filename; /* config filename (without path)*/ + FILE *file; /* file pointer */ + struct t_config_section *sections; /* config sections */ + struct t_config_section *last_section; /* last config section */ + struct t_config_file *prev_config; /* link to previous config file */ + struct t_config_file *next_config; /* link to next config file */ +}; + +struct t_config_section +{ + char *name; /* section name */ + void (*callback_read) /* called when unknown option */ + (struct t_config_file *, /* is read from config file */ + char *, char *); + void (*callback_write) /* called to write special */ + (struct t_config_file *); /* options in config file */ + void (*callback_write_default) /* called to write default */ + (struct t_config_file *); /* options in config file */ + struct t_config_option *options; /* options in section */ + struct t_config_option *last_option; /* last option in section */ + struct t_config_section *prev_section; /* link to previous section */ + struct t_config_section *next_section; /* link to next section */ +}; + +enum t_config_option_type +{ + CONFIG_OPTION_BOOLEAN = 0, + CONFIG_OPTION_INTEGER, + CONFIG_OPTION_STRING, + CONFIG_OPTION_COLOR, +}; + +struct t_config_option +{ + char *name; /* name */ + enum t_config_option_type type; /* type */ + char *description; /* description */ + char **string_values; /* allowed string values */ + int min, max; /* min and max for value */ + void *default_value; /* default value */ + void *value; /* value */ + void (*callback_change)(); /* called when value is changed */ + struct t_config_option *prev_option; /* link to previous option */ + struct t_config_option *next_option; /* link to next option */ +}; + +extern struct t_config_file *config_file_new (char *); +extern struct t_config_section *config_file_new_section (struct t_config_file *, + char *, + void (*)(struct t_config_file *, char *, char *), + void (*)(struct t_config_file *), + void (*)(struct t_config_file *)); +extern struct t_config_section *config_file_search_section (struct t_config_file *, + char *); +extern struct t_config_option *config_file_new_option_boolean (struct t_config_section *, + char *, char *, + int, + void (*)()); +extern struct t_config_option *config_file_new_option_integer (struct t_config_section *, + char *, char *, + int, int, int, + void (*)()); +extern struct t_config_option *config_file_new_option_integer_with_string (struct t_config_section *, + char *, + char *, + char *, + int, + void (*)()); +extern struct t_config_option *config_file_new_option_string (struct t_config_section *, + char *, char *, + int, int, + char *, void (*)()); +extern struct t_config_option *config_file_new_option_color (struct t_config_section *, + char *, char *, + int, char *, + void (*)()); +extern struct t_config_option *config_file_search_option (struct t_config_file *, + struct t_config_section *, + char *); +extern int config_file_option_set (struct t_config_option *, char *); + +extern int config_file_read (struct t_config_file *); +extern void config_file_write_line (struct t_config_file *, char *, char *); +extern int config_file_write (struct t_config_file *, int); +extern void config_file_print_stdout (struct t_config_file *); +extern void config_file_print_log (); #endif /* wee-config-file.h */ diff --git a/src/core/wee-config-option.c b/src/core/wee-config-option.c deleted file mode 100644 index 6b15b39d6..000000000 --- a/src/core/wee-config-option.c +++ /dev/null @@ -1,569 +0,0 @@ -/* - * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org> - * See README for License detail, AUTHORS for developers list. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* wee-config-option.c: manages WeeChat/protocols options */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <limits.h> -#include <time.h> -#include <pwd.h> -#include <sys/types.h> -#include <sys/stat.h> - -#include "weechat.h" -#include "wee-config-option.h" -#include "wee-hook.h" -#include "wee-string.h" -#include "wee-utf8.h" -#include "../gui/gui-chat.h" -#include "../gui/gui-color.h" - - -/* - * config_option_get_pos_array_values: return position of a string in an array of values - * return -1 if not found, otherwise position - */ - -int -config_option_get_pos_array_values (char **array, char *string) -{ - int i; - - i = 0; - while (array[i]) - { - if (string_strcasecmp (array[i], string) == 0) - return i; - i++; - } - - /* string not found in array */ - return -1; -} - -/* - * config_option_list_remove: remove an item from a list for an option - * (for options with value like: "abc:1,def:blabla") - */ - -void -config_option_list_remove (char **string, char *item) -{ - char *name, *pos, *pos2; - - if (!string || !(*string)) - return; - - name = (char *) malloc (strlen (item) + 2); - strcpy (name, item); - strcat (name, ":"); - pos = string_strcasestr (*string, name); - free (name); - if (pos) - { - pos2 = pos + strlen (item); - if (pos2[0] == ':') - { - pos2++; - if (pos2[0]) - { - while (pos2[0] && (pos2[0] != ',')) - pos2++; - if (pos2[0] == ',') - pos2++; - if (!pos2[0] && (pos != (*string))) - pos--; - strcpy (pos, pos2); - if (!(*string)[0]) - { - free (*string); - *string = NULL; - } - else - (*string) = (char *) realloc (*string, strlen (*string) + 1); - } - } - } -} - -/* - * config_option_list_set: set an item from a list for an option - * (for options with value like: "abc:1,def:blabla") - */ - -void -config_option_list_set (char **string, char *item, char *value) -{ - config_option_list_remove (string, item); - - if (!(*string)) - { - (*string) = (char *) malloc (strlen (item) + 1 + strlen (value) + 1); - (*string)[0] = '\0'; - } - else - (*string) = (char *) realloc (*string, - strlen (*string) + 1 + - strlen (item) + 1 + strlen (value) + 1); - - if ((*string)[0]) - strcat (*string, ","); - strcat (*string, item); - strcat (*string, ":"); - strcat (*string, value); -} - -/* - * config_option_list_get_value: return position of item value in the list - * (for options with value like: "abc:1,def:blabla") - */ - -void -config_option_list_get_value (char **string, char *item, - char **pos_found, int *length) -{ - char *name, *pos, *pos2, *pos_comma; - - *pos_found = NULL; - *length = 0; - - if (!string || !(*string)) - return; - - name = (char *) malloc (strlen (item) + 2); - strcpy (name, item); - strcat (name, ":"); - pos = string_strcasestr (*string, name); - free (name); - if (pos) - { - pos2 = pos + strlen (item); - if (pos2[0] == ':') - { - pos2++; - *pos_found = pos2; - pos_comma = strchr (pos2, ','); - if (pos_comma) - *length = pos_comma - pos2; - else - *length = strlen (pos2); - } - } -} - -/* - * config_option_option_get_boolean_value: get boolean value with user text - * return: BOOL_FALSE or BOOL_TRUE - */ - -int -config_option_option_get_boolean_value (char *text) -{ - if ((string_strcasecmp (text, "on") == 0) - || (string_strcasecmp (text, "yes") == 0) - || (string_strcasecmp (text, "y") == 0) - || (string_strcasecmp (text, "true") == 0) - || (string_strcasecmp (text, "t") == 0) - || (string_strcasecmp (text, "1") == 0)) - return BOOL_TRUE; - - if ((string_strcasecmp (text, "off") == 0) - || (string_strcasecmp (text, "no") == 0) - || (string_strcasecmp (text, "n") == 0) - || (string_strcasecmp (text, "false") == 0) - || (string_strcasecmp (text, "f") == 0) - || (string_strcasecmp (text, "0") == 0)) - return BOOL_FALSE; - - /* invalid text */ - return -1; -} - -/* - * config_option_set: set new value for an option - * return: 0 if success - * -1 if error (bad value) - */ - -int -config_option_set (struct t_config_option *option, char *value) -{ - int int_value; - - switch (option->type) - { - case OPTION_TYPE_BOOLEAN: - int_value = config_option_option_get_boolean_value (value); - switch (int_value) - { - case BOOL_TRUE: - *(option->ptr_int) = BOOL_TRUE; - break; - case BOOL_FALSE: - *(option->ptr_int) = BOOL_FALSE; - break; - default: - return -1; - } - break; - case OPTION_TYPE_INT: - int_value = atoi (value); - if ((int_value < option->min) || (int_value > option->max)) - return -1; - *(option->ptr_int) = int_value; - break; - case OPTION_TYPE_INT_WITH_STRING: - int_value = config_option_get_pos_array_values (option->array_values, - value); - if (int_value < 0) - return -1; - *(option->ptr_int) = int_value; - break; - case OPTION_TYPE_STRING: - if ((option->max > 0) && (utf8_strlen (value) > option->max)) - return -1; - if (*(option->ptr_string)) - free (*(option->ptr_string)); - *(option->ptr_string) = strdup (value); - break; - case OPTION_TYPE_COLOR: - if (!gui_color_assign (option->ptr_int, value)) - return -1; - break; - } - - hook_config_exec ("weechat", option->name, value); - - return 0; -} - -/* - * config_option_search: look for an option in a section and - * return pointer to this option - * If option is not found, NULL is returned - */ - -struct t_config_option * -config_option_search (struct t_config_option *config_options, char *option_name) -{ - int i; - - for (i = 0; config_options[i].name; i++) - { - /* if option found, return pointer */ - if (string_strcasecmp (config_options[i].name, option_name) == 0) - return &config_options[i]; - } - - /* option not found */ - return NULL; -} - -/* - * config_option_section_option_search: look for an option and return pointer to this option - * if option is not found, NULL is returned - */ - -struct t_config_option * -config_option_section_option_search (char **config_sections, - struct t_config_option **config_options, - char *option_name) -{ - int i; - struct t_config_option *ptr_option; - - for (i = 0; config_sections[i]; i++) - { - if (config_options[i]) - { - ptr_option = config_option_search (config_options[i], - option_name); - if (ptr_option) - return ptr_option; - } - } - - /* option not found */ - return NULL; -} - -/* - * config_option_section_option_search_get_value: look for type and value of an option - * if option is not found, NULL is returned - */ - -void -config_option_section_option_search_get_value (char **config_sections, - struct t_config_option **config_options, - char *option_name, - struct t_config_option **output_option, - void **output_option_value) -{ - struct t_config_option *ptr_option; - void *ptr_value; - - ptr_option = NULL; - ptr_value = NULL; - - ptr_option = config_option_section_option_search (config_sections, - config_options, - option_name); - if (ptr_option) - { - switch (ptr_option->type) - { - case OPTION_TYPE_BOOLEAN: - case OPTION_TYPE_INT: - case OPTION_TYPE_INT_WITH_STRING: - case OPTION_TYPE_COLOR: - ptr_value = (void *)(ptr_option->ptr_int); - break; - case OPTION_TYPE_STRING: - ptr_value = (void *)(ptr_option->ptr_string); - break; - } - if (ptr_option) - { - *output_option = ptr_option; - *output_option_value = ptr_value; - } - } -} - -/* - * config_option_section_option_set_value_by_name: set new value for an option (found by name) - * return: 0 if success - * -1 if bad value for option - * -2 if option is not found - */ - -int -config_option_section_option_set_value_by_name (char **config_sections, - struct t_config_option **config_options, - char *option_name, char *value) -{ - struct t_config_option *ptr_option; - - ptr_option = config_option_section_option_search (config_sections, - config_options, - option_name); - if (ptr_option) - return config_option_set (ptr_option, value); - else - return -2; -} - -/* - * config_option_section_get_index: get section index by name - * return -1 if section is not found - */ - -int -config_option_section_get_index (char **config_sections, char *section_name) -{ - int i; - - for (i = 0; config_sections[i]; i++) - { - if (string_strcasecmp (config_sections[i], section_name) == 0) - return i; - } - - /* option not found */ - return -1; -} - -/* - * config_option_section_get_name: get section name by option pointer - */ - -char * -config_option_section_get_name (char **config_sections, - struct t_config_option **config_options, - struct t_config_option *ptr_option) -{ - int i, j; - - for (i = 0; config_sections[i]; i++) - { - for (j = 0; config_options[i][j].name; j++) - { - /* if option found, return pointer to section name */ - if (ptr_option == &config_options[i][j]) - return config_sections[i]; - } - } - - /* option not found */ - return NULL; -} - -/* - * config_option_section_option_set_default_values: initialize config options - * with default values - */ - -void -config_option_section_option_set_default_values (char **config_sections, - struct t_config_option **config_options) -{ - int i, j, int_value; - - for (i = 0; config_sections[i]; i++) - { - if (config_options[i]) - { - for (j = 0; config_options[i][j].name; j++) - { - switch (config_options[i][j].type) - { - case OPTION_TYPE_BOOLEAN: - case OPTION_TYPE_INT: - *config_options[i][j].ptr_int = - config_options[i][j].default_int; - break; - case OPTION_TYPE_INT_WITH_STRING: - int_value = config_option_get_pos_array_values ( - config_options[i][j].array_values, - config_options[i][j].default_string); - if (int_value < 0) - gui_chat_printf (NULL, - _("Warning: unable to assign default int with " - "string (\"%s\")\n"), - config_options[i][j].default_string); - else - *config_options[i][j].ptr_int = int_value; - break; - case OPTION_TYPE_STRING: - *config_options[i][j].ptr_string = - strdup (config_options[i][j].default_string); - break; - case OPTION_TYPE_COLOR: - if (!gui_color_assign (config_options[i][j].ptr_int, - config_options[i][j].default_string)) - gui_chat_printf (NULL, - _("Warning: unable to assign default color " - "(\"%s\")\n"), - config_options[i][j].default_string); - break; - } - } - } - } -} - -/* - * config_option_print_stdout: print options on standard output - */ - -void -config_option_print_stdout (char **config_sections, - struct t_config_option **config_options) -{ - int i, j, k; - - for (i = 0; config_sections[i]; i++) - { - if (config_options[i]) - { - j = 0; - while (config_options[i][j].name) - { - string_iconv_fprintf (stdout, - "* %s:\n", - config_options[i][j].name); - switch (config_options[i][j].type) - { - case OPTION_TYPE_BOOLEAN: - string_iconv_fprintf (stdout, _(" . type: boolean\n")); - string_iconv_fprintf (stdout, _(" . values: 'on' or 'off'\n")); - string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), - (config_options[i][j].default_int == BOOL_TRUE) ? - "on" : "off"); - break; - case OPTION_TYPE_INT: - string_iconv_fprintf (stdout, _(" . type: integer\n")); - string_iconv_fprintf (stdout, _(" . values: between %d and %d\n"), - config_options[i][j].min, - config_options[i][j].max); - string_iconv_fprintf (stdout, _(" . default value: %d\n"), - config_options[i][j].default_int); - break; - case OPTION_TYPE_INT_WITH_STRING: - string_iconv_fprintf (stdout, _(" . type: string\n")); - string_iconv_fprintf (stdout, _(" . values: ")); - k = 0; - while (config_options[i][j].array_values[k]) - { - string_iconv_fprintf (stdout, "'%s'", - config_options[i][j].array_values[k]); - if (config_options[i][j].array_values[k + 1]) - string_iconv_fprintf (stdout, ", "); - k++; - } - string_iconv_fprintf (stdout, "\n"); - string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), - (config_options[i][j].default_string) ? - config_options[i][j].default_string : _("empty")); - break; - case OPTION_TYPE_STRING: - switch (config_options[i][j].max) - { - case 0: - string_iconv_fprintf (stdout, _(" . type: string\n")); - string_iconv_fprintf (stdout, _(" . values: any string\n")); - break; - case 1: - string_iconv_fprintf (stdout, _(" . type: char\n")); - string_iconv_fprintf (stdout, _(" . values: any char\n")); - break; - default: - string_iconv_fprintf (stdout, _(" . type: string\n")); - string_iconv_fprintf (stdout, _(" . values: any string (limit: %d chars)\n"), - config_options[i][j].max); - break; - } - string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), - (config_options[i][j].default_string) ? - config_options[i][j].default_string : _("empty")); - break; - case OPTION_TYPE_COLOR: - string_iconv_fprintf (stdout, _(" . type: color\n")); - string_iconv_fprintf (stdout, _(" . values: color (depends on GUI used)\n")); - string_iconv_fprintf (stdout, _(" . default value: '%s'\n"), - (config_options[i][j].default_string) ? - config_options[i][j].default_string : _("empty")); - break; - } - string_iconv_fprintf (stdout, _(" . description: %s\n"), - _(config_options[i][j].description)); - string_iconv_fprintf (stdout, "\n"); - j++; - } - } - } -} diff --git a/src/core/wee-config-option.h b/src/core/wee-config-option.h deleted file mode 100644 index 652c7d916..000000000 --- a/src/core/wee-config-option.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org> - * See README for License detail, AUTHORS for developers list. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef __WEECHAT_CONFIG_OPTION_H -#define __WEECHAT_CONFIG_OPTION_H 1 - -#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */ -#define OPTION_TYPE_INT 2 /* values: from min to max */ -#define OPTION_TYPE_INT_WITH_STRING 3 /* values: one from **array_values */ -#define OPTION_TYPE_STRING 4 /* values: any string, may be empty */ -#define OPTION_TYPE_COLOR 5 /* values: a color struct */ - - -#define BOOL_FALSE 0 -#define BOOL_TRUE 1 - -struct t_config_option -{ - char *name; - char *description; - int type; - int min, max; - int default_int; - char *default_string; - char **array_values; - int *ptr_int; - char **ptr_string; - void (*handler_change)(); -}; - -extern int config_option_get_pos_array_values (char **, char *); -extern void config_option_list_remove (char **, char *); -extern void config_option_list_set (char **, char *, char *); -extern void config_option_list_get_value (char **, char *, char **, int *); -extern int config_option_option_get_boolean_value (char *); -extern int config_option_set (struct t_config_option *, char *); -extern struct t_config_option *config_option_search (struct t_config_option *, char *); -extern struct t_config_option *config_option_section_option_search (char **, - struct t_config_option **, - char *); -extern void config_option_section_option_search_get_value (char **, struct t_config_option **, - char *, struct t_config_option **, - void **); -extern int config_option_section_option_set_value_by_name (char **, - struct t_config_option **, - char *, char *); -extern int config_option_section_get_index (char **, char *); -extern void config_option_section_option_set_default_values (char **, - struct t_config_option **); -extern void config_option_print_stdout (char **, struct t_config_option **); - -#endif /* wee-config-option.h */ diff --git a/src/core/wee-config.c b/src/core/wee-config.c index fe1a7fa84..4de2f29c2 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -35,816 +35,160 @@ #include "weechat.h" #include "wee-config.h" +#include "wee-config-file.h" #include "wee-alias.h" #include "wee-command.h" -#include "wee-config-file.h" -#include "wee-list.h" #include "wee-log.h" -#include "wee-string.h" #include "wee-util.h" +#include "wee-list.h" #include "../gui/gui-chat.h" +#include "../gui/gui-color.h" #include "../gui/gui-hotlist.h" #include "../gui/gui-keyboard.h" #include "../gui/gui-status.h" #include "../gui/gui-window.h" -/* config, look & feel section */ +struct t_config_file *weechat_config = NULL; -int cfg_look_color_real_white; -int cfg_look_save_on_exit; -int cfg_look_set_title; -int cfg_look_startup_logo; -int cfg_look_startup_version; -char *cfg_look_weechat_slogan; -int cfg_look_scroll_amount; -char *cfg_look_buffer_time_format; -int cfg_look_color_nicks_number; -int cfg_look_color_actions; -int cfg_look_nicklist; -int cfg_look_nicklist_position; -char *cfg_look_nicklist_position_values[] = -{ "left", "right", "top", "bottom", NULL }; -int cfg_look_nicklist_min_size; -int cfg_look_nicklist_max_size; -int cfg_look_nicklist_separator; -int cfg_look_nickmode; -int cfg_look_nickmode_empty; -char *cfg_look_no_nickname; -char *cfg_look_prefix[GUI_CHAT_PREFIX_NUMBER]; -int cfg_look_prefix_align; -char *cfg_look_prefix_align_values[] = -{ "none", "left", "right", NULL }; -int cfg_look_prefix_align_max; -char *cfg_look_prefix_suffix; -int cfg_look_align_text_offset; -char *cfg_look_nick_completor; -char *cfg_look_nick_completion_ignore; -int cfg_look_nick_completion_smart; -int cfg_look_nick_complete_first; -int cfg_look_infobar; -char *cfg_look_infobar_time_format; -int cfg_look_infobar_seconds; -int cfg_look_infobar_delay_highlight; -int cfg_look_hotlist_names_count; -int cfg_look_hotlist_names_level; -int cfg_look_hotlist_names_length; -int cfg_look_hotlist_sort; -char *cfg_look_hotlist_sort_values[] = -{ "group_time_asc", "group_time_desc", - "group_number_asc", "group_number_desc", - "number_asc", "number_desc" }; -int cfg_look_day_change; -char *cfg_look_day_change_time_format; -char *cfg_look_read_marker; -char *cfg_look_input_format; -int cfg_look_paste_max_lines; +/* config, look & feel section */ -struct t_config_option weechat_options_look[] = -{ { "look_color_real_white", - N_("if set, uses real white color, disabled by default for terms with " - "white background (if you never use white background, you should turn " - "on this option to see real white instead of default term foreground " - "color)"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL, - &cfg_look_color_real_white, NULL, weechat_config_change_color }, - { "look_save_on_exit", - N_("save configuration file on exit"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_save_on_exit, NULL, weechat_config_change_save_on_exit }, - { "look_set_title", - N_("set title for window (terminal for Curses GUI) with name and version"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_set_title, NULL, weechat_config_change_title }, - { "look_startup_logo", - N_("display WeeChat logo at startup"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_startup_logo, NULL, weechat_config_change_noop }, - { "look_startup_version", - N_("display WeeChat version at startup"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_startup_version, NULL, weechat_config_change_noop }, - { "look_weechat_slogan", - N_("WeeChat slogan (if empty, slogan is not used)"), - OPTION_TYPE_STRING, 0, 0, 0, "the geekest IRC client!", NULL, - NULL, &cfg_look_weechat_slogan, weechat_config_change_noop }, - { "look_scroll_amount", - N_("how many lines to scroll by with scroll_up and scroll_down"), - OPTION_TYPE_INT, 1, INT_MAX, 3, NULL, NULL, - &cfg_look_scroll_amount, NULL, weechat_config_change_buffer_content }, - { "look_buffer_time_format", - N_("time format for buffers"), - OPTION_TYPE_STRING, 0, 0, 0, "[%H:%M:%S]", NULL, - NULL, &cfg_look_buffer_time_format, weechat_config_change_buffer_time_format }, - { "look_color_nicks_number", - N_("number of colors to use for nicks colors"), - OPTION_TYPE_INT, 1, 10, 10, NULL, NULL, - &cfg_look_color_nicks_number, NULL, weechat_config_change_nicks_colors }, - { "look_color_actions", - N_("display actions with different colors"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_color_actions, NULL, weechat_config_change_noop }, - { "look_nicklist", - N_("display nicklist window (for channel windows)"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_nicklist, NULL, weechat_config_change_buffers }, - { "look_nicklist_position", - N_("nicklist position (top, left, right (default), bottom)"), - OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "right", cfg_look_nicklist_position_values, - &cfg_look_nicklist_position, NULL, weechat_config_change_buffers }, - { "look_nicklist_min_size", - N_("min size for nicklist (width or height, depending on look_nicklist_position " - "(0 = no min size))"), - OPTION_TYPE_INT, 0, 100, 0, NULL, NULL, - &cfg_look_nicklist_min_size, NULL, weechat_config_change_buffers }, - { "look_nicklist_max_size", - N_("max size for nicklist (width or height, depending on look_nicklist_position " - "(0 = no max size; if min = max and > 0, then size is fixed))"), - OPTION_TYPE_INT, 0, 100, 0, NULL, NULL, - &cfg_look_nicklist_max_size, NULL, weechat_config_change_buffers }, - { "look_nicklist_separator", - N_("separator between chat and nicklist"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_nicklist_separator, NULL, weechat_config_change_buffers }, - { "look_no_nickname", - N_("text to display instead of nick when not connected"), - OPTION_TYPE_STRING, 0, 0, 0, "-cmd-", NULL, - NULL, &cfg_look_no_nickname, weechat_config_change_buffer_content }, - { "look_nickmode", - N_("display nick mode ((half)op/voice) before each nick"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_nickmode, NULL, weechat_config_change_buffers }, - { "look_nickmode_empty", - N_("display space if nick mode is not (half)op/voice"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL, - &cfg_look_nickmode_empty, NULL, weechat_config_change_buffers }, - { "look_prefix_info", - N_("prefix for info messages"), - OPTION_TYPE_STRING, 0, 0, 0, "-=-", NULL, - NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_INFO], weechat_config_change_prefix }, - { "look_prefix_error", - N_("prefix for error messages"), - OPTION_TYPE_STRING, 0, 0, 0, "=!=", NULL, - NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_ERROR], weechat_config_change_prefix }, - { "look_prefix_network", - N_("prefix for network messages"), - OPTION_TYPE_STRING, 0, 0, 0, "-@-", NULL, - NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_NETWORK], weechat_config_change_prefix }, - { "look_prefix_action", - N_("prefix for action messages"), - OPTION_TYPE_STRING, 0, 0, 0, "-*-", NULL, - NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_ACTION], weechat_config_change_prefix }, - { "look_prefix_join", - N_("prefix for join messages"), - OPTION_TYPE_STRING, 0, 0, 0, "-->", NULL, - NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_JOIN], weechat_config_change_prefix }, - { "look_prefix_quit", - N_("prefix for quit messages"), - OPTION_TYPE_STRING, 0, 0, 0, "<--", NULL, - NULL, &cfg_look_prefix[GUI_CHAT_PREFIX_QUIT], weechat_config_change_prefix }, - { "look_prefix_align", - N_("prefix alignment (none, left, right))"), - OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "right", cfg_look_prefix_align_values, - &cfg_look_prefix_align, NULL, weechat_config_change_buffers }, - { "look_prefix_align_max", - N_("max size for prefix (0 = no max size)"), - OPTION_TYPE_INT, 0, 64, 0, NULL, NULL, - &cfg_look_prefix_align_max, NULL, weechat_config_change_buffers }, - { "look_prefix_suffix", - N_("string displayed after prefix"), - OPTION_TYPE_STRING, 0, 0, 0, "|", NULL, - NULL, &cfg_look_prefix_suffix, weechat_config_change_buffers }, - { "look_align_text_offset", - N_("offset for aligning lines of messages (except first lines), default " - "is -1 (align after prefix), a null or positive value is offset after " - "beginning of line"), - OPTION_TYPE_INT, -1, 64, -1, NULL, NULL, - &cfg_look_align_text_offset, NULL, weechat_config_change_buffers }, - { "look_nick_completor", - N_("the string inserted after nick completion"), - OPTION_TYPE_STRING, 0, 0, 0, ":", NULL, - NULL, &cfg_look_nick_completor, weechat_config_change_noop }, - { "look_nick_completion_ignore", - N_("chars ignored for nick completion"), - OPTION_TYPE_STRING, 0, 0, 0, "[]-^", NULL, - NULL, &cfg_look_nick_completion_ignore, weechat_config_change_noop }, - { "look_nick_completion_smart", - N_("smart completion for nicks (completes with last speakers first)"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_nick_completion_smart, NULL, weechat_config_change_noop }, - { "look_nick_complete_first", - N_("complete only with first nick found"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL, - &cfg_look_nick_complete_first, NULL, weechat_config_change_noop }, - { "look_infobar", - N_("enable info bar"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_infobar, NULL, weechat_config_change_buffers }, - { "look_infobar_time_format", - N_("time format for time in infobar"), - OPTION_TYPE_STRING, 0, 0, 0, "%B, %A %d %Y", NULL, - NULL, &cfg_look_infobar_time_format, weechat_config_change_buffer_content }, - { "look_infobar_seconds", - N_("display seconds in infobar time"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_infobar_seconds, NULL, weechat_config_change_buffer_content }, - { "look_infobar_delay_highlight", - N_("delay (in seconds) for highlight messages in infobar " - "(0 = disable highlight notifications in infobar)"), - OPTION_TYPE_INT, 0, INT_MAX, 7, NULL, NULL, - &cfg_look_infobar_delay_highlight, NULL, weechat_config_change_noop }, - { "look_hotlist_names_count", - N_("max number of names in hotlist (0 = no name displayed, only buffer numbers)"), - OPTION_TYPE_INT, 0, 32, 3, NULL, NULL, - &cfg_look_hotlist_names_count, NULL, weechat_config_change_buffer_content }, - { "look_hotlist_names_level", - N_("level for displaying names in hotlist (combination of: 1=join/part, " - "2=message, 4=private, 8=highlight, for example: 12=private+highlight)"), - OPTION_TYPE_INT, 1, 15, 12, NULL, NULL, - &cfg_look_hotlist_names_level, NULL, weechat_config_change_buffer_content }, - { "look_hotlist_names_length", - N_("max length of names in hotlist (0 = no limit)"), - OPTION_TYPE_INT, 0, 32, 0, NULL, NULL, - &cfg_look_hotlist_names_length, NULL, weechat_config_change_buffer_content }, - { "look_hotlist_sort", - N_("hotlist sort type (group_time_asc (default), group_time_desc, " - "group_number_asc, group_number_desc, number_asc, number_desc)"), - OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "group_time_asc", cfg_look_hotlist_sort_values, - &cfg_look_hotlist_sort, NULL, weechat_config_change_hotlist }, - { "look_day_change", - N_("display special message when day changes"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, - &cfg_look_day_change, NULL, weechat_config_change_noop }, - { "look_day_change_time_format", - N_("time format for date displayed when day changed"), - OPTION_TYPE_STRING, 0, 0, 0, "%a, %d %b %Y", NULL, - NULL, &cfg_look_day_change_time_format, weechat_config_change_noop }, - { "look_read_marker", - N_("use a marker on servers/channels to show first unread line"), - OPTION_TYPE_STRING, 0, 1, 0, " ", NULL, - NULL, &cfg_look_read_marker, weechat_config_change_read_marker }, - { "look_input_format", - N_("format for input prompt ('%c' is replaced by channel or server, " - "'%n' by nick and '%m' by nick modes)"), - OPTION_TYPE_STRING, 0, 0, 0, "[%n(%m)] ", NULL, - NULL, &cfg_look_input_format, weechat_config_change_buffer_content }, - { "look_paste_max_lines", - N_("max number of lines for paste without asking user (0 = disable this feature)"), - OPTION_TYPE_INT, 0, INT_MAX, 3, NULL, NULL, - &cfg_look_paste_max_lines, NULL, weechat_config_change_noop }, - { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } -}; +struct t_config_option *config_look_color_real_white; +struct t_config_option *config_look_save_on_exit; +struct t_config_option *config_look_set_title; +struct t_config_option *config_look_startup_logo; +struct t_config_option *config_look_startup_version; +struct t_config_option *config_look_weechat_slogan; +struct t_config_option *config_look_scroll_amount; +struct t_config_option *config_look_buffer_time_format; +struct t_config_option *config_look_color_nicks_number; +struct t_config_option *config_look_nicklist; +struct t_config_option *config_look_nicklist_position; +struct t_config_option *config_look_nicklist_min_size; +struct t_config_option *config_look_nicklist_max_size; +struct t_config_option *config_look_nicklist_separator; +struct t_config_option *config_look_nickmode; +struct t_config_option *config_look_nickmode_empty; +struct t_config_option *config_look_no_nickname; +struct t_config_option *config_look_prefix[GUI_CHAT_PREFIX_NUMBER]; +struct t_config_option *config_look_prefix_align; +struct t_config_option *config_look_prefix_align_max; +struct t_config_option *config_look_prefix_suffix; +struct t_config_option *config_look_nick_completor; +struct t_config_option *config_look_nick_completion_ignore; +struct t_config_option *config_look_nick_completion_smart; +struct t_config_option *config_look_nick_complete_first; +struct t_config_option *config_look_infobar; +struct t_config_option *config_look_infobar_time_format; +struct t_config_option *config_look_infobar_seconds; +struct t_config_option *config_look_infobar_delay_highlight; +struct t_config_option *config_look_hotlist_names_count; +struct t_config_option *config_look_hotlist_names_level; +struct t_config_option *config_look_hotlist_names_length; +struct t_config_option *config_look_hotlist_sort; +struct t_config_option *config_look_day_change; +struct t_config_option *config_look_day_change_time_format; +struct t_config_option *config_look_read_marker; +struct t_config_option *config_look_input_format; +struct t_config_option *config_look_paste_max_lines; /* config, colors section */ -int cfg_col_separator; -int cfg_col_title; -int cfg_col_title_bg; -int cfg_col_title_more; -int cfg_col_chat; -int cfg_col_chat_bg; -int cfg_col_chat_time; -int cfg_col_chat_time_delimiters; -int cfg_col_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; -int cfg_col_chat_prefix_more; -int cfg_col_chat_prefix_suffix; -int cfg_col_chat_buffer; -int cfg_col_chat_server; -int cfg_col_chat_channel; -int cfg_col_chat_nick; -int cfg_col_chat_nick_self; -int cfg_col_chat_nick_other; -int cfg_col_chat_nick_colors[GUI_COLOR_NICK_NUMBER]; -int cfg_col_chat_host; -int cfg_col_chat_delimiters; -int cfg_col_chat_highlight; -int cfg_col_chat_read_marker; -int cfg_col_chat_read_marker_bg; -int cfg_col_status; -int cfg_col_status_bg; -int cfg_col_status_delimiters; -int cfg_col_status_channel; -int cfg_col_status_data_msg; -int cfg_col_status_data_private; -int cfg_col_status_data_highlight; -int cfg_col_status_data_other; -int cfg_col_status_more; -int cfg_col_infobar; -int cfg_col_infobar_bg; -int cfg_col_infobar_delimiters; -int cfg_col_infobar_highlight; -int cfg_col_infobar_bg; -int cfg_col_input; -int cfg_col_input_bg; -int cfg_col_input_server; -int cfg_col_input_channel; -int cfg_col_input_nick; -int cfg_col_input_delimiters; -int cfg_col_input_text_not_found; -int cfg_col_input_actions; -int cfg_col_nicklist; -int cfg_col_nicklist_bg; -int cfg_col_nicklist_away; -int cfg_col_nicklist_prefix1; -int cfg_col_nicklist_prefix2; -int cfg_col_nicklist_prefix3; -int cfg_col_nicklist_prefix4; -int cfg_col_nicklist_prefix5; -int cfg_col_nicklist_more; -int cfg_col_nicklist_separator; -int cfg_col_info; -int cfg_col_info_bg; -int cfg_col_info_waiting; -int cfg_col_info_connecting; -int cfg_col_info_active; -int cfg_col_info_done; -int cfg_col_info_failed; -int cfg_col_info_aborted; - -struct t_config_option weechat_options_colors[] = -{ /* general color settings */ - { "col_separator", - N_("color for window separators (when splited)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_SEPARATOR, "blue", NULL, - &cfg_col_separator, NULL, weechat_config_change_color }, - - /* title window */ - { "col_title", - N_("color for title bar"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_TITLE, "default", NULL, - &cfg_col_title, NULL, weechat_config_change_color }, - { "col_title_bg", - N_("background color for title bar"), - OPTION_TYPE_COLOR, 0, 0, -1, "blue", NULL, - &cfg_col_title_bg, NULL, weechat_config_change_color }, - { "col_title_more", - N_("color for '+' when scrolling title"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_TITLE_MORE, "lightmagenta", NULL, - &cfg_col_title_more, NULL, weechat_config_change_color }, - - /* chat window */ - { "col_chat", - N_("color for chat text"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT, "default", NULL, - &cfg_col_chat, NULL, weechat_config_change_color }, - { "col_chat_bg", - N_("background for chat text"), - OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL, - &cfg_col_chat_bg, NULL, weechat_config_change_color }, - { "col_chat_time", - N_("color for time in chat window"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_TIME, "default", NULL, - &cfg_col_chat_time, NULL, weechat_config_change_color }, - { "col_chat_time_delimiters", - N_("color for time delimiters)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_TIME_DELIMITERS, "brown", NULL, - &cfg_col_chat_time_delimiters, NULL, weechat_config_change_color }, - { "col_chat_prefix_info", - N_("color for info prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_INFO, "lightcyan", NULL, - &cfg_col_chat_prefix[GUI_CHAT_PREFIX_INFO], NULL, weechat_config_change_color }, - { "col_chat_prefix_error", - N_("color for error prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_ERROR, "yellow", NULL, - &cfg_col_chat_prefix[GUI_CHAT_PREFIX_ERROR], NULL, weechat_config_change_color }, - { "col_chat_prefix_network", - N_("color for network prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_NETWORK, "lightmagenta", NULL, - &cfg_col_chat_prefix[GUI_CHAT_PREFIX_NETWORK], NULL, weechat_config_change_color }, - { "col_chat_prefix_action", - N_("color for action prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_ACTION, "white", NULL, - &cfg_col_chat_prefix[GUI_CHAT_PREFIX_ACTION], NULL, weechat_config_change_color }, - { "col_chat_prefix_join", - N_("color for join prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_JOIN, "lightgreen", NULL, - &cfg_col_chat_prefix[GUI_CHAT_PREFIX_JOIN], NULL, weechat_config_change_color }, - { "col_chat_prefix_quit", - N_("color for quit prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_QUIT, "lightred", NULL, - &cfg_col_chat_prefix[GUI_CHAT_PREFIX_QUIT], NULL, weechat_config_change_color }, - { "col_chat_prefix_more", - N_("color for '+' when prefix is too long"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_MORE, "lightmagenta", NULL, - &cfg_col_chat_prefix_more, NULL, weechat_config_change_color }, - { "col_chat_prefix_suffix", - N_("color for text after prefix"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_PREFIX_SUFFIX, "green", NULL, - &cfg_col_chat_prefix_suffix, NULL, weechat_config_change_color }, - { "col_chat_buffer", - N_("color for buffer names"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_BUFFER, "white", NULL, - &cfg_col_chat_buffer, NULL, weechat_config_change_color }, - { "col_chat_server", - N_("color for server names"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_SERVER, "brown", NULL, - &cfg_col_chat_server, NULL, weechat_config_change_color }, - { "col_chat_channel", - N_("color for channel names"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_CHANNEL, "white", NULL, - &cfg_col_chat_channel, NULL, weechat_config_change_color }, - { "col_chat_nick", - N_("color for nicks"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK, "lightcyan", NULL, - &cfg_col_chat_nick, NULL, weechat_config_change_color }, - { "col_chat_nick_self", - N_("color for local nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK_SELF, "white", NULL, - &cfg_col_chat_nick_self, NULL, weechat_config_change_color }, - { "col_chat_nick_other", - N_("color for other nick in private buffer"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK_OTHER, "default", NULL, - &cfg_col_chat_nick_other, NULL, weechat_config_change_color }, - { "col_chat_nick_color1", - N_("color #1 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK1, "cyan", NULL, - &cfg_col_chat_nick_colors[0], NULL, weechat_config_change_color }, - { "col_chat_nick_color2", - N_("color #2 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK2, "magenta", NULL, - &cfg_col_chat_nick_colors[1], NULL, weechat_config_change_color }, - { "col_chat_nick_color3", - N_("color #3 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK3, "green", NULL, - &cfg_col_chat_nick_colors[2], NULL, weechat_config_change_color }, - { "col_chat_nick_color4", - N_("color #4 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK4, "brown", NULL, - &cfg_col_chat_nick_colors[3], NULL, weechat_config_change_color }, - { "col_chat_nick_color5", - N_("color #5 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK5, "lightblue", NULL, - &cfg_col_chat_nick_colors[4], NULL, weechat_config_change_color }, - { "col_chat_nick_color6", - N_("color #6 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK6, "default", NULL, - &cfg_col_chat_nick_colors[5], NULL, weechat_config_change_color }, - { "col_chat_nick_color7", - N_("color #7 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK7, "lightcyan", NULL, - &cfg_col_chat_nick_colors[6], NULL, weechat_config_change_color }, - { "col_chat_nick_color8", - N_("color #8 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK8, "lightmagenta", NULL, - &cfg_col_chat_nick_colors[7], NULL, weechat_config_change_color }, - { "col_chat_nick_color9", - N_("color #9 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK9, "lightgreen", NULL, - &cfg_col_chat_nick_colors[8], NULL, weechat_config_change_color }, - { "col_chat_nick_color10", - N_("color #10 for nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_NICK10, "blue", NULL, - &cfg_col_chat_nick_colors[9], NULL, weechat_config_change_color }, - { "col_chat_host", - N_("color for hostnames"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_HOST, "cyan", NULL, - &cfg_col_chat_host, NULL, weechat_config_change_color }, - { "col_chat_delimiters", - N_("color for delimiters"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_DELIMITERS, "green", NULL, - &cfg_col_chat_delimiters, NULL, weechat_config_change_color }, - { "col_chat_highlight", - N_("color for highlighted nick"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_HIGHLIGHT, "yellow", NULL, - &cfg_col_chat_highlight, NULL, weechat_config_change_color }, - { "col_chat_read_marker", - N_("color for unread data marker"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_CHAT_READ_MARKER, "yellow", NULL, - &cfg_col_chat_read_marker, NULL, weechat_config_change_color }, - { "col_chat_read_marker_bg", - N_("background color for unread data marker"), - OPTION_TYPE_COLOR, 0, 0, -1, "magenta", NULL, - &cfg_col_chat_read_marker_bg, NULL, weechat_config_change_color }, - - /* status window */ - { "col_status", - N_("color for status bar"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS, "default", NULL, - &cfg_col_status, NULL, weechat_config_change_color }, - { "col_status_bg", - N_("background color for status bar"), - OPTION_TYPE_COLOR, 0, 0, -1, "blue", NULL, - &cfg_col_status_bg, NULL, weechat_config_change_color }, - { "col_status_delimiters", - N_("color for status bar delimiters"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DELIMITERS, "cyan", NULL, - &cfg_col_status_delimiters, NULL, weechat_config_change_color }, - { "col_status_channel", - N_("color for current channel in status bar"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_CHANNEL, "white", NULL, - &cfg_col_status_channel, NULL, weechat_config_change_color }, - { "col_status_data_msg", - N_("color for window with new messages (status bar)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_MSG, "yellow", NULL, - &cfg_col_status_data_msg, NULL, weechat_config_change_color }, - { "col_status_data_private", - N_("color for window with private message (status bar)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_PRIVATE, "lightmagenta", NULL, - &cfg_col_status_data_private, NULL, weechat_config_change_color }, - { "col_status_data_highlight", - N_("color for window with highlight (status bar)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_HIGHLIGHT, "lightred", NULL, - &cfg_col_status_data_highlight, NULL, weechat_config_change_color }, - { "col_status_data_other", - N_("color for window with new data (not messages) (status bar)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_DATA_OTHER, "default", NULL, - &cfg_col_status_data_other, NULL, weechat_config_change_color }, - { "col_status_more", - N_("color for window with new data (status bar)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_STATUS_MORE, "white", NULL, - &cfg_col_status_more, NULL, weechat_config_change_color }, - - /* infobar window */ - { "col_infobar", - N_("color for info bar text"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR, "black", NULL, - &cfg_col_infobar, NULL, weechat_config_change_color }, - { "col_infobar_bg", - N_("background color for info bar text"), - OPTION_TYPE_COLOR, 0, 0, -1, "cyan", NULL, - &cfg_col_infobar_bg, NULL, weechat_config_change_color }, - { "col_infobar_delimiters", - N_("color for infobar delimiters"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR_DELIMITERS, "blue", NULL, - &cfg_col_infobar_delimiters, NULL, weechat_config_change_color }, - { "col_infobar_highlight", - N_("color for info bar highlight notification"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFOBAR_HIGHLIGHT, "white", NULL, - &cfg_col_infobar_highlight, NULL, weechat_config_change_color }, - - /* input window */ - { "col_input", - N_("color for input text"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT, "default", NULL, - &cfg_col_input, NULL, weechat_config_change_color }, - { "col_input_bg", - N_("background color for input text"), - OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL, - &cfg_col_input_bg, NULL, weechat_config_change_color }, - { "col_input_server", - N_("color for input text (server name)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_SERVER, "brown", NULL, - &cfg_col_input_server, NULL, weechat_config_change_color }, - { "col_input_channel", - N_("color for input text (channel name)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_CHANNEL, "white", NULL, - &cfg_col_input_channel, NULL, weechat_config_change_color }, - { "col_input_nick", - N_("color for input text (nick name)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_NICK, "lightcyan", NULL, - &cfg_col_input_nick, NULL, weechat_config_change_color }, - { "col_input_delimiters", - N_("color for input text (delimiters)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_DELIMITERS, "cyan", NULL, - &cfg_col_input_delimiters, NULL, weechat_config_change_color }, - { "col_input_text_not_found", - N_("color for text not found"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_TEXT_NOT_FOUND, "red", NULL, - &cfg_col_input_text_not_found, NULL, weechat_config_change_color }, - { "col_input_actions", - N_("color for actions in input window"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INPUT_ACTIONS, "lightgreen", NULL, - &cfg_col_input_actions, NULL, weechat_config_change_color }, - - /* nicklist window */ - { "col_nicklist", - N_("color for nicklist"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST, "default", NULL, - &cfg_col_nicklist, NULL, weechat_config_change_color }, - { "col_nicklist_bg", - N_("background color for nicklist"), - OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL, - &cfg_col_nicklist_bg, NULL, weechat_config_change_color }, - { "col_nicklist_away", - N_("color for away nicknames"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_AWAY, "cyan", NULL, - &cfg_col_nicklist_away, NULL, weechat_config_change_color }, - { "col_nicklist_prefix1", - N_("color for prefix 1"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX1, "lightgreen", NULL, - &cfg_col_nicklist_prefix1, NULL, weechat_config_change_color }, - { "col_nicklist_prefix2", - N_("color for prefix 2"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX2, "lightmagenta", NULL, - &cfg_col_nicklist_prefix2, NULL, weechat_config_change_color }, - { "col_nicklist_prefix3", - N_("color for prefix 3"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX3, "yellow", NULL, - &cfg_col_nicklist_prefix3, NULL, weechat_config_change_color }, - { "col_nicklist_prefix4", - N_("color for prefix 4"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX4, "blue", NULL, - &cfg_col_nicklist_prefix4, NULL, weechat_config_change_color }, - { "col_nicklist_prefix5", - N_("color for prefix 5"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_PREFIX5, "brown", NULL, - &cfg_col_nicklist_prefix5, NULL, weechat_config_change_color }, - { "col_nicklist_more", - N_("color for '+' when scrolling nicks (nicklist)"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_MORE, "lightmagenta", NULL, - &cfg_col_nicklist_more, NULL, weechat_config_change_color }, - { "col_nicklist_separator", - N_("color for nicklist separator"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_NICKLIST_SEPARATOR, "blue", NULL, - &cfg_col_nicklist_separator, NULL, weechat_config_change_color }, - - /* status info (for example: file transfers) */ - { "col_info", - N_("color for status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO, "default", NULL, - &cfg_col_info, NULL, weechat_config_change_color }, - { "col_info_bg", - N_("background color for status info"), - OPTION_TYPE_COLOR, 0, 0, -1, "default", NULL, - &cfg_col_info_bg, NULL, weechat_config_change_color }, - { "col_info_waiting", - N_("color for \"waiting\" status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_WAITING, "lightcyan", NULL, - &cfg_col_info_waiting, NULL, weechat_config_change_color }, - { "col_info_connecting", - N_("color for \"connecting\" status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_CONNECTING, "yellow", NULL, - &cfg_col_info_connecting, NULL, weechat_config_change_color }, - { "col_info_active", - N_("color for \"active\" status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_ACTIVE, "lightblue", NULL, - &cfg_col_info_active, NULL, weechat_config_change_color }, - { "col_info_done", - N_("color for \"done\" status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_DONE, "lightgreen", NULL, - &cfg_col_info_done, NULL, weechat_config_change_color }, - { "col_info_failed", - N_("color for \"failed\" status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_FAILED, "lightred", NULL, - &cfg_col_info_failed, NULL, weechat_config_change_color }, - { "col_info_aborted", - N_("color for \"aborted\" status info"), - OPTION_TYPE_COLOR, 0, 0, GUI_COLOR_INFO_ABORTED, "lightred", NULL, - &cfg_col_info_aborted, NULL, weechat_config_change_color }, - - { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } -}; +struct t_config_option *config_color_separator; +struct t_config_option *config_color_title; +struct t_config_option *config_color_title_bg; +struct t_config_option *config_color_title_more; +struct t_config_option *config_color_chat; +struct t_config_option *config_color_chat_bg; +struct t_config_option *config_color_chat_time; +struct t_config_option *config_color_chat_time_delimiters; +struct t_config_option *config_color_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; +struct t_config_option *config_color_chat_prefix_more; +struct t_config_option *config_color_chat_prefix_suffix; +struct t_config_option *config_color_chat_buffer; +struct t_config_option *config_color_chat_server; +struct t_config_option *config_color_chat_channel; +struct t_config_option *config_color_chat_nick; +struct t_config_option *config_color_chat_nick_self; +struct t_config_option *config_color_chat_nick_other; +struct t_config_option *config_color_chat_nick_colors[GUI_COLOR_NICK_NUMBER]; +struct t_config_option *config_color_chat_host; +struct t_config_option *config_color_chat_delimiters; +struct t_config_option *config_color_chat_highlight; +struct t_config_option *config_color_chat_read_marker; +struct t_config_option *config_color_chat_read_marker_bg; +struct t_config_option *config_color_status; +struct t_config_option *config_color_status_bg; +struct t_config_option *config_color_status_delimiters; +struct t_config_option *config_color_status_channel; +struct t_config_option *config_color_status_data_msg; +struct t_config_option *config_color_status_data_private; +struct t_config_option *config_color_status_data_highlight; +struct t_config_option *config_color_status_data_other; +struct t_config_option *config_color_status_more; +struct t_config_option *config_color_infobar; +struct t_config_option *config_color_infobar_bg; +struct t_config_option *config_color_infobar_delimiters; +struct t_config_option *config_color_infobar_highlight; +struct t_config_option *config_color_infobar_bg; +struct t_config_option *config_color_input; +struct t_config_option *config_color_input_bg; +struct t_config_option *config_color_input_server; +struct t_config_option *config_color_input_channel; +struct t_config_option *config_color_input_nick; +struct t_config_option *config_color_input_delimiters; +struct t_config_option *config_color_input_text_not_found; +struct t_config_option *config_color_input_actions; +struct t_config_option *config_color_nicklist; +struct t_config_option *config_color_nicklist_bg; +struct t_config_option *config_color_nicklist_away; +struct t_config_option *config_color_nicklist_prefix1; +struct t_config_option *config_color_nicklist_prefix2; +struct t_config_option *config_color_nicklist_prefix3; +struct t_config_option *config_color_nicklist_prefix4; +struct t_config_option *config_color_nicklist_prefix5; +struct t_config_option *config_color_nicklist_more; +struct t_config_option *config_color_nicklist_separator; +struct t_config_option *config_color_info; +struct t_config_option *config_color_info_bg; +struct t_config_option *config_color_info_waiting; +struct t_config_option *config_color_info_connecting; +struct t_config_option *config_color_info_active; +struct t_config_option *config_color_info_done; +struct t_config_option *config_color_info_failed; +struct t_config_option *config_color_info_aborted; /* config, history section */ -int cfg_history_max_lines; -int cfg_history_max_commands; -int cfg_history_display_default; - -struct t_config_option weechat_options_history[] = -{ { "history_max_lines", - N_("maximum number of lines in history " - "for one server/channel/private window (0 = unlimited)"), - OPTION_TYPE_INT, 0, INT_MAX, 4096, NULL, NULL, - &cfg_history_max_lines, NULL, weechat_config_change_noop }, - { "history_max_commands", - N_("maximum number of user commands in history (0 = unlimited)"), - OPTION_TYPE_INT, 0, INT_MAX, 100, NULL, NULL, - &cfg_history_max_commands, NULL, weechat_config_change_noop }, - { "history_display_default", - N_("maximum number of commands to display by default in history listing " - "(0 = unlimited)"), - OPTION_TYPE_INT, 0, INT_MAX, 5, NULL, NULL, - &cfg_history_display_default, NULL, weechat_config_change_noop }, - { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } -}; +struct t_config_option *config_history_max_lines; +struct t_config_option *config_history_max_commands; +struct t_config_option *config_history_display_default; /* config, proxy section */ -int cfg_proxy_use; -int cfg_proxy_type; -int cfg_proxy_ipv6; -char *cfg_proxy_type_values[] = -{ "http", "socks4", "socks5", NULL }; -char *cfg_proxy_address; -int cfg_proxy_port; -char *cfg_proxy_username; -char *cfg_proxy_password; - -struct t_config_option weechat_options_proxy[] = -{ { "proxy_use", - N_("use a proxy server to connect to irc server"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL, - &cfg_proxy_use, NULL, weechat_config_change_noop }, - { "proxy_type", - N_("proxy type (http (default), socks4, socks5)"), - OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "http", cfg_proxy_type_values, - &cfg_proxy_type, NULL, weechat_config_change_noop }, - { "proxy_ipv6", - N_("connect to proxy in ipv6"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL, - &cfg_proxy_ipv6, NULL, weechat_config_change_noop }, - { "proxy_address", - N_("proxy server address (IP or hostname)"), - OPTION_TYPE_STRING, 0, 0, 0, "", NULL, - NULL, &cfg_proxy_address, weechat_config_change_noop }, - { "proxy_port", - N_("port for connecting to proxy server"), - OPTION_TYPE_INT, 0, 65535, 3128, NULL, NULL, - &cfg_proxy_port, NULL, weechat_config_change_noop }, - { "proxy_username", - N_("username for proxy server"), - OPTION_TYPE_STRING, 0, 0, 0, "", NULL, - NULL, &cfg_proxy_username, weechat_config_change_noop }, - { "proxy_password", - N_("password for proxy server"), - OPTION_TYPE_STRING, 0, 0, 0, "", NULL, - NULL, &cfg_proxy_password, weechat_config_change_noop }, - { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } -}; +struct t_config_option *config_proxy_use; +struct t_config_option *config_proxy_type; +struct t_config_option *config_proxy_ipv6; +struct t_config_option *config_proxy_address; +struct t_config_option *config_proxy_port; +struct t_config_option *config_proxy_username; +struct t_config_option *config_proxy_password; /* config, plugins section */ -char *cfg_plugins_path; -char *cfg_plugins_autoload; -char *cfg_plugins_extension; - -struct t_config_option weechat_options_plugins[] = -{ { "plugins_path", - N_("path for searching plugins ('%h' will be replaced by WeeChat home, " - "~/.weechat by default)"), - OPTION_TYPE_STRING, 0, 0, 0, "%h/plugins", NULL, - NULL, &cfg_plugins_path, weechat_config_change_noop }, - { "plugins_autoload", - N_("comma separated list of plugins to load automatically at startup, " - "\"*\" means all plugins found " - "(names may be partial, for example \"perl\" is ok for \"perl.so\")"), - OPTION_TYPE_STRING, 0, 0, 0, "*", NULL, - NULL, &cfg_plugins_autoload, weechat_config_change_noop }, - { "plugins_extension", - N_("standard plugins extension in filename, used for autoload " - "(if empty, then all files are loaded when autoload is \"*\")"), - OPTION_TYPE_STRING, 0, 0, 0, -#ifdef WIN32 - ".dll", -#else - ".so", -#endif - NULL, - NULL, &cfg_plugins_extension, weechat_config_change_noop }, - { NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } -}; - -char *weechat_config_sections[] = -{ "look", "colors", - "history", "proxy", - "plugins", "alias", - "keys", - NULL -}; - -struct t_config_option *weechat_config_options[] = -{ weechat_options_look, weechat_options_colors, - weechat_options_history, weechat_options_proxy, - weechat_options_plugins, NULL, - NULL, - NULL -}; - -t_config_func_read_option *weechat_config_read_functions[] = -{ config_file_read_option, config_file_read_option, - config_file_read_option, config_file_read_option, - config_file_read_option, weechat_config_read_alias, - weechat_config_read_key, - NULL -}; +struct t_config_option *config_plugins_path; +struct t_config_option *config_plugins_autoload; +struct t_config_option *config_plugins_extension; -t_config_func_write_options *weechat_config_write_functions[] = -{ config_file_write_options, config_file_write_options, - config_file_write_options, config_file_write_options, - config_file_write_options, weechat_config_write_alias, - weechat_config_write_keys, - NULL -}; - -t_config_func_write_options *weechat_config_write_default_functions[] = -{ config_file_write_options_default_values, config_file_write_options_default_values, - config_file_write_options_default_values, config_file_write_options_default_values, - config_file_write_options_default_values, weechat_config_write_alias_default_values, - weechat_config_write_keys_default_values, - NULL -}; - - -/* - * weechat_config_change_noop: called when an option is changed by /set command - * and that no special action is needed after that - */ - -void -weechat_config_change_noop () -{ - /* do nothing */ -} /* - * weechat_config_change_save_on_exit: called when "save_on_exit" flag is changed + * config_change_save_on_exit: called when "save_on_exit" flag is changed */ void -weechat_config_change_save_on_exit () +config_change_save_on_exit () { - if (!cfg_look_save_on_exit) + if (!config_look_save_on_exit) { gui_chat_printf (NULL, "\n"); gui_chat_printf (NULL, @@ -854,77 +198,77 @@ weechat_config_change_save_on_exit () } /* - * weechat_config_change_title: called when title is changed + * config_change_title: called when title is changed */ void -weechat_config_change_title () +config_change_title () { - if (cfg_look_set_title) + if (config_look_set_title) gui_window_title_set (); else gui_window_title_reset (); } /* - * weechat_config_change_buffers: called when buffers change (for example nicklist) + * config_change_buffers: called when buffers change (for example nicklist) */ void -weechat_config_change_buffers () +config_change_buffers () { gui_window_refresh_windows (); } /* - * weechat_config_change_buffer_content: called when content of a buffer changes + * config_change_buffer_content: called when content of a buffer changes */ void -weechat_config_change_buffer_content () +config_change_buffer_content () { gui_window_redraw_buffer (gui_current_window->buffer); } /* - * weechat_config_change_buffer_time_format: called when buffer time format changes + * config_change_buffer_time_format: called when buffer time format changes */ void -weechat_config_change_buffer_time_format () +config_change_buffer_time_format () { - gui_chat_time_length = util_get_time_length (cfg_look_buffer_time_format); + gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format)); gui_chat_change_time_format (); gui_window_redraw_buffer (gui_current_window->buffer); } /* - * weechat_config_change_hotlist: called when hotlist changes + * config_change_hotlist: called when hotlist changes */ void -weechat_config_change_hotlist () +config_change_hotlist () { gui_hotlist_resort (); gui_status_draw (gui_current_window->buffer, 1); } /* - * weechat_config_change_read_marker: called when read marker is changed + * config_change_read_marker: called when read marker is changed */ void -weechat_config_change_read_marker () +config_change_read_marker () { gui_window_redraw_all_buffers (); } /* - * weechat_config_change_prefix: called when a prefix is changed + * config_change_prefix: called when a prefix is changed */ void -weechat_config_change_prefix () +config_change_prefix () { int i; @@ -937,23 +281,26 @@ weechat_config_change_prefix () } /* - * weechat_config_change_color: called when a color is changed by /set command + * config_change_color: called when a color is changed by /set command */ void -weechat_config_change_color () +config_change_color () { - gui_color_init_pairs (); - gui_color_rebuild_weechat (); - gui_window_refresh_windows (); + if (gui_ok) + { + gui_color_init_pairs (); + gui_color_rebuild_weechat (); + gui_window_refresh_windows (); + } } /* - * weechat_config_change_nicks_colors: called when number of nicks color changed + * config_change_nicks_colors: called when number of nicks color changed */ void -weechat_config_change_nicks_colors () +config_change_nicks_colors () { struct t_gui_buffer *ptr_buffer; struct t_gui_nick *ptr_nick; @@ -973,137 +320,121 @@ weechat_config_change_nicks_colors () } /* - * weechat_config_read_alias: read an alias in configuration file - * Return: 0 = successful - * -1 = option not found - * -2 = bad format/value + * config_weechat_read_alias: read an alias in configuration file */ -int -weechat_config_read_alias (struct t_config_option *options, +void +config_weechat_read_alias (struct t_config_file *config_file, char *option_name, char *value) { /* make C compiler happy */ - (void) options; - - if (option_name) - { - /* create new alias */ - if (alias_new (option_name, value)) - weelist_add (&weechat_index_commands, - &weechat_last_index_command, - option_name, - WEELIST_POS_SORT); - else - return -2; - } - else - { - /* does nothing for new [alias] section */ - } + (void) config_file; - /* all ok */ - return 0; + /* create new alias */ + if (alias_new (option_name, value)) + weelist_add (&weechat_index_commands, + &weechat_last_index_command, + option_name, + WEELIST_POS_SORT); } /* - * weechat_config_read_key: read a key in configuration file - * Return: 0 = successful - * -1 = option not found - * -2 = bad format/value + * config_weechat_read_key: read a key in configuration file */ -int -weechat_config_read_key (struct t_config_option *options, +void +config_weechat_read_key (struct t_config_file *config_file, char *option_name, char *value) { /* make C compiler happy */ - (void) options; + (void) config_file; - if (option_name) + if (value[0]) { - if (value[0]) - { - /* bind key (overwrite any binding with same key) */ - gui_keyboard_bind (option_name, value); - } - else - { - /* unbin key if no value given */ - gui_keyboard_unbind (option_name); - } + /* bind key (overwrite any binding with same key) */ + gui_keyboard_bind (option_name, value); } else { - /* does nothing for new [key] section */ + /* unbin key if no value given */ + gui_keyboard_unbind (option_name); } - - /* all ok */ - return 0; } /* - * weechat_config_read: read WeeChat configuration file - * return: 0 = successful - * -1 = configuration file file not found - * -2 = error in configuration file - */ - -int -weechat_config_read () -{ - return config_file_read (weechat_config_sections, weechat_config_options, - weechat_config_read_functions, - config_file_read_option, - weechat_config_write_default_functions, - WEECHAT_CONFIG_NAME); -} - -/* - * weechat_config_write_alias: write alias section in configuration file + * config_weechat_write_alias: write alias section in configuration file * Return: 0 = successful * -1 = write error */ -int -weechat_config_write_alias (FILE *file, char *section_name, - struct t_config_option *options) +void +config_weechat_write_alias (struct t_config_file *config_file) { struct alias *ptr_alias; - - /* make C compiler happy */ - (void) options; - - string_iconv_fprintf (file, "\n[%s]\n", section_name); + char *string; for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias) { - string_iconv_fprintf (file, "%s = \"%s\"\n", - ptr_alias->name, ptr_alias->command); + string = (char *)malloc (strlen (ptr_alias->command) + 4); + if (string) + { + strcpy (string, "\""); + strcat (string, ptr_alias->command); + strcat (string, "\""); + config_file_write_line (config_file, + ptr_alias->name, + string); + free (string); + } } - - /* all ok */ - return 0; } /* - * weechat_config_write_keys: write alias section in configuration file + * config_weechat_write_alias_default_values: write alias section with default values + * in configuration file + */ + +void +config_weechat_write_alias_default_values (struct t_config_file *config_file) +{ + config_file_write_line (config_file, "SAY", "\"msg *\""); + config_file_write_line (config_file, "BYE", "\"quit\""); + config_file_write_line (config_file, "EXIT", "\"quit\""); + config_file_write_line (config_file, "SIGNOFF", "\"quit\""); + config_file_write_line (config_file, "C", "\"clear\""); + config_file_write_line (config_file, "CL", "\"clear\""); + config_file_write_line (config_file, "CLOSE", "\"buffer close\""); + config_file_write_line (config_file, "CHAT", "\"dcc chat\""); + config_file_write_line (config_file, "IG", "\"ignore\""); + config_file_write_line (config_file, "J", "\"join\""); + config_file_write_line (config_file, "K", "\"kick\""); + config_file_write_line (config_file, "KB", "\"kickban\""); + config_file_write_line (config_file, "LEAVE", "\"part\""); + config_file_write_line (config_file, "M", "\"msg\""); + config_file_write_line (config_file, "MUB", "\"unban *\""); + config_file_write_line (config_file, "N", "\"names\""); + config_file_write_line (config_file, "Q", "\"query\""); + config_file_write_line (config_file, "T", "\"topic\""); + config_file_write_line (config_file, "UB", "\"unban\""); + config_file_write_line (config_file, "UNIG", "\"unignore\""); + config_file_write_line (config_file, "W", "\"who\""); + config_file_write_line (config_file, "WC", "\"window merge\""); + config_file_write_line (config_file, "WI", "\"whois\""); + config_file_write_line (config_file, "WW", "\"whowas\""); +} + +/* + * config_weechat_write_keys: write alias section in configuration file * Return: 0 = successful * -1 = write error */ -int -weechat_config_write_keys (FILE *file, char *section_name, - struct t_config_option *options) +void +config_weechat_write_keys (struct t_config_file *config_file) { t_gui_key *ptr_key; - char *expanded_name, *function_name; - - /* make C compiler happy */ - (void) options; - - string_iconv_fprintf (file, "\n[%s]\n", section_name); + char *expanded_name, *function_name, *string; for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) { @@ -1112,135 +443,699 @@ weechat_config_write_keys (FILE *file, char *section_name, { function_name = gui_keyboard_function_search_by_ptr (ptr_key->function); if (function_name) - string_iconv_fprintf (file, "%s = \"%s%s%s\"\n", - (expanded_name) ? expanded_name : ptr_key->key, - function_name, - (ptr_key->args) ? " " : "", - (ptr_key->args) ? ptr_key->args : ""); + { + string = (char *)malloc (strlen (function_name) + 8 + + ((ptr_key->args) ? strlen (ptr_key->args) : 0)); + if (string) + { + strcpy (string, "\""); + strcat (string, function_name); + if (ptr_key->args) + { + strcat (string, " "); + strcat (string, ptr_key->args); + } + strcat (string, "\""); + config_file_write_line (config_file, + (expanded_name) ? + expanded_name : ptr_key->key, + string); + free (string); + } + } } else - string_iconv_fprintf (file, "%s = \"%s\"\n", - (expanded_name) ? expanded_name : ptr_key->key, - ptr_key->command); + { + string = (char *)malloc (strlen (ptr_key->command) + 4); + if (string) + { + strcpy (string, "\""); + strcat (string, ptr_key->command); + strcat (string, "\""); + config_file_write_line (config_file, + (expanded_name) ? + expanded_name : ptr_key->key, + string); + free (string); + } + } if (expanded_name) free (expanded_name); } - - /* all ok */ - return 0; } /* - * weechat_config_write_alias_default_values: write alias section with default values - * in configuration file - * Return: 0 = successful - * -1 = write error + * config_weechat_init: init options with default values */ -int -weechat_config_write_alias_default_values (FILE *file, char *section_name, - struct t_config_option *options) +void +config_weechat_init () { - /* make C compiler happy */ - (void) options; + struct t_config_section *section; - string_iconv_fprintf (file, "\n[%s]\n", section_name); - - string_iconv_fprintf (file, "SAY = \"msg *\"\n"); - string_iconv_fprintf (file, "BYE = \"quit\"\n"); - string_iconv_fprintf (file, "EXIT = \"quit\"\n"); - string_iconv_fprintf (file, "SIGNOFF = \"quit\"\n"); - string_iconv_fprintf (file, "C = \"clear\"\n"); - string_iconv_fprintf (file, "CL = \"clear\"\n"); - string_iconv_fprintf (file, "CLOSE = \"buffer close\"\n"); - string_iconv_fprintf (file, "CHAT = \"dcc chat\"\n"); - string_iconv_fprintf (file, "IG = \"ignore\"\n"); - string_iconv_fprintf (file, "J = \"join\"\n"); - string_iconv_fprintf (file, "K = \"kick\"\n"); - string_iconv_fprintf (file, "KB = \"kickban\"\n"); - string_iconv_fprintf (file, "LEAVE = \"part\"\n"); - string_iconv_fprintf (file, "M = \"msg\"\n"); - string_iconv_fprintf (file, "MUB = \"unban *\"\n"); - string_iconv_fprintf (file, "N = \"names\"\n"); - string_iconv_fprintf (file, "Q = \"query\"\n"); - string_iconv_fprintf (file, "T = \"topic\"\n"); - string_iconv_fprintf (file, "UB = \"unban\"\n"); - string_iconv_fprintf (file, "UNIG = \"unignore\"\n"); - string_iconv_fprintf (file, "W = \"who\"\n"); - string_iconv_fprintf (file, "WC = \"window merge\"\n"); - string_iconv_fprintf (file, "WI = \"whois\"\n"); - string_iconv_fprintf (file, "WW = \"whowas\"\n"); - - /* all ok */ - return 0; -} + weechat_config = config_file_new (WEECHAT_CONFIG_FILENAME); + if (weechat_config) + { + /* look */ + section = config_file_new_section (weechat_config, "look", + NULL, NULL, NULL); + if (section) + { + config_look_color_real_white = config_file_new_option_boolean ( + section, "look_color_real_white", + N_("if set, uses real white color, disabled by default " + "for terms with white background (if you never use " + "white background, you should turn on this option to " + "see real white instead of default term foreground " + "color)"), + CONFIG_BOOLEAN_FALSE, &config_change_color); + config_look_save_on_exit = config_file_new_option_boolean ( + section, "look_save_on_exit", + N_("save configuration file on exit"), + CONFIG_BOOLEAN_TRUE, &config_change_save_on_exit); + config_look_set_title = config_file_new_option_boolean ( + section, "look_set_title", + N_("set title for window (terminal for Curses GUI) with " + "name and version"), + CONFIG_BOOLEAN_TRUE, &config_change_title); + config_look_startup_logo = config_file_new_option_boolean ( + section, "look_startup_logo", + N_("display WeeChat logo at startup"), + CONFIG_BOOLEAN_TRUE, NULL); + config_look_startup_version = config_file_new_option_boolean ( + section, "look_startup_version", + N_("display WeeChat version at startup"), + CONFIG_BOOLEAN_TRUE, NULL); + config_look_weechat_slogan = config_file_new_option_string ( + section, "look_weechat_slogan", + N_("WeeChat slogan (if empty, slogan is not used)"), + 0, 0, "the geekest IRC client!", NULL); + config_look_scroll_amount = config_file_new_option_integer ( + section, "look_scroll_amount", + N_("how many lines to scroll by with scroll_up and " + "scroll_down"), + 1, INT_MAX, 3, &config_change_buffer_content); + config_look_buffer_time_format = config_file_new_option_string ( + section, "look_buffer_time_format", + N_("time format for buffers"), + 0, 0, "[%H:%M:%S]", &config_change_buffer_time_format); + config_look_color_nicks_number = config_file_new_option_integer ( + section, "look_color_nicks_number", + N_("number of colors to use for nicks colors"), + 1, 10, 10, &config_change_nicks_colors); + config_look_nicklist = config_file_new_option_boolean ( + section, "look_nicklist", + N_("display nicklist (on buffers with nicklist enabled"), + CONFIG_BOOLEAN_TRUE, &config_change_buffers); + config_look_nicklist_position = config_file_new_option_integer_with_string ( + section, "look_nicklist_position", + N_("nicklist position (top, left, right (default), " + "bottom)"), + "left|right|top|bottom", 1, &config_change_buffers); + config_look_nicklist_min_size = config_file_new_option_integer ( + section, "look_nicklist_min_size", + N_("min size for nicklist (width or height, depending on " + "look_nicklist_position "), + 0, 100, 0, &config_change_buffers); + config_look_nicklist_max_size = config_file_new_option_integer ( + section, "look_nicklist_max_size", + N_("max size for nicklist (width or height, depending on " + "look_nicklist_position (0 = no max size; if min = max " + "and > 0, then size is fixed))"), + 0, 100, 0, &config_change_buffers); + config_look_nicklist_separator = config_file_new_option_boolean ( + section, "look_nicklist_separator", + N_("separator between chat and nicklist"), + CONFIG_BOOLEAN_TRUE, &config_change_buffers); + config_look_nickmode = config_file_new_option_boolean ( + section, "look_nickmode", + N_("display nick mode ((half)op/voice) before each nick"), + CONFIG_BOOLEAN_TRUE, &config_change_buffers); + config_look_nickmode_empty = config_file_new_option_boolean ( + section, "look_nickmode_empty", + N_("display space if nick mode is not (half)op/voice"), + CONFIG_BOOLEAN_FALSE, &config_change_buffers); + config_look_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option_string ( + section, "look_prefix_info", + N_("prefix for info messages"), + 0, 0, "-=-", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option_string ( + section, "look_prefix_error", + N_("prefix for error messages"), + 0, 0, "=!=", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option_string ( + section, "look_prefix_network", + N_("prefix for network messages"), + 0, 0, "-@-", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option_string ( + section, "look_prefix_action", + N_("prefix for action messages"), + 0, 0, "-*-", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option_string ( + section, "look_prefix_join", + N_("prefix for join messages"), + 0, 0, "-->", &config_change_prefix); + config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option_string ( + section, "look_prefix_quit", + N_("prefix for quit messages"), + 0, 0, "<--", &config_change_prefix); + config_look_prefix_align = config_file_new_option_integer_with_string ( + section, "look_prefix_align", + N_("prefix alignment (none, left, right (default))"), + "none|left|right", 2, &config_change_buffers); + config_look_prefix_align_max = config_file_new_option_integer ( + section, "look_prefix_align_max", + N_("max size for prefix (0 = no max size)"), + 0, 64, 0, &config_change_buffers); + config_look_prefix_suffix = config_file_new_option_string ( + section, "look_prefix_suffix", + N_("string displayed after prefix"), + 0, 0, "|", &config_change_buffers); + config_look_nick_completor = config_file_new_option_string ( + section, "look_nick_completor", + N_("the string inserted after nick completion"), + 0, 0, ":", NULL); + config_look_nick_completion_ignore = config_file_new_option_string ( + section, "look_nick_completion_ignore", + N_("chars ignored for nick completion"), + 0, 0, "[]-^", NULL); + config_look_nick_completion_smart = config_file_new_option_boolean ( + section, "look_nick_completion_smart", + N_("smart completion for nicks (completes with last speakers first)"), + CONFIG_BOOLEAN_TRUE, NULL); + config_look_nick_complete_first = config_file_new_option_boolean ( + section, "look_nick_complete_first", + N_("complete only with first nick found"), + CONFIG_BOOLEAN_FALSE, NULL); + config_look_infobar = config_file_new_option_boolean ( + section, "look_infobar", + N_("enable info bar"), + CONFIG_BOOLEAN_TRUE, &config_change_buffers); + config_look_infobar_time_format = config_file_new_option_string ( + section, "look_infobar_time_format", + N_("time format for time in infobar"), + 0, 0, "%B, %A %d %Y", &config_change_buffer_content); + config_look_infobar_seconds = config_file_new_option_boolean ( + section, "look_infobar_seconds", + N_("display seconds in infobar time"), + CONFIG_BOOLEAN_TRUE, &config_change_buffer_content); + config_look_infobar_delay_highlight = config_file_new_option_integer ( + section, "look_infobar_delay_highlight", + N_("delay (in seconds) for highlight messages in " + "infobar (0 = disable highlight notifications in " + "infobar)"), + 0, INT_MAX, 7, NULL); + config_look_hotlist_names_count = config_file_new_option_integer ( + section, "look_hotlist_names_count", + N_("max number of names in hotlist (0 = no name " + "displayed, only buffer numbers)"), + 0, 32, 3, &config_change_buffer_content); + config_look_hotlist_names_level = config_file_new_option_integer ( + section, "look_hotlist_names_level", + N_("level for displaying names in hotlist (combination " + "of: 1=join/part, 2=message, 4=private, 8=highlight, " + "for example: 12=private+highlight)"), + 1, 15, 12, &config_change_buffer_content); + config_look_hotlist_names_length = config_file_new_option_integer ( + section, "look_hotlist_names_length", + N_("max length of names in hotlist (0 = no limit)"), + 0, 32, 0, &config_change_buffer_content); + config_look_hotlist_sort = config_file_new_option_integer_with_string ( + section, "look_hotlist_sort", + N_("hotlist sort type (group_time_asc (default), " + "group_time_desc, group_number_asc, group_number_desc, " + "number_asc, number_desc)"), + "group_time_asc|group_time_desc|group_number_asc|" + "group_number_desc|number_asc|number_desc", + 0, &config_change_hotlist); + config_look_day_change = config_file_new_option_boolean ( + section, "look_day_change", + N_("display special message when day changes"), + CONFIG_BOOLEAN_TRUE, NULL); + config_look_day_change_time_format = config_file_new_option_string ( + section, "look_day_change_time_format", + N_("time format for date displayed when day changed"), + 0, 0, "%a, %d %b %Y", NULL); + config_look_read_marker = config_file_new_option_string ( + section, "look_read_marker", + N_("use a marker on servers/channels to show first unread " + "line"), + 0, 1, " ", &config_change_read_marker); + config_look_input_format = config_file_new_option_string ( + section, "look_input_format", + N_("format for input prompt ('%c' is replaced by channel " + "or server, '%n' by nick and '%m' by nick modes)"), + 0, 0, "[%n(%m)] ", &config_change_buffer_content); + config_look_paste_max_lines = config_file_new_option_integer ( + section, "look_paste_max_lines", + N_("max number of lines for paste without asking user " + "(0 = disable this feature)"), + 0, INT_MAX, 3, NULL); + } + + /* colors */ + section = config_file_new_section (weechat_config, "colors", + NULL, NULL, NULL); + if (section) + { + /* general color settings */ + config_color_separator = config_file_new_option_color ( + section, "color_separator", + N_("color for window separators (when splited)"), + GUI_COLOR_SEPARATOR, "blue", &config_change_color); + /* title window */ + config_color_title = config_file_new_option_color ( + section, "color_title", + N_("color for title bar"), + GUI_COLOR_TITLE, "default", &config_change_color); + config_color_title_bg = config_file_new_option_color ( + section, "color_title_bg", + N_("background color for title bar"), + -1, "blue", &config_change_color); + config_color_title_more = config_file_new_option_color ( + section, "color_title_more", + N_("color for '+' when scrolling title"), + GUI_COLOR_TITLE_MORE, "lightmagenta", &config_change_color); + /* chat window */ + config_color_chat = config_file_new_option_color ( + section, "color_chat", + N_("color for chat text"), + GUI_COLOR_CHAT, "default", &config_change_color); + config_color_chat_bg = config_file_new_option_color ( + section, "color_chat_bg", + N_("background for chat text"), + -1, "default", &config_change_color); + config_color_chat_time = config_file_new_option_color ( + section, "color_chat_time", + N_("color for time in chat window"), + GUI_COLOR_CHAT_TIME, "default", &config_change_color); + config_color_chat_time_delimiters = config_file_new_option_color ( + section, "color_chat_time_delimiters", + N_("color for time delimiters)"), + GUI_COLOR_CHAT_TIME_DELIMITERS, "brown", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_INFO] = config_file_new_option_color ( + section, "color_chat_prefix_info", + N_("color for info prefix"), + GUI_COLOR_CHAT_PREFIX_INFO, "lightcyan", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option_color ( + section, "color_chat_prefix_error", + N_("color for error prefix"), + GUI_COLOR_CHAT_PREFIX_ERROR, "yellow", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option_color ( + section, "color_chat_prefix_network", + N_("color for network prefix"), + GUI_COLOR_CHAT_PREFIX_NETWORK, "lightmagenta", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option_color ( + section, "color_chat_prefix_action", + N_("color for action prefix"), + GUI_COLOR_CHAT_PREFIX_ACTION, "white", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option_color ( + section, "color_chat_prefix_join", + N_("color for join prefix"), + GUI_COLOR_CHAT_PREFIX_JOIN, "lightgreen", &config_change_color); + config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option_color ( + section, "color_chat_prefix_quit", + N_("color for quit prefix"), + GUI_COLOR_CHAT_PREFIX_QUIT, "lightred", &config_change_color); + config_color_chat_prefix_more = config_file_new_option_color ( + section, "color_chat_prefix_more", + N_("color for '+' when prefix is too long"), + GUI_COLOR_CHAT_PREFIX_MORE, "lightmagenta", &config_change_color); + config_color_chat_prefix_suffix = config_file_new_option_color ( + section, "color_chat_prefix_suffix", + N_("color for text after prefix"), + GUI_COLOR_CHAT_PREFIX_SUFFIX, "green", &config_change_color); + config_color_chat_buffer = config_file_new_option_color ( + section, "color_chat_buffer", + N_("color for buffer names"), + GUI_COLOR_CHAT_BUFFER, "white", &config_change_color); + config_color_chat_server = config_file_new_option_color ( + section, "color_chat_server", + N_("color for server names"), + GUI_COLOR_CHAT_SERVER, "brown", &config_change_color); + config_color_chat_channel = config_file_new_option_color ( + section, "color_chat_channel", + N_("color for channel names"), + GUI_COLOR_CHAT_CHANNEL, "white", &config_change_color); + config_color_chat_nick = config_file_new_option_color ( + section, "color_chat_nick", + N_("color for nicks"), + GUI_COLOR_CHAT_NICK, "lightcyan", &config_change_color); + config_color_chat_nick_self = config_file_new_option_color ( + section, "color_chat_nick_self", + N_("color for local nick"), + GUI_COLOR_CHAT_NICK_SELF, "white", &config_change_color); + config_color_chat_nick_other = config_file_new_option_color ( + section, "color_chat_nick_other", + N_("color for other nick in private buffer"), + GUI_COLOR_CHAT_NICK_OTHER, "default", &config_change_color); + config_color_chat_nick_colors[0] = config_file_new_option_color ( + section, "color_chat_nick_color1", + N_("color #1 for nick"), + GUI_COLOR_CHAT_NICK1, "cyan", &config_change_color); + config_color_chat_nick_colors[1] = config_file_new_option_color ( + section, "color_chat_nick_color2", + N_("color #2 for nick"), + GUI_COLOR_CHAT_NICK2, "magenta", &config_change_color); + config_color_chat_nick_colors[2] = config_file_new_option_color ( + section, "color_chat_nick_color3", + N_("color #3 for nick"), + GUI_COLOR_CHAT_NICK3, "green", &config_change_color); + config_color_chat_nick_colors[3] = config_file_new_option_color ( + section, "color_chat_nick_color4", + N_("color #4 for nick"), + GUI_COLOR_CHAT_NICK4, "brown", &config_change_color); + config_color_chat_nick_colors[4] = config_file_new_option_color ( + section, "color_chat_nick_color5", + N_("color #5 for nick"), + GUI_COLOR_CHAT_NICK5, "lightblue", &config_change_color); + config_color_chat_nick_colors[5] = config_file_new_option_color ( + section, "color_chat_nick_color6", + N_("color #6 for nick"), + GUI_COLOR_CHAT_NICK6, "default", &config_change_color); + config_color_chat_nick_colors[6] = config_file_new_option_color ( + section, "color_chat_nick_color7", + N_("color #7 for nick"), + GUI_COLOR_CHAT_NICK7, "lightcyan", &config_change_color); + config_color_chat_nick_colors[7] = config_file_new_option_color ( + section, "color_chat_nick_color8", + N_("color #8 for nick"), + GUI_COLOR_CHAT_NICK8, "lightmagenta", &config_change_color); + config_color_chat_nick_colors[8] = config_file_new_option_color ( + section, "color_chat_nick_color9", + N_("color #9 for nick"), + GUI_COLOR_CHAT_NICK9, "lightgreen", &config_change_color); + config_color_chat_nick_colors[9] = config_file_new_option_color ( + section, "color_chat_nick_color10", + N_("color #10 for nick"), + GUI_COLOR_CHAT_NICK10, "blue", &config_change_color); + config_color_chat_host = config_file_new_option_color ( + section, "color_chat_host", + N_("color for hostnames"), + GUI_COLOR_CHAT_HOST, "cyan", &config_change_color); + config_color_chat_delimiters = config_file_new_option_color ( + section, "color_chat_delimiters", + N_("color for delimiters"), + GUI_COLOR_CHAT_DELIMITERS, "green", &config_change_color); + config_color_chat_highlight = config_file_new_option_color ( + section, "color_chat_highlight", + N_("color for highlighted nick"), + GUI_COLOR_CHAT_HIGHLIGHT, "yellow", &config_change_color); + config_color_chat_read_marker = config_file_new_option_color ( + section, "color_chat_read_marker", + N_("color for unread data marker"), + GUI_COLOR_CHAT_READ_MARKER, "yellow", &config_change_color); + config_color_chat_read_marker_bg = config_file_new_option_color ( + section, "color_chat_read_marker_bg", + N_("background color for unread data marker"), + -1, "magenta", &config_change_color); + /* status window */ + config_color_status = config_file_new_option_color ( + section, "color_status", + N_("color for status bar"), + GUI_COLOR_STATUS, "default", &config_change_color); + config_color_status_bg = config_file_new_option_color ( + section, "color_status_bg", + N_("background color for status bar"), + -1, "blue", &config_change_color); + config_color_status_delimiters = config_file_new_option_color ( + section, "color_status_delimiters", + N_("color for status bar delimiters"), + GUI_COLOR_STATUS_DELIMITERS, "cyan", &config_change_color); + config_color_status_channel = config_file_new_option_color ( + section, "color_status_channel", + N_("color for current channel in status bar"), + GUI_COLOR_STATUS_CHANNEL, "white", &config_change_color); + config_color_status_data_msg = config_file_new_option_color ( + section, "color_status_data_msg", + N_("color for window with new messages (status bar)"), + GUI_COLOR_STATUS_DATA_MSG, "yellow", &config_change_color); + config_color_status_data_private = config_file_new_option_color ( + section, "color_status_data_private", + N_("color for window with private message (status bar)"), + GUI_COLOR_STATUS_DATA_PRIVATE, "lightgreen", &config_change_color); + config_color_status_data_highlight = config_file_new_option_color ( + section, "color_status_data_highlight", + N_("color for window with highlight (status bar)"), + GUI_COLOR_STATUS_DATA_HIGHLIGHT, "lightmagenta", &config_change_color); + config_color_status_data_other = config_file_new_option_color ( + section, "color_status_data_other", + N_("color for window with new data (not messages) " + "(status bar)"), + GUI_COLOR_STATUS_DATA_OTHER, "default", &config_change_color); + config_color_status_more = config_file_new_option_color ( + section, "color_status_more", + N_("color for window with new data (status bar)"), + GUI_COLOR_STATUS_MORE, "white", &config_change_color); + /* infobar window */ + config_color_infobar = config_file_new_option_color ( + section, "color_infobar", + N_("color for infobar text"), + GUI_COLOR_INFOBAR, "black", &config_change_color); + config_color_infobar_bg = config_file_new_option_color ( + section, "color_infobar_bg", + N_("background color for info bar text"), + -1, "cyan", &config_change_color); + config_color_infobar_delimiters = config_file_new_option_color ( + section, "color_infobar_delimiters", + N_("color for infobar delimiters"), + GUI_COLOR_INFOBAR_DELIMITERS, "blue", &config_change_color); + config_color_infobar_highlight = config_file_new_option_color ( + section, "color_infobar_highlight", + N_("color for infobar highlight notification"), + GUI_COLOR_INFOBAR_HIGHLIGHT, "white", &config_change_color); + /* input window */ + config_color_input = config_file_new_option_color ( + section, "color_input", + N_("color for input text"), + GUI_COLOR_INPUT, "default", &config_change_color); + config_color_input_bg = config_file_new_option_color ( + section, "color_input_bg", + N_("background color for input text"), + -1, "default", &config_change_color); + config_color_input_server = config_file_new_option_color ( + section, "color_input_server", + N_("color for input text (server name)"), + GUI_COLOR_INPUT_SERVER, "brown", &config_change_color); + config_color_input_channel = config_file_new_option_color ( + section, "color_input_channel", + N_("color for input text (channel name)"), + GUI_COLOR_INPUT_CHANNEL, "white", &config_change_color); + config_color_input_nick = config_file_new_option_color ( + section, "color_input_nick", + N_("color for input text (nick name)"), + GUI_COLOR_INPUT_NICK, "lightcyan", &config_change_color); + config_color_input_delimiters = config_file_new_option_color ( + section, "color_input_delimiters", + N_("color for input text (delimiters)"), + GUI_COLOR_INPUT_DELIMITERS, "cyan", &config_change_color); + config_color_input_text_not_found = config_file_new_option_color ( + section, "color_input_text_not_found", + N_("color for text not found"), + GUI_COLOR_INPUT_TEXT_NOT_FOUND, "red", &config_change_color); + config_color_input_actions = config_file_new_option_color ( + section, "color_input_actions", + N_("color for actions in input window"), + GUI_COLOR_INPUT_ACTIONS, "lightgreen", &config_change_color); + /* nicklist window */ + config_color_nicklist = config_file_new_option_color ( + section, "color_nicklist", + N_("color for nicklist"), + GUI_COLOR_NICKLIST, "default", &config_change_color); + config_color_nicklist_bg = config_file_new_option_color ( + section, "color_nicklist_bg", + N_("background color for nicklist"), + -1, "default", &config_change_color); + config_color_nicklist_away = config_file_new_option_color ( + section, "color_nicklist_away", + N_("color for away nicknames"), + GUI_COLOR_NICKLIST_AWAY, "cyan", &config_change_color); + config_color_nicklist_prefix1 = config_file_new_option_color ( + section, "color_nicklist_prefix1", + N_("color for prefix 1"), + GUI_COLOR_NICKLIST_PREFIX1, "lightgreen", &config_change_color); + config_color_nicklist_prefix2 = config_file_new_option_color ( + section, "color_nicklist_prefix2", + N_("color for prefix 2"), + GUI_COLOR_NICKLIST_PREFIX2, "lightmagenta", &config_change_color); + config_color_nicklist_prefix3 = config_file_new_option_color ( + section, "color_nicklist_prefix3", + N_("color for prefix 3"), + GUI_COLOR_NICKLIST_PREFIX3, "yellow", &config_change_color); + config_color_nicklist_prefix4 = config_file_new_option_color ( + section, "color_nicklist_prefix4", + N_("color for prefix 4"), + GUI_COLOR_NICKLIST_PREFIX4, "blue", &config_change_color); + config_color_nicklist_prefix5 = config_file_new_option_color ( + section, "color_nicklist_prefix5", + N_("color for prefix 5"), + GUI_COLOR_NICKLIST_PREFIX5, "brown", &config_change_color); + config_color_nicklist_more = config_file_new_option_color ( + section, "color_nicklist_more", + N_("color for '+' when scrolling nicks (nicklist)"), + GUI_COLOR_NICKLIST_MORE, "lightmagenta", &config_change_color); + config_color_nicklist_separator = config_file_new_option_color ( + section, "color_nicklist_separator", + N_("color for nicklist separator"), + GUI_COLOR_NICKLIST_SEPARATOR, "blue", &config_change_color); + /* status info */ + config_color_info = config_file_new_option_color ( + section, "color_info", + N_("color for status info"), + GUI_COLOR_INFO, "default", &config_change_color); + config_color_info_bg = config_file_new_option_color ( + section, "color_info_bg", + N_("background color for status info"), + -1, "default", &config_change_color); + config_color_info_waiting = config_file_new_option_color ( + section, "color_info_waiting", + N_("color for \"waiting\" status info"), + GUI_COLOR_INFO_WAITING, "lightcyan", &config_change_color); + config_color_info_connecting = config_file_new_option_color ( + section, "color_info_connecting", + N_("color for \"connecting\" status info"), + GUI_COLOR_INFO_CONNECTING, "yellow", &config_change_color); + config_color_info_active = config_file_new_option_color ( + section, "color_info_active", + N_("color for \"active\" status info"), + GUI_COLOR_INFO_ACTIVE, "lightblue", &config_change_color); + config_color_info_done = config_file_new_option_color ( + section, "color_info_done", + N_("color for \"done\" status info"), + GUI_COLOR_INFO_DONE, "lightgreen", &config_change_color); + config_color_info_failed = config_file_new_option_color ( + section, "color_info_failed", + N_("color for \"failed\" status info"), + GUI_COLOR_INFO_FAILED, "lightred", &config_change_color); + config_color_info_aborted = config_file_new_option_color ( + section, "color_info_aborted", + N_("color for \"aborted\" status info"), + GUI_COLOR_INFO_ABORTED, "lightred", &config_change_color); + } -/* - * weechat_config_write_keys_default_values: write keys section with default values - * in configuration file - * Return: 0 = successful - * -1 = write error - */ + /* history */ + section = config_file_new_section (weechat_config, "history", + NULL, NULL, NULL); + if (section) + { + config_history_max_lines = config_file_new_option_integer ( + section, "history_max_lines", + N_("maximum number of lines in history per buffer " + "(0 = unlimited)"), + 0, INT_MAX, 4096, NULL); + config_history_max_commands = config_file_new_option_integer ( + section, "history_max_commands", + N_("maximum number of user commands in history (0 = " + "unlimited)"), + 0, INT_MAX, 100, NULL); + config_history_display_default = config_file_new_option_integer ( + section, "history_display_default", + N_("maximum number of commands to display by default in " + "history listing (0 = unlimited)"), + 0, INT_MAX, 5, NULL); + } -int -weechat_config_write_keys_default_values (FILE *file, char *section_name, - struct t_config_option *options) -{ - t_gui_key *ptr_key; - char *expanded_name, *function_name; - - /* make C compiler happy */ - (void) options; - - string_iconv_fprintf (file, "\n[%s]\n", section_name); - - for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) - { - expanded_name = gui_keyboard_get_expanded_name (ptr_key->key); - if (ptr_key->function) + /* proxy */ + section = config_file_new_section (weechat_config, "proxy", + NULL, NULL, NULL); + if (section) { - function_name = gui_keyboard_function_search_by_ptr (ptr_key->function); - if (function_name) - string_iconv_fprintf (file, "%s = \"%s%s%s\"\n", - (expanded_name) ? expanded_name : ptr_key->key, - function_name, - (ptr_key->args) ? " " : "", - (ptr_key->args) ? ptr_key->args : ""); + config_proxy_use = config_file_new_option_boolean ( + section, "proxy_use", + N_("use a proxy server"), + CONFIG_BOOLEAN_FALSE, NULL); + config_proxy_type = config_file_new_option_integer_with_string ( + section, "proxy_type", + N_("proxy type (http (default), socks4, socks5)"), + "http|socks4|socks5", 0, NULL); + config_proxy_ipv6 = config_file_new_option_boolean ( + section, "proxy_ipv6", + N_("connect to proxy using ipv6"), + CONFIG_BOOLEAN_FALSE, NULL); + config_proxy_address = config_file_new_option_string ( + section, "proxy_address", + N_("proxy server address (IP or hostname)"), + 0, 0, "", NULL); + config_proxy_port = config_file_new_option_integer ( + section, "proxy_port", + N_("port for connecting to proxy server"), + 0, 65535, 3128, NULL); + config_proxy_username = config_file_new_option_string ( + section, "proxy_username", + N_("username for proxy server"), + 0, 0, "", NULL); + config_proxy_password = config_file_new_option_string ( + section, "proxy_password", + N_("password for proxy server"), + 0, 0, "", NULL); } - else - string_iconv_fprintf (file, "%s = \"%s\"\n", - (expanded_name) ? expanded_name : ptr_key->key, - ptr_key->command); - if (expanded_name) - free (expanded_name); + + /* plugins */ + section = config_file_new_section (weechat_config, "plugins", + NULL, NULL, NULL); + if (section) + { + config_plugins_path = config_file_new_option_string ( + section, "plugins_path", + N_("path for searching plugins ('%h' will be replaced by " + "WeeChat home, ~/.weechat by default)"), + 0, 0, "%h/plugins", NULL); + config_plugins_autoload = config_file_new_option_string ( + section, "plugins_autoload", + N_("comma separated list of plugins to load automatically " + "at startup, \"*\" means all plugins found (names may " + "be partial, for example \"perl\" is ok for " + "\"perl.so\")"), + 0, 0, "*", NULL); + config_plugins_extension = config_file_new_option_string ( + section, "plugins_extension", + N_("standard plugins extension in filename (for example " + "\".so\" under Linux or \".dll\" under Windows)"), + 0, 0, +#ifdef WIN32 + ".dll", +#else + ".so", +#endif + NULL); + } + + /* alias */ + section = config_file_new_section (weechat_config, "alias", + &config_weechat_read_alias, + &config_weechat_write_alias, + &config_weechat_write_alias_default_values); + + /* keys */ + section = config_file_new_section (weechat_config, "keys", + &config_weechat_read_key, + &config_weechat_write_keys, + &config_weechat_write_keys); } - - /* all ok */ - return 0; } /* - * weechat_config_write: write WeeChat configuration file - * return: 0 if ok - * < 0 if error + * config_weechat_read: read WeeChat configuration file + * return: 0 = successful + * -1 = configuration file file not found + * -2 = error in configuration file */ int -weechat_config_write () +config_weechat_read () { - log_printf (_("Saving WeeChat configuration to disk\n")); - return config_file_write (weechat_config_sections, weechat_config_options, - weechat_config_write_functions, - WEECHAT_CONFIG_NAME); + return config_file_read (weechat_config); } /* - * weechat_config_print_stdout: print WeeChat options on standard output + * config_weechat_write: write WeeChat configuration file + * return: 0 if ok + * < 0 if error */ -void -weechat_config_print_stdout () +int +config_weechat_write () { - config_option_print_stdout (weechat_config_sections, - weechat_config_options); + log_printf (_("Saving WeeChat configuration to disk\n")); + return config_file_write (weechat_config, 0); } diff --git a/src/core/wee-config.h b/src/core/wee-config.h index ac62dbe32..d7ac9748a 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -20,183 +20,165 @@ #ifndef __WEECHAT_CONFIG_H #define __WEECHAT_CONFIG_H 1 -#include "wee-config-option.h" #include "wee-config-file.h" -#include "../gui/gui-chat.h" -#include "../gui/gui-color.h" - -#define WEECHAT_CONFIG_NAME "weechat.rc" - -#define CFG_LOOK_NICKLIST_LEFT 0 -#define CFG_LOOK_NICKLIST_RIGHT 1 -#define CFG_LOOK_NICKLIST_TOP 2 -#define CFG_LOOK_NICKLIST_BOTTOM 3 - -#define CFG_LOOK_PREFIX_ALIGN_NONE 0 -#define CFG_LOOK_PREFIX_ALIGN_LEFT 1 -#define CFG_LOOK_PREFIX_ALIGN_RIGHT 2 - -#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0 -#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1 -#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2 -#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3 -#define CFG_LOOK_HOTLIST_SORT_NUMBER_ASC 4 -#define CFG_LOOK_HOTLIST_SORT_NUMBER_DESC 5 - -extern struct t_config_option weechat_options_look[]; -extern int cfg_look_color_real_white; -extern int cfg_look_save_on_exit; -extern int cfg_look_set_title; -extern int cfg_look_startup_logo; -extern int cfg_look_startup_version; -extern char *cfg_look_weechat_slogan; -extern int cfg_look_one_server_buffer; -extern int cfg_look_open_near_server; -extern int cfg_look_scroll_amount; -extern char *cfg_look_buffer_time_format; -extern int cfg_look_color_nicks_number; -extern int cfg_look_color_actions; -extern int cfg_look_nicklist; -extern int cfg_look_nicklist_position; -extern int cfg_look_nicklist_min_size; -extern int cfg_look_nicklist_max_size; -extern int cfg_look_nicklist_separator; -extern int cfg_look_nickmode; -extern int cfg_look_nickmode_empty; -extern char *cfg_look_no_nickname; -extern char *cfg_look_prefix[GUI_CHAT_PREFIX_NUMBER]; -extern int cfg_look_prefix_align; -extern int cfg_look_prefix_align_max; -extern char *cfg_look_prefix_suffix; -extern int cfg_look_align_text_offset; -extern char *cfg_look_nick_completor; -extern char *cfg_look_nick_completion_ignore; -extern int cfg_look_nick_completion_smart; -extern int cfg_look_nick_complete_first; -extern int cfg_look_infobar; -extern char *cfg_look_infobar_time_format; -extern int cfg_look_infobar_seconds; -extern int cfg_look_infobar_delay_highlight; -extern int cfg_look_hotlist_names_count; -extern int cfg_look_hotlist_names_level; -extern int cfg_look_hotlist_names_length; -extern int cfg_look_hotlist_sort; -extern int cfg_look_day_change; -extern char *cfg_look_day_change_time_format; -extern char *cfg_look_read_marker; -extern char *cfg_look_input_format; -extern int cfg_look_paste_max_lines; - -extern struct t_config_option weechat_options_colors[]; -extern int cfg_col_separator; -extern int cfg_col_title; -extern int cfg_col_title_bg; -extern int cfg_col_title_more; -extern int cfg_col_chat; -extern int cfg_col_chat_bg; -extern int cfg_col_chat_time; -extern int cfg_col_chat_time_delimiters; -extern int cfg_col_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; -extern int cfg_col_chat_prefix_more; -extern int cfg_col_chat_prefix_suffix; -extern int cfg_col_chat_buffer; -extern int cfg_col_chat_server; -extern int cfg_col_chat_channel; -extern int cfg_col_chat_nick; -extern int cfg_col_chat_nick_self; -extern int cfg_col_chat_nick_other; -extern int cfg_col_chat_nick_colors[GUI_COLOR_NICK_NUMBER]; -extern int cfg_col_chat_host; -extern int cfg_col_chat_delimiters; -extern int cfg_col_chat_highlight; -extern int cfg_col_chat_read_marker; -extern int cfg_col_chat_read_marker_bg; -extern int cfg_col_status; -extern int cfg_col_status_bg; -extern int cfg_col_status_delimiters; -extern int cfg_col_status_channel; -extern int cfg_col_status_data_msg; -extern int cfg_col_status_data_private; -extern int cfg_col_status_data_highlight; -extern int cfg_col_status_data_other; -extern int cfg_col_status_more; -extern int cfg_col_infobar; -extern int cfg_col_infobar_bg; -extern int cfg_col_infobar_delimiters; -extern int cfg_col_infobar_highlight; -extern int cfg_col_infobar_bg; -extern int cfg_col_input; -extern int cfg_col_input_bg; -extern int cfg_col_input_server; -extern int cfg_col_input_channel; -extern int cfg_col_input_nick; -extern int cfg_col_input_delimiters; -extern int cfg_col_input_text_not_found; -extern int cfg_col_input_actions; -extern int cfg_col_nicklist; -extern int cfg_col_nicklist_bg; -extern int cfg_col_nicklist_away; -extern int cfg_col_nicklist_prefix1; -extern int cfg_col_nicklist_prefix2; -extern int cfg_col_nicklist_prefix3; -extern int cfg_col_nicklist_prefix4; -extern int cfg_col_nicklist_prefix5; -extern int cfg_col_nicklist_more; -extern int cfg_col_nicklist_separator; -extern int cfg_col_info; -extern int cfg_col_info_bg; -extern int cfg_col_info_waiting; -extern int cfg_col_info_connecting; -extern int cfg_col_info_active; -extern int cfg_col_info_done; -extern int cfg_col_info_failed; -extern int cfg_col_info_aborted; - -extern struct t_config_option weechat_options_history[]; -extern int cfg_history_max_lines; -extern int cfg_history_max_commands; -extern int cfg_history_display_default; - -extern struct t_config_option weechat_options_proxy[]; -extern int cfg_proxy_use; -extern int cfg_proxy_type; -extern char *cfg_proxy_type_values[]; -extern int cfg_proxy_ipv6; -extern char *cfg_proxy_address; -extern int cfg_proxy_port; -extern char *cfg_proxy_username; -extern char *cfg_proxy_password; - -extern struct t_config_option weechat_options_plugins[]; -extern char *cfg_plugins_path; -extern char *cfg_plugins_autoload; -extern char *cfg_plugins_extension; - -extern char *weechat_config_sections[]; -extern struct t_config_option *weechat_config_options[]; - -extern void weechat_config_change_noop (); -extern void weechat_config_change_save_on_exit (); -extern void weechat_config_change_title (); -extern void weechat_config_change_buffers (); -extern void weechat_config_change_buffer_content (); -extern void weechat_config_change_buffer_time_format (); -extern void weechat_config_change_hotlist (); -extern void weechat_config_change_read_marker (); -extern void weechat_config_change_prefix (); -extern void weechat_config_change_color (); -extern void weechat_config_change_nicks_colors (); - -extern int weechat_config_read_alias (struct t_config_option *, char *, char *); -extern int weechat_config_read_key (struct t_config_option *, char *, char *); -extern int weechat_config_read (); -extern int weechat_config_write_alias (FILE *, char *, struct t_config_option *); -extern int weechat_config_write_keys (FILE *, char *, struct t_config_option *); -extern int weechat_config_write_alias_default_values (FILE *, char *, - struct t_config_option *); -extern int weechat_config_write_keys_default_values (FILE *, char *, - struct t_config_option *); -extern int weechat_config_write (); -extern void weechat_config_print_stdout (); + +#define WEECHAT_CONFIG_FILENAME "weechat.rc" + +#define CONFIG_LOOK_NICKLIST_LEFT 0 +#define CONFIG_LOOK_NICKLIST_RIGHT 1 +#define CONFIG_LOOK_NICKLIST_TOP 2 +#define CONFIG_LOOK_NICKLIST_BOTTOM 3 + +#define CONFIG_LOOK_PREFIX_ALIGN_NONE 0 +#define CONFIG_LOOK_PREFIX_ALIGN_LEFT 1 +#define CONFIG_LOOK_PREFIX_ALIGN_RIGHT 2 + +#define CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0 +#define CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1 +#define CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2 +#define CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3 +#define CONFIG_LOOK_HOTLIST_SORT_NUMBER_ASC 4 +#define CONFIG_LOOK_HOTLIST_SORT_NUMBER_DESC 5 + +extern struct t_config_file *weechat_config; + +extern struct t_config_option *config_look_color_real_white; +extern struct t_config_option *config_look_save_on_exit; +extern struct t_config_option *config_look_set_title; +extern struct t_config_option *config_look_startup_logo; +extern struct t_config_option *config_look_startup_version; +extern struct t_config_option *config_look_weechat_slogan; +extern struct t_config_option *config_look_one_server_buffer; +extern struct t_config_option *config_look_open_near_server; +extern struct t_config_option *config_look_scroll_amount; +extern struct t_config_option *config_look_buffer_time_format; +extern struct t_config_option *config_look_color_nicks_number; +extern struct t_config_option *config_look_color_actions; +extern struct t_config_option *config_look_nicklist; +extern struct t_config_option *config_look_nicklist_position; +extern struct t_config_option *config_look_nicklist_min_size; +extern struct t_config_option *config_look_nicklist_max_size; +extern struct t_config_option *config_look_nicklist_separator; +extern struct t_config_option *config_look_nickmode; +extern struct t_config_option *config_look_nickmode_empty; +extern struct t_config_option *config_look_no_nickname; +extern struct t_config_option *config_look_prefix[]; +extern struct t_config_option *config_look_prefix_align; +extern struct t_config_option *config_look_prefix_align_max; +extern struct t_config_option *config_look_prefix_suffix; +extern struct t_config_option *config_look_nick_completor; +extern struct t_config_option *config_look_nick_completion_ignore; +extern struct t_config_option *config_look_nick_completion_smart; +extern struct t_config_option *config_look_nick_complete_first; +extern struct t_config_option *config_look_infobar; +extern struct t_config_option *config_look_infobar_time_format; +extern struct t_config_option *config_look_infobar_seconds; +extern struct t_config_option *config_look_infobar_delay_highlight; +extern struct t_config_option *config_look_hotlist_names_count; +extern struct t_config_option *config_look_hotlist_names_level; +extern struct t_config_option *config_look_hotlist_names_length; +extern struct t_config_option *config_look_hotlist_sort; +extern struct t_config_option *config_look_day_change; +extern struct t_config_option *config_look_day_change_time_format; +extern struct t_config_option *config_look_read_marker; +extern struct t_config_option *config_look_input_format; +extern struct t_config_option *config_look_paste_max_lines; + +extern struct t_config_option *config_color_separator; +extern struct t_config_option *config_color_title; +extern struct t_config_option *config_color_title_bg; +extern struct t_config_option *config_color_title_more; +extern struct t_config_option *config_color_chat; +extern struct t_config_option *config_color_chat_bg; +extern struct t_config_option *config_color_chat_time; +extern struct t_config_option *config_color_chat_time_delimiters; +extern struct t_config_option *config_color_chat_prefix[]; +extern struct t_config_option *config_color_chat_prefix_more; +extern struct t_config_option *config_color_chat_prefix_suffix; +extern struct t_config_option *config_color_chat_buffer; +extern struct t_config_option *config_color_chat_server; +extern struct t_config_option *config_color_chat_channel; +extern struct t_config_option *config_color_chat_nick; +extern struct t_config_option *config_color_chat_nick_self; +extern struct t_config_option *config_color_chat_nick_other; +extern struct t_config_option *config_color_chat_nick_colors[]; +extern struct t_config_option *config_color_chat_host; +extern struct t_config_option *config_color_chat_delimiters; +extern struct t_config_option *config_color_chat_highlight; +extern struct t_config_option *config_color_chat_read_marker; +extern struct t_config_option *config_color_chat_read_marker_bg; +extern struct t_config_option *config_color_status; +extern struct t_config_option *config_color_status_bg; +extern struct t_config_option *config_color_status_delimiters; +extern struct t_config_option *config_color_status_channel; +extern struct t_config_option *config_color_status_data_msg; +extern struct t_config_option *config_color_status_data_private; +extern struct t_config_option *config_color_status_data_highlight; +extern struct t_config_option *config_color_status_data_other; +extern struct t_config_option *config_color_status_more; +extern struct t_config_option *config_color_infobar; +extern struct t_config_option *config_color_infobar_bg; +extern struct t_config_option *config_color_infobar_delimiters; +extern struct t_config_option *config_color_infobar_highlight; +extern struct t_config_option *config_color_infobar_bg; +extern struct t_config_option *config_color_input; +extern struct t_config_option *config_color_input_bg; +extern struct t_config_option *config_color_input_server; +extern struct t_config_option *config_color_input_channel; +extern struct t_config_option *config_color_input_nick; +extern struct t_config_option *config_color_input_delimiters; +extern struct t_config_option *config_color_input_text_not_found; +extern struct t_config_option *config_color_input_actions; +extern struct t_config_option *config_color_nicklist; +extern struct t_config_option *config_color_nicklist_bg; +extern struct t_config_option *config_color_nicklist_away; +extern struct t_config_option *config_color_nicklist_prefix1; +extern struct t_config_option *config_color_nicklist_prefix2; +extern struct t_config_option *config_color_nicklist_prefix3; +extern struct t_config_option *config_color_nicklist_prefix4; +extern struct t_config_option *config_color_nicklist_prefix5; +extern struct t_config_option *config_color_nicklist_more; +extern struct t_config_option *config_color_nicklist_separator; +extern struct t_config_option *config_color_info; +extern struct t_config_option *config_color_info_bg; +extern struct t_config_option *config_color_info_waiting; +extern struct t_config_option *config_color_info_connecting; +extern struct t_config_option *config_color_info_active; +extern struct t_config_option *config_color_info_done; +extern struct t_config_option *config_color_info_failed; +extern struct t_config_option *config_color_info_aborted; + +extern struct t_config_option *config_history_max_lines; +extern struct t_config_option *config_history_max_commands; +extern struct t_config_option *config_history_display_default; + +extern struct t_config_option *config_proxy_use; +extern struct t_config_option *config_proxy_type; +extern struct t_config_option *config_proxy_ipv6; +extern struct t_config_option *config_proxy_address; +extern struct t_config_option *config_proxy_port; +extern struct t_config_option *config_proxy_username; +extern struct t_config_option *config_proxy_password; + +extern struct t_config_option *config_plugins_path; +extern struct t_config_option *config_plugins_autoload; +extern struct t_config_option *config_plugins_extension; + +extern void config_change_noop (); +extern void config_change_save_on_exit (); +extern void config_change_title (); +extern void config_change_buffers (); +extern void config_change_buffer_content (); +extern void config_change_buffer_time_format (); +extern void config_change_hotlist (); +extern void config_change_read_marker (); +extern void config_change_prefix (); +extern void config_change_color (); +extern void config_change_nicks_colors (); + +extern void config_weechat_init (); +extern int config_weechat_read (); +extern int config_weechat_write (); +extern void config_weechat_print_stdout (); #endif /* wee-config.h */ diff --git a/src/core/wee-input.c b/src/core/wee-input.c index a395b4725..74beb81a1 100644 --- a/src/core/wee-input.c +++ b/src/core/wee-input.c @@ -33,6 +33,7 @@ #include "wee-config.h" #include "wee-hook.h" #include "wee-string.h" +#include "../gui/gui-chat.h" #include "../plugins/plugin.h" diff --git a/src/core/wee-util.c b/src/core/wee-util.c index 70f90094e..408998164 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -157,15 +157,17 @@ util_search_full_lib_name (char *filename, char *sys_directory) return strdup (filename); length = strlen (filename) + 16; - if (cfg_plugins_extension && cfg_plugins_extension[0]) - length += strlen (cfg_plugins_extension); + if (CONFIG_STRING(config_plugins_extension) + && CONFIG_STRING(config_plugins_extension)[0]) + length += strlen (CONFIG_STRING(config_plugins_extension)); name_with_ext = (char *)malloc (length); if (!name_with_ext) return strdup (filename); strcpy (name_with_ext, filename); if (!strchr (filename, '.') - && cfg_plugins_extension && cfg_plugins_extension[0]) - strcat (name_with_ext, cfg_plugins_extension); + && CONFIG_STRING(config_plugins_extension) + && CONFIG_STRING(config_plugins_extension)[0]) + strcat (name_with_ext, CONFIG_STRING(config_plugins_extension)); /* try WeeChat user's dir */ length = strlen (weechat_home) + strlen (name_with_ext) + diff --git a/src/core/weechat.c b/src/core/weechat.c index e516e53b5..323b740ce 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -63,6 +63,7 @@ #include "wee-util.h" #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" +#include "../gui/gui-color.h" #include "../gui/gui-hotlist.h" #include "../gui/gui-main.h" #include "../gui/gui-keyboard.h" @@ -129,7 +130,7 @@ weechat_display_config_options () /* TRANSLATORS: %s is "WeeChat" */ _("%s configuration options:\n"), PACKAGE_NAME); - weechat_config_print_stdout (); + config_file_print_stdout (weechat_config); } /* @@ -425,7 +426,7 @@ weechat_init_vars () void weechat_welcome_message () { - if (cfg_look_startup_logo) + if (CONFIG_BOOLEAN(config_look_startup_logo)) { gui_chat_printf (NULL, "%s ___ __ ______________ _____ \n" @@ -439,27 +440,31 @@ weechat_welcome_message () GUI_COLOR(GUI_COLOR_CHAT_NICK), GUI_COLOR(GUI_COLOR_CHAT_NICK)); } - if (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) + if (CONFIG_STRING(config_look_weechat_slogan) + && CONFIG_STRING(config_look_weechat_slogan)[0]) { gui_chat_printf (NULL, _("%sWelcome to %s%s%s, %s"), - (cfg_look_startup_logo) ? " " : "", + (CONFIG_BOOLEAN(config_look_startup_logo)) ? + " " : "", GUI_COLOR(GUI_COLOR_CHAT_BUFFER), PACKAGE_NAME, GUI_NO_COLOR, - cfg_look_weechat_slogan); + CONFIG_STRING(config_look_weechat_slogan)); } - if (cfg_look_startup_version) + if (CONFIG_BOOLEAN(config_look_startup_version)) { gui_chat_printf (NULL, "%s%s%s%s, %s %s %s", - (cfg_look_startup_logo) ? " " : "", + (CONFIG_BOOLEAN(config_look_startup_logo)) ? + " " : "", GUI_COLOR(GUI_COLOR_CHAT_BUFFER), PACKAGE_STRING, GUI_NO_COLOR, _("compiled on"), __DATE__, __TIME__); } - if (cfg_look_startup_logo || - (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) || - cfg_look_startup_version) + if (CONFIG_BOOLEAN(config_look_startup_logo) || + (CONFIG_STRING(config_look_weechat_slogan) + && CONFIG_STRING(config_look_weechat_slogan)[0]) || + CONFIG_BOOLEAN(config_look_startup_version)) gui_chat_printf (NULL, "%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-", GUI_COLOR(GUI_COLOR_CHAT_NICK)); @@ -592,10 +597,11 @@ main (int argc, char *argv[]) gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */ weechat_init_vars (); /* initialize some variables */ gui_keyboard_init (); /* init keyb. (default key bindings)*/ + config_weechat_init (); /* init options with default values */ weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dirs (); /* create WeeChat directories */ log_init (); /* init log file */ - if (weechat_config_read () < 0) /* read WeeChat configuration */ + if (config_weechat_read () < 0) /* read WeeChat configuration */ exit (EXIT_FAILURE); command_index_build (); /* build cmd index for completion */ gui_main_init (); /* init WeeChat interface */ @@ -605,8 +611,8 @@ main (int argc, char *argv[]) plugin_init (auto_load_plugins); /* init plugin interface(s) */ gui_main_loop (); /* WeeChat main loop */ plugin_end (); /* end plugin interface(s) */ - if (cfg_look_save_on_exit) - (void) weechat_config_write (NULL); /* save WeeChat config file */ + if (CONFIG_BOOLEAN(config_look_save_on_exit)) + (void) config_weechat_write (NULL); /* save WeeChat config file */ command_index_free (); /* free commands index */ gui_main_end (); /* shut down WeeChat GUI */ weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */ diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index dd0e86c69..1558c4708 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -32,6 +32,7 @@ #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" #include "../gui-chat.h" +#include "../gui-color.h" #include "../gui-main.h" #include "../gui-window.h" #include "gui-curses.h" @@ -248,7 +249,7 @@ int gui_chat_get_real_width (struct t_gui_window *window) { if (window->buffer->nicklist - && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_RIGHT)) + && (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_RIGHT)) return window->win_chat_width - 1; else return window->win_chat_width; @@ -478,12 +479,13 @@ gui_chat_display_word (struct t_gui_window *window, } window->win_chat_cursor_x += length_align; if (!simulate - && (cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE) - && (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0])) + && (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) + && (CONFIG_STRING(config_look_prefix_suffix) + && CONFIG_STRING(config_look_prefix_suffix)[0])) { gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX); - gui_chat_display_word_raw (window, cfg_look_prefix_suffix, 1); - window->win_chat_cursor_x += gui_chat_strlen_screen (cfg_look_prefix_suffix); + gui_chat_display_word_raw (window, CONFIG_STRING(config_look_prefix_suffix), 1); + window->win_chat_cursor_x += gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)); gui_chat_display_word_raw (window, str_space, 1); window->win_chat_cursor_x += gui_chat_strlen_screen (str_space); gui_chat_set_weechat_color (window, GUI_COLOR_CHAT); @@ -572,23 +574,23 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, /* display prefix */ if (line->prefix && (line->prefix[0] - || (cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE))) + || (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE))) { if (!simulate) gui_chat_reset_style (window); - if (cfg_look_prefix_align_max > 0) + if (CONFIG_INTEGER(config_look_prefix_align_max) > 0) { length_allowed = - (window->buffer->prefix_max_length <= cfg_look_prefix_align_max) ? - window->buffer->prefix_max_length : cfg_look_prefix_align_max; + (window->buffer->prefix_max_length <= CONFIG_INTEGER(config_look_prefix_align_max)) ? + window->buffer->prefix_max_length : CONFIG_INTEGER(config_look_prefix_align_max); } else length_allowed = window->buffer->prefix_max_length; num_spaces = length_allowed - line->prefix_length; - if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_RIGHT) + if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT) { for (i = 0; i < num_spaces; i++) { @@ -598,7 +600,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, } } /* not enough space to display full prefix ? => truncate it! */ - if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE) + if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) && (num_spaces < 0)) { gui_chat_display_word (window, line, line->prefix, @@ -618,7 +620,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, if (!simulate) gui_chat_reset_style (window); - if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_LEFT) + if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT) { for (i = 0; i < num_spaces; i++) { @@ -627,7 +629,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, simulate); } } - if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE) + if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) && (num_spaces < 0)) { if (!simulate) @@ -642,12 +644,14 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, NULL, 1, num_lines, count, lines_displayed, simulate); } - if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE) - && (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0])) + if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) + && (CONFIG_STRING(config_look_prefix_suffix) + && CONFIG_STRING(config_look_prefix_suffix)[0])) { if (!simulate) gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX); - gui_chat_display_word (window, line, cfg_look_prefix_suffix, + gui_chat_display_word (window, line, + CONFIG_STRING(config_look_prefix_suffix), NULL, 1, num_lines, count, lines_displayed, simulate); gui_chat_display_word (window, line, str_space, @@ -809,7 +813,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, } else { - if (cfg_look_read_marker && cfg_look_read_marker[0]) + if (CONFIG_STRING(config_look_read_marker) + && CONFIG_STRING(config_look_read_marker)[0]) { /* display marker if line is matching user search */ if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED) @@ -821,7 +826,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, GUI_COLOR_CHAT_READ_MARKER); mvwprintw (GUI_CURSES(window)->win_chat, read_marker_y, read_marker_x, - "%c", cfg_look_read_marker[0]); + "%c", CONFIG_STRING(config_look_read_marker)[0]); } } else @@ -834,7 +839,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, GUI_COLOR_CHAT_READ_MARKER); mvwprintw (GUI_CURSES(window)->win_chat, read_marker_y, read_marker_x, - "%c", cfg_look_read_marker[0]); + "%c", CONFIG_STRING(config_look_read_marker)[0]); } } } diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 35bee21a4..71a9c63f4 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -32,6 +32,7 @@ #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" #include "../gui-color.h" +#include "../gui-chat.h" #include "gui-curses.h" @@ -330,7 +331,7 @@ gui_color_init_pairs () init_pair (63, -1, -1); /* white on default bg is default (-1) */ - if (!cfg_look_color_real_white) + if (!CONFIG_BOOLEAN(config_look_color_real_white)) init_pair (COLOR_WHITE, -1, -1); } } @@ -344,75 +345,75 @@ gui_color_init_weechat () { int i; - gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, cfg_col_separator, cfg_col_separator); + gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_separator)); - gui_color[GUI_COLOR_TITLE] = gui_color_build (GUI_COLOR_TITLE, cfg_col_title, cfg_col_title_bg); - gui_color[GUI_COLOR_TITLE_MORE] = gui_color_build (GUI_COLOR_TITLE_MORE, cfg_col_title_more, cfg_col_title_bg); + gui_color[GUI_COLOR_TITLE] = gui_color_build (GUI_COLOR_TITLE, CONFIG_COLOR(config_color_title), CONFIG_COLOR(config_color_title_bg)); + gui_color[GUI_COLOR_TITLE_MORE] = gui_color_build (GUI_COLOR_TITLE_MORE, CONFIG_COLOR(config_color_title_more), CONFIG_COLOR(config_color_title_bg)); - gui_color[GUI_COLOR_CHAT] = gui_color_build (GUI_COLOR_CHAT, cfg_col_chat, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_TIME] = gui_color_build (GUI_COLOR_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_TIME_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, cfg_col_chat_time_delimiters, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_INFO] = gui_color_build (GUI_COLOR_CHAT_PREFIX_INFO, cfg_col_chat_prefix[GUI_CHAT_PREFIX_INFO], cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_ERROR] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ERROR, cfg_col_chat_prefix[GUI_CHAT_PREFIX_ERROR], cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_NETWORK] = gui_color_build (GUI_COLOR_CHAT_PREFIX_NETWORK, cfg_col_chat_prefix[GUI_CHAT_PREFIX_NETWORK], cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_ACTION] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ACTION, cfg_col_chat_prefix[GUI_CHAT_PREFIX_ACTION], cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_JOIN] = gui_color_build (GUI_COLOR_CHAT_PREFIX_JOIN, cfg_col_chat_prefix[GUI_CHAT_PREFIX_JOIN], cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_QUIT] = gui_color_build (GUI_COLOR_CHAT_PREFIX_QUIT, cfg_col_chat_prefix[GUI_CHAT_PREFIX_QUIT], cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_MORE] = gui_color_build (GUI_COLOR_CHAT_PREFIX_MORE, cfg_col_chat_prefix_more, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_PREFIX_SUFFIX] = gui_color_build (GUI_COLOR_CHAT_PREFIX_SUFFIX, cfg_col_chat_prefix_suffix, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_BUFFER] = gui_color_build (GUI_COLOR_CHAT_BUFFER, cfg_col_chat_buffer, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_SERVER] = gui_color_build (GUI_COLOR_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_CHANNEL] = gui_color_build (GUI_COLOR_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_NICK] = gui_color_build (GUI_COLOR_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_NICK_SELF] = gui_color_build (GUI_COLOR_CHAT_NICK_SELF, cfg_col_chat_nick_self, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_NICK_OTHER] = gui_color_build (GUI_COLOR_CHAT_NICK_OTHER, cfg_col_chat_nick_other, cfg_col_chat_bg); + gui_color[GUI_COLOR_CHAT] = gui_color_build (GUI_COLOR_CHAT, CONFIG_COLOR(config_color_chat), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_TIME] = gui_color_build (GUI_COLOR_CHAT_TIME, CONFIG_COLOR(config_color_chat_time), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_TIME_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, CONFIG_COLOR(config_color_chat_time_delimiters), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_INFO] = gui_color_build (GUI_COLOR_CHAT_PREFIX_INFO, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_INFO]), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_ERROR] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ERROR, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_ERROR]), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_NETWORK] = gui_color_build (GUI_COLOR_CHAT_PREFIX_NETWORK, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_NETWORK]), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_ACTION] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ACTION, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_ACTION]), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_JOIN] = gui_color_build (GUI_COLOR_CHAT_PREFIX_JOIN, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_JOIN]), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_QUIT] = gui_color_build (GUI_COLOR_CHAT_PREFIX_QUIT, CONFIG_COLOR(config_color_chat_prefix[GUI_CHAT_PREFIX_QUIT]), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_MORE] = gui_color_build (GUI_COLOR_CHAT_PREFIX_MORE, CONFIG_COLOR(config_color_chat_prefix_more), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_PREFIX_SUFFIX] = gui_color_build (GUI_COLOR_CHAT_PREFIX_SUFFIX, CONFIG_COLOR(config_color_chat_prefix_suffix), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_BUFFER] = gui_color_build (GUI_COLOR_CHAT_BUFFER, CONFIG_COLOR(config_color_chat_buffer), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_SERVER] = gui_color_build (GUI_COLOR_CHAT_SERVER, CONFIG_COLOR(config_color_chat_server), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_CHANNEL] = gui_color_build (GUI_COLOR_CHAT_CHANNEL, CONFIG_COLOR(config_color_chat_channel), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_NICK] = gui_color_build (GUI_COLOR_CHAT_NICK, CONFIG_COLOR(config_color_chat_nick), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_NICK_SELF] = gui_color_build (GUI_COLOR_CHAT_NICK_SELF, CONFIG_COLOR(config_color_chat_nick_self), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_NICK_OTHER] = gui_color_build (GUI_COLOR_CHAT_NICK_OTHER, CONFIG_COLOR(config_color_chat_nick_other), CONFIG_COLOR(config_color_chat_bg)); for (i = 0; i < GUI_COLOR_NICK_NUMBER; i++) { - gui_color[GUI_COLOR_CHAT_NICK1 + i] = gui_color_build (GUI_COLOR_CHAT_NICK1 + i, cfg_col_chat_nick_colors[i], cfg_col_chat_bg); + gui_color[GUI_COLOR_CHAT_NICK1 + i] = gui_color_build (GUI_COLOR_CHAT_NICK1 + i, CONFIG_COLOR(config_color_chat_nick_colors[i]), CONFIG_COLOR(config_color_chat_bg)); } - gui_color[GUI_COLOR_CHAT_HOST] = gui_color_build (GUI_COLOR_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_DELIMITERS, cfg_col_chat_delimiters, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg); - gui_color[GUI_COLOR_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg); + gui_color[GUI_COLOR_CHAT_HOST] = gui_color_build (GUI_COLOR_CHAT_HOST, CONFIG_COLOR(config_color_chat_host), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_DELIMITERS, CONFIG_COLOR(config_color_chat_delimiters), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, CONFIG_COLOR(config_color_chat_highlight), CONFIG_COLOR(config_color_chat_bg)); + gui_color[GUI_COLOR_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_CHAT_READ_MARKER, CONFIG_COLOR(config_color_chat_read_marker), CONFIG_COLOR(config_color_chat_read_marker_bg)); - gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, cfg_col_status, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_CHANNEL] = gui_color_build (GUI_COLOR_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_DATA_HIGHLIGHT] = gui_color_build (GUI_COLOR_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_DATA_OTHER] = gui_color_build (GUI_COLOR_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg); - gui_color[GUI_COLOR_STATUS_MORE] = gui_color_build (GUI_COLOR_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg); + gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, CONFIG_COLOR(config_color_status), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_STATUS_DELIMITERS, CONFIG_COLOR(config_color_status_delimiters), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_CHANNEL] = gui_color_build (GUI_COLOR_STATUS_CHANNEL, CONFIG_COLOR(config_color_status_channel), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_STATUS_DATA_MSG, CONFIG_COLOR(config_color_status_data_msg), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, CONFIG_COLOR(config_color_status_data_private), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_DATA_HIGHLIGHT] = gui_color_build (GUI_COLOR_STATUS_DATA_HIGHLIGHT, CONFIG_COLOR(config_color_status_data_highlight), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_DATA_OTHER] = gui_color_build (GUI_COLOR_STATUS_DATA_OTHER, CONFIG_COLOR(config_color_status_data_other), CONFIG_COLOR(config_color_status_bg)); + gui_color[GUI_COLOR_STATUS_MORE] = gui_color_build (GUI_COLOR_STATUS_MORE, CONFIG_COLOR(config_color_status_more), CONFIG_COLOR(config_color_status_bg)); - gui_color[GUI_COLOR_INFOBAR] = gui_color_build (GUI_COLOR_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg); - gui_color[GUI_COLOR_INFOBAR_DELIMITERS] = gui_color_build (GUI_COLOR_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg); - gui_color[GUI_COLOR_INFOBAR_HIGHLIGHT] = gui_color_build (GUI_COLOR_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg); + gui_color[GUI_COLOR_INFOBAR] = gui_color_build (GUI_COLOR_INFOBAR, CONFIG_COLOR(config_color_infobar), CONFIG_COLOR(config_color_infobar_bg)); + gui_color[GUI_COLOR_INFOBAR_DELIMITERS] = gui_color_build (GUI_COLOR_INFOBAR_DELIMITERS, CONFIG_COLOR(config_color_infobar_delimiters), CONFIG_COLOR(config_color_infobar_bg)); + gui_color[GUI_COLOR_INFOBAR_HIGHLIGHT] = gui_color_build (GUI_COLOR_INFOBAR_HIGHLIGHT, CONFIG_COLOR(config_color_infobar_highlight), CONFIG_COLOR(config_color_infobar_bg)); - gui_color[GUI_COLOR_INPUT] = gui_color_build (GUI_COLOR_INPUT, cfg_col_input, cfg_col_input_bg); - gui_color[GUI_COLOR_INPUT_SERVER] = gui_color_build (GUI_COLOR_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg); - gui_color[GUI_COLOR_INPUT_CHANNEL] = gui_color_build (GUI_COLOR_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg); - gui_color[GUI_COLOR_INPUT_NICK] = gui_color_build (GUI_COLOR_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg); - gui_color[GUI_COLOR_INPUT_DELIMITERS] = gui_color_build (GUI_COLOR_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg); - gui_color[GUI_COLOR_INPUT_TEXT_NOT_FOUND] = gui_color_build (GUI_COLOR_INPUT_TEXT_NOT_FOUND, cfg_col_input_text_not_found, cfg_col_input_bg); - gui_color[GUI_COLOR_INPUT_ACTIONS] = gui_color_build (GUI_COLOR_INPUT_ACTIONS, cfg_col_input_actions, cfg_col_input_bg); + gui_color[GUI_COLOR_INPUT] = gui_color_build (GUI_COLOR_INPUT, CONFIG_COLOR(config_color_input), CONFIG_COLOR(config_color_input_bg)); + gui_color[GUI_COLOR_INPUT_SERVER] = gui_color_build (GUI_COLOR_INPUT_SERVER, CONFIG_COLOR(config_color_input_server), CONFIG_COLOR(config_color_input_bg)); + gui_color[GUI_COLOR_INPUT_CHANNEL] = gui_color_build (GUI_COLOR_INPUT_CHANNEL, CONFIG_COLOR(config_color_input_channel), CONFIG_COLOR(config_color_input_bg)); + gui_color[GUI_COLOR_INPUT_NICK] = gui_color_build (GUI_COLOR_INPUT_NICK, CONFIG_COLOR(config_color_input_nick), CONFIG_COLOR(config_color_input_bg)); + gui_color[GUI_COLOR_INPUT_DELIMITERS] = gui_color_build (GUI_COLOR_INPUT_DELIMITERS, CONFIG_COLOR(config_color_input_delimiters), CONFIG_COLOR(config_color_input_bg)); + gui_color[GUI_COLOR_INPUT_TEXT_NOT_FOUND] = gui_color_build (GUI_COLOR_INPUT_TEXT_NOT_FOUND, CONFIG_COLOR(config_color_input_text_not_found), CONFIG_COLOR(config_color_input_bg)); + gui_color[GUI_COLOR_INPUT_ACTIONS] = gui_color_build (GUI_COLOR_INPUT_ACTIONS, CONFIG_COLOR(config_color_input_actions), CONFIG_COLOR(config_color_input_bg)); - gui_color[GUI_COLOR_NICKLIST] = gui_color_build (GUI_COLOR_NICKLIST, cfg_col_nicklist, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_AWAY] = gui_color_build (GUI_COLOR_NICKLIST_AWAY, cfg_col_nicklist_away, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_PREFIX1] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX1, cfg_col_nicklist_prefix1, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_PREFIX2] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX2, cfg_col_nicklist_prefix2, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_PREFIX3] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX3, cfg_col_nicklist_prefix3, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_PREFIX4] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX4, cfg_col_nicklist_prefix4, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_PREFIX5] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX5, cfg_col_nicklist_prefix5, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_MORE] = gui_color_build (GUI_COLOR_NICKLIST_MORE, cfg_col_nicklist_more, cfg_col_nicklist_bg); - gui_color[GUI_COLOR_NICKLIST_SEPARATOR] = gui_color_build (GUI_COLOR_NICKLIST_SEPARATOR, cfg_col_nicklist_separator, cfg_col_nicklist_bg); + gui_color[GUI_COLOR_NICKLIST] = gui_color_build (GUI_COLOR_NICKLIST, CONFIG_COLOR(config_color_nicklist), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_AWAY] = gui_color_build (GUI_COLOR_NICKLIST_AWAY, CONFIG_COLOR(config_color_nicklist_away), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_PREFIX1] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX1, CONFIG_COLOR(config_color_nicklist_prefix1), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_PREFIX2] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX2, CONFIG_COLOR(config_color_nicklist_prefix2), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_PREFIX3] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX3, CONFIG_COLOR(config_color_nicklist_prefix3), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_PREFIX4] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX4, CONFIG_COLOR(config_color_nicklist_prefix4), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_PREFIX5] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX5, CONFIG_COLOR(config_color_nicklist_prefix5), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_MORE] = gui_color_build (GUI_COLOR_NICKLIST_MORE, CONFIG_COLOR(config_color_nicklist_more), CONFIG_COLOR(config_color_nicklist_bg)); + gui_color[GUI_COLOR_NICKLIST_SEPARATOR] = gui_color_build (GUI_COLOR_NICKLIST_SEPARATOR, CONFIG_COLOR(config_color_nicklist_separator), CONFIG_COLOR(config_color_nicklist_bg)); - gui_color[GUI_COLOR_INFO] = gui_color_build (GUI_COLOR_INFO, cfg_col_info, cfg_col_info_bg); - gui_color[GUI_COLOR_INFO_WAITING] = gui_color_build (GUI_COLOR_INFO_WAITING, cfg_col_info_waiting, cfg_col_info_bg); - gui_color[GUI_COLOR_INFO_CONNECTING] = gui_color_build (GUI_COLOR_INFO_CONNECTING, cfg_col_info_connecting, cfg_col_info_bg); - gui_color[GUI_COLOR_INFO_ACTIVE] = gui_color_build (GUI_COLOR_INFO_ACTIVE, cfg_col_info_active, cfg_col_info_bg); - gui_color[GUI_COLOR_INFO_DONE] = gui_color_build (GUI_COLOR_INFO_DONE, cfg_col_info_done, cfg_col_info_bg); - gui_color[GUI_COLOR_INFO_FAILED] = gui_color_build (GUI_COLOR_INFO_FAILED, cfg_col_info_failed, cfg_col_info_bg); - gui_color[GUI_COLOR_INFO_ABORTED] = gui_color_build (GUI_COLOR_INFO_ABORTED, cfg_col_info_aborted, cfg_col_info_bg); + gui_color[GUI_COLOR_INFO] = gui_color_build (GUI_COLOR_INFO, CONFIG_COLOR(config_color_info), CONFIG_COLOR(config_color_info_bg)); + gui_color[GUI_COLOR_INFO_WAITING] = gui_color_build (GUI_COLOR_INFO_WAITING, CONFIG_COLOR(config_color_info_waiting), CONFIG_COLOR(config_color_info_bg)); + gui_color[GUI_COLOR_INFO_CONNECTING] = gui_color_build (GUI_COLOR_INFO_CONNECTING, CONFIG_COLOR(config_color_info_connecting), CONFIG_COLOR(config_color_info_bg)); + gui_color[GUI_COLOR_INFO_ACTIVE] = gui_color_build (GUI_COLOR_INFO_ACTIVE, CONFIG_COLOR(config_color_info_active), CONFIG_COLOR(config_color_info_bg)); + gui_color[GUI_COLOR_INFO_DONE] = gui_color_build (GUI_COLOR_INFO_DONE, CONFIG_COLOR(config_color_info_done), CONFIG_COLOR(config_color_info_bg)); + gui_color[GUI_COLOR_INFO_FAILED] = gui_color_build (GUI_COLOR_INFO_FAILED, CONFIG_COLOR(config_color_info_failed), CONFIG_COLOR(config_color_info_bg)); + gui_color[GUI_COLOR_INFO_ABORTED] = gui_color_build (GUI_COLOR_INFO_ABORTED, CONFIG_COLOR(config_color_info_aborted), CONFIG_COLOR(config_color_info_bg)); } /* diff --git a/src/gui/curses/gui-curses-infobar.c b/src/gui/curses/gui-curses-infobar.c index 1ff4dc925..eec538c4b 100644 --- a/src/gui/curses/gui-curses-infobar.c +++ b/src/gui/curses/gui-curses-infobar.c @@ -30,6 +30,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-string.h" #include "../gui-infobar.h" +#include "../gui-color.h" #include "../gui-main.h" #include "../gui-window.h" #include "gui-curses.h" @@ -64,7 +65,7 @@ gui_infobar_draw_time (struct t_gui_buffer *buffer) 0, 1, "%02d:%02d", local_time->tm_hour, local_time->tm_min); - if (cfg_look_infobar_seconds) + if (CONFIG_BOOLEAN(config_look_infobar_seconds)) wprintw (GUI_CURSES(ptr_win)->win_infobar, ":%02d", local_time->tm_sec); @@ -105,7 +106,8 @@ gui_infobar_draw (struct t_gui_buffer *buffer, int erase) if (local_time) { strftime (text_time, sizeof (text_time), - cfg_look_infobar_time_format, local_time); + CONFIG_STRING(config_look_infobar_time_format), + local_time); gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_INFOBAR_DELIMITERS); wprintw (GUI_CURSES(ptr_win)->win_infobar, "["); @@ -114,7 +116,7 @@ gui_infobar_draw (struct t_gui_buffer *buffer, int erase) wprintw (GUI_CURSES(ptr_win)->win_infobar, "%02d:%02d", local_time->tm_hour, local_time->tm_min); - if (cfg_look_infobar_seconds) + if (CONFIG_BOOLEAN(config_look_infobar_seconds)) wprintw (GUI_CURSES(ptr_win)->win_infobar, ":%02d", local_time->tm_sec); diff --git a/src/gui/curses/gui-curses-input.c b/src/gui/curses/gui-curses-input.c index 174865096..68eefc5a8 100644 --- a/src/gui/curses/gui-curses-input.c +++ b/src/gui/curses/gui-curses-input.c @@ -32,6 +32,7 @@ #include "../../core/wee-utf8.h" #include "../../plugins/plugin.h" #include "../gui-input.h" +#include "../gui-color.h" #include "../gui-keyboard.h" #include "../gui-main.h" #include "../gui-window.h" @@ -90,7 +91,7 @@ gui_input_draw_prompt (struct t_gui_window *window) return; } - pos = cfg_look_input_format; + pos = CONFIG_STRING(config_look_input_format); while (pos && pos[0]) { switch (pos[0]) diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index 19b91add1..86f542606 100644 --- a/src/gui/curses/gui-curses-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -31,6 +31,7 @@ #include "../../core/wee-utf8.h" #include "../../core/wee-string.h" #include "../gui-keyboard.h" +#include "../gui-color.h" #include "../gui-input.h" #include "../gui-completion.h" #include "../gui-window.h" @@ -218,10 +219,10 @@ gui_keyboard_read () { /* detect user paste or large amount of text if so, ask user what to do */ - if (cfg_look_paste_max_lines > 0) + if (CONFIG_INTEGER(config_look_paste_max_lines) > 0) { paste_lines = gui_keyboard_get_paste_lines (); - if (paste_lines > cfg_look_paste_max_lines) + if (paste_lines > CONFIG_INTEGER(config_look_paste_max_lines)) { gui_keyboard_paste_pending = 1; gui_input_draw (gui_current_window->buffer, 1); diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 7fbcd40cc..a885dafc5 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -36,12 +36,14 @@ #include "../../core/wee-utf8.h" #include "../../core/wee-util.h" #include "../../plugins/plugin.h" +#include "../gui-main.h" +#include "../gui-chat.h" +#include "../gui-color.h" #include "../gui-infobar.h" #include "../gui-input.h" #include "../gui-history.h" #include "../gui-hotlist.h" #include "../gui-keyboard.h" -#include "../gui-main.h" #include "../gui-window.h" #include "gui-curses.h" @@ -87,7 +89,7 @@ gui_main_init () gui_input_clipboard = NULL; /* get time length */ - gui_chat_time_length = util_get_time_length (cfg_look_buffer_time_format); + gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format)); /* create new window/buffer */ if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100)) @@ -105,7 +107,7 @@ gui_main_init () else gui_init_ok = 0; - if (cfg_look_set_title) + if (CONFIG_BOOLEAN(config_look_set_title)) gui_window_title_set (); signal (SIGWINCH, gui_window_refresh_screen_sigwinch); @@ -179,11 +181,12 @@ gui_main_loop () old_min = local_time->tm_min; gui_infobar_draw (gui_current_window->buffer, 1); - if (cfg_look_day_change + if (CONFIG_BOOLEAN(config_look_day_change) && (local_time->tm_mday != old_day)) { strftime (text_time, sizeof (text_time), - cfg_look_day_change_time_format, local_time); + CONFIG_STRING(config_look_day_change_time_format), + local_time); text_time2 = string_iconv_to_internal (NULL, text_time); gui_add_hotlist = 0; for (ptr_buffer = gui_buffers; ptr_buffer; @@ -208,7 +211,7 @@ gui_main_loop () old_sec = local_time->tm_sec; /* display time in infobar (if seconds displayed) */ - if (cfg_look_infobar_seconds) + if (CONFIG_BOOLEAN(config_look_infobar_seconds)) { gui_infobar_draw_time (gui_current_window->buffer); wmove (GUI_CURSES(gui_current_window)->win_input, @@ -305,7 +308,7 @@ gui_main_end () gui_infobar_remove (); /* reset title */ - if (cfg_look_set_title) + if (CONFIG_BOOLEAN(config_look_set_title)) gui_window_title_reset (); /* end of Curses output */ diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c index 5be8c4984..a0a253609 100644 --- a/src/gui/curses/gui-curses-nicklist.c +++ b/src/gui/curses/gui-curses-nicklist.c @@ -30,6 +30,8 @@ #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" #include "../gui-nicklist.h" +#include "../gui-chat.h" +#include "../gui-color.h" #include "../gui-main.h" #include "../gui-window.h" #include "gui-curses.h" @@ -91,39 +93,39 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase) } } - if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || - (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) + if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) || + (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) max_chars = max_length; else - max_chars = ((cfg_look_nicklist_min_size > 0) - && (max_length < cfg_look_nicklist_min_size)) ? - cfg_look_nicklist_min_size : - (((cfg_look_nicklist_max_size > 0) - && (max_length > cfg_look_nicklist_max_size)) ? - cfg_look_nicklist_max_size : max_length); + max_chars = ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0) + && (max_length < CONFIG_INTEGER(config_look_nicklist_min_size))) ? + CONFIG_INTEGER(config_look_nicklist_min_size) : + (((CONFIG_INTEGER(config_look_nicklist_max_size) > 0) + && (max_length > CONFIG_INTEGER(config_look_nicklist_max_size))) ? + CONFIG_INTEGER(config_look_nicklist_max_size) : max_length); - if (cfg_look_nicklist_separator && has_colors ()) + if (CONFIG_BOOLEAN(config_look_nicklist_separator) && has_colors ()) { gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_NICKLIST_SEPARATOR); - switch (cfg_look_nicklist_position) + switch (CONFIG_INTEGER(config_look_nicklist_position)) { - case CFG_LOOK_NICKLIST_LEFT: + case CONFIG_LOOK_NICKLIST_LEFT: mvwvline (GUI_CURSES(ptr_win)->win_nick, 0, ptr_win->win_nick_width - 1, ACS_VLINE, ptr_win->win_chat_height); break; - case CFG_LOOK_NICKLIST_RIGHT: + case CONFIG_LOOK_NICKLIST_RIGHT: mvwvline (GUI_CURSES(ptr_win)->win_nick, 0, 0, ACS_VLINE, ptr_win->win_chat_height); break; - case CFG_LOOK_NICKLIST_TOP: + case CONFIG_LOOK_NICKLIST_TOP: mvwhline (GUI_CURSES(ptr_win)->win_nick, ptr_win->win_nick_height - 1, 0, ACS_HLINE, ptr_win->win_chat_width); break; - case CFG_LOOK_NICKLIST_BOTTOM: + case CONFIG_LOOK_NICKLIST_BOTTOM: mvwhline (GUI_CURSES(ptr_win)->win_nick, 0, 0, ACS_HLINE, ptr_win->win_chat_width); @@ -134,30 +136,31 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase) gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_NICKLIST); x = 0; - y = (cfg_look_nicklist_separator - && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ? + y = (CONFIG_BOOLEAN(config_look_nicklist_separator) + && (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) ? 1 : 0; max_y = 0; - switch (cfg_look_nicklist_position) + switch (CONFIG_INTEGER(config_look_nicklist_position)) { - case CFG_LOOK_NICKLIST_LEFT: - case CFG_LOOK_NICKLIST_RIGHT: + case CONFIG_LOOK_NICKLIST_LEFT: + case CONFIG_LOOK_NICKLIST_RIGHT: max_y = 0; break; - case CFG_LOOK_NICKLIST_TOP: + case CONFIG_LOOK_NICKLIST_TOP: max_y = ptr_win->win_nick_height - - cfg_look_nicklist_separator; + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); break; - case CFG_LOOK_NICKLIST_BOTTOM: + case CONFIG_LOOK_NICKLIST_BOTTOM: max_y = ptr_win->win_nick_height; break; } column = 0; - if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || - (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) + if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) || + (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) nicks_displayed = (ptr_win->win_width / (max_length + 2)) * - (ptr_win->win_nick_height - cfg_look_nicklist_separator); + (ptr_win->win_nick_height - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0)); else nicks_displayed = ptr_win->win_nick_height; @@ -172,16 +175,16 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase) { for (i = 0; i < nicks_displayed; i++) { - switch (cfg_look_nicklist_position) + switch (CONFIG_INTEGER(config_look_nicklist_position)) { - case CFG_LOOK_NICKLIST_LEFT: + case CONFIG_LOOK_NICKLIST_LEFT: x = 0; break; - case CFG_LOOK_NICKLIST_RIGHT: - x = cfg_look_nicklist_separator; + case CONFIG_LOOK_NICKLIST_RIGHT: + x = (CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0; break; - case CFG_LOOK_NICKLIST_TOP: - case CFG_LOOK_NICKLIST_BOTTOM: + case CONFIG_LOOK_NICKLIST_TOP: + case CONFIG_LOOK_NICKLIST_BOTTOM: x = column; break; } @@ -253,7 +256,7 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase) x++; } gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, - ((cfg_irc_away_check > 0) && (ptr_nick->flags & IRC_NICK_AWAY)) ? + ((config_irc_away_check > 0) && (ptr_nick->flags & IRC_NICK_AWAY)) ? GUI_COLOR_WIN_NICK_AWAY : GUI_COLOR_WIN_NICK);*/ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, @@ -291,14 +294,14 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase) break; } y++; - if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || - (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) + if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) || + (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) { if (y >= max_y) { column += max_length + 2; - y = (cfg_look_nicklist_separator - && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ? + y = (CONFIG_BOOLEAN(config_look_nicklist_separator) + && (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) ? 1 : 0; } } diff --git a/src/gui/curses/gui-curses-status.c b/src/gui/curses/gui-curses-status.c index 6b975edda..9ced1e317 100644 --- a/src/gui/curses/gui-curses-status.c +++ b/src/gui/curses/gui-curses-status.c @@ -30,6 +30,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-utf8.h" #include "../gui-status.h" +#include "../gui-color.h" #include "../gui-main.h" #include "../gui-hotlist.h" #include "../gui-window.h" @@ -121,22 +122,22 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase) case GUI_HOTLIST_LOW: gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_STATUS_DATA_OTHER); - display_name = ((cfg_look_hotlist_names_level & 1) != 0); + display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 1) != 0); break; case GUI_HOTLIST_MSG: gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_STATUS_DATA_MSG); - display_name = ((cfg_look_hotlist_names_level & 2) != 0); + display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 2) != 0); break; case GUI_HOTLIST_PRIVATE: gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_STATUS_DATA_PRIVATE); - display_name = ((cfg_look_hotlist_names_level & 4) != 0); + display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 4) != 0); break; case GUI_HOTLIST_HIGHLIGHT: gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_STATUS_DATA_HIGHLIGHT); - display_name = ((cfg_look_hotlist_names_level & 8) != 0); + display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 8) != 0); break; default: display_name = 0; @@ -146,8 +147,9 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase) wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); - if (display_name && (cfg_look_hotlist_names_count != 0) - && (names_count < cfg_look_hotlist_names_count)) + if (display_name + && (CONFIG_INTEGER(config_look_hotlist_names_count) != 0) + && (names_count < CONFIG_INTEGER(config_look_hotlist_names_count))) { names_count++; @@ -157,12 +159,12 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase) gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_STATUS); - if (cfg_look_hotlist_names_length == 0) + if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0) snprintf (format, sizeof (format) - 1, "%%s"); else snprintf (format, sizeof (format) - 1, "%%.%ds", - cfg_look_hotlist_names_length); + CONFIG_INTEGER(config_look_hotlist_names_length)); gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, format, ptr_hotlist->buffer->name); @@ -179,7 +181,7 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase) /* display lag */ /*if (GUI_SERVER(ptr_win->buffer)) { - if (GUI_SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show) + if (GUI_SERVER(ptr_win->buffer)->lag / 1000 >= config_irc_lag_min_show) { gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_STATUS_DELIMITERS); diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index a2619a652..004a0ef7e 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -34,6 +34,8 @@ #include "../../core/wee-log.h" #include "../../core/wee-string.h" #include "../gui-window.h" +#include "../gui-chat.h" +#include "../gui-color.h" #include "../gui-hotlist.h" #include "../gui-infobar.h" #include "../gui-input.h" @@ -206,18 +208,18 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) lines = 0; - if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_LEFT) || - (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_RIGHT)) + if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_LEFT) || + (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_RIGHT)) { - if ((cfg_look_nicklist_min_size > 0) - && (max_length < cfg_look_nicklist_min_size)) - max_length = cfg_look_nicklist_min_size; - else if ((cfg_look_nicklist_max_size > 0) - && (max_length > cfg_look_nicklist_max_size)) - max_length = cfg_look_nicklist_max_size; + if ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0) + && (max_length < CONFIG_INTEGER(config_look_nicklist_min_size))) + max_length = CONFIG_INTEGER(config_look_nicklist_min_size); + else if ((CONFIG_INTEGER(config_look_nicklist_max_size) > 0) + && (max_length > CONFIG_INTEGER(config_look_nicklist_max_size))) + max_length = CONFIG_INTEGER(config_look_nicklist_max_size); if (!force_calculate && (window->win_nick_width == - max_length + 1 + cfg_look_nicklist_separator)) + max_length + 1 + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0))) return 0; } else @@ -227,33 +229,36 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) lines = ((max_length + 2) * window->buffer->nicks_count) / width_used; else lines = (((max_length + 2) * window->buffer->nicks_count) / width_used) + 1; - if ((cfg_look_nicklist_max_size > 0) - && (lines > cfg_look_nicklist_max_size)) - lines = cfg_look_nicklist_max_size; - if ((cfg_look_nicklist_min_size > 0) - && (lines < cfg_look_nicklist_min_size)) - lines = cfg_look_nicklist_min_size; - max_height = (cfg_look_infobar) ? + if ((CONFIG_INTEGER(config_look_nicklist_max_size) > 0) + && (lines > CONFIG_INTEGER(config_look_nicklist_max_size))) + lines = CONFIG_INTEGER(config_look_nicklist_max_size); + if ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0) + && (lines < CONFIG_INTEGER(config_look_nicklist_min_size))) + lines = CONFIG_INTEGER(config_look_nicklist_min_size); + max_height = (CONFIG_BOOLEAN(config_look_infobar)) ? window->win_height - 3 - 4 : window->win_height - 2 - 4; if (lines > max_height) lines = max_height; if (!force_calculate && (window->win_nick_height == - lines + cfg_look_nicklist_separator)) + lines + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0))) return 0; } - switch (cfg_look_nicklist_position) + switch (CONFIG_INTEGER(config_look_nicklist_position)) { - case CFG_LOOK_NICKLIST_LEFT: - window->win_chat_x = window->win_x + max_length + 1 + cfg_look_nicklist_separator; + case CONFIG_LOOK_NICKLIST_LEFT: + window->win_chat_x = window->win_x + max_length + 1 + + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_chat_y = window->win_y + 1; - window->win_chat_width = window->win_width - max_length - 1 - cfg_look_nicklist_separator; + window->win_chat_width = window->win_width - max_length - 1 - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_x = window->win_x + 0; window->win_nick_y = window->win_y + 1; - window->win_nick_width = max_length + 1 + cfg_look_nicklist_separator; - if (cfg_look_infobar) + window->win_nick_width = max_length + 1 + + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); + if (CONFIG_BOOLEAN(config_look_infobar)) { window->win_chat_height = window->win_height - 4; window->win_nick_height = window->win_height - 4; @@ -265,14 +270,18 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) } window->win_nick_num_max = window->win_nick_height; break; - case CFG_LOOK_NICKLIST_RIGHT: + case CONFIG_LOOK_NICKLIST_RIGHT: window->win_chat_x = window->win_x; window->win_chat_y = window->win_y + 1; - window->win_chat_width = window->win_width - max_length - 1 - cfg_look_nicklist_separator; - window->win_nick_x = window->win_x + window->win_width - max_length - 1 - cfg_look_nicklist_separator; + window->win_chat_width = window->win_width - max_length - 1 - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); + window->win_nick_x = window->win_x + window->win_width - + max_length - 1 - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_y = window->win_y + 1; - window->win_nick_width = max_length + 1 + cfg_look_nicklist_separator; - if (cfg_look_infobar) + window->win_nick_width = max_length + 1 + + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); + if (CONFIG_BOOLEAN(config_look_infobar)) { window->win_chat_height = window->win_height - 4; window->win_nick_height = window->win_height - 4; @@ -284,35 +293,46 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) } window->win_nick_num_max = window->win_nick_height; break; - case CFG_LOOK_NICKLIST_TOP: + case CONFIG_LOOK_NICKLIST_TOP: window->win_chat_x = window->win_x; - window->win_chat_y = window->win_y + 1 + lines + cfg_look_nicklist_separator; + window->win_chat_y = window->win_y + 1 + lines + + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_chat_width = window->win_width; - if (cfg_look_infobar) - window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator - 1; + if (CONFIG_BOOLEAN(config_look_infobar)) + window->win_chat_height = window->win_height - 3 - lines - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1; else - window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator; + window->win_chat_height = window->win_height - 3 - lines - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_x = window->win_x; window->win_nick_y = window->win_y + 1; window->win_nick_width = window->win_width; - window->win_nick_height = lines + cfg_look_nicklist_separator; + window->win_nick_height = lines + + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2)); break; - case CFG_LOOK_NICKLIST_BOTTOM: + case CONFIG_LOOK_NICKLIST_BOTTOM: window->win_chat_x = window->win_x; window->win_chat_y = window->win_y + 1; window->win_chat_width = window->win_width; - if (cfg_look_infobar) - window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator - 1; + if (CONFIG_BOOLEAN(config_look_infobar)) + window->win_chat_height = window->win_height - 3 - lines - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1; else - window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator; + window->win_chat_height = window->win_height - 3 - lines - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_x = window->win_x; - if (cfg_look_infobar) - window->win_nick_y = window->win_y + window->win_height - 2 - lines - cfg_look_nicklist_separator - 1; + if (CONFIG_BOOLEAN(config_look_infobar)) + window->win_nick_y = window->win_y + window->win_height - + 2 - lines - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1; else - window->win_nick_y = window->win_y + window->win_height - 2 - lines - cfg_look_nicklist_separator; + window->win_nick_y = window->win_y + window->win_height - + 2 - lines - + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_width = window->win_width; - window->win_nick_height = lines + cfg_look_nicklist_separator; + window->win_nick_height = lines + + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0); window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2)); break; } @@ -325,7 +345,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) window->win_chat_x = window->win_x; window->win_chat_y = window->win_y + 1; window->win_chat_width = window->win_width; - if (cfg_look_infobar) + if (CONFIG_BOOLEAN(config_look_infobar)) window->win_chat_height = window->win_height - 4; else window->win_chat_height = window->win_height - 3; @@ -346,7 +366,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) /* status window */ window->win_status_x = window->win_x; - if (cfg_look_infobar) + if (CONFIG_BOOLEAN(config_look_infobar)) window->win_status_y = window->win_y + window->win_height - 3; else window->win_status_y = window->win_y + window->win_height - 2; @@ -354,7 +374,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) window->win_status_height = 1; /* infobar window */ - if (cfg_look_infobar) + if (CONFIG_BOOLEAN(config_look_infobar)) { window->win_infobar_x = window->win_x; window->win_infobar_y = window->win_y + window->win_height - 2; @@ -424,7 +444,7 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer) if (GUI_CURSES(ptr_win)->win_nick) gui_nicklist_draw (buffer, 1); gui_status_draw (buffer, 1); - if (cfg_look_infobar) + if (CONFIG_BOOLEAN(config_look_infobar)) gui_infobar_draw (buffer, 1); gui_input_draw (buffer, 1); } @@ -494,7 +514,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window, window->win_chat_width, window->win_chat_y, window->win_chat_x); - if (cfg_look_nicklist) + if (CONFIG_BOOLEAN(config_look_nicklist)) GUI_CURSES(window)->win_nick = newwin (window->win_nick_height, window->win_nick_width, window->win_nick_y, @@ -513,7 +533,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window, } /* create status/infobar windows */ - if (cfg_look_infobar) + if (CONFIG_BOOLEAN(config_look_infobar)) GUI_CURSES(window)->win_infobar = newwin (window->win_infobar_height, window->win_infobar_width, window->win_infobar_y, @@ -616,8 +636,9 @@ gui_window_scroll_up (struct t_gui_window *window) gui_chat_calculate_line_diff (window, &window->start_line, &window->start_line_pos, (window->start_line) ? - (-1) * cfg_look_scroll_amount : - (-1) * ( (window->win_chat_height - 1) + cfg_look_scroll_amount)); + (-1) * CONFIG_INTEGER(config_look_scroll_amount) : + (-1) * ( (window->win_chat_height - 1) + + CONFIG_INTEGER(config_look_scroll_amount))); gui_chat_draw (window->buffer, 0); if (!window->scroll) { @@ -645,7 +666,7 @@ gui_window_scroll_down (struct t_gui_window *window) { gui_chat_calculate_line_diff (window, &window->start_line, &window->start_line_pos, - cfg_look_scroll_amount); + CONFIG_INTEGER(config_look_scroll_amount)); /* check if we can display all */ ptr_line = window->start_line; diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c index c3f6f409f..97a11ddb8 100644 --- a/src/gui/gtk/gui-gtk-chat.c +++ b/src/gui/gtk/gui-gtk-chat.c @@ -31,6 +31,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-utf8.h" #include "../gui-chat.h" +#include "../gui-color.h" #include "../gui-main.h" #include "../gui-window.h" #include "gui-gtk.h" diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c index 3107ae391..e4a52b214 100644 --- a/src/gui/gtk/gui-gtk-color.c +++ b/src/gui/gtk/gui-gtk-color.c @@ -31,6 +31,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-string.h" #include "../gui-color.h" +#include "../gui-chat.h" #include "gui-gtk.h" diff --git a/src/gui/gtk/gui-gtk-infobar.c b/src/gui/gtk/gui-gtk-infobar.c index f546cbf97..b6bcafd33 100644 --- a/src/gui/gtk/gui-gtk-infobar.c +++ b/src/gui/gtk/gui-gtk-infobar.c @@ -29,7 +29,7 @@ #include "../../core/weechat.h" #include "../../core/wee-config.h" #include "../gui-infobar.h" -#include "../gui-main.h" +#include "../gui-window.h" #include "gui-gtk.h" diff --git a/src/gui/gtk/gui-gtk-input.c b/src/gui/gtk/gui-gtk-input.c index 35111c01c..16347735b 100644 --- a/src/gui/gtk/gui-gtk-input.c +++ b/src/gui/gtk/gui-gtk-input.c @@ -30,7 +30,7 @@ #include "../../core/wee-utf8.h" #include "../../plugins/plugin.h" #include "../gui-input.h" -#include "../gui-main.h" +#include "../gui-window.h" #include "gui-gtk.h" diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c index 46fd7380c..33d1fc9b2 100644 --- a/src/gui/gtk/gui-gtk-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -174,7 +174,7 @@ gui_main_init () else gui_init_ok = 0; - if (cfg_look_set_title) + if (CONFIG_BOOLEAN(config_look_set_title)) gui_window_title_set (); } } @@ -226,6 +226,6 @@ gui_main_end () gui_infobar_remove (); /* reset title */ - if (cfg_look_set_title) + if (CONFIG_BOOLEAN(config_look_set_title)) gui_window_title_reset (); } diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c index e6f00e873..73c310bf8 100644 --- a/src/gui/gtk/gui-gtk-window.c +++ b/src/gui/gtk/gui-gtk-window.c @@ -30,6 +30,7 @@ #include "../../core/wee-config.h" #include "../../core/wee-log.h" #include "../gui-window.h" +#include "../gui-chat.h" #include "../gui-hotlist.h" #include "../gui-nicklist.h" #include "../gui-main.h" @@ -300,8 +301,9 @@ gui_window_scroll_up (struct t_gui_window *window) gui_chat_calculate_line_diff (window, &window->start_line, &window->start_line_pos, (window->start_line) ? - (-1) * cfg_look_scroll_amount : - (-1) * ( (window->win_chat_height - 1) + cfg_look_scroll_amount)); + (-1) * CONFIG_INTEGER(config_look_scroll_amount) : + (-1) * ( (window->win_chat_height - 1) + + CONFIG_INTEGER(config_look_scroll_amount))); gui_chat_draw (window->buffer, 0); gui_status_draw (window->buffer, 0); } @@ -324,7 +326,7 @@ gui_window_scroll_down (struct t_gui_window *window) { gui_chat_calculate_line_diff (window, &window->start_line, &window->start_line_pos, - cfg_look_scroll_amount); + CONFIG_INTEGER(config_look_scroll_amount)); /* check if we can display all */ ptr_line = window->start_line; diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index 55b45e44a..55324c507 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -39,6 +39,7 @@ #include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "gui-buffer.h" +#include "gui-chat.h" #include "gui-completion.h" #include "gui-history.h" #include "gui-hotlist.h" @@ -1387,8 +1388,8 @@ gui_action_scroll_unread (char *args) if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED) { - if (cfg_look_read_marker && - cfg_look_read_marker[0] && + if (CONFIG_STRING(config_look_read_marker) && + CONFIG_STRING(config_look_read_marker)[0] && (gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATED) && gui_current_window->buffer->last_read_line && gui_current_window->buffer->last_read_line != gui_current_window->buffer->last_line) diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index f4719d572..0f2abb410 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -33,6 +33,9 @@ #include <ctype.h> #include "../core/weechat.h" +#include "gui-buffer.h" +#include "gui-chat.h" +#include "gui-color.h" #include "gui-completion.h" #include "gui-history.h" #include "gui-hotlist.h" diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 3c4ee4099..911946c90 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -35,6 +35,7 @@ #include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "gui-chat.h" +#include "gui-color.h" #include "gui-hotlist.h" #include "gui-main.h" #include "gui-status.h" @@ -56,32 +57,32 @@ gui_chat_prefix_build () snprintf (prefix, sizeof (prefix), "%s%s\t", GUI_COLOR(GUI_COLOR_CHAT_PREFIX_INFO), - cfg_look_prefix[GUI_CHAT_PREFIX_INFO]); + CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_INFO])); gui_chat_prefix[GUI_CHAT_PREFIX_INFO] = strdup (prefix); snprintf (prefix, sizeof (prefix), "%s%s\t", GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ERROR), - cfg_look_prefix[GUI_CHAT_PREFIX_ERROR]); + CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ERROR])); gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (prefix); snprintf (prefix, sizeof (prefix), "%s%s\t", GUI_COLOR(GUI_COLOR_CHAT_PREFIX_NETWORK), - cfg_look_prefix[GUI_CHAT_PREFIX_NETWORK]); + CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_NETWORK])); gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (prefix); snprintf (prefix, sizeof (prefix), "%s%s\t", GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ACTION), - cfg_look_prefix[GUI_CHAT_PREFIX_ACTION]); + CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ACTION])); gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (prefix); snprintf (prefix, sizeof (prefix), "%s%s\t", GUI_COLOR(GUI_COLOR_CHAT_PREFIX_JOIN), - cfg_look_prefix[GUI_CHAT_PREFIX_JOIN]); + CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_JOIN])); gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (prefix); snprintf (prefix, sizeof (prefix), "%s%s\t", GUI_COLOR(GUI_COLOR_CHAT_PREFIX_QUIT), - cfg_look_prefix[GUI_CHAT_PREFIX_QUIT]); + CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_QUIT])); gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (prefix); } @@ -210,13 +211,14 @@ gui_chat_get_time_string (time_t date) int i, time_first_digit, time_last_digit, last_color; struct tm *local_time; - if (!cfg_look_buffer_time_format - || !cfg_look_buffer_time_format[0]) + if (!CONFIG_STRING(config_look_buffer_time_format) + || !CONFIG_STRING(config_look_buffer_time_format)[0]) return NULL; local_time = localtime (&date); if (strftime (text_time, sizeof (text_time), - cfg_look_buffer_time_format, local_time) == 0) + CONFIG_STRING(config_look_buffer_time_format), + local_time) == 0) return NULL; time_first_digit = -1; @@ -325,17 +327,18 @@ gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line, { int length_suffix; - if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_NONE) + if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE) return gui_chat_time_length + 1 + line->prefix_length + 2; length_suffix = 0; if (with_suffix) { - if (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0]) - length_suffix = gui_chat_strlen_screen (cfg_look_prefix_suffix) + 1; + if (CONFIG_STRING(config_look_prefix_suffix) + && CONFIG_STRING(config_look_prefix_suffix)[0]) + length_suffix = gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)) + 1; } - if (cfg_look_prefix_align_max > 0) - return gui_chat_time_length + 1 + cfg_look_prefix_align_max + + if (CONFIG_INTEGER(config_look_prefix_align_max) > 0) + return gui_chat_time_length + 1 + CONFIG_INTEGER(config_look_prefix_align_max) + length_suffix + 1; else return gui_chat_time_length + 1 + buffer->prefix_max_length + @@ -434,8 +437,8 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, buffer->lines_count++; /* remove one line if necessary */ - if ((cfg_history_max_lines > 0) - && (buffer->lines_count > cfg_history_max_lines)) + if ((CONFIG_INTEGER(config_history_max_lines) > 0) + && (buffer->lines_count > CONFIG_INTEGER(config_history_max_lines))) { if (buffer->last_line == buffer->lines) buffer->last_line = NULL; diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index ad391c0e3..09fa063e7 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -47,16 +47,20 @@ int gui_color_search_config (char *color_name) { - int i; + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; if (color_name) { - i = 0; - while (weechat_options_colors[i].name) + ptr_section = config_file_search_section (weechat_config, "colors"); + if (ptr_section) { - if (string_strcasecmp (weechat_options_colors[i].name, color_name) == 0) - return weechat_options_colors[i].default_int; - i++; + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + if (string_strcasecmp (ptr_option->name, color_name) == 0) + return ptr_option->min; + } } } diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 44e56832a..f7869e34e 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -42,6 +42,7 @@ #include "../plugins/plugin.h" #include "../plugins/plugin-config.h" #include "gui-completion.h" +#include "gui-color.h" #include "gui-keyboard.h" @@ -203,7 +204,8 @@ gui_completion_is_only_alphanum (char *string) { while (string[0]) { - if (strchr (cfg_look_nick_completion_ignore, string[0])) + if (strchr (CONFIG_STRING(config_look_nick_completion_ignore), + string[0])) return 0; string++; } @@ -223,7 +225,8 @@ gui_completion_strdup_alphanum (char *string) pos = result; while (string[0]) { - if (!strchr (cfg_look_nick_completion_ignore, string[0])) + if (!strchr (CONFIG_STRING(config_look_nick_completion_ignore), + string[0])) { pos[0] = string[0]; pos++; @@ -245,8 +248,8 @@ gui_completion_nickncmp (char *base_word, char *nick, int max) char *base_word2, *nick2; int return_cmp; - if (!cfg_look_nick_completion_ignore - || !cfg_look_nick_completion_ignore[0] + if (!CONFIG_STRING(config_look_nick_completion_ignore) + || !CONFIG_STRING(config_look_nick_completion_ignore)[0] || !base_word || !nick || !base_word[0] || !nick[0] || (!gui_completion_is_only_alphanum (base_word))) return string_strncasecmp (base_word, nick, max); @@ -600,7 +603,7 @@ gui_completion_list_add_channel_nicks (struct t_gui_completion *completion) } // add nicks speaking recently on this channel - if (cfg_look_nick_completion_smart) + if (CONFIG_BOOLEAN(config_look_nick_completion_smart)) { for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking; ptr_weelist; ptr_weelist = ptr_weelist->next_weelist) @@ -684,19 +687,18 @@ gui_completion_list_add_channel_nicks_hosts (struct t_gui_completion *completion void gui_completion_list_add_option (struct t_gui_completion *completion) { - int i, j; - - /* WeeChat options */ - for (i = 0; weechat_config_sections[i]; i++) + struct t_config_section *ptr_section; + struct t_config_option *ptr_option; + + for (ptr_section = weechat_config->sections; ptr_section; + ptr_section = ptr_section->next_section) { - if (weechat_config_options[i]) + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) { - for (j = 0; weechat_config_options[i][j].name; j++) - { - gui_completion_list_add (completion, - weechat_config_options[i][j].name, - 0, WEELIST_POS_SORT); - } + gui_completion_list_add (completion, + ptr_option->name, + 0, WEELIST_POS_SORT); } } } @@ -708,12 +710,13 @@ gui_completion_list_add_option (struct t_gui_completion *completion) void gui_completion_list_add_plugin_option (struct t_gui_completion *completion) { - struct t_plugin_option *ptr_option; + struct t_config_option *ptr_option; for (ptr_option = plugin_options; ptr_option; ptr_option = ptr_option->next_option) { - gui_completion_list_add (completion, ptr_option->name, 0, WEELIST_POS_SORT); + gui_completion_list_add (completion, ptr_option->name, + 0, WEELIST_POS_SORT); } } @@ -725,8 +728,8 @@ void gui_completion_list_add_part (struct t_gui_completion *completion) { (void) completion; - /*if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0]) - gui_completion_list_add (completion, cfg_irc_default_msg_part, + /*if (config_irc_default_msg_part && config_irc_default_msg_part[0]) + gui_completion_list_add (completion, config_irc_default_msg_part, 0, WEELIST_POS_SORT);*/ } @@ -755,8 +758,8 @@ void gui_completion_list_add_quit (struct t_gui_completion *completion) { (void) completion; - /*if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0]) - gui_completion_list_add (completion, cfg_irc_default_msg_quit, + /*if (config_irc_default_msg_quit && config_irc_default_msg_quit[0]) + gui_completion_list_add (completion, config_irc_default_msg_quit, 0, WEELIST_POS_SORT);*/ } @@ -806,7 +809,7 @@ gui_completion_list_add_topic (struct t_gui_completion *completion) && ((t_irc_channel *)(completion->channel))->topic && ((t_irc_channel *)(completion->channel))->topic[0]) { - if (cfg_irc_colors_send) + if (config_irc_colors_send) string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)(completion->channel))->topic); else string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)(completion->channel))->topic, 0, 0); @@ -826,65 +829,54 @@ gui_completion_list_add_topic (struct t_gui_completion *completion) void gui_completion_list_add_option_value (struct t_gui_completion *completion) { - char *pos; - struct t_config_option *option; - void *option_value; - char option_string[2048]; + char *pos, *color_name, option_string[2048]; + struct t_config_option *ptr_option; if (completion->args) { pos = strchr (completion->args, ' '); if (pos) pos[0] = '\0'; - option = NULL; - option_value = NULL; - //config_option_search_option_value (completion->args, &option, &option_value); - config_option_section_option_search_get_value (weechat_config_sections, - weechat_config_options, - completion->args, - &option, - &option_value); - if (option && option_value) + ptr_option = config_file_search_option (weechat_config, + NULL, + completion->args); + if (ptr_option) { - switch (option->type) + switch (ptr_option->type) { - case OPTION_TYPE_BOOLEAN: - if (option_value && (*((int *)(option_value)))) + case CONFIG_OPTION_BOOLEAN: + if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE) gui_completion_list_add (completion, "on", 0, WEELIST_POS_SORT); else gui_completion_list_add (completion, "off", 0, WEELIST_POS_SORT); break; - case OPTION_TYPE_INT: - snprintf (option_string, sizeof (option_string) - 1, - "%d", (option_value) ? *((int *)(option_value)) : option->default_int); + case CONFIG_OPTION_INTEGER: + if (ptr_option->string_values) + snprintf (option_string, sizeof (option_string) - 1, + "%s", + ptr_option->string_values[CONFIG_INTEGER(ptr_option)]); + else + snprintf (option_string, sizeof (option_string) - 1, + "%d", CONFIG_INTEGER(ptr_option)); gui_completion_list_add (completion, option_string, 0, WEELIST_POS_SORT); break; - case OPTION_TYPE_INT_WITH_STRING: - gui_completion_list_add (completion, - (option_value) ? - option->array_values[*((int *)(option_value))] : - option->array_values[option->default_int], - 0, WEELIST_POS_SORT); - break; - case OPTION_TYPE_COLOR: - gui_completion_list_add (completion, - (option_value) ? - gui_color_get_name (*((int *)(option_value))) : - option->default_string, - 0, WEELIST_POS_SORT); - break; - case OPTION_TYPE_STRING: + case CONFIG_OPTION_STRING: snprintf (option_string, sizeof (option_string) - 1, "\"%s\"", - ((option_value) && (*((char **)(option_value)))) ? - *((char **)(option_value)) : - option->default_string); + CONFIG_STRING(ptr_option)); gui_completion_list_add (completion, option_string, 0, WEELIST_POS_SORT); break; + case CONFIG_OPTION_COLOR: + color_name = gui_color_get_name (CONFIG_INTEGER(ptr_option)); + if (color_name) + gui_completion_list_add (completion, + color_name, + 0, WEELIST_POS_SORT); + break; } } if (pos) @@ -900,7 +892,7 @@ void gui_completion_list_add_plugin_option_value (struct t_gui_completion *completion) { char *pos; - struct t_plugin_option *ptr_option; + struct t_config_option *ptr_option; if (completion->args) { @@ -1443,7 +1435,7 @@ gui_completion_nick (struct t_gui_completion *completion) } // add nicks speaking recently on this channel - if (cfg_look_nick_completion_smart) + if (CONFIG_BOOLEAN(config_look_nick_completion_smart)) { for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking; ptr_weelist; ptr_weelist = ptr_weelist->next_weelist) @@ -1485,7 +1477,7 @@ gui_completion_nick (struct t_gui_completion *completion) if (completion->word_found) free (completion->word_found); completion->word_found = strdup (ptr_weelist->data); - if (cfg_look_nick_complete_first) + if (CONFIG_BOOLEAN(config_look_nick_complete_first)) { completion->position = -1; return; diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c index 3ce9f0022..216ee7e6b 100644 --- a/src/gui/gui-history.c +++ b/src/gui/gui-history.c @@ -30,6 +30,7 @@ #include "../core/wee-config.h" #include "../core/wee-string.h" #include "gui-history.h" +#include "gui-buffer.h" struct t_gui_history *history_global = NULL; @@ -43,46 +44,50 @@ int num_history_global = 0; */ void -gui_history_buffer_add (struct t_gui_buffer *buffer, char *string) +gui_history_buffer_add (void *buffer, char *string) { + struct t_gui_buffer *ptr_buffer; struct t_gui_history *new_history, *ptr_history; + ptr_buffer = (struct t_gui_buffer *)buffer; + if (!string) return; - if (!buffer->history - || (buffer->history - && (string_strcasecmp (buffer->history->text, string) != 0))) + if (!ptr_buffer->history + || (ptr_buffer->history + && (string_strcasecmp (ptr_buffer->history->text, + string) != 0))) { new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history)); if (new_history) { new_history->text = strdup (string); - /*if (cfg_log_hide_nickserv_pwd) + /*if (config_log_hide_nickserv_pwd) irc_display_hide_password (new_history->text, 1);*/ - if (buffer->history) - buffer->history->prev_history = new_history; + if (ptr_buffer->history) + ptr_buffer->history->prev_history = new_history; else - buffer->last_history = new_history; - new_history->next_history = buffer->history; + ptr_buffer->last_history = new_history; + new_history->next_history = ptr_buffer->history; new_history->prev_history = NULL; - buffer->history = new_history; - buffer->num_history++; + ptr_buffer->history = new_history; + ptr_buffer->num_history++; /* remove one command if necessary */ - if ((cfg_history_max_commands > 0) - && (buffer->num_history > cfg_history_max_commands)) + if ((CONFIG_INTEGER(config_history_max_commands) > 0) + && (ptr_buffer->num_history > CONFIG_INTEGER(config_history_max_commands))) { - ptr_history = buffer->last_history->prev_history; - if (buffer->ptr_history == buffer->last_history) - buffer->ptr_history = ptr_history; - buffer->last_history->prev_history->next_history = NULL; - if (buffer->last_history->text) - free (buffer->last_history->text); - free (buffer->last_history); - buffer->last_history = ptr_history; - buffer->num_history++; + ptr_history = ptr_buffer->last_history->prev_history; + if (ptr_buffer->ptr_history == ptr_buffer->last_history) + ptr_buffer->ptr_history = ptr_history; + ptr_buffer->last_history->prev_history->next_history = NULL; + if (ptr_buffer->last_history->text) + free (ptr_buffer->last_history->text); + free (ptr_buffer->last_history); + ptr_buffer->last_history = ptr_history; + ptr_buffer->num_history++; } } } @@ -108,7 +113,7 @@ gui_history_global_add (char *string) if (new_history) { new_history->text = strdup (string); - /*if (cfg_log_hide_nickserv_pwd) + /*if (config_log_hide_nickserv_pwd) irc_display_hide_password (new_history->text, 1);*/ if (history_global) @@ -121,8 +126,8 @@ gui_history_global_add (char *string) num_history_global++; /* remove one command if necessary */ - if ((cfg_history_max_commands > 0) - && (num_history_global > cfg_history_max_commands)) + if ((CONFIG_INTEGER(config_history_max_commands) > 0) + && (num_history_global > CONFIG_INTEGER(config_history_max_commands))) { ptr_history = history_global_last->prev_history; if (history_global_ptr == history_global_last) @@ -167,20 +172,23 @@ gui_history_global_free () */ void -gui_history_buffer_free (struct t_gui_buffer *buffer) +gui_history_buffer_free (void *buffer) { + struct t_gui_buffer *ptr_buffer; struct t_gui_history *ptr_history; - while (buffer->history) + ptr_buffer = (struct t_gui_buffer *)buffer; + + while (ptr_buffer->history) { - ptr_history = buffer->history->next_history; - if (buffer->history->text) - free (buffer->history->text); - free (buffer->history); - buffer->history = ptr_history; + ptr_history = ptr_buffer->history->next_history; + if (ptr_buffer->history->text) + free (ptr_buffer->history->text); + free (ptr_buffer->history); + ptr_buffer->history = ptr_history; } - buffer->history = NULL; - buffer->last_history = NULL; - buffer->ptr_history = NULL; - buffer->num_history = 0; + ptr_buffer->history = NULL; + ptr_buffer->last_history = NULL; + ptr_buffer->ptr_history = NULL; + ptr_buffer->num_history = 0; } diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h index aa9296813..40fedc71b 100644 --- a/src/gui/gui-history.h +++ b/src/gui/gui-history.h @@ -32,9 +32,9 @@ extern struct t_gui_history *history_global_last; extern struct t_gui_history *history_global_ptr; /* history functions (gui-history.c) */ -extern void gui_history_buffer_add (struct t_gui_buffer *, char *); +extern void gui_history_buffer_add (void *, char *); extern void gui_history_global_add (char *); extern void gui_history_global_free (); -extern void gui_history_buffer_free (struct t_gui_buffer *); +extern void gui_history_buffer_free (void *); #endif /* gui-history.h */ diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c index b969768be..f0c2c3c46 100644 --- a/src/gui/gui-hotlist.c +++ b/src/gui/gui-hotlist.c @@ -31,6 +31,7 @@ #include "../core/wee-log.h" #include "../core/wee-util.h" #include "gui-hotlist.h" +#include "gui-buffer.h" #include "gui-window.h" @@ -70,9 +71,9 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h { struct t_gui_hotlist *ptr_hotlist; - switch (cfg_look_hotlist_sort) + switch (CONFIG_INTEGER(config_look_hotlist_sort)) { - case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC: + case CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC: for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { @@ -83,7 +84,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h return ptr_hotlist; } break; - case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC: + case CONFIG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC: for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { @@ -94,7 +95,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h return ptr_hotlist; } break; - case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC: + case CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC: for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { @@ -104,7 +105,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h return ptr_hotlist; } break; - case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC: + case CONFIG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC: for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { @@ -114,7 +115,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h return ptr_hotlist; } break; - case CFG_LOOK_HOTLIST_SORT_NUMBER_ASC: + case CONFIG_LOOK_HOTLIST_SORT_NUMBER_ASC: for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { @@ -122,7 +123,7 @@ gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_h return ptr_hotlist; } break; - case CFG_LOOK_HOTLIST_SORT_NUMBER_DESC: + case CONFIG_LOOK_HOTLIST_SORT_NUMBER_DESC: for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist) { diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index cec1b2eb3..3144e25c7 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -242,13 +242,15 @@ gui_input_complete (struct t_gui_buffer *buffer) { if (strncmp (utf8_add_offset (buffer->input_buffer, buffer->input_buffer_pos), - cfg_look_nick_completor, strlen (cfg_look_nick_completor)) != 0) - gui_input_insert_string (buffer, cfg_look_nick_completor, + CONFIG_STRING(config_look_nick_completor), + strlen (CONFIG_STRING(config_look_nick_completor))) != 0) + gui_input_insert_string (buffer, + CONFIG_STRING(config_look_nick_completor), buffer->input_buffer_pos); else - buffer->input_buffer_pos += utf8_strlen (cfg_look_nick_completor); + buffer->input_buffer_pos += utf8_strlen (CONFIG_STRING(config_look_nick_completor)); if (buffer->completion->position >= 0) - buffer->completion->position += strlen (cfg_look_nick_completor); + buffer->completion->position += strlen (CONFIG_STRING(config_look_nick_completor)); if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer, buffer->input_buffer_pos)] != ' ') gui_input_insert_string (buffer, " ", @@ -315,7 +317,7 @@ gui_input_get_prompt_length (struct t_gui_buffer *buffer) } length = 0; - pos = cfg_look_input_format; + pos = CONFIG_STRING(config_look_input_format); while (pos && pos[0]) { switch (pos[0]) diff --git a/src/gui/gui-main.h b/src/gui/gui-main.h index f657db0cf..04c3f2e24 100644 --- a/src/gui/gui-main.h +++ b/src/gui/gui-main.h @@ -20,11 +20,6 @@ #ifndef __WEECHAT_GUI_MAIN_H #define __WEECHAT_GUI_MAIN_H 1 -/* main variables */ - -extern int gui_init_ok; -extern int gui_ok; - /* main functions (GUI dependent) */ extern void gui_main_loop (); diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index f7baa1bad..c8cba5124 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -38,6 +38,7 @@ #include "../core/wee-log.h" #include "../core/wee-utf8.h" #include "gui-window.h" +#include "gui-chat.h" #include "gui-input.h" #include "gui-hotlist.h" #include "gui-status.h" diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h index af29faba5..e1aab192c 100644 --- a/src/gui/gui-window.h +++ b/src/gui/gui-window.h @@ -20,6 +20,9 @@ #ifndef __WEECHAT_GUI_WINDOW_H #define __WEECHAT_GUI_WINDOW_H 1 +extern int gui_init_ok; +extern int gui_ok; + /* window structures */ struct t_gui_window diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 97202d154..7c91277e3 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -41,6 +41,7 @@ #include "../core/wee-utf8.h" #include "../core/wee-util.h" #include "../gui/gui-chat.h" +#include "../gui/gui-color.h" #include "../gui/gui-infobar.h" #include "../gui/gui-input.h" #include "../gui/gui-keyboard.h" @@ -1110,26 +1111,22 @@ plugin_api_get_config_str_value (struct t_config_option *option) switch (option->type) { - case OPTION_TYPE_BOOLEAN: - return (*((int *)(option->ptr_int))) ? + case CONFIG_OPTION_BOOLEAN: + return (CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ? strdup ("on") : strdup ("off"); - break; - case OPTION_TYPE_INT: - snprintf (buf_temp, sizeof (buf_temp), "%d", - *((int *)(option->ptr_int))); + case CONFIG_OPTION_INTEGER: + if (option->string_values) + snprintf (buf_temp, sizeof (buf_temp), "%s", + option->string_values[CONFIG_INTEGER(option)]); + else + snprintf (buf_temp, sizeof (buf_temp), "%d", + CONFIG_INTEGER(option)); return strdup (buf_temp); - break; - case OPTION_TYPE_INT_WITH_STRING: - return strdup (option->array_values[*((int *)(option->ptr_int))]); - break; - case OPTION_TYPE_STRING: - return (*((char **)(option->ptr_string))) ? - strdup (*((char **)(option->ptr_string))) : strdup (""); - break; - case OPTION_TYPE_COLOR: - color_name = gui_color_get_name (*((int *)(option->ptr_int))); + case CONFIG_OPTION_STRING: + return strdup (CONFIG_STRING(option)); + case CONFIG_OPTION_COLOR: + color_name = gui_color_get_name (CONFIG_INTEGER(option)); return (color_name) ? strdup (color_name) : strdup (""); - break; } /* should never be executed! */ @@ -1137,7 +1134,7 @@ plugin_api_get_config_str_value (struct t_config_option *option) } /* - * plugin_api_config_get: get value of a config option + * plugin_api_config_get: get value of a WeeChat config option */ char * @@ -1147,11 +1144,9 @@ plugin_api_config_get (struct t_weechat_plugin *plugin, char *option_name) /* make C compiler happy */ (void) plugin; - - /* search a WeeChat command */ - ptr_option = config_option_section_option_search (weechat_config_sections, - weechat_config_options, - option_name); + + /* search WeeChat config option */ + ptr_option = config_file_search_option (weechat_config, NULL, option_name); if (ptr_option) return plugin_api_get_config_str_value (ptr_option); @@ -1168,6 +1163,7 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name, char *value) { struct t_config_option *ptr_option; + int rc; /* make C compiler happy */ (void) plugin; @@ -1175,22 +1171,16 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name, if (!option_name || !value) return 0; - /* search and set WeeChat option if found */ - ptr_option = config_option_section_option_search (weechat_config_sections, - weechat_config_options, - option_name); + /* search and set WeeChat config option if found */ + ptr_option = config_file_search_option (weechat_config, NULL, option_name); if (ptr_option) { - if (ptr_option->handler_change) - { - if (config_option_set (ptr_option, value) == 0) - { - (void) (ptr_option->handler_change()); - return 1; - } - } - else + rc = config_file_option_set (ptr_option, value); + if ((rc == 2) && (ptr_option->callback_change)) + (void) (ptr_option->callback_change) (); + if (rc == 0) return 0; + return 1; } /* failed to set config option */ @@ -1202,16 +1192,16 @@ plugin_api_config_set (struct t_weechat_plugin *plugin, char *option_name, */ char * -plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option) +plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option_name) { - struct t_plugin_option *ptr_plugin_option; + struct t_config_option *ptr_option; - if (!option) + if (!option_name) return NULL; - ptr_plugin_option = plugin_config_search (plugin->name, option); - if (ptr_plugin_option) - return (ptr_plugin_option->value) ? strdup (ptr_plugin_option->value) : NULL; + ptr_option = plugin_config_search (plugin->name, option_name); + if (ptr_option) + return (ptr_option->value) ? strdup (ptr_option->value) : NULL; /* option not found */ return NULL; @@ -1222,13 +1212,13 @@ plugin_api_plugin_config_get (struct t_weechat_plugin *plugin, char *option) */ int -plugin_api_plugin_config_set (struct t_weechat_plugin *plugin, char *option, - char *value) +plugin_api_plugin_config_set (struct t_weechat_plugin *plugin, + char *option_name, char *value) { - if (!option) + if (!option_name) return 0; - if (plugin_config_set (plugin->name, option, value)) + if (plugin_config_set (plugin->name, option_name, value)) { plugin_config_write (); return 1; diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c index 197fe1182..b621e0a71 100644 --- a/src/plugins/plugin-config.c +++ b/src/plugins/plugin-config.c @@ -37,20 +37,9 @@ #include "plugin-config.h" -struct t_plugin_option *plugin_options = NULL; -struct t_plugin_option *last_plugin_option = NULL; - -char *plugin_config_sections[] = -{ "plugin", NULL }; - -struct t_config_option *plugin_config_options[] = -{ NULL, NULL }; - -t_config_func_read_option *plugin_config_read_functions[] = -{ plugin_config_read_option, NULL }; - -t_config_func_write_options *plugin_config_write_functions[] = -{ plugin_config_write_options, NULL }; +struct t_config_file *plugin_config = NULL; +struct t_config_option *plugin_options = NULL; +struct t_config_option *last_plugin_option = NULL; /* @@ -58,17 +47,17 @@ t_config_func_write_options *plugin_config_write_functions[] = * This function should not be called directly. */ -struct t_plugin_option * -plugin_config_search_internal (char *option) +struct t_config_option * +plugin_config_search_internal (char *option_name) { - struct t_plugin_option *ptr_plugin_option; + struct t_config_option *ptr_option; - for (ptr_plugin_option = plugin_options; ptr_plugin_option; - ptr_plugin_option = ptr_plugin_option->next_option) + for (ptr_option = plugin_options; ptr_option; + ptr_option = ptr_option->next_option) { - if (string_strcasecmp (ptr_plugin_option->name, option) == 0) + if (string_strcasecmp (ptr_option->name, option_name) == 0) { - return ptr_plugin_option; + return ptr_option; } } @@ -80,36 +69,36 @@ plugin_config_search_internal (char *option) * plugin_config_search: search a plugin option */ -struct t_plugin_option * -plugin_config_search (char *plugin_name, char *option) +struct t_config_option * +plugin_config_search (char *plugin_name, char *option_name) { char *internal_option; - struct t_plugin_option *ptr_plugin_option; + struct t_config_option *ptr_option; internal_option = (char *)malloc (strlen (plugin_name) + - strlen (option) + 2); + strlen (option_name) + 2); if (!internal_option) return NULL; strcpy (internal_option, plugin_name); strcat (internal_option, "."); - strcat (internal_option, option); + strcat (internal_option, option_name); - ptr_plugin_option = plugin_config_search_internal (internal_option); + ptr_option = plugin_config_search_internal (internal_option); free (internal_option); - return ptr_plugin_option; + return ptr_option; } /* * plugin_config_find_pos: find position for a plugin option (for sorting options) */ -struct t_plugin_option * +struct t_config_option * plugin_config_find_pos (char *name) { - struct t_plugin_option *ptr_option; + struct t_config_option *ptr_option; for (ptr_option = plugin_options; ptr_option; ptr_option = ptr_option->next_option) @@ -117,6 +106,8 @@ plugin_config_find_pos (char *name) if (string_strcasecmp (name, ptr_option->name) < 0) return ptr_option; } + + /* position not found (we will add to the end of list) */ return NULL; } @@ -129,33 +120,33 @@ plugin_config_find_pos (char *name) int plugin_config_set_internal (char *option, char *value) { - struct t_plugin_option *ptr_plugin_option, *pos_option; + struct t_config_option *ptr_option, *pos_option; int rc; rc = 0; - ptr_plugin_option = plugin_config_search_internal (option); - if (ptr_plugin_option) + ptr_option = plugin_config_search_internal (option); + if (ptr_option) { if (!value || !value[0]) { /* remove option from list */ - if (ptr_plugin_option->prev_option) - (ptr_plugin_option->prev_option)->next_option = - ptr_plugin_option->next_option; + if (ptr_option->prev_option) + (ptr_option->prev_option)->next_option = + ptr_option->next_option; else - plugin_options = ptr_plugin_option->next_option; - if (ptr_plugin_option->next_option) - (ptr_plugin_option->next_option)->prev_option = - ptr_plugin_option->prev_option; + plugin_options = ptr_option->next_option; + if (ptr_option->next_option) + (ptr_option->next_option)->prev_option = + ptr_option->prev_option; rc = 1; } else { /* replace old value by new one */ - if (ptr_plugin_option->value) - free (ptr_plugin_option->value); - ptr_plugin_option->value = strdup (value); + if (ptr_option->value) + free (ptr_option->value); + ptr_option->value = strdup (value); rc = 1; } } @@ -163,43 +154,50 @@ plugin_config_set_internal (char *option, char *value) { if (value && value[0]) { - ptr_plugin_option = (struct t_plugin_option *)malloc (sizeof (struct t_plugin_option)); - if (ptr_plugin_option) + ptr_option = (struct t_config_option *)malloc (sizeof (struct t_config_option)); + if (ptr_option) { /* create new option */ - ptr_plugin_option->name = strdup (option); - string_tolower (ptr_plugin_option->name); - ptr_plugin_option->value = strdup (value); + ptr_option->name = strdup (option); + string_tolower (ptr_option->name); + ptr_option->type = CONFIG_OPTION_STRING; + ptr_option->description = NULL; + ptr_option->string_values = NULL; + ptr_option->min = 0; + ptr_option->max = 0; + ptr_option->default_value = NULL; + ptr_option->value = strdup (value); + ptr_option->callback_change = NULL; if (plugin_options) { - pos_option = plugin_config_find_pos (ptr_plugin_option->name); + pos_option = plugin_config_find_pos (ptr_option->name); if (pos_option) { /* insert option into the list (before option found) */ - ptr_plugin_option->prev_option = pos_option->prev_option; - ptr_plugin_option->next_option = pos_option; + ptr_option->prev_option = pos_option->prev_option; + ptr_option->next_option = pos_option; if (pos_option->prev_option) - pos_option->prev_option->next_option = ptr_plugin_option; + pos_option->prev_option->next_option = ptr_option; else - plugin_options = ptr_plugin_option; - pos_option->prev_option = ptr_plugin_option; + plugin_options = ptr_option; + pos_option->prev_option = ptr_option; } else { /* add option to the end */ - ptr_plugin_option->prev_option = last_plugin_option; - ptr_plugin_option->next_option = NULL; - last_plugin_option->next_option = ptr_plugin_option; - last_plugin_option = ptr_plugin_option; + ptr_option->prev_option = last_plugin_option; + ptr_option->next_option = NULL; + last_plugin_option->next_option = ptr_option; + last_plugin_option = ptr_option; } } else { - ptr_plugin_option->prev_option = NULL; - ptr_plugin_option->next_option = NULL; - plugin_options = ptr_plugin_option; - last_plugin_option = ptr_plugin_option; + ptr_option->prev_option = NULL; + ptr_option->next_option = NULL; + plugin_options = ptr_option; + last_plugin_option = ptr_option; } rc = 1; } @@ -220,19 +218,19 @@ plugin_config_set_internal (char *option, char *value) */ int -plugin_config_set (char *plugin_name, char *option, char *value) +plugin_config_set (char *plugin_name, char *option_name, char *value) { char *internal_option; int return_code; internal_option = (char *)malloc (strlen (plugin_name) + - strlen (option) + 2); + strlen (option_name) + 2); if (!internal_option) return 0; strcpy (internal_option, plugin_name); strcat (internal_option, "."); - strcat (internal_option, option); + strcat (internal_option, option_name); return_code = plugin_config_set_internal (internal_option, value); free (internal_option); @@ -247,76 +245,67 @@ plugin_config_set (char *plugin_name, char *option, char *value) * -2 = bad format/value */ -int -plugin_config_read_option (struct t_config_option *options, +void +plugin_config_read_option (struct t_config_file *config_file, char *option_name, char *value) { char *value2; /* make C compiler happy */ - (void) options; + (void) config_file; - if (option_name) - { - value2 = string_iconv_to_internal (NULL, value); - plugin_config_set_internal (option_name, - (value2) ? value2 : value); - if (value2) - free (value2); - } - else + value2 = string_iconv_to_internal (NULL, value); + plugin_config_set_internal (option_name, + (value2) ? value2 : value); + if (value2) + free (value2); +} + +/* + * plugin_config_write_options: write plugin options in configuration file + */ + +void +plugin_config_write_options (struct t_config_file *config_file) +{ + struct t_config_option *ptr_option; + + for (ptr_option = plugin_options; ptr_option; + ptr_option = ptr_option->next_option) { - /* does nothing for new [plugin] section */ + config_file_write_line (config_file, + ptr_option->name, + ptr_option->value); } - - /* all ok */ - return 0; -} +} /* * plugin_config_read: read WeeChat plugins configuration file * return: 0 = successful * -1 = config file file not found * -2 = error in config file + * -3 = not enough memory */ int plugin_config_read () { - return config_file_read (plugin_config_sections, plugin_config_options, - plugin_config_read_functions, - plugin_config_read_option, - NULL, - WEECHAT_PLUGIN_CONFIG_NAME); -} - -/* - * plugin_config_write_options: write plugin options in configuration file - * Return: 0 = successful - * -1 = write error - */ - -int -plugin_config_write_options (FILE *file, char *section_name, - struct t_config_option *options) -{ - /* make C compiler happy */ - (void) options; - - struct t_plugin_option *ptr_plugin_option; - - string_iconv_fprintf (file, "\n[%s]\n", section_name); - - for (ptr_plugin_option = plugin_options; ptr_plugin_option; - ptr_plugin_option = ptr_plugin_option->next_option) + if (!plugin_config) { - string_iconv_fprintf (file, "%s = \"%s\"\n", - ptr_plugin_option->name, - ptr_plugin_option->value); + plugin_config = config_file_new (PLUGIN_CONFIG_FILENAME); + if (plugin_config) + { + config_file_new_section (plugin_config, "plugin", + &plugin_config_read_option, + &plugin_config_write_options, + NULL); + } } - /* all ok */ - return 0; + if (!plugin_config) + return -3; + + return config_file_read (plugin_config); } /* @@ -329,7 +318,5 @@ int plugin_config_write () { log_printf (_("Saving plugins configuration to disk\n")); - return config_file_write (plugin_config_sections, plugin_config_options, - plugin_config_write_functions, - WEECHAT_PLUGIN_CONFIG_NAME); + return config_file_write (plugin_config, 0); } diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h index 27ce60b4f..7558388ba 100644 --- a/src/plugins/plugin-config.h +++ b/src/plugins/plugin-config.h @@ -20,28 +20,16 @@ #ifndef __WEECHAT_PLUGIN_CONFIG_H #define __WEECHAT_PLUGIN_CONFIG_H 1 -#include "../core/wee-config-option.h" +#define PLUGIN_CONFIG_FILENAME "plugins.rc" -#define WEECHAT_PLUGIN_CONFIG_NAME "plugins.rc" +extern struct t_config_file *plugin_config; +extern struct t_config_option *plugin_options; -struct t_plugin_option -{ - char *name; /* option name in config file */ - char *value; /* value of option */ - struct t_plugin_option *prev_option; /* link to previous option */ - struct t_plugin_option *next_option; /* link to next option */ -}; - -extern struct t_plugin_option *plugin_options; - -extern struct t_plugin_option *plugin_config_search_internal (char *); -extern struct t_plugin_option *plugin_config_search (char *, char *); +extern struct t_config_option *plugin_config_search_internal (char *); +extern struct t_config_option *plugin_config_search (char *, char *); extern int plugin_config_set_internal (char *, char *); extern int plugin_config_set (char *, char *, char *); -extern int plugin_config_read_option (struct t_config_option *, char *, char *); extern int plugin_config_read (); -extern int plugin_config_write_options (FILE *, char *, - struct t_config_option *); extern int plugin_config_write (); #endif /* plugin-config.h */ diff --git a/src/plugins/plugin-list.c b/src/plugins/plugin-list.c index 8a1c56809..da3de5dac 100644 --- a/src/plugins/plugin-list.c +++ b/src/plugins/plugin-list.c @@ -588,7 +588,7 @@ plugin_list_print_log () switch (ptr_var->type) { case PLUGIN_LIST_VAR_INTEGER: - log_printf (" value (int). . . . . : %d\n", *((int *)ptr_var->value)); + log_printf (" value (integer). . . : %d\n", *((int *)ptr_var->value)); break; case PLUGIN_LIST_VAR_STRING: log_printf (" value (string) . . . : '%s'\n", (char *)ptr_var->value); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 7734d8503..54eea1191 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -338,12 +338,14 @@ plugin_auto_load_file (struct t_weechat_plugin *plugin, char *filename) /* make C compiler happy */ (void) plugin; - if (cfg_plugins_extension && cfg_plugins_extension[0]) + if (CONFIG_STRING(config_plugins_extension) + && CONFIG_STRING(config_plugins_extension)[0]) { - pos = strstr (filename, cfg_plugins_extension); + pos = strstr (filename, CONFIG_STRING(config_plugins_extension)); if (pos) { - if (string_strcasecmp (pos, cfg_plugins_extension) == 0) + if (string_strcasecmp (pos, + CONFIG_STRING(config_plugins_extension)) == 0) plugin_load (filename); } } @@ -362,22 +364,26 @@ plugin_auto_load () char *ptr_home, *dir_name, *plugins_path, *plugins_path2; char *list_plugins, *pos, *pos2; - if (cfg_plugins_autoload && cfg_plugins_autoload[0]) + if (CONFIG_STRING(config_plugins_autoload) + && CONFIG_STRING(config_plugins_autoload)[0]) { - if (string_strcasecmp (cfg_plugins_autoload, "*") == 0) + if (string_strcasecmp (CONFIG_STRING(config_plugins_autoload), + "*") == 0) { /* auto-load plugins in WeeChat home dir */ - if (cfg_plugins_path && cfg_plugins_path[0]) + if (CONFIG_STRING(config_plugins_path) + && CONFIG_STRING(config_plugins_path)[0]) { ptr_home = getenv ("HOME"); - plugins_path = string_replace (cfg_plugins_path, "~", ptr_home); + plugins_path = string_replace (CONFIG_STRING(config_plugins_path), + "~", ptr_home); plugins_path2 = string_replace ((plugins_path) ? - plugins_path : cfg_plugins_path, + plugins_path : CONFIG_STRING(config_plugins_path), "%h", weechat_home); plugin_exec_on_files (NULL, (plugins_path2) ? plugins_path2 : ((plugins_path) ? - plugins_path : cfg_plugins_path), + plugins_path : CONFIG_STRING(config_plugins_path)), &plugin_auto_load_file); if (plugins_path) free (plugins_path); @@ -397,7 +403,7 @@ plugin_auto_load () } else { - list_plugins = strdup (cfg_plugins_autoload); + list_plugins = strdup (CONFIG_STRING(config_plugins_autoload)); if (list_plugins) { pos = list_plugins; |