diff options
Diffstat (limited to 'src/plugins/aspell')
-rw-r--r-- | src/plugins/aspell/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/plugins/aspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-bar-item.c | 82 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-bar-item.h | 6 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-command.c | 14 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-command.h | 8 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-completion.c | 13 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-completion.h | 8 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-config.c | 209 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-config.h | 15 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-info.c | 8 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-info.h | 8 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-speller.c | 13 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-speller.h | 8 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell.c | 36 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell.h | 8 |
16 files changed, 292 insertions, 148 deletions
diff --git a/src/plugins/aspell/CMakeLists.txt b/src/plugins/aspell/CMakeLists.txt index 846ef4c4e..d15151b32 100644 --- a/src/plugins/aspell/CMakeLists.txt +++ b/src/plugins/aspell/CMakeLists.txt @@ -1,6 +1,6 @@ # # Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> -# Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> +# Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> # # This file is part of WeeChat, the extensible chat client. # diff --git a/src/plugins/aspell/Makefile.am b/src/plugins/aspell/Makefile.am index 70464ca3c..a446f7f16 100644 --- a/src/plugins/aspell/Makefile.am +++ b/src/plugins/aspell/Makefile.am @@ -1,6 +1,6 @@ # # Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> -# Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> +# Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> # # This file is part of WeeChat, the extensible chat client. # diff --git a/src/plugins/aspell/weechat-aspell-bar-item.c b/src/plugins/aspell/weechat-aspell-bar-item.c index f088cbf0c..cdcb1a612 100644 --- a/src/plugins/aspell/weechat-aspell-bar-item.c +++ b/src/plugins/aspell/weechat-aspell-bar-item.c @@ -2,7 +2,7 @@ * weechat-aspell-bar-item.c - bar items for aspell plugin * * Copyright (C) 2012 Nils Görs <weechatter@arcor.de> - * Copyright (C) 2012-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2012-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -35,7 +35,8 @@ */ char * -weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item, +weechat_aspell_bar_item_dict (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) @@ -43,6 +44,7 @@ weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item, const char *dict_list; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -61,16 +63,18 @@ weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item, */ char * -weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item, +weechat_aspell_bar_item_suggest (const void *pointer, void *data, + struct t_gui_bar_item *item, struct t_gui_window *window, struct t_gui_buffer *buffer, struct t_hashtable *extra_info) { const char *ptr_suggestions, *pos; - char **suggestions, *suggestions2; - int i, num_suggestions, length; + char **suggestions, **suggestions2, **str_suggest; + int i, j, num_suggestions, num_suggestions2; /* make C compiler happy */ + (void) pointer; (void) data; (void) item; (void) window; @@ -92,37 +96,61 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item, pos++; else pos = ptr_suggestions; + + str_suggest = weechat_string_dyn_alloc (256); + if (!str_suggest) + return NULL; + suggestions = weechat_string_split (pos, "/", 0, 0, &num_suggestions); - if (suggestions) + if (!suggestions) + goto end; + + for (i = 0; i < num_suggestions; i++) { - length = 64 + 1; - for (i = 0; i < num_suggestions; i++) + if (i > 0) { - length += strlen (suggestions[i]) + 64; + weechat_string_dyn_concat ( + str_suggest, + weechat_color ( + weechat_config_string ( + weechat_aspell_config_color_suggestion_delimiter_dict))); + weechat_string_dyn_concat ( + str_suggest, + weechat_config_string ( + weechat_aspell_config_look_suggestion_delimiter_dict)); } - suggestions2 = malloc (length); + suggestions2 = weechat_string_split (suggestions[i], ",", 0, 0, + &num_suggestions2); if (suggestions2) { - suggestions2[0] = '\0'; - strcat (suggestions2, - weechat_color (weechat_config_string (weechat_aspell_config_color_suggestions))); - for (i = 0; i < num_suggestions; i++) + for (j = 0; j < num_suggestions2; j++) { - if (i > 0) + if (j > 0) { - strcat (suggestions2, weechat_color ("bar_delim")); - strcat (suggestions2, "/"); - strcat (suggestions2, - weechat_color (weechat_config_string (weechat_aspell_config_color_suggestions))); + weechat_string_dyn_concat ( + str_suggest, + weechat_color ( + weechat_config_string ( + weechat_aspell_config_color_suggestion_delimiter_word))); + weechat_string_dyn_concat ( + str_suggest, + weechat_config_string ( + weechat_aspell_config_look_suggestion_delimiter_word)); } - strcat (suggestions2, suggestions[i]); + weechat_string_dyn_concat ( + str_suggest, + weechat_color ( + weechat_config_string ( + weechat_aspell_config_color_suggestion))); + weechat_string_dyn_concat (str_suggest, suggestions2[j]); } - weechat_string_free_split (suggestions); - return suggestions2; + weechat_string_free_split (suggestions2); } - weechat_string_free_split (suggestions); } - return strdup (pos); + weechat_string_free_split (suggestions); + +end: + return weechat_string_dyn_free (str_suggest, 0); } /* @@ -132,6 +160,8 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item, void weechat_aspell_bar_item_init () { - weechat_bar_item_new ("aspell_dict", &weechat_aspell_bar_item_dict, NULL); - weechat_bar_item_new ("aspell_suggest", &weechat_aspell_bar_item_suggest, NULL); + weechat_bar_item_new ("aspell_dict", + &weechat_aspell_bar_item_dict, NULL, NULL); + weechat_bar_item_new ("aspell_suggest", + &weechat_aspell_bar_item_suggest, NULL, NULL); } diff --git a/src/plugins/aspell/weechat-aspell-bar-item.h b/src/plugins/aspell/weechat-aspell-bar-item.h index 678bf9732..da8ebf714 100644 --- a/src/plugins/aspell/weechat-aspell-bar-item.h +++ b/src/plugins/aspell/weechat-aspell-bar-item.h @@ -17,9 +17,9 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_BAR_ITEM_H -#define WEECHAT_ASPELL_BAR_ITEM_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_BAR_ITEM_H +#define WEECHAT_PLUGIN_ASPELL_BAR_ITEM_H extern void weechat_aspell_bar_item_init (); -#endif /* WEECHAT_ASPELL_BAR_ITEM_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_BAR_ITEM_H */ diff --git a/src/plugins/aspell/weechat-aspell-command.c b/src/plugins/aspell/weechat-aspell-command.c index 343467a36..6d66eb7d4 100644 --- a/src/plugins/aspell/weechat-aspell-command.c +++ b/src/plugins/aspell/weechat-aspell-command.c @@ -1,7 +1,7 @@ /* * weechat-aspell-command.c - aspell commands * - * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2013-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -158,7 +158,7 @@ weechat_aspell_command_speller_list_dicts () enchant_broker_list_dicts (broker, weechat_aspell_enchant_dict_describe_cb, NULL); #else - config = new_aspell_config(); + config = new_aspell_config (); list = get_aspell_dict_info_list (config); elements = aspell_dict_info_list_elements (list); @@ -191,7 +191,9 @@ weechat_aspell_command_speller_list_dicts () } snprintf (str_dict, sizeof (str_dict), "%-22s %s%s", - dict->name, lang, str_country); + dict->name, + (lang) ? lang : "?", + str_country); weechat_printf (NULL, " %s", str_dict); @@ -330,7 +332,8 @@ end: */ int -weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer, +weechat_aspell_command_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { char *dicts; @@ -339,6 +342,7 @@ weechat_aspell_command_cb (void *data, struct t_gui_buffer *buffer, int number; /* make C compiler happy */ + (void) pointer; (void) data; if (argc == 1) @@ -499,5 +503,5 @@ weechat_aspell_command_init () " || setdict %(aspell_dicts)" " || deldict" " || addword", - &weechat_aspell_command_cb, NULL); + &weechat_aspell_command_cb, NULL, NULL); } diff --git a/src/plugins/aspell/weechat-aspell-command.h b/src/plugins/aspell/weechat-aspell-command.h index 1cbf8f391..c2a86286d 100644 --- a/src/plugins/aspell/weechat-aspell-command.h +++ b/src/plugins/aspell/weechat-aspell-command.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2013-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -17,9 +17,9 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_COMMAND_H -#define WEECHAT_ASPELL_COMMAND_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_COMMAND_H +#define WEECHAT_PLUGIN_ASPELL_COMMAND_H extern void weechat_aspell_command_init (); -#endif /* WEECHAT_ASPELL_COMMAND_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_COMMAND_H */ diff --git a/src/plugins/aspell/weechat-aspell-completion.c b/src/plugins/aspell/weechat-aspell-completion.c index f0b3ef191..244b794b2 100644 --- a/src/plugins/aspell/weechat-aspell-completion.c +++ b/src/plugins/aspell/weechat-aspell-completion.c @@ -1,7 +1,7 @@ /* * weechat-aspell-completion.c - completion for aspell commands * - * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2013-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -33,13 +33,15 @@ */ int -weechat_aspell_completion_langs_cb (void *data, const char *completion_item, +weechat_aspell_completion_langs_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { int i; /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; (void) buffer; @@ -81,7 +83,7 @@ weechat_aspell_completion_enchant_add_dict_cb (const char *lang_tag, */ int -weechat_aspell_completion_dicts_cb (void *data, +weechat_aspell_completion_dicts_cb (const void *pointer, void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) @@ -94,6 +96,7 @@ weechat_aspell_completion_dicts_cb (void *data, #endif /* USE_ENCHANT */ /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; (void) buffer; @@ -129,8 +132,8 @@ weechat_aspell_completion_init () { weechat_hook_completion ("aspell_langs", N_("list of all languages supported by aspell"), - &weechat_aspell_completion_langs_cb, NULL); + &weechat_aspell_completion_langs_cb, NULL, NULL); weechat_hook_completion ("aspell_dicts", N_("list of aspell installed dictionaries"), - &weechat_aspell_completion_dicts_cb, NULL); + &weechat_aspell_completion_dicts_cb, NULL, NULL); } diff --git a/src/plugins/aspell/weechat-aspell-completion.h b/src/plugins/aspell/weechat-aspell-completion.h index cba724bb4..f7119ab8a 100644 --- a/src/plugins/aspell/weechat-aspell-completion.h +++ b/src/plugins/aspell/weechat-aspell-completion.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2013-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -17,9 +17,9 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_COMPLETION_H -#define WEECHAT_ASPELL_COMPLETION_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_COMPLETION_H +#define WEECHAT_PLUGIN_ASPELL_COMPLETION_H extern void weechat_aspell_completion_init (); -#endif /* WEECHAT_ASPELL_COMPLETION_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_COMPLETION_H */ diff --git a/src/plugins/aspell/weechat-aspell-config.c b/src/plugins/aspell/weechat-aspell-config.c index ac381359d..1899bb09b 100644 --- a/src/plugins/aspell/weechat-aspell-config.c +++ b/src/plugins/aspell/weechat-aspell-config.c @@ -2,7 +2,7 @@ * weechat-aspell-config.c - aspell configuration options (file aspell.conf) * * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> - * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -38,7 +38,9 @@ int weechat_aspell_config_loading = 0; /* aspell config, color section */ struct t_config_option *weechat_aspell_config_color_misspelled; -struct t_config_option *weechat_aspell_config_color_suggestions; +struct t_config_option *weechat_aspell_config_color_suggestion; +struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_dict; +struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_word; /* aspell config, check section */ @@ -50,6 +52,11 @@ struct t_config_option *weechat_aspell_config_check_real_time; struct t_config_option *weechat_aspell_config_check_suggestions; struct t_config_option *weechat_aspell_config_check_word_min_length; +/* aspell config, look section */ + +struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_dict; +struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_word; + char **weechat_aspell_commands_to_check = NULL; int weechat_aspell_count_commands_to_check = 0; @@ -61,13 +68,14 @@ int *weechat_aspell_length_commands_to_check = NULL; */ void -weechat_aspell_config_change_commands (void *data, +weechat_aspell_config_change_commands (const void *pointer, void *data, struct t_config_option *option) { const char *value; int i; /* make C compiler happy */ + (void) pointer; (void) data; if (weechat_aspell_commands_to_check) @@ -106,10 +114,11 @@ weechat_aspell_config_change_commands (void *data, */ void -weechat_aspell_config_change_default_dict (void *data, +weechat_aspell_config_change_default_dict (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -123,9 +132,11 @@ weechat_aspell_config_change_default_dict (void *data, */ void -weechat_aspell_config_change_enabled (void *data, struct t_config_option *option) +weechat_aspell_config_change_enabled (const void *pointer, void *data, + struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; aspell_enabled = weechat_config_boolean (option); @@ -140,10 +151,11 @@ weechat_aspell_config_change_enabled (void *data, struct t_config_option *option */ void -weechat_aspell_config_change_suggestions (void *data, +weechat_aspell_config_change_suggestions (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -155,10 +167,11 @@ weechat_aspell_config_change_suggestions (void *data, */ void -weechat_aspell_config_dict_change (void *data, +weechat_aspell_config_dict_change (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -172,12 +185,13 @@ weechat_aspell_config_dict_change (void *data, */ int -weechat_aspell_config_dict_delete_option (void *data, +weechat_aspell_config_dict_delete_option (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) config_file; (void) section; @@ -196,7 +210,7 @@ weechat_aspell_config_dict_delete_option (void *data, */ int -weechat_aspell_config_dict_create_option (void *data, +weechat_aspell_config_dict_create_option (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, @@ -206,6 +220,7 @@ weechat_aspell_config_dict_create_option (void *data, int rc; /* make C compiler happy */ + (void) pointer; (void) data; rc = WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -236,9 +251,9 @@ weechat_aspell_config_dict_create_option (void *data, option_name, "string", _("comma separated list of dictionaries to use on this buffer"), NULL, 0, 0, "", value, 0, - NULL, NULL, - &weechat_aspell_config_dict_change, NULL, - NULL, NULL); + NULL, NULL, NULL, + &weechat_aspell_config_dict_change, NULL, NULL, + NULL, NULL, NULL); rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; } @@ -269,10 +284,11 @@ weechat_aspell_config_dict_create_option (void *data, */ void -weechat_aspell_config_option_change (void *data, +weechat_aspell_config_option_change (const void *pointer, void *data, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -286,12 +302,13 @@ weechat_aspell_config_option_change (void *data, */ int -weechat_aspell_config_option_delete_option (void *data, +weechat_aspell_config_option_delete_option (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) config_file; (void) section; @@ -310,7 +327,7 @@ weechat_aspell_config_option_delete_option (void *data, */ int -weechat_aspell_config_option_create_option (void *data, +weechat_aspell_config_option_create_option (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, @@ -320,6 +337,7 @@ weechat_aspell_config_option_create_option (void *data, int rc; /* make C compiler happy */ + (void) pointer; (void) data; rc = WEECHAT_CONFIG_OPTION_SET_ERROR; @@ -348,9 +366,9 @@ weechat_aspell_config_option_create_option (void *data, _("option for aspell (for list of available options and " "format, run command \"aspell config\" in a shell)"), NULL, 0, 0, "", value, 0, - NULL, NULL, - &weechat_aspell_config_option_change, NULL, - NULL, NULL); + NULL, NULL, NULL, + &weechat_aspell_config_option_change, NULL, NULL, + NULL, NULL, NULL); rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; } @@ -395,7 +413,7 @@ weechat_aspell_config_get_dict (const char *name) int weechat_aspell_config_set_dict (const char *name, const char *value) { - return weechat_aspell_config_dict_create_option (NULL, + return weechat_aspell_config_dict_create_option (NULL, NULL, weechat_aspell_config_file, weechat_aspell_config_section_dict, name, @@ -416,19 +434,23 @@ weechat_aspell_config_init () struct t_config_section *ptr_section; weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME, - NULL, NULL); + NULL, NULL, NULL); if (!weechat_aspell_config_file) return 0; /* color */ - ptr_section = weechat_config_new_section (weechat_aspell_config_file, "color", - 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + ptr_section = weechat_config_new_section ( + weechat_aspell_config_file, "color", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (weechat_aspell_config_file); + weechat_aspell_config_file = NULL; return 0; } @@ -436,22 +458,43 @@ weechat_aspell_config_init () weechat_aspell_config_file, ptr_section, "misspelled", "color", N_("text color for misspelled words (input bar)"), - NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - weechat_aspell_config_color_suggestions = weechat_config_new_option ( + NULL, 0, 0, "lightred", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + weechat_aspell_config_color_suggestion = weechat_config_new_option ( + weechat_aspell_config_file, ptr_section, + "suggestion", "color", + N_("text color for suggestion on a misspelled word in bar item " + "\"aspell_suggest\""), + NULL, 0, 0, "default", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + weechat_aspell_config_color_suggestion_delimiter_dict = weechat_config_new_option ( + weechat_aspell_config_file, ptr_section, + "suggestion_delimiter_dict", "color", + N_("text color for delimiters displayed between two dictionaries " + "in bar item \"aspell_suggest\""), + NULL, 0, 0, "cyan", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + weechat_aspell_config_color_suggestion_delimiter_word = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, - "suggestions", "color", - N_("text color for suggestions on a misspelled word (status bar)"), - NULL, 0, 0, "default", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + "suggestion_delimiter_word", "color", + N_("text color for delimiters displayed between two words in bar item " + "\"aspell_suggest\""), + NULL, 0, 0, "cyan", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); /* check */ - ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check", - 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + ptr_section = weechat_config_new_section ( + weechat_aspell_config_file, "check", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (weechat_aspell_config_file); + weechat_aspell_config_file = NULL; return 0; } @@ -463,7 +506,9 @@ weechat_aspell_config_init () NULL, 0, 0, "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query," "quit,topic", NULL, 0, - NULL, NULL, &weechat_aspell_config_change_commands, NULL, NULL, NULL); + NULL, NULL, NULL, + &weechat_aspell_config_change_commands, NULL, NULL, + NULL, NULL, NULL); weechat_aspell_config_check_default_dict = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, "default_dict", "string", @@ -471,24 +516,30 @@ weechat_aspell_config_init () "use when buffer has no dictionary defined (leave blank to disable " "aspell on buffers for which you didn't explicitly enabled it)"), NULL, 0, 0, "", NULL, 0, - NULL, NULL, &weechat_aspell_config_change_default_dict, NULL, NULL, NULL); + NULL, NULL, NULL, + &weechat_aspell_config_change_default_dict, NULL, NULL, + NULL, NULL, NULL); weechat_aspell_config_check_during_search = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, "during_search", "boolean", N_("check words during text search in buffer"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); weechat_aspell_config_check_enabled = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, "enabled", "boolean", N_("enable aspell check for command line"), NULL, 0, 0, "off", NULL, 0, - NULL, NULL, &weechat_aspell_config_change_enabled, NULL, NULL, NULL); + NULL, NULL, NULL, + &weechat_aspell_config_change_enabled, NULL, NULL, + NULL, NULL, NULL); weechat_aspell_config_check_real_time = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, "real_time", "boolean", N_("real-time spell checking of words (slower, disabled by default: " "words are checked only if there's delimiter after)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); weechat_aspell_config_check_suggestions = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, "suggestions", "integer", @@ -496,41 +547,83 @@ weechat_aspell_config_init () "for each dictionary set in buffer (-1 = disable suggestions, " "0 = display all possible suggestions in all languages)"), NULL, -1, INT_MAX, "-1", NULL, 0, - NULL, NULL, &weechat_aspell_config_change_suggestions, NULL, NULL, NULL); + NULL, NULL, NULL, + &weechat_aspell_config_change_suggestions, NULL, NULL, + NULL, NULL, NULL); weechat_aspell_config_check_word_min_length = weechat_config_new_option ( weechat_aspell_config_file, ptr_section, "word_min_length", "integer", N_("minimum length for a word to be spell checked (use 0 to check all " "words)"), - NULL, 0, INT_MAX, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, INT_MAX, "2", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); /* dict */ - ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict", - 1, 1, - NULL, NULL, - NULL, NULL, - NULL, NULL, - &weechat_aspell_config_dict_create_option, NULL, - &weechat_aspell_config_dict_delete_option, NULL); + ptr_section = weechat_config_new_section ( + weechat_aspell_config_file, "dict", + 1, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + &weechat_aspell_config_dict_create_option, NULL, NULL, + &weechat_aspell_config_dict_delete_option, NULL, NULL); if (!ptr_section) { weechat_config_free (weechat_aspell_config_file); + weechat_aspell_config_file = NULL; return 0; } weechat_aspell_config_section_dict = ptr_section; + /* look */ + ptr_section = weechat_config_new_section ( + weechat_aspell_config_file, "look", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); + if (!ptr_section) + { + weechat_config_free (weechat_aspell_config_file); + weechat_aspell_config_file = NULL; + return 0; + } + + weechat_aspell_config_look_suggestion_delimiter_dict = weechat_config_new_option ( + weechat_aspell_config_file, ptr_section, + "suggestion_delimiter_dict", "string", + N_("delimiter displayed between two dictionaries in bar item " + "\"aspell_suggest\""), + NULL, 0, 0, " / ", NULL, 0, + NULL, NULL, NULL, + &weechat_aspell_config_change_suggestions, NULL, NULL, + NULL, NULL, NULL); + weechat_aspell_config_look_suggestion_delimiter_word = weechat_config_new_option ( + weechat_aspell_config_file, ptr_section, + "suggestion_delimiter_word", "string", + N_("delimiter displayed between two words in bar item " + "\"aspell_suggest\""), + NULL, 0, 0, ",", NULL, 0, + NULL, NULL, NULL, + &weechat_aspell_config_change_suggestions, NULL, NULL, + NULL, NULL, NULL); + /* option */ - ptr_section = weechat_config_new_section (weechat_aspell_config_file, "option", - 1, 1, - NULL, NULL, - NULL, NULL, - NULL, NULL, - &weechat_aspell_config_option_create_option, NULL, - &weechat_aspell_config_option_delete_option, NULL); + ptr_section = weechat_config_new_section ( + weechat_aspell_config_file, "option", + 1, 1, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + &weechat_aspell_config_option_create_option, NULL, NULL, + &weechat_aspell_config_option_delete_option, NULL, NULL); if (!ptr_section) { weechat_config_free (weechat_aspell_config_file); + weechat_aspell_config_file = NULL; return 0; } @@ -551,8 +644,8 @@ weechat_aspell_config_read () weechat_aspell_config_loading = 0; if (rc == WEECHAT_CONFIG_READ_OK) { - weechat_aspell_config_change_commands (NULL, - weechat_aspell_config_check_commands); + weechat_aspell_config_change_commands ( + NULL, NULL, weechat_aspell_config_check_commands); } weechat_aspell_speller_remove_unused (); diff --git a/src/plugins/aspell/weechat-aspell-config.h b/src/plugins/aspell/weechat-aspell-config.h index 010350209..f662b52a4 100644 --- a/src/plugins/aspell/weechat-aspell-config.h +++ b/src/plugins/aspell/weechat-aspell-config.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> - * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -18,14 +18,16 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_CONFIG_H -#define WEECHAT_ASPELL_CONFIG_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_CONFIG_H +#define WEECHAT_PLUGIN_ASPELL_CONFIG_H #define ASPELL_CONFIG_NAME "aspell" extern struct t_config_option *weechat_aspell_config_color_misspelled; -extern struct t_config_option *weechat_aspell_config_color_suggestions; +extern struct t_config_option *weechat_aspell_config_color_suggestion; +extern struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_dict; +extern struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_word; extern struct t_config_option *weechat_aspell_config_check_commands; extern struct t_config_option *weechat_aspell_config_check_default_dict; @@ -35,6 +37,9 @@ extern struct t_config_option *weechat_aspell_config_check_real_time; extern struct t_config_option *weechat_aspell_config_check_suggestions; extern struct t_config_option *weechat_aspell_config_check_word_min_length; +extern struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_dict; +extern struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_word; + extern char **weechat_aspell_commands_to_check; extern int weechat_aspell_count_commands_to_check; extern int *weechat_aspell_length_commands_to_check; @@ -46,4 +51,4 @@ extern int weechat_aspell_config_read (); extern int weechat_aspell_config_write (); extern void weechat_aspell_config_free (); -#endif /* WEECHAT_ASPELL_CONFIG_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_CONFIG_H */ diff --git a/src/plugins/aspell/weechat-aspell-info.c b/src/plugins/aspell/weechat-aspell-info.c index 8860c9bba..831971699 100644 --- a/src/plugins/aspell/weechat-aspell-info.c +++ b/src/plugins/aspell/weechat-aspell-info.c @@ -1,7 +1,7 @@ /* * weechat-aspell-info.c - info for aspell plugin * - * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2013-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -32,7 +32,8 @@ */ const char * -weechat_aspell_info_info_aspell_dict_cb (void *data, const char *info_name, +weechat_aspell_info_info_aspell_dict_cb (const void *pointer, void *data, + const char *info_name, const char *arguments) { int rc; @@ -41,6 +42,7 @@ weechat_aspell_info_info_aspell_dict_cb (void *data, const char *info_name, const char *buffer_full_name; /* make C compiler happy */ + (void) pointer; (void) data; (void) info_name; @@ -83,5 +85,5 @@ weechat_aspell_info_init () N_("comma-separated list of dictionaries used in buffer"), N_("buffer pointer (\"0x12345678\") or buffer full name " "(\"irc.freenode.#weechat\")"), - &weechat_aspell_info_info_aspell_dict_cb, NULL); + &weechat_aspell_info_info_aspell_dict_cb, NULL, NULL); } diff --git a/src/plugins/aspell/weechat-aspell-info.h b/src/plugins/aspell/weechat-aspell-info.h index e170709b8..c25e766f2 100644 --- a/src/plugins/aspell/weechat-aspell-info.h +++ b/src/plugins/aspell/weechat-aspell-info.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2013-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -17,9 +17,9 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_INFO_H -#define WEECHAT_ASPELL_INFO_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_INFO_H +#define WEECHAT_PLUGIN_ASPELL_INFO_H extern void weechat_aspell_info_init (); -#endif /* WEECHAT_ASPELL_INFO_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_INFO_H */ diff --git a/src/plugins/aspell/weechat-aspell-speller.c b/src/plugins/aspell/weechat-aspell-speller.c index 460c7509c..4e9bf099b 100644 --- a/src/plugins/aspell/weechat-aspell-speller.c +++ b/src/plugins/aspell/weechat-aspell-speller.c @@ -2,7 +2,7 @@ * weechat-aspell-speller.c - speller management for aspell plugin * * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> - * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -161,7 +161,7 @@ weechat_aspell_speller_new (const char *lang) } #else /* create a speller instance for the newly created cell */ - config = new_aspell_config(); + config = new_aspell_config (); aspell_config_replace (config, "lang", lang); #endif /* USE_ENCHANT */ @@ -272,8 +272,7 @@ weechat_aspell_speller_remove_unused () used_spellers = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, - NULL, - NULL); + NULL, NULL); if (!used_spellers) return; @@ -448,8 +447,7 @@ weechat_aspell_speller_init () weechat_aspell_spellers = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_POINTER, - NULL, - NULL); + NULL, NULL); if (!weechat_aspell_spellers) return 0; weechat_hashtable_set_pointer (weechat_aspell_spellers, @@ -459,8 +457,7 @@ weechat_aspell_speller_init () weechat_aspell_speller_buffer = weechat_hashtable_new (32, WEECHAT_HASHTABLE_POINTER, WEECHAT_HASHTABLE_POINTER, - NULL, - NULL); + NULL, NULL); if (!weechat_aspell_speller_buffer) { weechat_hashtable_free (weechat_aspell_spellers); diff --git a/src/plugins/aspell/weechat-aspell-speller.h b/src/plugins/aspell/weechat-aspell-speller.h index cc696f4e2..9f33880b0 100644 --- a/src/plugins/aspell/weechat-aspell-speller.h +++ b/src/plugins/aspell/weechat-aspell-speller.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> - * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -18,8 +18,8 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_SPELLER_H -#define WEECHAT_ASPELL_SPELLER_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_SPELLER_H +#define WEECHAT_PLUGIN_ASPELL_SPELLER_H struct t_aspell_speller_buffer { @@ -48,4 +48,4 @@ extern struct t_aspell_speller_buffer *weechat_aspell_speller_buffer_new (struct extern int weechat_aspell_speller_init (); extern void weechat_aspell_speller_end (); -#endif /* WEECHAT_ASPELL_SPELLER_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_SPELLER_H */ diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/aspell/weechat-aspell.c index ae2775b2c..67dfe3a18 100644 --- a/src/plugins/aspell/weechat-aspell.c +++ b/src/plugins/aspell/weechat-aspell.c @@ -2,7 +2,7 @@ * weechat-aspell.c - aspell plugin for WeeChat: color for misspelled words * * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> - * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> * Copyright (C) 2012 Nils Görs <weechatter@arcor.de> * * This file is part of WeeChat, the extensible chat client. @@ -46,7 +46,7 @@ WEECHAT_PLUGIN_DESCRIPTION(N_("Spell checker for input (with Aspell)")); WEECHAT_PLUGIN_AUTHOR("Sébastien Helleu <flashcode@flashtux.org>"); WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION); WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE); -WEECHAT_PLUGIN_PRIORITY(9000); +WEECHAT_PLUGIN_PRIORITY(11000); struct t_weechat_plugin *weechat_aspell_plugin = NULL; @@ -604,7 +604,8 @@ weechat_aspell_get_suggestions (struct t_aspell_speller_buffer *speller_buffer, */ char * -weechat_aspell_modifier_cb (void *data, const char *modifier, +weechat_aspell_modifier_cb (const void *pointer, void *data, + const char *modifier, const char *modifier_data, const char *string) { long unsigned int value; @@ -621,6 +622,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, int input_pos, current_pos, word_start_pos, word_end_pos, word_end_pos_valid; /* make C compiler happy */ + (void) pointer; (void) data; (void) modifier; @@ -932,10 +934,12 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, */ int -weechat_aspell_buffer_switch_cb (void *data, const char *signal, - const char *type_data, void *signal_data) +weechat_aspell_buffer_switch_cb (const void *pointer, void *data, + const char *signal, const char *type_data, + void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -953,10 +957,12 @@ weechat_aspell_buffer_switch_cb (void *data, const char *signal, */ int -weechat_aspell_window_switch_cb (void *data, const char *signal, +weechat_aspell_window_switch_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -975,10 +981,12 @@ weechat_aspell_window_switch_cb (void *data, const char *signal, */ int -weechat_aspell_buffer_closed_cb (void *data, const char *signal, +weechat_aspell_buffer_closed_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -993,10 +1001,12 @@ weechat_aspell_buffer_closed_cb (void *data, const char *signal, */ int -weechat_aspell_debug_libs_cb (void *data, const char *signal, +weechat_aspell_debug_libs_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -1059,20 +1069,20 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) * (from other plugins) will be called before this one */ weechat_hook_modifier ("500|input_text_display", - &weechat_aspell_modifier_cb, NULL); + &weechat_aspell_modifier_cb, NULL, NULL); weechat_aspell_bar_item_init (); weechat_aspell_info_init (); weechat_hook_signal ("buffer_switch", - &weechat_aspell_buffer_switch_cb, NULL); + &weechat_aspell_buffer_switch_cb, NULL, NULL); weechat_hook_signal ("window_switch", - &weechat_aspell_window_switch_cb, NULL); + &weechat_aspell_window_switch_cb, NULL, NULL); weechat_hook_signal ("buffer_closed", - &weechat_aspell_buffer_closed_cb, NULL); + &weechat_aspell_buffer_closed_cb, NULL, NULL); weechat_hook_signal ("debug_libs", - &weechat_aspell_debug_libs_cb, NULL); + &weechat_aspell_debug_libs_cb, NULL, NULL); return WEECHAT_RC_OK; } diff --git a/src/plugins/aspell/weechat-aspell.h b/src/plugins/aspell/weechat-aspell.h index fbcbc3fb8..192d40767 100644 --- a/src/plugins/aspell/weechat-aspell.h +++ b/src/plugins/aspell/weechat-aspell.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> - * Copyright (C) 2006-2015 Sébastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2006-2018 Sébastien Helleu <flashcode@flashtux.org> * * This file is part of WeeChat, the extensible chat client. * @@ -18,8 +18,8 @@ * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef WEECHAT_ASPELL_H -#define WEECHAT_ASPELL_H 1 +#ifndef WEECHAT_PLUGIN_ASPELL_H +#define WEECHAT_PLUGIN_ASPELL_H #ifdef USE_ENCHANT #include <enchant.h> @@ -49,4 +49,4 @@ extern char *weechat_aspell_build_option_name (struct t_gui_buffer *buffer); extern const char *weechat_aspell_get_dict_with_buffer_name (const char *name); extern const char *weechat_aspell_get_dict (struct t_gui_buffer *buffer); -#endif /* WEECHAT_ASPELL_H */ +#endif /* WEECHAT_PLUGIN_ASPELL_H */ |