diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-04-11 18:36:06 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-04-11 18:36:06 +0200 |
commit | d975629686360821c020bb7304b7af1528a877f9 (patch) | |
tree | b021375ae20ae8dcffc9b18b86e3dc24ff538dc8 /src/gui | |
parent | 8211dd6043557f445bf664507fe6daf22a5aa694 (diff) | |
download | weechat-d975629686360821c020bb7304b7af1528a877f9.zip |
Improved /set command, added /unset command, new name for config files (*.conf)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-bar.c | 5 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-color.c | 1 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 6 | ||||
-rw-r--r-- | src/gui/gui-chat.c | 15 | ||||
-rw-r--r-- | src/gui/gui-chat.h | 7 | ||||
-rw-r--r-- | src/gui/gui-color.c | 4 | ||||
-rw-r--r-- | src/gui/gui-color.h | 1 | ||||
-rw-r--r-- | src/gui/gui-completion.c | 252 |
8 files changed, 147 insertions, 144 deletions
diff --git a/src/gui/curses/gui-curses-bar.c b/src/gui/curses/gui-curses-bar.c index 3f9b9c355..2b073c0d9 100644 --- a/src/gui/curses/gui-curses-bar.c +++ b/src/gui/curses/gui-curses-bar.c @@ -94,7 +94,6 @@ gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window, total_size += ptr_bar_window->width; break; case GUI_BAR_NUM_POSITIONS: - /* make C compiler happy */ break; } if (ptr_bar_window->bar->separator) @@ -209,7 +208,6 @@ gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window, bar_window->height = y2 - y1 + 1; break; case GUI_BAR_NUM_POSITIONS: - /* make C compiler happy */ break; } } @@ -266,7 +264,6 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window) bar_window->x - 1); break; case GUI_BAR_NUM_POSITIONS: - /* make C compiler happy */ break; } } @@ -706,7 +703,6 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, } break; case GUI_BAR_NUM_POSITIONS: - /* make C compiler happy */ break; } x = 0; @@ -806,7 +802,6 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, bar_window->height); break; case GUI_BAR_NUM_POSITIONS: - /* make C compiler happy */ break; } wnoutrefresh (bar_window->win_separator); diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index e18c04732..45d709e0c 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -351,7 +351,6 @@ gui_color_init_weechat () 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)); diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 7f266db8c..51fb06960 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -227,8 +227,10 @@ char * gui_buffer_get_string (struct t_gui_buffer *buffer, char *property) { static char value[32]; - - if (string_strcasecmp (property, "category") == 0) + + if (string_strcasecmp (property, "plugin") == 0) + return (buffer->plugin) ? buffer->plugin->name : NULL; + else if (string_strcasecmp (property, "category") == 0) return buffer->category; else if (string_strcasecmp (property, "name") == 0) return buffer->name; diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index c3b8e0340..16c0d3b82 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -47,8 +47,8 @@ #include "gui-window.h" -char *gui_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; /* prefixes */ -char gui_chat_prefix_empty[] = ""; /* empty prefix */ +char *gui_chat_prefix[GUI_CHAT_NUM_PREFIXES]; /* prefixes */ +char gui_chat_prefix_empty[] = ""; /* empty prefix */ int gui_chat_time_length = 0; /* length of time for each line (in chars) */ @@ -60,7 +60,6 @@ int gui_chat_time_length = 0; /* length of time for each line (in chars) */ void gui_chat_prefix_build_empty () { - gui_chat_prefix[GUI_CHAT_PREFIX_INFO] = strdup (gui_chat_prefix_empty); gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (gui_chat_prefix_empty); gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (gui_chat_prefix_empty); gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (gui_chat_prefix_empty); @@ -79,7 +78,7 @@ gui_chat_prefix_build () char prefix[128]; int i; - for (i = 0; i < GUI_CHAT_PREFIX_NUMBER; i++) + for (i = 0; i < GUI_CHAT_NUM_PREFIXES; i++) { if (gui_chat_prefix[i]) { @@ -89,11 +88,6 @@ gui_chat_prefix_build () } snprintf (prefix, sizeof (prefix), "%s%s\t", - GUI_COLOR(GUI_COLOR_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), CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ERROR])); gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (prefix); @@ -807,6 +801,9 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, char *pos, *pos_prefix, *pos_tab, *pos_end; struct t_gui_line *ptr_line; + if (!gui_buffer_valid (buffer)) + return; + if (!message) return; diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h index 0db9bf6f9..685d9fb94 100644 --- a/src/gui/gui-chat.h +++ b/src/gui/gui-chat.h @@ -31,17 +31,16 @@ struct t_gui_line; enum t_gui_prefix { - GUI_CHAT_PREFIX_INFO = 0, - GUI_CHAT_PREFIX_ERROR, + GUI_CHAT_PREFIX_ERROR = 0, GUI_CHAT_PREFIX_NETWORK, GUI_CHAT_PREFIX_ACTION, GUI_CHAT_PREFIX_JOIN, GUI_CHAT_PREFIX_QUIT, - GUI_CHAT_PREFIX_NUMBER, + GUI_CHAT_NUM_PREFIXES, }; -extern char *gui_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; +extern char *gui_chat_prefix[GUI_CHAT_NUM_PREFIXES]; extern char gui_chat_prefix_empty[]; extern int gui_chat_time_length; diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 45ccf0760..2df69ca80 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -52,11 +52,11 @@ gui_color_search_config (char *color_name) { struct t_config_section *ptr_section; struct t_config_option *ptr_option; - + if (color_name) { ptr_section = config_file_search_section (weechat_config_file, - "colors"); + "color"); if (ptr_section) { for (ptr_option = ptr_section->options; ptr_option; diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 83de11aa7..e36660f08 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -32,7 +32,6 @@ enum t_gui_color_enum GUI_COLOR_CHAT, GUI_COLOR_CHAT_TIME, GUI_COLOR_CHAT_TIME_DELIMITERS, - GUI_COLOR_CHAT_PREFIX_INFO, GUI_COLOR_CHAT_PREFIX_ERROR, GUI_COLOR_CHAT_PREFIX_NETWORK, GUI_COLOR_CHAT_PREFIX_ACTION, diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index e0d9ce8eb..00290b7c6 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -329,7 +329,7 @@ gui_completion_list_add_config_files (struct t_gui_completion *completion) for (ptr_config_file = config_files; ptr_config_file; ptr_config_file = ptr_config_file->next_config) { - gui_completion_list_add (completion, ptr_config_file->filename, + gui_completion_list_add (completion, ptr_config_file->name, 0, WEECHAT_LIST_POS_SORT); } } @@ -529,40 +529,41 @@ gui_completion_list_add_nicks (struct t_gui_completion *completion) void gui_completion_list_add_option (struct t_gui_completion *completion) { + struct t_config_file *ptr_config; struct t_config_section *ptr_section; struct t_config_option *ptr_option; - - for (ptr_section = weechat_config_file->sections; ptr_section; - ptr_section = ptr_section->next_section) + int length; + char *option_full_name; + + for (ptr_config = config_files; ptr_config; + ptr_config = ptr_config->next_config) { - for (ptr_option = ptr_section->options; ptr_option; - ptr_option = ptr_option->next_option) + for (ptr_section = ptr_config->sections; ptr_section; + ptr_section = ptr_section->next_section) { - gui_completion_list_add (completion, - ptr_option->name, - 0, WEECHAT_LIST_POS_SORT); + for (ptr_option = ptr_section->options; ptr_option; + ptr_option = ptr_option->next_option) + { + length = strlen (ptr_config->name) + 1 + + strlen (ptr_section->name) + 1 + + strlen (ptr_option->name) + 1; + option_full_name = malloc (length); + if (option_full_name) + { + snprintf (option_full_name, length, "%s.%s.%s", + ptr_config->name, ptr_section->name, + ptr_option->name); + gui_completion_list_add (completion, + option_full_name, + 0, WEECHAT_LIST_POS_SORT); + free (option_full_name); + } + } } } } /* - * gui_completion_list_add_plugin_option: add plugin option to completion list - */ - -void -gui_completion_list_add_plugin_option (struct t_gui_completion *completion) -{ - 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, WEECHAT_LIST_POS_SORT); - } -} - -/* * gui_completion_list_add_plugin: add plugin name to completion list */ @@ -580,104 +581,124 @@ gui_completion_list_add_plugin (struct t_gui_completion *completion) } /* - * gui_completion_list_add_quit: add quit message to completion list - */ - -void -gui_completion_list_add_quit (struct t_gui_completion *completion) -{ - if (CONFIG_STRING(config_look_default_msg_quit) - && CONFIG_STRING(config_look_default_msg_quit)[0]) - gui_completion_list_add (completion, - CONFIG_STRING(config_look_default_msg_quit), - 0, WEECHAT_LIST_POS_SORT); -} - -/* * gui_completion_list_add_option_value: add option value to completion list */ void gui_completion_list_add_option_value (struct t_gui_completion *completion) { - char *pos, *color_name, option_string[2048]; - struct t_config_option *ptr_option; + char *pos_space, *option_full_name, *color_name, *pos_section, *pos_option; + char *file, *section, *value_string; + int length; + struct t_config_file *ptr_config; + struct t_config_section *ptr_section, *section_found; + struct t_config_option *option_found; if (completion->args) { - pos = strchr (completion->args, ' '); - if (pos) - pos[0] = '\0'; - ptr_option = config_file_search_option (weechat_config_file, - NULL, - completion->args); - if (ptr_option) + pos_space = strchr (completion->args, ' '); + if (pos_space) + option_full_name = string_strndup (completion->args, + pos_space - completion->args); + else + option_full_name = strdup (completion->args); + + if (option_full_name) { - switch (ptr_option->type) + file = NULL; + section = NULL; + pos_option = NULL; + + pos_section = strchr (option_full_name, '.'); + pos_option = (pos_section) ? strchr (pos_section + 1, '.') : NULL; + + if (pos_section && pos_option) { - case CONFIG_OPTION_BOOLEAN: - if (CONFIG_BOOLEAN(ptr_option) == CONFIG_BOOLEAN_TRUE) - gui_completion_list_add (completion, "on", - 0, WEECHAT_LIST_POS_SORT); - else - gui_completion_list_add (completion, "off", - 0, WEECHAT_LIST_POS_SORT); - break; - 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, WEECHAT_LIST_POS_SORT); - break; - case CONFIG_OPTION_STRING: - snprintf (option_string, sizeof (option_string) - 1, - "\"%s\"", - CONFIG_STRING(ptr_option)); - gui_completion_list_add (completion, option_string, - 0, WEECHAT_LIST_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, WEECHAT_LIST_POS_SORT); - break; + file = string_strndup (option_full_name, + pos_section - option_full_name); + section = string_strndup (pos_section + 1, + pos_option - pos_section - 1); + pos_option++; + } + if (file && section && pos_option) + { + ptr_config = config_file_search (file); + if (ptr_config) + { + ptr_section = config_file_search_section (ptr_config, + section); + if (ptr_section) + { + config_file_search_section_option (ptr_config, + ptr_section, + pos_option, + §ion_found, + &option_found); + if (option_found) + { + switch (option_found->type) + { + case CONFIG_OPTION_TYPE_BOOLEAN: + if (CONFIG_BOOLEAN(option_found) == CONFIG_BOOLEAN_TRUE) + gui_completion_list_add (completion, "on", + 0, WEECHAT_LIST_POS_SORT); + else + gui_completion_list_add (completion, "off", + 0, WEECHAT_LIST_POS_SORT); + break; + case CONFIG_OPTION_TYPE_INTEGER: + length = 64; + value_string = malloc (length); + if (value_string) + { + if (option_found->string_values) + snprintf (value_string, length, + "%s", + option_found->string_values[CONFIG_INTEGER(option_found)]); + else + snprintf (value_string, length, + "%d", CONFIG_INTEGER(option_found)); + gui_completion_list_add (completion, + value_string, + 0, WEECHAT_LIST_POS_SORT); + free (value_string); + } + break; + case CONFIG_OPTION_TYPE_STRING: + length = strlen (CONFIG_STRING(option_found)) + 2 + 1; + value_string = malloc (length); + if (value_string) + { + snprintf (value_string, length, + "\"%s\"", + CONFIG_STRING(option_found)); + gui_completion_list_add (completion, + value_string, + 0, WEECHAT_LIST_POS_SORT); + free (value_string); + } + break; + case CONFIG_OPTION_TYPE_COLOR: + color_name = gui_color_get_name (CONFIG_INTEGER(option_found)); + if (color_name) + { + gui_completion_list_add (completion, + color_name, + 0, WEECHAT_LIST_POS_SORT); + } + break; + case CONFIG_NUM_OPTION_TYPES: + break; + } + } + } + } } + if (file) + free (file); + if (section) + free (section); } - if (pos) - pos[0] = ' '; - } -} - -/* - * gui_completion_list_add_plugin_option_value: add plugin option value to completion list - */ - -void -gui_completion_list_add_plugin_option_value (struct t_gui_completion *completion) -{ - char *pos; - struct t_config_option *ptr_option; - - if (completion->args) - { - pos = strchr (completion->args, ' '); - if (pos) - pos[0] = '\0'; - - ptr_option = plugin_config_search_internal (completion->args); - if (ptr_option) - gui_completion_list_add (completion, ptr_option->value, - 0, WEECHAT_LIST_POS_SORT); - - if (pos) - pos[0] = ' '; } } @@ -793,24 +814,15 @@ gui_completion_build_list_template (struct t_gui_completion *completion, case 'o': /* config option */ gui_completion_list_add_option (completion); break; - case 'O': /* plugin option */ - gui_completion_list_add_plugin_option (completion); - break; case 'p': /* plugin name */ gui_completion_list_add_plugin (completion); break; - case 'q': /* quit message */ - gui_completion_list_add_quit (completion); - break; case 'r': /* bar names */ gui_completion_list_add_bars_names (completion); break; case 'v': /* value of config option */ gui_completion_list_add_option_value (completion); break; - case 'V': /* value of plugin option */ - gui_completion_list_add_plugin_option_value (completion); - break; case 'w': /* WeeChat commands */ gui_completion_list_add_weechat_cmd (completion); break; |