summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CMakeLists.txt44
-rw-r--r--src/plugins/Makefile.am10
-rw-r--r--src/plugins/aspell/weechat-aspell-config.c678
-rw-r--r--src/plugins/aspell/weechat-aspell-config.h54
-rw-r--r--src/plugins/spell/CMakeLists.txt (renamed from src/plugins/aspell/CMakeLists.txt)24
-rw-r--r--src/plugins/spell/Makefile.am (renamed from src/plugins/aspell/Makefile.am)34
-rw-r--r--src/plugins/spell/spell-bar-item.c (renamed from src/plugins/aspell/weechat-aspell-bar-item.c)58
-rw-r--r--src/plugins/spell/spell-bar-item.h (renamed from src/plugins/aspell/weechat-aspell-bar-item.h)8
-rw-r--r--src/plugins/spell/spell-command.c (renamed from src/plugins/aspell/weechat-aspell-command.c)182
-rw-r--r--src/plugins/spell/spell-command.h (renamed from src/plugins/aspell/weechat-aspell-info.h)8
-rw-r--r--src/plugins/spell/spell-completion.c (renamed from src/plugins/aspell/weechat-aspell-completion.c)54
-rw-r--r--src/plugins/spell/spell-completion.h (renamed from src/plugins/aspell/weechat-aspell-command.h)8
-rw-r--r--src/plugins/spell/spell-config.c676
-rw-r--r--src/plugins/spell/spell-config.h54
-rw-r--r--src/plugins/spell/spell-info.c (renamed from src/plugins/aspell/weechat-aspell-info.c)22
-rw-r--r--src/plugins/spell/spell-info.h (renamed from src/plugins/aspell/weechat-aspell-completion.h)8
-rw-r--r--src/plugins/spell/spell-speller.c (renamed from src/plugins/aspell/weechat-aspell-speller.c)156
-rw-r--r--src/plugins/spell/spell-speller.h (renamed from src/plugins/aspell/weechat-aspell-speller.h)28
-rw-r--r--src/plugins/spell/spell.c (renamed from src/plugins/aspell/weechat-aspell.c)252
-rw-r--r--src/plugins/spell/spell.h (renamed from src/plugins/aspell/weechat-aspell.h)26
20 files changed, 1191 insertions, 1193 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 526b206c3..609a55eaf 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -49,28 +49,6 @@ if(ENABLE_ALIAS)
add_subdirectory(alias)
endif()
-if(ENABLE_ASPELL)
- if(ENABLE_ENCHANT)
- # Check for enchant libraries
- find_package(ENCHANT)
- if(ENCHANT_FOUND)
- add_subdirectory(aspell)
- else()
- # Check for aspell libraries
- find_package(Aspell)
- if(ASPELL_FOUND)
- add_subdirectory(aspell)
- endif()
- endif()
- else()
- # Check for aspell libraries
- find_package(Aspell)
- if(ASPELL_FOUND)
- add_subdirectory(aspell)
- endif()
- endif()
-endif()
-
if(ENABLE_BUFLIST)
add_subdirectory(buflist)
endif()
@@ -166,6 +144,28 @@ if(ENABLE_SCRIPTS AND ENABLE_PHP)
endif()
endif()
+if(ENABLE_SPELL)
+ if(ENABLE_ENCHANT)
+ # Check for enchant libraries
+ find_package(ENCHANT)
+ if(ENCHANT_FOUND)
+ add_subdirectory(spell)
+ else()
+ # Check for aspell libraries
+ find_package(Aspell)
+ if(ASPELL_FOUND)
+ add_subdirectory(spell)
+ endif()
+ endif()
+ else()
+ # Check for aspell libraries
+ find_package(Aspell)
+ if(ASPELL_FOUND)
+ add_subdirectory(spell)
+ endif()
+ endif()
+endif()
+
if(ENABLE_TRIGGER)
add_subdirectory(trigger)
endif()
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 24f9395ec..45e304378 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -45,10 +45,6 @@ if PLUGIN_ALIAS
alias_dir = alias
endif
-if PLUGIN_ASPELL
-aspell_dir = aspell
-endif
-
if PLUGIN_BUFLIST
buflist_dir = buflist
endif
@@ -117,6 +113,10 @@ if PLUGIN_PHP
php_dir = php
endif
+if PLUGIN_SPELL
+spell_dir = spell
+endif
+
if PLUGIN_TRIGGER
trigger_dir = trigger
endif
@@ -127,7 +127,6 @@ endif
SUBDIRS = . \
$(alias_dir) \
- $(aspell_dir) \
$(buflist_dir) \
$(charset_dir) \
$(exec_dir) \
@@ -145,6 +144,7 @@ SUBDIRS = . \
$(guile_dir) \
$(javascript_dir) \
$(php_dir) \
+ $(spell_dir) \
$(trigger_dir) \
$(xfer_dir)
diff --git a/src/plugins/aspell/weechat-aspell-config.c b/src/plugins/aspell/weechat-aspell-config.c
deleted file mode 100644
index 1eec7aab5..000000000
--- a/src/plugins/aspell/weechat-aspell-config.c
+++ /dev/null
@@ -1,678 +0,0 @@
-/*
- * weechat-aspell-config.c - aspell configuration options (file aspell.conf)
- *
- * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2019 Sébastien Helleu <flashcode@flashtux.org>
- *
- * This file is part of WeeChat, the extensible chat client.
- *
- * WeeChat 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.
- *
- * WeeChat 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 WeeChat. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
-#include "weechat-aspell-config.h"
-#include "weechat-aspell-speller.h"
-
-
-struct t_config_file *weechat_aspell_config_file = NULL;
-struct t_config_section *weechat_aspell_config_section_dict = NULL;
-
-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_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 */
-
-struct t_config_option *weechat_aspell_config_check_commands;
-struct t_config_option *weechat_aspell_config_check_default_dict;
-struct t_config_option *weechat_aspell_config_check_during_search;
-struct t_config_option *weechat_aspell_config_check_enabled;
-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;
-int *weechat_aspell_length_commands_to_check = NULL;
-
-
-/*
- * Callback for changes on option "aspell.check.commands".
- */
-
-void
-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)
- {
- weechat_string_free_split (weechat_aspell_commands_to_check);
- weechat_aspell_commands_to_check = NULL;
- weechat_aspell_count_commands_to_check = 0;
- }
-
- if (weechat_aspell_length_commands_to_check)
- {
- free (weechat_aspell_length_commands_to_check);
- weechat_aspell_length_commands_to_check = NULL;
- }
-
- value = weechat_config_string (option);
- if (value && value[0])
- {
- weechat_aspell_commands_to_check = weechat_string_split (value,
- ",", 0, 0,
- &weechat_aspell_count_commands_to_check);
- if (weechat_aspell_count_commands_to_check > 0)
- {
- weechat_aspell_length_commands_to_check = malloc (weechat_aspell_count_commands_to_check *
- sizeof (int));
- for (i = 0; i < weechat_aspell_count_commands_to_check; i++)
- {
- weechat_aspell_length_commands_to_check[i] = strlen (weechat_aspell_commands_to_check[i]);
- }
- }
- }
-}
-
-/*
- * Callback for changes on option "aspell.check.default_dict".
- */
-
-void
-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;
-
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
-}
-
-/*
- * Callback for changes on option "aspell.check.enabled".
- */
-
-void
-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);
-
- /* refresh input and aspell suggestions */
- weechat_bar_item_update ("input_text");
- weechat_bar_item_update ("aspell_suggest");
-}
-
-/*
- * Callback for changes on option "aspell.check.suggestions".
- */
-
-void
-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;
-
- weechat_bar_item_update ("aspell_suggest");
-}
-
-/*
- * Callback for changes on a dictionary.
- */
-
-void
-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;
-
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
-}
-
-/*
- * Callback called when an option is deleted in section "dict".
- */
-
-int
-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;
-
- weechat_config_option_free (option);
-
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
-
- return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
-}
-
-/*
- * Creates an option in section "dict".
- */
-
-int
-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,
- const char *value)
-{
- struct t_config_option *ptr_option;
- int rc;
-
- /* make C compiler happy */
- (void) pointer;
- (void) data;
-
- rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
-
- if (value && value[0])
- weechat_aspell_speller_check_dictionaries (value);
-
- if (option_name)
- {
- ptr_option = weechat_config_search_option (config_file, section,
- option_name);
- if (ptr_option)
- {
- if (value && value[0])
- rc = weechat_config_option_set (ptr_option, value, 0);
- else
- {
- weechat_config_option_free (ptr_option);
- rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
- }
- }
- else
- {
- if (value && value[0])
- {
- ptr_option = weechat_config_new_option (
- config_file, section,
- option_name, "string",
- _("comma separated list of dictionaries to use on this buffer"),
- NULL, 0, 0, "", value, 0,
- 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;
- }
- else
- rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
- }
- }
-
- if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
- {
- weechat_printf (NULL,
- _("%s%s: error creating aspell dictionary \"%s\" => \"%s\""),
- weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
- option_name, value);
- }
- else
- {
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
- }
-
- return rc;
-}
-
-/*
- * Callback for changes on an aspell option.
- */
-
-void
-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;
-
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
-}
-
-/*
- * Callback called when an option is deleted in section "option".
- */
-
-int
-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;
-
- weechat_config_option_free (option);
-
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
-
- return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
-}
-
-/*
- * Callback called when an option is created in section "option".
- */
-
-int
-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,
- const char *value)
-{
- struct t_config_option *ptr_option;
- int rc;
-
- /* make C compiler happy */
- (void) pointer;
- (void) data;
-
- rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
-
- if (option_name)
- {
- ptr_option = weechat_config_search_option (config_file, section,
- option_name);
- if (ptr_option)
- {
- if (value && value[0])
- rc = weechat_config_option_set (ptr_option, value, 1);
- else
- {
- weechat_config_option_free (ptr_option);
- rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
- }
- }
- else
- {
- if (value && value[0])
- {
- ptr_option = weechat_config_new_option (
- config_file, section,
- option_name, "string",
- _("option for aspell (for list of available options and "
- "format, run command \"aspell config\" in a shell)"),
- NULL, 0, 0, "", value, 0,
- 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;
- }
- else
- rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
- }
- }
-
- if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
- {
- weechat_printf (NULL,
- _("%s%s: error creating aspell option \"%s\" => \"%s\""),
- weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
- option_name, value);
- }
- else
- {
- weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
- if (!weechat_aspell_config_loading)
- weechat_aspell_speller_remove_unused ();
- }
-
- return rc;
-}
-
-/*
- * Gets a list of dictionaries for a buffer.
- */
-
-struct t_config_option *
-weechat_aspell_config_get_dict (const char *name)
-{
- return weechat_config_search_option (weechat_aspell_config_file,
- weechat_aspell_config_section_dict,
- name);
-}
-
-/*
- * Sets a list of dictionaries for a buffer.
- */
-
-int
-weechat_aspell_config_set_dict (const char *name, const char *value)
-{
- return weechat_aspell_config_dict_create_option (NULL, NULL,
- weechat_aspell_config_file,
- weechat_aspell_config_section_dict,
- name,
- value);
-}
-
-/*
- * Initializes aspell configuration file.
- *
- * Returns:
- * 1: OK
- * 0: error
- */
-
-int
-weechat_aspell_config_init ()
-{
- struct t_config_section *ptr_section;
-
- weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
- 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, 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_color_misspelled = weechat_config_new_option (
- 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, 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,
- "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, 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_check_commands = weechat_config_new_option (
- weechat_aspell_config_file, ptr_section,
- "commands", "string",
- N_("comma separated list of commands for which spell checking is "
- "enabled (spell checking is disabled for all other commands)"),
- NULL, 0, 0,
- "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,"
- "quit,topic", NULL, 0,
- 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",
- N_("default dictionary (or comma separated list of dictionaries) to "
- "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, 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, 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, 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, NULL, NULL);
- weechat_aspell_config_check_suggestions = weechat_config_new_option (
- weechat_aspell_config_file, ptr_section,
- "suggestions", "integer",
- N_("number of suggestions to display in bar item \"aspell_suggest\" "
- "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, 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, NULL, NULL);
-
- /* dict */
- 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,
- 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;
- }
-
- return 1;
-}
-
-/*
- * Reads aspell configuration file.
- */
-
-int
-weechat_aspell_config_read ()
-{
- int rc;
-
- weechat_aspell_config_loading = 1;
- rc = weechat_config_read (weechat_aspell_config_file);
- weechat_aspell_config_loading = 0;
- if (rc == WEECHAT_CONFIG_READ_OK)
- {
- weechat_aspell_config_change_commands (
- NULL, NULL, weechat_aspell_config_check_commands);
- }
- weechat_aspell_speller_remove_unused ();
-
- return rc;
-}
-
-/*
- * Writes aspell configuration file.
- */
-
-int
-weechat_aspell_config_write ()
-{
- return weechat_config_write (weechat_aspell_config_file);
-}
-
-/*
- * Frees aspell configuration.
- */
-
-void
-weechat_aspell_config_free ()
-{
- weechat_config_free (weechat_aspell_config_file);
-
- if (weechat_aspell_commands_to_check)
- weechat_string_free_split (weechat_aspell_commands_to_check);
- if (weechat_aspell_length_commands_to_check)
- free (weechat_aspell_length_commands_to_check);
-}
diff --git a/src/plugins/aspell/weechat-aspell-config.h b/src/plugins/aspell/weechat-aspell-config.h
deleted file mode 100644
index aecc05e55..000000000
--- a/src/plugins/aspell/weechat-aspell-config.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
- * Copyright (C) 2006-2019 Sébastien Helleu <flashcode@flashtux.org>
- *
- * This file is part of WeeChat, the extensible chat client.
- *
- * WeeChat 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.
- *
- * WeeChat 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 WeeChat. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#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_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;
-extern struct t_config_option *weechat_aspell_config_check_during_search;
-extern struct t_config_option *weechat_aspell_config_check_enabled;
-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;
-
-extern struct t_config_option *weechat_aspell_config_get_dict (const char *name);
-extern int weechat_aspell_config_set_dict (const char *name, const char *value);
-extern int weechat_aspell_config_init ();
-extern int weechat_aspell_config_read ();
-extern int weechat_aspell_config_write ();
-extern void weechat_aspell_config_free ();
-
-#endif /* WEECHAT_PLUGIN_ASPELL_CONFIG_H */
diff --git a/src/plugins/aspell/CMakeLists.txt b/src/plugins/spell/CMakeLists.txt
index d897de4e9..0a1c51bb1 100644
--- a/src/plugins/aspell/CMakeLists.txt
+++ b/src/plugins/spell/CMakeLists.txt
@@ -18,25 +18,25 @@
# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
#
-add_library(aspell MODULE
-weechat-aspell.c weechat-aspell.h
-weechat-aspell-bar-item.c weechat-aspell-bar-item.h
-weechat-aspell-command.c weechat-aspell-command.h
-weechat-aspell-completion.c weechat-aspell-completion.h
-weechat-aspell-config.c weechat-aspell-config.h
-weechat-aspell-info.c weechat-aspell-info.h
-weechat-aspell-speller.c weechat-aspell-speller.h)
-set_target_properties(aspell PROPERTIES PREFIX "")
+add_library(spell MODULE
+spell.c spell.h
+spell-bar-item.c spell-bar-item.h
+spell-command.c spell-command.h
+spell-completion.c spell-completion.h
+spell-config.c spell-config.h
+spell-info.c spell-info.h
+spell-speller.c spell-speller.h)
+set_target_properties(spell PROPERTIES PREFIX "")
if(ENCHANT_FOUND)
include_directories(${ENCHANT_INCLUDE_DIR})
- target_link_libraries(aspell ${ENCHANT_LIBRARIES})
+ target_link_libraries(spell ${ENCHANT_LIBRARIES})
add_definitions(-DUSE_ENCHANT)
else()
if(ASPELL_FOUND)
include_directories(${ASPELL_INCLUDE_PATH})
- target_link_libraries(aspell ${ASPELL_LIBRARY})
+ target_link_libraries(spell ${ASPELL_LIBRARY})
endif()
endif()
-install(TARGETS aspell LIBRARY DESTINATION ${LIBDIR}/plugins)
+install(TARGETS spell LIBRARY DESTINATION ${LIBDIR}/plugins)
diff --git a/src/plugins/aspell/Makefile.am b/src/plugins/spell/Makefile.am
index e0dccd71e..b3313d9f4 100644
--- a/src/plugins/aspell/Makefile.am
+++ b/src/plugins/spell/Makefile.am
@@ -22,23 +22,23 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(ASPELL_CFLAGS) $(ENCHANT_CFLAG
libdir = ${weechat_libdir}/plugins
-lib_LTLIBRARIES = aspell.la
+lib_LTLIBRARIES = spell.la
-aspell_la_SOURCES = weechat-aspell.c \
- weechat-aspell.h \
- weechat-aspell-bar-item.c \
- weechat-aspell-bar-item.h \
- weechat-aspell-command.c \
- weechat-aspell-command.h \
- weechat-aspell-completion.c \
- weechat-aspell-completion.h \
- weechat-aspell-config.c \
- weechat-aspell-config.h \
- weechat-aspell-info.c \
- weechat-aspell-info.h \
- weechat-aspell-speller.c \
- weechat-aspell-speller.h
-aspell_la_LDFLAGS = -module -no-undefined
-aspell_la_LIBADD = $(ASPELL_LFLAGS) $(ENCHANT_LIBS)
+spell_la_SOURCES = spell.c \
+ spell.h \
+ spell-bar-item.c \
+ spell-bar-item.h \
+ spell-command.c \
+ spell-command.h \
+ spell-completion.c \
+ spell-completion.h \
+ spell-config.c \
+ spell-config.h \
+ spell-info.c \
+ spell-info.h \
+ spell-speller.c \
+ spell-speller.h
+spell_la_LDFLAGS = -module -no-undefined
+spell_la_LIBADD = $(ASPELL_LFLAGS) $(ENCHANT_LIBS)
EXTRA_DIST = CMakeLists.txt
diff --git a/src/plugins/aspell/weechat-aspell-bar-item.c b/src/plugins/spell/spell-bar-item.c
index 983427925..0b9ef5453 100644
--- a/src/plugins/aspell/weechat-aspell-bar-item.c
+++ b/src/plugins/spell/spell-bar-item.c
@@ -1,5 +1,5 @@
/*
- * weechat-aspell-bar-item.c - bar items for aspell plugin
+ * spell-bar-item.c - bar items for spell checker plugin
*
* Copyright (C) 2012 Nils Görs <weechatter@arcor.de>
* Copyright (C) 2012-2019 Sébastien Helleu <flashcode@flashtux.org>
@@ -25,21 +25,21 @@
#include <string.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
-#include "weechat-aspell-config.h"
+#include "spell.h"
+#include "spell-config.h"
/*
- * Returns content of bar item "aspell_dict": aspell dictionary used on current
+ * Returns content of bar item "spell_dict": spell dictionary used on current
* buffer.
*/
char *
-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)
+spell_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)
{
const char *dict_list;
@@ -53,21 +53,21 @@ weechat_aspell_bar_item_dict (const void *pointer, void *data,
if (!buffer)
return NULL;
- dict_list = weechat_aspell_get_dict (buffer);
+ dict_list = spell_get_dict (buffer);
return (dict_list) ? strdup (dict_list) : NULL;
}
/*
- * Returns content of bar item "aspell_suggest": aspell suggestions.
+ * Returns content of bar item "spell_suggest": spell checker suggestions.
*/
char *
-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)
+spell_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, **str_suggest;
@@ -80,14 +80,14 @@ weechat_aspell_bar_item_suggest (const void *pointer, void *data,
(void) window;
(void) extra_info;
- if (!aspell_enabled)
+ if (!spell_enabled)
return NULL;
if (!buffer)
return NULL;
ptr_suggestions = weechat_buffer_get_string (buffer,
- "localvar_aspell_suggest");
+ "localvar_spell_suggest");
if (!ptr_suggestions)
return NULL;
@@ -113,11 +113,11 @@ weechat_aspell_bar_item_suggest (const void *pointer, void *data,
str_suggest,
weechat_color (
weechat_config_string (
- weechat_aspell_config_color_suggestion_delimiter_dict)));
+ spell_config_color_suggestion_delimiter_dict)));
weechat_string_dyn_concat (
str_suggest,
weechat_config_string (
- weechat_aspell_config_look_suggestion_delimiter_dict));
+ spell_config_look_suggestion_delimiter_dict));
}
suggestions2 = weechat_string_split (suggestions[i], ",", 0, 0,
&num_suggestions2);
@@ -131,17 +131,17 @@ weechat_aspell_bar_item_suggest (const void *pointer, void *data,
str_suggest,
weechat_color (
weechat_config_string (
- weechat_aspell_config_color_suggestion_delimiter_word)));
+ spell_config_color_suggestion_delimiter_word)));
weechat_string_dyn_concat (
str_suggest,
weechat_config_string (
- weechat_aspell_config_look_suggestion_delimiter_word));
+ spell_config_look_suggestion_delimiter_word));
}
weechat_string_dyn_concat (
str_suggest,
weechat_color (
weechat_config_string (
- weechat_aspell_config_color_suggestion)));
+ spell_config_color_suggestion)));
weechat_string_dyn_concat (str_suggest, suggestions2[j]);
}
weechat_string_free_split (suggestions2);
@@ -154,14 +154,14 @@ end:
}
/*
- * Initializes aspell bar items.
+ * Initializes spell bar items.
*/
void
-weechat_aspell_bar_item_init ()
+spell_bar_item_init ()
{
- 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);
+ weechat_bar_item_new ("spell_dict",
+ &spell_bar_item_dict, NULL, NULL);
+ weechat_bar_item_new ("spell_suggest",
+ &spell_bar_item_suggest, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-bar-item.h b/src/plugins/spell/spell-bar-item.h
index a6f105fdc..84f65681e 100644
--- a/src/plugins/aspell/weechat-aspell-bar-item.h
+++ b/src/plugins/spell/spell-bar-item.h
@@ -17,9 +17,9 @@
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_ASPELL_BAR_ITEM_H
-#define WEECHAT_PLUGIN_ASPELL_BAR_ITEM_H
+#ifndef WEECHAT_PLUGIN_SPELL_BAR_ITEM_H
+#define WEECHAT_PLUGIN_SPELL_BAR_ITEM_H
-extern void weechat_aspell_bar_item_init ();
+extern void spell_bar_item_init ();
-#endif /* WEECHAT_PLUGIN_ASPELL_BAR_ITEM_H */
+#endif /* WEECHAT_PLUGIN_SPELL_BAR_ITEM_H */
diff --git a/src/plugins/aspell/weechat-aspell-command.c b/src/plugins/spell/spell-command.c
index f8e80b2bc..5d27aa9d7 100644
--- a/src/plugins/aspell/weechat-aspell-command.c
+++ b/src/plugins/spell/spell-command.c
@@ -1,5 +1,5 @@
/*
- * weechat-aspell-command.c - aspell commands
+ * spell-command.c - spell checker commands
*
* Copyright (C) 2013-2019 Sébastien Helleu <flashcode@flashtux.org>
*
@@ -24,26 +24,26 @@
#include <string.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
-#include "weechat-aspell-config.h"
-#include "weechat-aspell-speller.h"
+#include "spell.h"
+#include "spell-config.h"
+#include "spell-speller.h"
/*
- * Converts an aspell ISO lang code in its English full name.
+ * Converts an ISO lang code in its English full name.
*
* Note: result must be freed after use.
*/
char *
-weechat_aspell_command_iso_to_lang (const char *code)
+spell_command_iso_to_lang (const char *code)
{
int i;
- for (i = 0; aspell_langs[i].code; i++)
+ for (i = 0; spell_langs[i].code; i++)
{
- if (strcmp (aspell_langs[i].code, code) == 0)
- return strdup (aspell_langs[i].name);
+ if (strcmp (spell_langs[i].code, code) == 0)
+ return strdup (spell_langs[i].name);
}
/* lang code not found */
@@ -51,20 +51,20 @@ weechat_aspell_command_iso_to_lang (const char *code)
}
/*
- * Converts an aspell ISO country code in its English full name.
+ * Converts an ISO country code in its English full name.
*
* Note: result must be freed after use.
*/
char *
-weechat_aspell_command_iso_to_country (const char *code)
+spell_command_iso_to_country (const char *code)
{
int i;
- for (i = 0; aspell_countries[i].code; i++)
+ for (i = 0; spell_countries[i].code; i++)
{
- if (strcmp (aspell_countries[i].code, code) == 0)
- return strdup (aspell_countries[i].name);
+ if (strcmp (spell_countries[i].code, code) == 0)
+ return strdup (spell_countries[i].name);
}
/* country code not found */
@@ -77,11 +77,11 @@ weechat_aspell_command_iso_to_country (const char *code)
#ifdef USE_ENCHANT
void
-weechat_aspell_enchant_dict_describe_cb (const char *lang_tag,
- const char *provider_name,
- const char *provider_desc,
- const char *provider_file,
- void *user_data)
+spell_enchant_dict_describe_cb (const char *lang_tag,
+ const char *provider_name,
+ const char *provider_desc,
+ const char *provider_file,
+ void *user_data)
{
char *country, *lang, *pos, *iso;
char str_dict[256];
@@ -102,13 +102,13 @@ weechat_aspell_enchant_dict_describe_cb (const char *lang_tag,
iso = weechat_strndup (lang_tag, pos - lang_tag);
if (iso)
{
- lang = weechat_aspell_command_iso_to_lang (iso);
- country = weechat_aspell_command_iso_to_country (pos + 1);
+ lang = spell_command_iso_to_lang (iso);
+ country = spell_command_iso_to_country (pos + 1);
free (iso);
}
}
else
- lang = weechat_aspell_command_iso_to_lang ((char *)lang_tag);
+ lang = spell_command_iso_to_lang ((char *)lang_tag);
if (lang)
{
@@ -133,11 +133,11 @@ weechat_aspell_enchant_dict_describe_cb (const char *lang_tag,
#endif /* USE_ENCHANT */
/*
- * Displays list of aspell dictionaries installed on system.
+ * Displays list of dictionaries installed on system.
*/
void
-weechat_aspell_command_speller_list_dicts ()
+spell_command_speller_list_dicts ()
{
#ifndef USE_ENCHANT
char *country, *lang, *pos, *iso;
@@ -150,12 +150,12 @@ weechat_aspell_command_speller_list_dicts ()
weechat_printf (NULL, "");
weechat_printf (NULL,
- /* TRANSLATORS: "%s" is "aspell" */
+ /* TRANSLATORS: "%s" is "spell" (name of plugin) */
_( "%s dictionaries list:"),
- ASPELL_PLUGIN_NAME);
+ SPELL_PLUGIN_NAME);
#ifdef USE_ENCHANT
- enchant_broker_list_dicts (broker, weechat_aspell_enchant_dict_describe_cb,
+ enchant_broker_list_dicts (broker, spell_enchant_dict_describe_cb,
NULL);
#else
config = new_aspell_config ();
@@ -173,13 +173,13 @@ weechat_aspell_command_speller_list_dicts ()
iso = weechat_strndup (dict->code, pos - dict->code);
if (iso)
{
- lang = weechat_aspell_command_iso_to_lang (iso);
- country = weechat_aspell_command_iso_to_country (pos + 1);
+ lang = spell_command_iso_to_lang (iso);
+ country = spell_command_iso_to_country (pos + 1);
free (iso);
}
}
else
- lang = weechat_aspell_command_iso_to_lang ((char*)dict->code);
+ lang = spell_command_iso_to_lang ((char*)dict->code);
str_country[0] = '\0';
if (country || dict->jargon[0])
@@ -213,22 +213,22 @@ weechat_aspell_command_speller_list_dicts ()
*/
void
-weechat_aspell_command_set_dict (struct t_gui_buffer *buffer, const char *value)
+spell_command_set_dict (struct t_gui_buffer *buffer, const char *value)
{
char *name;
- name = weechat_aspell_build_option_name (buffer);
+ name = spell_build_option_name (buffer);
if (!name)
return;
- if (weechat_aspell_config_set_dict (name, value) > 0)
+ if (spell_config_set_dict (name, value) > 0)
{
if (value && value[0])
weechat_printf (NULL, "%s: \"%s\" => %s",
- ASPELL_PLUGIN_NAME, name, value);
+ SPELL_PLUGIN_NAME, name, value);
else
weechat_printf (NULL, _("%s: \"%s\" removed"),
- ASPELL_PLUGIN_NAME, name);
+ SPELL_PLUGIN_NAME, name);
}
free (name);
@@ -239,10 +239,10 @@ weechat_aspell_command_set_dict (struct t_gui_buffer *buffer, const char *value)
*/
void
-weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
+spell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
const char *word)
{
- struct t_aspell_speller_buffer *ptr_speller_buffer;
+ struct t_spell_speller_buffer *ptr_speller_buffer;
#ifdef USE_ENCHANT
EnchantDict *new_speller, *ptr_speller;
#else
@@ -253,18 +253,18 @@ weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
if (dict)
{
- ptr_speller = weechat_hashtable_get (weechat_aspell_spellers, dict);
+ ptr_speller = weechat_hashtable_get (spell_spellers, dict);
if (!ptr_speller)
{
- if (!weechat_aspell_speller_dict_supported (dict))
+ if (!spell_speller_dict_supported (dict))
{
weechat_printf (NULL,
_("%s: error: dictionary \"%s\" is not "
"available on your system"),
- ASPELL_PLUGIN_NAME, dict);
+ SPELL_PLUGIN_NAME, dict);
return;
}
- new_speller = weechat_aspell_speller_new (dict);
+ new_speller = spell_speller_new (dict);
if (!new_speller)
return;
ptr_speller = new_speller;
@@ -272,10 +272,10 @@ weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
}
else
{
- ptr_speller_buffer = weechat_hashtable_get (weechat_aspell_speller_buffer,
+ ptr_speller_buffer = weechat_hashtable_get (spell_speller_buffer,
buffer);
if (!ptr_speller_buffer)
- ptr_speller_buffer = weechat_aspell_speller_buffer_new (buffer);
+ ptr_speller_buffer = spell_speller_buffer_new (buffer);
if (!ptr_speller_buffer)
goto error;
if (!ptr_speller_buffer->spellers || !ptr_speller_buffer->spellers[0])
@@ -284,7 +284,7 @@ weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
_("%s%s: no dictionary on this buffer for "
"adding word"),
weechat_prefix ("error"),
- ASPELL_PLUGIN_NAME);
+ SPELL_PLUGIN_NAME);
return;
}
else if (ptr_speller_buffer->spellers[1])
@@ -293,7 +293,7 @@ weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
_("%s%s: many dictionaries are defined for "
"this buffer, please specify dictionary"),
weechat_prefix ("error"),
- ASPELL_PLUGIN_NAME);
+ SPELL_PLUGIN_NAME);
return;
}
ptr_speller = ptr_speller_buffer->spellers[0];
@@ -308,7 +308,7 @@ weechat_aspell_command_add_word (struct t_gui_buffer *buffer, const char *dict,
{
weechat_printf (NULL,
_("%s: word \"%s\" added to personal dictionary"),
- ASPELL_PLUGIN_NAME, word);
+ SPELL_PLUGIN_NAME, word);
}
else
goto error;
@@ -320,21 +320,21 @@ error:
weechat_printf (NULL,
_("%s%s: failed to add word to personal "
"dictionary"),
- weechat_prefix ("error"), ASPELL_PLUGIN_NAME);
+ weechat_prefix ("error"), SPELL_PLUGIN_NAME);
end:
if (new_speller)
- weechat_hashtable_remove (weechat_aspell_spellers, dict);
+ weechat_hashtable_remove (spell_spellers, dict);
}
/*
- * Callback for command "/aspell".
+ * Callback for command "/spell".
*/
int
-weechat_aspell_command_cb (const void *pointer, void *data,
- struct t_gui_buffer *buffer,
- int argc, char **argv, char **argv_eol)
+spell_command_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
+ int argc, char **argv, char **argv_eol)
{
char *dicts;
const char *default_dict;
@@ -347,25 +347,25 @@ weechat_aspell_command_cb (const void *pointer, void *data,
if (argc == 1)
{
- /* display aspell status */
+ /* display spell status */
weechat_printf (NULL, "");
weechat_printf (NULL,
/* TRANSLATORS: second "%s" is "aspell" or "enchant" */
_("%s (using %s)"),
- (aspell_enabled) ? _("Spell checking is enabled") : _("Spell checking is disabled"),
+ (spell_enabled) ? _("Spell checking is enabled") : _("Spell checking is disabled"),
#ifdef USE_ENCHANT
"enchant"
#else
"aspell"
#endif /* USE_ENCHANT */
);
- default_dict = weechat_config_string (weechat_aspell_config_check_default_dict);
+ default_dict = weechat_config_string (spell_config_check_default_dict);
weechat_printf (NULL,
_("Default dictionary: %s"),
(default_dict && default_dict[0]) ?
default_dict : _("(not set)"));
number = 0;
- infolist = weechat_infolist_get ("option", NULL, "aspell.dict.*");
+ infolist = weechat_infolist_get ("option", NULL, "spell.dict.*");
if (infolist)
{
while (weechat_infolist_next (infolist))
@@ -382,34 +382,34 @@ weechat_aspell_command_cb (const void *pointer, void *data,
return WEECHAT_RC_OK;
}
- /* enable aspell */
+ /* enable spell */
if (weechat_strcasecmp (argv[1], "enable") == 0)
{
- weechat_config_option_set (weechat_aspell_config_check_enabled, "1", 1);
- weechat_printf (NULL, _("Aspell enabled"));
+ weechat_config_option_set (spell_config_check_enabled, "1", 1);
+ weechat_printf (NULL, _("Spell checker enabled"));
return WEECHAT_RC_OK;
}
- /* disable aspell */
+ /* disable spell */
if (weechat_strcasecmp (argv[1], "disable") == 0)
{
- weechat_config_option_set (weechat_aspell_config_check_enabled, "0", 1);
- weechat_printf (NULL, _("Aspell disabled"));
+ weechat_config_option_set (spell_config_check_enabled, "0", 1);
+ weechat_printf (NULL, _("Spell checker disabled"));
return WEECHAT_RC_OK;
}
- /* toggle aspell */
+ /* toggle spell */
if (weechat_strcasecmp (argv[1], "toggle") == 0)
{
- if (aspell_enabled)
+ if (spell_enabled)
{
- weechat_config_option_set (weechat_aspell_config_check_enabled, "0", 1);
- weechat_printf (NULL, _("Aspell disabled"));
+ weechat_config_option_set (spell_config_check_enabled, "0", 1);
+ weechat_printf (NULL, _("Spell checker disabled"));
}
else
{
- weechat_config_option_set (weechat_aspell_config_check_enabled, "1", 1);
- weechat_printf (NULL, _("Aspell enabled"));
+ weechat_config_option_set (spell_config_check_enabled, "1", 1);
+ weechat_printf (NULL, _("Spell checker enabled"));
}
return WEECHAT_RC_OK;
}
@@ -417,7 +417,7 @@ weechat_aspell_command_cb (const void *pointer, void *data,
/* list of dictionaries */
if (weechat_strcasecmp (argv[1], "listdict") == 0)
{
- weechat_aspell_command_speller_list_dicts ();
+ spell_command_speller_list_dicts ();
return WEECHAT_RC_OK;
}
@@ -426,8 +426,8 @@ weechat_aspell_command_cb (const void *pointer, void *data,
{
WEECHAT_COMMAND_MIN_ARGS(3, "setdict");
dicts = weechat_string_replace (argv_eol[2], " ", "");
- weechat_aspell_command_set_dict (buffer,
- (dicts) ? dicts : argv[2]);
+ spell_command_set_dict (buffer,
+ (dicts) ? dicts : argv[2]);
if (dicts)
free (dicts);
return WEECHAT_RC_OK;
@@ -436,7 +436,7 @@ weechat_aspell_command_cb (const void *pointer, void *data,
/* delete dictionary used on current buffer */
if (weechat_strcasecmp (argv[1], "deldict") == 0)
{
- weechat_aspell_command_set_dict (buffer, NULL);
+ spell_command_set_dict (buffer, NULL);
return WEECHAT_RC_OK;
}
@@ -447,12 +447,12 @@ weechat_aspell_command_cb (const void *pointer, void *data,
if (argc > 3)
{
/* use a given dict */
- weechat_aspell_command_add_word (buffer, argv[2], argv_eol[3]);
+ spell_command_add_word (buffer, argv[2], argv_eol[3]);
}
else
{
/* use default dict */
- weechat_aspell_command_add_word (buffer, NULL, argv_eol[2]);
+ spell_command_add_word (buffer, NULL, argv_eol[2]);
}
return WEECHAT_RC_OK;
}
@@ -461,47 +461,47 @@ weechat_aspell_command_cb (const void *pointer, void *data,
}
/*
- * Hooks aspell command.
+ * Hooks spell command.
*/
void
-weechat_aspell_command_init ()
+spell_command_init ()
{
weechat_hook_command (
- "aspell",
- N_("aspell plugin configuration"),
+ "spell",
+ N_("spell plugin configuration"),
N_("enable|disable|toggle"
" || listdict"
" || setdict <dict>[,<dict>...]"
" || deldict"
" || addword [<dict>] <word>"),
- N_(" enable: enable aspell\n"
- " disable: disable aspell\n"
- " toggle: toggle aspell\n"
+ N_(" enable: enable spell checker\n"
+ " disable: disable spell checker\n"
+ " toggle: toggle spell checker\n"
"listdict: show installed dictionaries\n"
" setdict: set dictionary for current buffer (multiple dictionaries "
"can be separated by a comma)\n"
" deldict: delete dictionary used on current buffer\n"
- " addword: add a word in personal aspell dictionary\n"
+ " addword: add a word in personal dictionary\n"
"\n"
"Input line beginning with a '/' is not checked, except for some "
- "commands (see /set aspell.check.commands).\n"
+ "commands (see /set spell.check.commands).\n"
"\n"
- "To enable aspell on all buffers, use option \"default_dict\", then "
- "enable aspell, for example:\n"
- " /set aspell.check.default_dict \"en\"\n"
- " /aspell enable\n"
+ "To enable spell checker on all buffers, use option \"default_dict\", "
+ "then enable spell checker, for example:\n"
+ " /set spell.check.default_dict \"en\"\n"
+ " /spell enable\n"
"\n"
"To display a list of suggestions in a bar, use item "
- "\"aspell_suggest\".\n"
+ "\"spell_suggest\".\n"
"\n"
- "Default key to toggle aspell is alt-s."),
+ "Default key to toggle spell checker is alt-s."),
"enable"
" || disable"
" || toggle"
" || listdict"
- " || setdict %(aspell_dicts)"
+ " || setdict %(spell_dicts)"
" || deldict"
" || addword",
- &weechat_aspell_command_cb, NULL, NULL);
+ &spell_command_cb, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-info.h b/src/plugins/spell/spell-command.h
index ec4aa9d11..822955c0c 100644
--- a/src/plugins/aspell/weechat-aspell-info.h
+++ b/src/plugins/spell/spell-command.h
@@ -17,9 +17,9 @@
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_ASPELL_INFO_H
-#define WEECHAT_PLUGIN_ASPELL_INFO_H
+#ifndef WEECHAT_PLUGIN_SPELL_COMMAND_H
+#define WEECHAT_PLUGIN_SPELL_COMMAND_H
-extern void weechat_aspell_info_init ();
+extern void spell_command_init ();
-#endif /* WEECHAT_PLUGIN_ASPELL_INFO_H */
+#endif /* WEECHAT_PLUGIN_SPELL_COMMAND_H */
diff --git a/src/plugins/aspell/weechat-aspell-completion.c b/src/plugins/spell/spell-completion.c
index 524a204d5..f80030add 100644
--- a/src/plugins/aspell/weechat-aspell-completion.c
+++ b/src/plugins/spell/spell-completion.c
@@ -1,5 +1,5 @@
/*
- * weechat-aspell-completion.c - completion for aspell commands
+ * spell-completion.c - completion for spell checker commands
*
* Copyright (C) 2013-2019 Sébastien Helleu <flashcode@flashtux.org>
*
@@ -24,19 +24,19 @@
#include <string.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
+#include "spell.h"
/*
- * Adds aspell langs (all langs, even for dictionaries not installed) to
+ * Adds spell langs (all langs, even for dictionaries not installed) to
* completion list.
*/
int
-weechat_aspell_completion_langs_cb (const void *pointer, void *data,
- const char *completion_item,
- struct t_gui_buffer *buffer,
- struct t_gui_completion *completion)
+spell_completion_langs_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
{
int i;
@@ -46,10 +46,10 @@ weechat_aspell_completion_langs_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
- for (i = 0; aspell_langs[i].code; i++)
+ for (i = 0; spell_langs[i].code; i++)
{
weechat_hook_completion_list_add (completion,
- aspell_langs[i].code,
+ spell_langs[i].code,
0, WEECHAT_LIST_POS_SORT);
}
@@ -62,11 +62,11 @@ weechat_aspell_completion_langs_cb (const void *pointer, void *data,
#ifdef USE_ENCHANT
void
-weechat_aspell_completion_enchant_add_dict_cb (const char *lang_tag,
- const char *provider_name,
- const char *provider_desc,
- const char *provider_file,
- void *user_data)
+spell_completion_enchant_add_dict_cb (const char *lang_tag,
+ const char *provider_name,
+ const char *provider_desc,
+ const char *provider_file,
+ void *user_data)
{
/* make C compiler happy */
(void) provider_name;
@@ -79,14 +79,14 @@ weechat_aspell_completion_enchant_add_dict_cb (const char *lang_tag,
#endif /* USE_ENCHANT */
/*
- * Adds aspell dictionaries (only installed dictionaries) to completion list.
+ * Adds spell dictionaries (only installed dictionaries) to completion list.
*/
int
-weechat_aspell_completion_dicts_cb (const void *pointer, void *data,
- const char *completion_item,
- struct t_gui_buffer *buffer,
- struct t_gui_completion *completion)
+spell_completion_dicts_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
{
#ifndef USE_ENCHANT
struct AspellConfig *config;
@@ -103,7 +103,7 @@ weechat_aspell_completion_dicts_cb (const void *pointer, void *data,
#ifdef USE_ENCHANT
enchant_broker_list_dicts (broker,
- weechat_aspell_completion_enchant_add_dict_cb,
+ spell_completion_enchant_add_dict_cb,
completion);
#else
config = new_aspell_config ();
@@ -128,12 +128,12 @@ weechat_aspell_completion_dicts_cb (const void *pointer, void *data,
*/
void
-weechat_aspell_completion_init ()
+spell_completion_init ()
{
- weechat_hook_completion ("aspell_langs",
- N_("list of all languages supported by aspell"),
- &weechat_aspell_completion_langs_cb, NULL, NULL);
- weechat_hook_completion ("aspell_dicts",
- N_("list of aspell installed dictionaries"),
- &weechat_aspell_completion_dicts_cb, NULL, NULL);
+ weechat_hook_completion ("spell_langs",
+ N_("list of all languages supported"),
+ &spell_completion_langs_cb, NULL, NULL);
+ weechat_hook_completion ("spell_dicts",
+ N_("list of installed dictionaries"),
+ &spell_completion_dicts_cb, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-command.h b/src/plugins/spell/spell-completion.h
index aa314bad2..4c3ad6097 100644
--- a/src/plugins/aspell/weechat-aspell-command.h
+++ b/src/plugins/spell/spell-completion.h
@@ -17,9 +17,9 @@
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_ASPELL_COMMAND_H
-#define WEECHAT_PLUGIN_ASPELL_COMMAND_H
+#ifndef WEECHAT_PLUGIN_SPELL_COMPLETION_H
+#define WEECHAT_PLUGIN_SPELL_COMPLETION_H
-extern void weechat_aspell_command_init ();
+extern void spell_completion_init ();
-#endif /* WEECHAT_PLUGIN_ASPELL_COMMAND_H */
+#endif /* WEECHAT_PLUGIN_SPELL_COMPLETION_H */
diff --git a/src/plugins/spell/spell-config.c b/src/plugins/spell/spell-config.c
new file mode 100644
index 000000000..cc24efc35
--- /dev/null
+++ b/src/plugins/spell/spell-config.c
@@ -0,0 +1,676 @@
+/*
+ * spell-config.c - spell checker configuration options (file spell.conf)
+ *
+ * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
+ * Copyright (C) 2006-2019 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat 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.
+ *
+ * WeeChat 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 WeeChat. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include "../weechat-plugin.h"
+#include "spell.h"
+#include "spell-config.h"
+#include "spell-speller.h"
+
+
+struct t_config_file *spell_config_file = NULL;
+struct t_config_section *spell_config_section_dict = NULL;
+
+int spell_config_loading = 0;
+
+/* spell config, color section */
+
+struct t_config_option *spell_config_color_misspelled;
+struct t_config_option *spell_config_color_suggestion;
+struct t_config_option *spell_config_color_suggestion_delimiter_dict;
+struct t_config_option *spell_config_color_suggestion_delimiter_word;
+
+/* spell config, check section */
+
+struct t_config_option *spell_config_check_commands;
+struct t_config_option *spell_config_check_default_dict;
+struct t_config_option *spell_config_check_during_search;
+struct t_config_option *spell_config_check_enabled;
+struct t_config_option *spell_config_check_real_time;
+struct t_config_option *spell_config_check_suggestions;
+struct t_config_option *spell_config_check_word_min_length;
+
+/* spell config, look section */
+
+struct t_config_option *spell_config_look_suggestion_delimiter_dict;
+struct t_config_option *spell_config_look_suggestion_delimiter_word;
+
+
+char **spell_commands_to_check = NULL;
+int spell_count_commands_to_check = 0;
+int *spell_length_commands_to_check = NULL;
+
+
+/*
+ * Callback for changes on option "spell.check.commands".
+ */
+
+void
+spell_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 (spell_commands_to_check)
+ {
+ weechat_string_free_split (spell_commands_to_check);
+ spell_commands_to_check = NULL;
+ spell_count_commands_to_check = 0;
+ }
+
+ if (spell_length_commands_to_check)
+ {
+ free (spell_length_commands_to_check);
+ spell_length_commands_to_check = NULL;
+ }
+
+ value = weechat_config_string (option);
+ if (value && value[0])
+ {
+ spell_commands_to_check = weechat_string_split (value,
+ ",", 0, 0,
+ &spell_count_commands_to_check);
+ if (spell_count_commands_to_check > 0)
+ {
+ spell_length_commands_to_check = malloc (spell_count_commands_to_check *
+ sizeof (int));
+ for (i = 0; i < spell_count_commands_to_check; i++)
+ {
+ spell_length_commands_to_check[i] = strlen (spell_commands_to_check[i]);
+ }
+ }
+ }
+}
+
+/*
+ * Callback for changes on option "spell.check.default_dict".
+ */
+
+void
+spell_config_change_default_dict (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+}
+
+/*
+ * Callback for changes on option "spell.check.enabled".
+ */
+
+void
+spell_config_change_enabled (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ spell_enabled = weechat_config_boolean (option);
+
+ /* refresh input and spell suggestions */
+ weechat_bar_item_update ("input_text");
+ weechat_bar_item_update ("spell_suggest");
+}
+
+/*
+ * Callback for changes on option "spell.check.suggestions".
+ */
+
+void
+spell_config_change_suggestions (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ weechat_bar_item_update ("spell_suggest");
+}
+
+/*
+ * Callback for changes on a dictionary.
+ */
+
+void
+spell_config_dict_change (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+}
+
+/*
+ * Callback called when an option is deleted in section "dict".
+ */
+
+int
+spell_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;
+
+ weechat_config_option_free (option);
+
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+
+ return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
+}
+
+/*
+ * Creates an option in section "dict".
+ */
+
+int
+spell_config_dict_create_option (const void *pointer, void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ const char *option_name,
+ const char *value)
+{
+ struct t_config_option *ptr_option;
+ int rc;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
+
+ if (value && value[0])
+ spell_speller_check_dictionaries (value);
+
+ if (option_name)
+ {
+ ptr_option = weechat_config_search_option (config_file, section,
+ option_name);
+ if (ptr_option)
+ {
+ if (value && value[0])
+ rc = weechat_config_option_set (ptr_option, value, 0);
+ else
+ {
+ weechat_config_option_free (ptr_option);
+ rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
+ }
+ }
+ else
+ {
+ if (value && value[0])
+ {
+ ptr_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ _("comma separated list of dictionaries to use on this buffer"),
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &spell_config_dict_change, NULL, NULL,
+ NULL, NULL, NULL);
+ rc = (ptr_option) ?
+ WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
+ }
+ else
+ rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
+ }
+ }
+
+ if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating spell dictionary \"%s\" => \"%s\""),
+ weechat_prefix ("error"), SPELL_PLUGIN_NAME,
+ option_name, value);
+ }
+ else
+ {
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+ }
+
+ return rc;
+}
+
+/*
+ * Callback for changes on an spell option.
+ */
+
+void
+spell_config_option_change (const void *pointer, void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+}
+
+/*
+ * Callback called when an option is deleted in section "option".
+ */
+
+int
+spell_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;
+
+ weechat_config_option_free (option);
+
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+
+ return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
+}
+
+/*
+ * Callback called when an option is created in section "option".
+ */
+
+int
+spell_config_option_create_option (const void *pointer, void *data,
+ struct t_config_file *config_file,
+ struct t_config_section *section,
+ const char *option_name,
+ const char *value)
+{
+ struct t_config_option *ptr_option;
+ int rc;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+
+ rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
+
+ if (option_name)
+ {
+ ptr_option = weechat_config_search_option (config_file, section,
+ option_name);
+ if (ptr_option)
+ {
+ if (value && value[0])
+ rc = weechat_config_option_set (ptr_option, value, 1);
+ else
+ {
+ weechat_config_option_free (ptr_option);
+ rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
+ }
+ }
+ else
+ {
+ if (value && value[0])
+ {
+ ptr_option = weechat_config_new_option (
+ config_file, section,
+ option_name, "string",
+ _("option for aspell (for list of available options and "
+ "format, run command \"aspell config\" in a shell)"),
+ NULL, 0, 0, "", value, 0,
+ NULL, NULL, NULL,
+ &spell_config_option_change, NULL, NULL,
+ NULL, NULL, NULL);
+ rc = (ptr_option) ?
+ WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
+ }
+ else
+ rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
+ }
+ }
+
+ if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
+ {
+ weechat_printf (NULL,
+ _("%s%s: error creating spell option \"%s\" => \"%s\""),
+ weechat_prefix ("error"), SPELL_PLUGIN_NAME,
+ option_name, value);
+ }
+ else
+ {
+ weechat_hashtable_remove_all (spell_speller_buffer);
+ if (!spell_config_loading)
+ spell_speller_remove_unused ();
+ }
+
+ return rc;
+}
+
+/*
+ * Gets a list of dictionaries for a buffer.
+ */
+
+struct t_config_option *
+spell_config_get_dict (const char *name)
+{
+ return weechat_config_search_option (spell_config_file,
+ spell_config_section_dict,
+ name);
+}
+
+/*
+ * Sets a list of dictionaries for a buffer.
+ */
+
+int
+spell_config_set_dict (const char *name, const char *value)
+{
+ return spell_config_dict_create_option (NULL, NULL,
+ spell_config_file,
+ spell_config_section_dict,
+ name,
+ value);
+}
+
+/*
+ * Initializes spell configuration file.
+ *
+ * Returns:
+ * 1: OK
+ * 0: error
+ */
+
+int
+spell_config_init ()
+{
+ struct t_config_section *ptr_section;
+
+ spell_config_file = weechat_config_new (SPELL_CONFIG_NAME,
+ NULL, NULL, NULL);
+ if (!spell_config_file)
+ return 0;
+
+ /* color */
+ ptr_section = weechat_config_new_section (
+ spell_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 (spell_config_file);
+ spell_config_file = NULL;
+ return 0;
+ }
+
+ spell_config_color_misspelled = weechat_config_new_option (
+ spell_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, NULL, NULL, NULL);
+ spell_config_color_suggestion = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "suggestion", "color",
+ N_("text color for suggestion on a misspelled word in bar item "
+ "\"spell_suggest\""),
+ NULL, 0, 0, "default", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ spell_config_color_suggestion_delimiter_dict = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "suggestion_delimiter_dict", "color",
+ N_("text color for delimiters displayed between two dictionaries "
+ "in bar item \"spell_suggest\""),
+ NULL, 0, 0, "cyan", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ spell_config_color_suggestion_delimiter_word = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "suggestion_delimiter_word", "color",
+ N_("text color for delimiters displayed between two words in bar item "
+ "\"spell_suggest\""),
+ NULL, 0, 0, "cyan", NULL, 0,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+ /* check */
+ ptr_section = weechat_config_new_section (
+ spell_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 (spell_config_file);
+ spell_config_file = NULL;
+ return 0;
+ }
+
+ spell_config_check_commands = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "commands", "string",
+ N_("comma separated list of commands for which spell checking is "
+ "enabled (spell checking is disabled for all other commands)"),
+ NULL, 0, 0,
+ "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,"
+ "quit,topic", NULL, 0,
+ NULL, NULL, NULL,
+ &spell_config_change_commands, NULL, NULL,
+ NULL, NULL, NULL);
+ spell_config_check_default_dict = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "default_dict", "string",
+ N_("default dictionary (or comma separated list of dictionaries) to "
+ "use when buffer has no dictionary defined (leave blank to disable "
+ "spell checker on buffers for which you didn't explicitly "
+ "enabled it)"),
+ NULL, 0, 0, "", NULL, 0,
+ NULL, NULL, NULL,
+ &spell_config_change_default_dict, NULL, NULL,
+ NULL, NULL, NULL);
+ spell_config_check_during_search = weechat_config_new_option (
+ spell_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, NULL, NULL);
+ spell_config_check_enabled = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "enabled", "boolean",
+ N_("enable spell checker for command line"),
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &spell_config_change_enabled, NULL, NULL,
+ NULL, NULL, NULL);
+ spell_config_check_real_time = weechat_config_new_option (
+ spell_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, NULL, NULL);
+ spell_config_check_suggestions = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "suggestions", "integer",
+ N_("number of suggestions to display in bar item \"spell_suggest\" "
+ "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, NULL,
+ &spell_config_change_suggestions, NULL, NULL,
+ NULL, NULL, NULL);
+ spell_config_check_word_min_length = weechat_config_new_option (
+ spell_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, NULL, NULL);
+
+ /* dict */
+ ptr_section = weechat_config_new_section (
+ spell_config_file, "dict",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &spell_config_dict_create_option, NULL, NULL,
+ &spell_config_dict_delete_option, NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (spell_config_file);
+ spell_config_file = NULL;
+ return 0;
+ }
+
+ spell_config_section_dict = ptr_section;
+
+ /* look */
+ ptr_section = weechat_config_new_section (
+ spell_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 (spell_config_file);
+ spell_config_file = NULL;
+ return 0;
+ }
+
+ spell_config_look_suggestion_delimiter_dict = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "suggestion_delimiter_dict", "string",
+ N_("delimiter displayed between two dictionaries in bar item "
+ "\"spell_suggest\""),
+ NULL, 0, 0, " / ", NULL, 0,
+ NULL, NULL, NULL,
+ &spell_config_change_suggestions, NULL, NULL,
+ NULL, NULL, NULL);
+ spell_config_look_suggestion_delimiter_word = weechat_config_new_option (
+ spell_config_file, ptr_section,
+ "suggestion_delimiter_word", "string",
+ N_("delimiter displayed between two words in bar item "
+ "\"spell_suggest\""),
+ NULL, 0, 0, ",", NULL, 0,
+ NULL, NULL, NULL,
+ &spell_config_change_suggestions, NULL, NULL,
+ NULL, NULL, NULL);
+
+ /* option */
+ ptr_section = weechat_config_new_section (
+ spell_config_file, "option",
+ 1, 1,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ &spell_config_option_create_option, NULL, NULL,
+ &spell_config_option_delete_option, NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (spell_config_file);
+ spell_config_file = NULL;
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Reads spell configuration file.
+ */
+
+int
+spell_config_read ()
+{
+ int rc;
+
+ spell_config_loading = 1;
+ rc = weechat_config_read (spell_config_file);
+ spell_config_loading = 0;
+ if (rc == WEECHAT_CONFIG_READ_OK)
+ spell_config_change_commands (NULL, NULL, spell_config_check_commands);
+ spell_speller_remove_unused ();
+
+ return rc;
+}
+
+/*
+ * Writes spell configuration file.
+ */
+
+int
+spell_config_write ()
+{
+ return weechat_config_write (spell_config_file);
+}
+
+/*
+ * Frees spell configuration.
+ */
+
+void
+spell_config_free ()
+{
+ weechat_config_free (spell_config_file);
+
+ if (spell_commands_to_check)
+ weechat_string_free_split (spell_commands_to_check);
+ if (spell_length_commands_to_check)
+ free (spell_length_commands_to_check);
+}
diff --git a/src/plugins/spell/spell-config.h b/src/plugins/spell/spell-config.h
new file mode 100644
index 000000000..2e036e0a2
--- /dev/null
+++ b/src/plugins/spell/spell-config.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
+ * Copyright (C) 2006-2019 Sébastien Helleu <flashcode@flashtux.org>
+ *
+ * This file is part of WeeChat, the extensible chat client.
+ *
+ * WeeChat 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.
+ *
+ * WeeChat 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 WeeChat. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef WEECHAT_PLUGIN_SPELL_CONFIG_H
+#define WEECHAT_PLUGIN_SPELL_CONFIG_H
+
+#define SPELL_CONFIG_NAME "spell"
+
+
+extern struct t_config_option *spell_config_color_misspelled;
+extern struct t_config_option *spell_config_color_suggestion;
+extern struct t_config_option *spell_config_color_suggestion_delimiter_dict;
+extern struct t_config_option *spell_config_color_suggestion_delimiter_word;
+
+extern struct t_config_option *spell_config_check_commands;
+extern struct t_config_option *spell_config_check_default_dict;
+extern struct t_config_option *spell_config_check_during_search;
+extern struct t_config_option *spell_config_check_enabled;
+extern struct t_config_option *spell_config_check_real_time;
+extern struct t_config_option *spell_config_check_suggestions;
+extern struct t_config_option *spell_config_check_word_min_length;
+
+extern struct t_config_option *spell_config_look_suggestion_delimiter_dict;
+extern struct t_config_option *spell_config_look_suggestion_delimiter_word;
+
+extern char **spell_commands_to_check;
+extern int spell_count_commands_to_check;
+extern int *spell_length_commands_to_check;
+
+extern struct t_config_option *spell_config_get_dict (const char *name);
+extern int spell_config_set_dict (const char *name, const char *value);
+extern int spell_config_init ();
+extern int spell_config_read ();
+extern int spell_config_write ();
+extern void spell_config_free ();
+
+#endif /* WEECHAT_PLUGIN_SPELL_CONFIG_H */
diff --git a/src/plugins/aspell/weechat-aspell-info.c b/src/plugins/spell/spell-info.c
index 13bc496c1..27024c09a 100644
--- a/src/plugins/aspell/weechat-aspell-info.c
+++ b/src/plugins/spell/spell-info.c
@@ -1,5 +1,5 @@
/*
- * weechat-aspell-info.c - info for aspell plugin
+ * spell-info.c - info for spell checker plugin
*
* Copyright (C) 2013-2019 Sébastien Helleu <flashcode@flashtux.org>
*
@@ -24,17 +24,17 @@
#include <string.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
+#include "spell.h"
/*
- * Returns aspell info "aspell_dict".
+ * Returns spell info "spell_dict".
*/
const char *
-weechat_aspell_info_info_aspell_dict_cb (const void *pointer, void *data,
- const char *info_name,
- const char *arguments)
+spell_info_info_spell_dict_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
{
int rc;
unsigned long value;
@@ -67,23 +67,23 @@ weechat_aspell_info_info_aspell_dict_cb (const void *pointer, void *data,
buffer_full_name = arguments;
if (buffer_full_name)
- return weechat_aspell_get_dict_with_buffer_name (buffer_full_name);
+ return spell_get_dict_with_buffer_name (buffer_full_name);
return NULL;
}
/*
- * Hooks info for aspell plugin.
+ * Hooks info for spell plugin.
*/
void
-weechat_aspell_info_init ()
+spell_info_init ()
{
/* info hooks */
weechat_hook_info (
- "aspell_dict",
+ "spell_dict",
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, NULL);
+ &spell_info_info_spell_dict_cb, NULL, NULL);
}
diff --git a/src/plugins/aspell/weechat-aspell-completion.h b/src/plugins/spell/spell-info.h
index 169573a17..e529236be 100644
--- a/src/plugins/aspell/weechat-aspell-completion.h
+++ b/src/plugins/spell/spell-info.h
@@ -17,9 +17,9 @@
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_ASPELL_COMPLETION_H
-#define WEECHAT_PLUGIN_ASPELL_COMPLETION_H
+#ifndef WEECHAT_PLUGIN_SPELL_INFO_H
+#define WEECHAT_PLUGIN_SPELL_INFO_H
-extern void weechat_aspell_completion_init ();
+extern void spell_info_init ();
-#endif /* WEECHAT_PLUGIN_ASPELL_COMPLETION_H */
+#endif /* WEECHAT_PLUGIN_SPELL_INFO_H */
diff --git a/src/plugins/aspell/weechat-aspell-speller.c b/src/plugins/spell/spell-speller.c
index 4b5746eff..0b0ac5492 100644
--- a/src/plugins/aspell/weechat-aspell-speller.c
+++ b/src/plugins/spell/spell-speller.c
@@ -1,5 +1,5 @@
/*
- * weechat-aspell-speller.c - speller management for aspell plugin
+ * spell-speller.c - speller management for spell checker plugin
*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2006-2019 Sébastien Helleu <flashcode@flashtux.org>
@@ -24,34 +24,34 @@
#include <string.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
-#include "weechat-aspell-speller.h"
-#include "weechat-aspell-config.h"
+#include "spell.h"
+#include "spell-speller.h"
+#include "spell-config.h"
/*
* spellers: one by dictionary (key is name of dictionary (eg: "fr"), value is
* pointer on AspellSpeller)
*/
-struct t_hashtable *weechat_aspell_spellers = NULL;
+struct t_hashtable *spell_spellers = NULL;
/*
* spellers by buffer (key is buffer pointer, value is pointer on
- * struct t_aspell_speller_buffer)
+ * struct t_spell_speller_buffer)
*/
-struct t_hashtable *weechat_aspell_speller_buffer = NULL;
+struct t_hashtable *spell_speller_buffer = NULL;
/*
- * Checks if an aspell dictionary is supported (installed on system).
+ * Checks if a spelling dictionary is supported (installed on system).
*
* Returns:
- * 1: aspell dict is supported
- * 0: aspell dict is NOT supported
+ * 1: spell dict is supported
+ * 0: spell dict is NOT supported
*/
int
-weechat_aspell_speller_dict_supported (const char *lang)
+spell_speller_dict_supported (const char *lang)
{
#ifdef USE_ENCHANT
return enchant_broker_dict_exists (broker, lang);
@@ -92,7 +92,7 @@ weechat_aspell_speller_dict_supported (const char *lang)
*/
void
-weechat_aspell_speller_check_dictionaries (const char *dict_list)
+spell_speller_check_dictionaries (const char *dict_list)
{
char **argv;
int argc, i;
@@ -104,12 +104,12 @@ weechat_aspell_speller_check_dictionaries (const char *dict_list)
{
for (i = 0; i < argc; i++)
{
- if (!weechat_aspell_speller_dict_supported (argv[i]))
+ if (!spell_speller_dict_supported (argv[i]))
{
weechat_printf (NULL,
_("%s: warning: dictionary \"%s\" is not "
"available on your system"),
- ASPELL_PLUGIN_NAME, argv[i]);
+ SPELL_PLUGIN_NAME, argv[i]);
}
}
weechat_string_free_split (argv);
@@ -120,7 +120,7 @@ weechat_aspell_speller_check_dictionaries (const char *dict_list)
/*
* Creates and adds a new speller instance in the hashtable.
*
- * Returns pointer to new aspell speller, NULL if error.
+ * Returns pointer to new speller, NULL if error.
*/
#ifdef USE_ENCHANT
@@ -128,7 +128,7 @@ EnchantDict *
#else
AspellSpeller *
#endif /* USE_ENCHANT */
-weechat_aspell_speller_new (const char *lang)
+spell_speller_new (const char *lang)
{
#ifdef USE_ENCHANT
EnchantDict *new_speller;
@@ -142,11 +142,11 @@ weechat_aspell_speller_new (const char *lang)
if (!lang)
return NULL;
- if (weechat_aspell_plugin->debug)
+ if (weechat_spell_plugin->debug)
{
weechat_printf (NULL,
"%s: creating new speller for lang \"%s\"",
- ASPELL_PLUGIN_NAME, lang);
+ SPELL_PLUGIN_NAME, lang);
}
#ifdef USE_ENCHANT
@@ -155,7 +155,7 @@ weechat_aspell_speller_new (const char *lang)
{
weechat_printf (NULL,
_("%s%s: error: unable to create speller for lang \"%s\""),
- weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
+ weechat_prefix ("error"), SPELL_PLUGIN_NAME,
lang);
return NULL;
}
@@ -166,7 +166,7 @@ weechat_aspell_speller_new (const char *lang)
#endif /* USE_ENCHANT */
/* apply all options */
- infolist = weechat_infolist_get ("option", NULL, "aspell.option.*");
+ infolist = weechat_infolist_get ("option", NULL, "spell.option.*");
if (infolist)
{
while (weechat_infolist_next (infolist))
@@ -189,7 +189,7 @@ weechat_aspell_speller_new (const char *lang)
{
weechat_printf (NULL,
"%s%s: error: %s",
- weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
+ weechat_prefix ("error"), SPELL_PLUGIN_NAME,
aspell_error_message (ret));
delete_aspell_config (config);
delete_aspell_can_have_error (ret);
@@ -199,7 +199,7 @@ weechat_aspell_speller_new (const char *lang)
new_speller = to_aspell_speller (ret);
#endif /* USE_ENCHANT */
- weechat_hashtable_set (weechat_aspell_spellers, lang, new_speller);
+ weechat_hashtable_set (spell_spellers, lang, new_speller);
#ifndef USE_ENCHANT
/* free configuration */
@@ -209,9 +209,13 @@ weechat_aspell_speller_new (const char *lang)
return new_speller;
}
+/*
+ * Creates hashtable entries with a string containing a list of dicts.
+ */
+
void
-weechat_aspell_speller_add_dicts_to_hash (struct t_hashtable *hashtable,
- const char *dict)
+spell_speller_add_dicts_to_hash (struct t_hashtable *hashtable,
+ const char *dict)
{
char **dicts;
int num_dicts, i;
@@ -235,9 +239,9 @@ weechat_aspell_speller_add_dicts_to_hash (struct t_hashtable *hashtable,
*/
void
-weechat_aspell_speller_remove_unused_cb (void *data,
- struct t_hashtable *hashtable,
- const void *key, const void *value)
+spell_speller_remove_unused_cb (void *data,
+ struct t_hashtable *hashtable,
+ const void *key, const void *value)
{
struct t_hashtable *used_spellers;
@@ -252,20 +256,20 @@ weechat_aspell_speller_remove_unused_cb (void *data,
}
/*
- * Removes unused spellers from hashtable "weechat_aspell_spellers".
+ * Removes unused spellers from hashtable "spell_spellers".
*/
void
-weechat_aspell_speller_remove_unused ()
+spell_speller_remove_unused ()
{
struct t_hashtable *used_spellers;
struct t_infolist *infolist;
- if (weechat_aspell_plugin->debug)
+ if (weechat_spell_plugin->debug)
{
weechat_printf (NULL,
"%s: removing unused spellers",
- ASPELL_PLUGIN_NAME);
+ SPELL_PLUGIN_NAME);
}
/* create a hashtable that will contain all used spellers */
@@ -277,15 +281,15 @@ weechat_aspell_speller_remove_unused ()
return;
/* collect used spellers and store them in hashtable "used_spellers" */
- weechat_aspell_speller_add_dicts_to_hash (used_spellers,
- weechat_config_string (weechat_aspell_config_check_default_dict));
- infolist = weechat_infolist_get ("option", NULL, "aspell.dict.*");
+ spell_speller_add_dicts_to_hash (used_spellers,
+ weechat_config_string (spell_config_check_default_dict));
+ infolist = weechat_infolist_get ("option", NULL, "spell.dict.*");
if (infolist)
{
while (weechat_infolist_next (infolist))
{
- weechat_aspell_speller_add_dicts_to_hash (used_spellers,
- weechat_infolist_string (infolist, "value"));
+ spell_speller_add_dicts_to_hash (used_spellers,
+ weechat_infolist_string (infolist, "value"));
}
weechat_infolist_free (infolist);
}
@@ -294,19 +298,19 @@ weechat_aspell_speller_remove_unused ()
* look at current spellers, and remove spellers that are not in hashtable
* "used_spellers"
*/
- weechat_hashtable_map (weechat_aspell_spellers,
- &weechat_aspell_speller_remove_unused_cb,
+ weechat_hashtable_map (spell_spellers,
+ &spell_speller_remove_unused_cb,
used_spellers);
weechat_hashtable_free (used_spellers);
}
/*
- * Callback called when a key is removed in hashtable "weechat_aspell_spellers".
+ * Callback called when a key is removed in hashtable "spell_spellers".
*/
void
-weechat_aspell_speller_free_value_cb (struct t_hashtable *hashtable,
+spell_speller_free_value_cb (struct t_hashtable *hashtable,
const void *key, void *value)
{
#ifdef USE_ENCHANT
@@ -318,11 +322,11 @@ weechat_aspell_speller_free_value_cb (struct t_hashtable *hashtable,
/* make C compiler happy */
(void) hashtable;
- if (weechat_aspell_plugin->debug)
+ if (weechat_spell_plugin->debug)
{
weechat_printf (NULL,
"%s: removing speller for lang \"%s\"",
- ASPELL_PLUGIN_NAME, (const char *)key);
+ SPELL_PLUGIN_NAME, (const char *)key);
}
/* free speller */
@@ -338,16 +342,16 @@ weechat_aspell_speller_free_value_cb (struct t_hashtable *hashtable,
/*
* Creates a structure for buffer speller info in hashtable
- * "weechat_aspell_buffer_spellers".
+ * "spell_buffer_spellers".
*/
-struct t_aspell_speller_buffer *
-weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer)
+struct t_spell_speller_buffer *
+spell_speller_buffer_new (struct t_gui_buffer *buffer)
{
const char *buffer_dicts;
char **dicts;
int num_dicts, i;
- struct t_aspell_speller_buffer *new_speller_buffer;
+ struct t_spell_speller_buffer *new_speller_buffer;
#ifdef USE_ENCHANT
EnchantDict *ptr_speller;
#else
@@ -357,7 +361,7 @@ weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer)
if (!buffer)
return NULL;
- weechat_hashtable_remove (weechat_aspell_speller_buffer, buffer);
+ weechat_hashtable_remove (spell_speller_buffer, buffer);
new_speller_buffer = malloc (sizeof (*new_speller_buffer));
if (!new_speller_buffer)
@@ -368,7 +372,7 @@ weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer)
new_speller_buffer->input_pos = -1;
new_speller_buffer->modifier_result = NULL;
- buffer_dicts = weechat_aspell_get_dict (buffer);
+ buffer_dicts = spell_get_dict (buffer);
if (buffer_dicts)
{
dicts = weechat_string_split (buffer_dicts, ",", 0, 0, &num_dicts);
@@ -384,10 +388,10 @@ weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer)
{
for (i = 0; i < num_dicts; i++)
{
- ptr_speller = weechat_hashtable_get (weechat_aspell_spellers,
+ ptr_speller = weechat_hashtable_get (spell_spellers,
dicts[i]);
if (!ptr_speller)
- ptr_speller = weechat_aspell_speller_new (dicts[i]);
+ ptr_speller = spell_speller_new (dicts[i]);
new_speller_buffer->spellers[i] = ptr_speller;
}
new_speller_buffer->spellers[num_dicts] = NULL;
@@ -397,31 +401,31 @@ weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer)
weechat_string_free_split (dicts);
}
- weechat_hashtable_set (weechat_aspell_speller_buffer,
+ weechat_hashtable_set (spell_speller_buffer,
buffer,
new_speller_buffer);
- weechat_bar_item_update ("aspell_dict");
+ weechat_bar_item_update ("spell_dict");
return new_speller_buffer;
}
/*
* Callback called when a key is removed in hashtable
- * "weechat_aspell_speller_buffer".
+ * "spell_speller_buffer".
*/
void
-weechat_aspell_speller_buffer_free_value_cb (struct t_hashtable *hashtable,
- const void *key, void *value)
+spell_speller_buffer_free_value_cb (struct t_hashtable *hashtable,
+ const void *key, void *value)
{
- struct t_aspell_speller_buffer *ptr_speller_buffer;
+ struct t_spell_speller_buffer *ptr_speller_buffer;
/* make C compiler happy */
(void) hashtable;
(void) key;
- ptr_speller_buffer = (struct t_aspell_speller_buffer *)value;
+ ptr_speller_buffer = (struct t_spell_speller_buffer *)value;
if (ptr_speller_buffer->spellers)
free (ptr_speller_buffer->spellers);
@@ -442,30 +446,30 @@ weechat_aspell_speller_buffer_free_value_cb (struct t_hashtable *hashtable,
*/
int
-weechat_aspell_speller_init ()
+spell_speller_init ()
{
- weechat_aspell_spellers = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_POINTER,
- NULL, NULL);
- if (!weechat_aspell_spellers)
+ spell_spellers = weechat_hashtable_new (32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL, NULL);
+ if (!spell_spellers)
return 0;
- weechat_hashtable_set_pointer (weechat_aspell_spellers,
+ weechat_hashtable_set_pointer (spell_spellers,
"callback_free_value",
- &weechat_aspell_speller_free_value_cb);
+ &spell_speller_free_value_cb);
- weechat_aspell_speller_buffer = weechat_hashtable_new (32,
- WEECHAT_HASHTABLE_POINTER,
- WEECHAT_HASHTABLE_POINTER,
- NULL, NULL);
- if (!weechat_aspell_speller_buffer)
+ spell_speller_buffer = weechat_hashtable_new (32,
+ WEECHAT_HASHTABLE_POINTER,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL, NULL);
+ if (!spell_speller_buffer)
{
- weechat_hashtable_free (weechat_aspell_spellers);
+ weechat_hashtable_free (spell_spellers);
return 0;
}
- weechat_hashtable_set_pointer (weechat_aspell_speller_buffer,
+ weechat_hashtable_set_pointer (spell_speller_buffer,
"callback_free_value",
- &weechat_aspell_speller_buffer_free_value_cb);
+ &spell_speller_buffer_free_value_cb);
return 1;
}
@@ -475,8 +479,8 @@ weechat_aspell_speller_init ()
*/
void
-weechat_aspell_speller_end ()
+spell_speller_end ()
{
- weechat_hashtable_free (weechat_aspell_spellers);
- weechat_hashtable_free (weechat_aspell_speller_buffer);
+ weechat_hashtable_free (spell_spellers);
+ weechat_hashtable_free (spell_speller_buffer);
}
diff --git a/src/plugins/aspell/weechat-aspell-speller.h b/src/plugins/spell/spell-speller.h
index fd2b79821..2d47d7e24 100644
--- a/src/plugins/aspell/weechat-aspell-speller.h
+++ b/src/plugins/spell/spell-speller.h
@@ -18,10 +18,10 @@
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_ASPELL_SPELLER_H
-#define WEECHAT_PLUGIN_ASPELL_SPELLER_H
+#ifndef WEECHAT_PLUGIN_SPELL_SPELLER_H
+#define WEECHAT_PLUGIN_SPELL_SPELLER_H
-struct t_aspell_speller_buffer
+struct t_spell_speller_buffer
{
#ifdef USE_ENCHANT
EnchantDict **spellers; /* enchant spellers for buffer */
@@ -33,19 +33,19 @@ struct t_aspell_speller_buffer
char *modifier_result; /* last modifier result */
};
-extern struct t_hashtable *weechat_aspell_spellers;
-extern struct t_hashtable *weechat_aspell_speller_buffer;
+extern struct t_hashtable *spell_spellers;
+extern struct t_hashtable *spell_speller_buffer;
-extern int weechat_aspell_speller_dict_supported (const char *lang);
-extern void weechat_aspell_speller_check_dictionaries (const char *dict_list);
+extern int spell_speller_dict_supported (const char *lang);
+extern void spell_speller_check_dictionaries (const char *dict_list);
#ifdef USE_ENCHANT
-extern EnchantDict *weechat_aspell_speller_new (const char *lang);
+extern EnchantDict *spell_speller_new (const char *lang);
#else
-extern AspellSpeller *weechat_aspell_speller_new (const char *lang);
+extern AspellSpeller *spell_speller_new (const char *lang);
#endif /* USE_ENCHANT */
-extern void weechat_aspell_speller_remove_unused ();
-extern struct t_aspell_speller_buffer *weechat_aspell_speller_buffer_new (struct t_gui_buffer *buffer);
-extern int weechat_aspell_speller_init ();
-extern void weechat_aspell_speller_end ();
+extern void spell_speller_remove_unused ();
+extern struct t_spell_speller_buffer *spell_speller_buffer_new (struct t_gui_buffer *buffer);
+extern int spell_speller_init ();
+extern void spell_speller_end ();
-#endif /* WEECHAT_PLUGIN_ASPELL_SPELLER_H */
+#endif /* WEECHAT_PLUGIN_SPELL_SPELLER_H */
diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/spell/spell.c
index 6151f5be7..b39e5ce54 100644
--- a/src/plugins/aspell/weechat-aspell.c
+++ b/src/plugins/spell/spell.c
@@ -1,5 +1,5 @@
/*
- * weechat-aspell.c - aspell plugin for WeeChat: color for misspelled words
+ * spell.c - spell checker plugin for WeeChat
*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2006-2019 Sébastien Helleu <flashcode@flashtux.org>
@@ -32,28 +32,28 @@
#include <wctype.h>
#include "../weechat-plugin.h"
-#include "weechat-aspell.h"
-#include "weechat-aspell-bar-item.h"
-#include "weechat-aspell-command.h"
-#include "weechat-aspell-completion.h"
-#include "weechat-aspell-config.h"
-#include "weechat-aspell-info.h"
-#include "weechat-aspell-speller.h"
+#include "spell.h"
+#include "spell-bar-item.h"
+#include "spell-command.h"
+#include "spell-completion.h"
+#include "spell-config.h"
+#include "spell-info.h"
+#include "spell-speller.h"
-WEECHAT_PLUGIN_NAME(ASPELL_PLUGIN_NAME);
-WEECHAT_PLUGIN_DESCRIPTION(N_("Spell checker for input (with Aspell)"));
+WEECHAT_PLUGIN_NAME(SPELL_PLUGIN_NAME);
+WEECHAT_PLUGIN_DESCRIPTION(N_("Spell checker for input"));
WEECHAT_PLUGIN_AUTHOR("Sébastien Helleu <flashcode@flashtux.org>");
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
WEECHAT_PLUGIN_PRIORITY(11000);
-struct t_weechat_plugin *weechat_aspell_plugin = NULL;
+struct t_weechat_plugin *weechat_spell_plugin = NULL;
-int aspell_enabled = 0;
+int spell_enabled = 0;
-char *aspell_nick_completer = NULL;
-int aspell_len_nick_completer = 0;
+char *spell_nick_completer = NULL;
+int spell_len_nick_completer = 0;
#ifdef USE_ENCHANT
EnchantBroker *broker = NULL;
@@ -64,7 +64,7 @@ EnchantBroker *broker = NULL;
* URL: ftp://ftp.gnu.org/gnu/aspell/dict/0index.html
*/
-struct t_aspell_code aspell_langs[] =
+struct t_spell_code spell_langs[] =
{
{ "af", "Afrikaans" },
{ "am", "Amharic" },
@@ -160,7 +160,7 @@ struct t_aspell_code aspell_langs[] =
{ NULL, NULL}
};
-struct t_aspell_code aspell_countries[] =
+struct t_spell_code spell_countries[] =
{
{ "AT", "Austria" },
{ "BR", "Brazil" },
@@ -175,7 +175,7 @@ struct t_aspell_code aspell_countries[] =
{ NULL, NULL}
};
-char *aspell_url_prefix[] =
+char *spell_url_prefix[] =
{ "http:", "https:", "ftp:", "tftp:", "ftps:", "ssh:", "fish:", "dict:",
"ldap:", "file:", "telnet:", "gopher:", "irc:", "ircs:", "irc6:", "irc6s:",
"cvs:", "svn:", "svn+ssh:", "git:", NULL };
@@ -188,7 +188,7 @@ char *aspell_url_prefix[] =
*/
char *
-weechat_aspell_build_option_name (struct t_gui_buffer *buffer)
+spell_build_option_name (struct t_gui_buffer *buffer)
{
const char *plugin_name, *name;
char *option_name;
@@ -218,7 +218,7 @@ weechat_aspell_build_option_name (struct t_gui_buffer *buffer)
*/
const char *
-weechat_aspell_get_dict_with_buffer_name (const char *name)
+spell_get_dict_with_buffer_name (const char *name)
{
char *option_name, *ptr_end;
struct t_config_option *ptr_option;
@@ -232,7 +232,7 @@ weechat_aspell_get_dict_with_buffer_name (const char *name)
ptr_end = option_name + strlen (option_name);
while (ptr_end >= option_name)
{
- ptr_option = weechat_aspell_config_get_dict (option_name);
+ ptr_option = spell_config_get_dict (option_name);
if (ptr_option)
{
free (option_name);
@@ -246,7 +246,7 @@ weechat_aspell_get_dict_with_buffer_name (const char *name)
if ((ptr_end >= option_name) && (ptr_end[0] == '.'))
ptr_end[0] = '\0';
}
- ptr_option = weechat_aspell_config_get_dict (option_name);
+ ptr_option = spell_config_get_dict (option_name);
free (option_name);
@@ -255,10 +255,10 @@ weechat_aspell_get_dict_with_buffer_name (const char *name)
}
/* nothing found => return default dictionary (if set) */
- if (weechat_config_string (weechat_aspell_config_check_default_dict)
- && weechat_config_string (weechat_aspell_config_check_default_dict)[0])
+ if (weechat_config_string (spell_config_check_default_dict)
+ && weechat_config_string (spell_config_check_default_dict)[0])
{
- return weechat_config_string (weechat_aspell_config_check_default_dict);
+ return weechat_config_string (spell_config_check_default_dict);
}
/* no default dictionary set */
@@ -273,16 +273,16 @@ weechat_aspell_get_dict_with_buffer_name (const char *name)
*/
const char *
-weechat_aspell_get_dict (struct t_gui_buffer *buffer)
+spell_get_dict (struct t_gui_buffer *buffer)
{
char *name;
const char *dict;
- name = weechat_aspell_build_option_name (buffer);
+ name = spell_build_option_name (buffer);
if (!name)
return NULL;
- dict = weechat_aspell_get_dict_with_buffer_name (name);
+ dict = spell_get_dict_with_buffer_name (name);
free (name);
@@ -298,7 +298,7 @@ weechat_aspell_get_dict (struct t_gui_buffer *buffer)
*/
int
-weechat_aspell_command_authorized (const char *command)
+spell_command_authorized (const char *command)
{
int length_command, i;
@@ -307,11 +307,11 @@ weechat_aspell_command_authorized (const char *command)
length_command = strlen (command);
- for (i = 0; i < weechat_aspell_count_commands_to_check; i++)
+ for (i = 0; i < spell_count_commands_to_check; i++)
{
- if ((weechat_aspell_length_commands_to_check[i] == length_command)
+ if ((spell_length_commands_to_check[i] == length_command)
&& (weechat_strcasecmp (command,
- weechat_aspell_commands_to_check[i]) == 0))
+ spell_commands_to_check[i]) == 0))
{
/* command is authorized */
return 1;
@@ -331,14 +331,14 @@ weechat_aspell_command_authorized (const char *command)
*/
int
-weechat_aspell_string_is_url (const char *word)
+spell_string_is_url (const char *word)
{
int i;
- for (i = 0; aspell_url_prefix[i]; i++)
+ for (i = 0; spell_url_prefix[i]; i++)
{
- if (weechat_strncasecmp (word, aspell_url_prefix[i],
- strlen (aspell_url_prefix[i])) == 0)
+ if (weechat_strncasecmp (word, spell_url_prefix[i],
+ strlen (spell_url_prefix[i])) == 0)
return 1;
}
@@ -355,21 +355,21 @@ weechat_aspell_string_is_url (const char *word)
*/
int
-weechat_aspell_string_is_nick (struct t_gui_buffer *buffer, const char *word)
+spell_string_is_nick (struct t_gui_buffer *buffer, const char *word)
{
char *pos, *pos_nick_completer, *pos_space, saved_char;
const char *buffer_type, *buffer_nick, *buffer_channel;
int rc;
- pos_nick_completer = (aspell_nick_completer) ?
- strstr (word, aspell_nick_completer) : NULL;
+ pos_nick_completer = (spell_nick_completer) ?
+ strstr (word, spell_nick_completer) : NULL;
pos_space = strchr (word, ' ');
pos = NULL;
if (pos_nick_completer && pos_space)
{
if ((pos_nick_completer < pos_space)
- && (pos_nick_completer + aspell_len_nick_completer == pos_space))
+ && (pos_nick_completer + spell_len_nick_completer == pos_space))
{
pos = pos_nick_completer;
}
@@ -378,7 +378,8 @@ weechat_aspell_string_is_nick (struct t_gui_buffer *buffer, const char *word)
}
else
{
- pos = (pos_nick_completer && !pos_nick_completer[aspell_len_nick_completer]) ?
+ pos = (pos_nick_completer
+ && !pos_nick_completer[spell_len_nick_completer]) ?
pos_nick_completer : pos_space;
}
@@ -431,7 +432,7 @@ weechat_aspell_string_is_nick (struct t_gui_buffer *buffer, const char *word)
*/
int
-weechat_aspell_string_is_simili_number (const char *word)
+spell_string_is_simili_number (const char *word)
{
int code_point;
@@ -459,18 +460,18 @@ weechat_aspell_string_is_simili_number (const char *word)
*/
int
-weechat_aspell_check_word (struct t_aspell_speller_buffer *speller_buffer,
- const char *word)
+spell_check_word (struct t_spell_speller_buffer *speller_buffer,
+ const char *word)
{
int i;
/* word too small? then do not check word */
- if ((weechat_config_integer (weechat_aspell_config_check_word_min_length) > 0)
- && ((int)strlen (word) < weechat_config_integer (weechat_aspell_config_check_word_min_length)))
+ if ((weechat_config_integer (spell_config_check_word_min_length) > 0)
+ && ((int)strlen (word) < weechat_config_integer (spell_config_check_word_min_length)))
return 1;
/* word is a number? then do not check word */
- if (weechat_aspell_string_is_simili_number (word))
+ if (spell_string_is_simili_number (word))
return 1;
/* check word with all spellers (order is important) */
@@ -500,8 +501,8 @@ weechat_aspell_check_word (struct t_aspell_speller_buffer *speller_buffer,
*/
char *
-weechat_aspell_get_suggestions (struct t_aspell_speller_buffer *speller_buffer,
- const char *word)
+spell_get_suggestions (struct t_spell_speller_buffer *speller_buffer,
+ const char *word)
{
int i, size, max_suggestions, num_suggestions;
char *suggestions, *suggestions2;
@@ -514,7 +515,7 @@ weechat_aspell_get_suggestions (struct t_aspell_speller_buffer *speller_buffer,
AspellStringEnumeration *elements;
#endif /* USE_ENCHANT */
- max_suggestions = weechat_config_integer (weechat_aspell_config_check_suggestions);
+ max_suggestions = weechat_config_integer (spell_config_check_suggestions);
if (max_suggestions < 0)
return NULL;
@@ -603,13 +604,13 @@ weechat_aspell_get_suggestions (struct t_aspell_speller_buffer *speller_buffer,
*/
char *
-weechat_aspell_modifier_cb (const void *pointer, void *data,
- const char *modifier,
- const char *modifier_data, const char *string)
+spell_modifier_cb (const void *pointer, void *data,
+ const char *modifier,
+ const char *modifier_data, const char *string)
{
unsigned long value;
struct t_gui_buffer *buffer;
- struct t_aspell_speller_buffer *ptr_speller_buffer;
+ struct t_spell_speller_buffer *ptr_speller_buffer;
char *result, *ptr_string, *ptr_string_orig, *pos_space;
char *ptr_end, *ptr_end_valid, save_end;
char *misspelled_word, *old_misspelled_word, *old_suggestions, *suggestions;
@@ -625,7 +626,7 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
(void) data;
(void) modifier;
- if (!aspell_enabled)
+ if (!spell_enabled)
return NULL;
if (!string)
@@ -639,15 +640,15 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
/* check text during search only if option is enabled */
if (weechat_buffer_get_integer (buffer, "text_search")
- && !weechat_config_boolean (weechat_aspell_config_check_during_search))
+ && !weechat_config_boolean (spell_config_check_during_search))
return NULL;
/* get structure with speller info for buffer */
- ptr_speller_buffer = weechat_hashtable_get (weechat_aspell_speller_buffer,
+ ptr_speller_buffer = weechat_hashtable_get (spell_speller_buffer,
buffer);
if (!ptr_speller_buffer)
{
- ptr_speller_buffer = weechat_aspell_speller_buffer_new (buffer);
+ ptr_speller_buffer = spell_speller_buffer_new (buffer);
if (!ptr_speller_buffer)
return NULL;
}
@@ -661,7 +662,7 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
input_pos = weechat_buffer_get_integer (buffer, "input_pos");
if (ptr_speller_buffer->modifier_string
&& (strcmp (string, ptr_speller_buffer->modifier_string) == 0)
- && ((weechat_config_integer (weechat_aspell_config_check_suggestions) < 0)
+ && ((weechat_config_integer (spell_config_check_suggestions) < 0)
|| (input_pos == ptr_speller_buffer->input_pos)))
{
return (ptr_speller_buffer->modifier_result) ?
@@ -688,7 +689,7 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
color_normal = weechat_color ("bar_fg");
length_color_normal = strlen (color_normal);
- color_error = weechat_color (weechat_config_string (weechat_aspell_config_color_misspelled));
+ color_error = weechat_color (weechat_config_string (spell_config_color_misspelled));
length_color_error = strlen (color_error);
length = strlen (string);
@@ -720,7 +721,7 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
pos_space[0] = '\0';
/* exit if command is not authorized for spell checking */
- if (!weechat_aspell_command_authorized (ptr_string))
+ if (!spell_command_authorized (ptr_string))
{
free (result);
return NULL;
@@ -787,8 +788,8 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
ptr_end = (char *)weechat_utf8_next_char (ptr_end_valid);
word_end_pos = word_end_pos_valid;
word_ok = 0;
- if (weechat_aspell_string_is_url (ptr_string)
- || weechat_aspell_string_is_nick (buffer, ptr_string_orig))
+ if (spell_string_is_url (ptr_string)
+ || spell_string_is_nick (buffer, ptr_string_orig))
{
/*
* word is an URL or a nick, then it is OK: search for next
@@ -814,10 +815,10 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
if (!word_ok)
{
if ((save_end != '\0')
- || (weechat_config_integer (weechat_aspell_config_check_real_time)))
+ || (weechat_config_integer (spell_config_check_real_time)))
{
- word_ok = weechat_aspell_check_word (ptr_speller_buffer,
- ptr_string);
+ word_ok = spell_check_word (ptr_speller_buffer,
+ ptr_string);
if (!word_ok && (input_pos >= word_start_pos))
{
/*
@@ -864,7 +865,7 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
/* save old suggestions in buffer */
ptr_suggestions = weechat_buffer_get_string (buffer,
- "localvar_aspell_suggest");
+ "localvar_spell_suggest");
old_suggestions = (ptr_suggestions) ? strdup (ptr_suggestions) : NULL;
/* if there is a misspelled word, get suggestions and set them in buffer */
@@ -872,7 +873,7 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
{
/*
* get the old misspelled word; we'll get suggestions or clear
- * local variable "aspell_suggest" only if the current misspelled
+ * local variable "spell_suggest" only if the current misspelled
* word is different
*/
old_misspelled_word = NULL;
@@ -887,8 +888,8 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
if (!old_misspelled_word
|| (strcmp (old_misspelled_word, misspelled_word) != 0))
{
- suggestions = weechat_aspell_get_suggestions (ptr_speller_buffer,
- misspelled_word);
+ suggestions = spell_get_suggestions (ptr_speller_buffer,
+ misspelled_word);
if (suggestions)
{
length = strlen (misspelled_word) + 1 /* ":" */
@@ -898,21 +899,21 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
{
snprintf (word_and_suggestions, length, "%s:%s",
misspelled_word, suggestions);
- weechat_buffer_set (buffer, "localvar_set_aspell_suggest",
+ weechat_buffer_set (buffer, "localvar_set_spell_suggest",
word_and_suggestions);
free (word_and_suggestions);
}
else
{
weechat_buffer_set (buffer,
- "localvar_del_aspell_suggest", "");
+ "localvar_del_spell_suggest", "");
}
free (suggestions);
}
else
{
/* set a misspelled word in buffer, also without suggestions */
- weechat_buffer_set (buffer, "localvar_set_aspell_suggest",
+ weechat_buffer_set (buffer, "localvar_set_spell_suggest",
misspelled_word);
}
}
@@ -924,22 +925,22 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
}
else
{
- weechat_buffer_set (buffer, "localvar_del_aspell_suggest", "");
+ weechat_buffer_set (buffer, "localvar_del_spell_suggest", "");
}
/*
* if suggestions have changed, update the bar item
- * and send signal "aspell_suggest"
+ * and send signal "spell_suggest"
*/
ptr_suggestions = weechat_buffer_get_string (buffer,
- "localvar_aspell_suggest");
+ "localvar_spell_suggest");
if ((old_suggestions && !ptr_suggestions)
|| (!old_suggestions && ptr_suggestions)
|| (old_suggestions && ptr_suggestions
&& (strcmp (old_suggestions, ptr_suggestions) != 0)))
{
- weechat_bar_item_update ("aspell_suggest");
- (void) weechat_hook_signal_send ("aspell_suggest",
+ weechat_bar_item_update ("spell_suggest");
+ (void) weechat_hook_signal_send ("spell_suggest",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
if (old_suggestions)
@@ -958,9 +959,8 @@ weechat_aspell_modifier_cb (const void *pointer, void *data,
*/
int
-weechat_aspell_buffer_switch_cb (const void *pointer, void *data,
- const char *signal, const char *type_data,
- void *signal_data)
+spell_buffer_switch_cb (const void *pointer, void *data, const char *signal,
+ const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) pointer;
@@ -970,8 +970,8 @@ weechat_aspell_buffer_switch_cb (const void *pointer, void *data,
(void) signal_data;
/* refresh bar items (for root bars) */
- weechat_bar_item_update ("aspell_dict");
- weechat_bar_item_update ("aspell_suggest");
+ weechat_bar_item_update ("spell_dict");
+ weechat_bar_item_update ("spell_suggest");
return WEECHAT_RC_OK;
}
@@ -981,9 +981,8 @@ weechat_aspell_buffer_switch_cb (const void *pointer, void *data,
*/
int
-weechat_aspell_window_switch_cb (const void *pointer, void *data,
- const char *signal,
- const char *type_data, void *signal_data)
+spell_window_switch_cb (const void *pointer, void *data, const char *signal,
+ const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) pointer;
@@ -993,21 +992,20 @@ weechat_aspell_window_switch_cb (const void *pointer, void *data,
(void) signal_data;
/* refresh bar items (for root bars) */
- weechat_bar_item_update ("aspell_dict");
- weechat_bar_item_update ("aspell_suggest");
+ weechat_bar_item_update ("spell_dict");
+ weechat_bar_item_update ("spell_suggest");
return WEECHAT_RC_OK;
}
/*
- * Removes struct for buffer in hashtable "weechat_aspell_speller_buffer" on
+ * Removes struct for buffer in hashtable "spell_speller_buffer" on
* signal "buffer_closed".
*/
int
-weechat_aspell_buffer_closed_cb (const void *pointer, void *data,
- const char *signal,
- const char *type_data, void *signal_data)
+spell_buffer_closed_cb (const void *pointer, void *data, const char *signal,
+ const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) pointer;
@@ -1015,7 +1013,7 @@ weechat_aspell_buffer_closed_cb (const void *pointer, void *data,
(void) signal;
(void) type_data;
- weechat_hashtable_remove (weechat_aspell_speller_buffer, signal_data);
+ weechat_hashtable_remove (spell_speller_buffer, signal_data);
return WEECHAT_RC_OK;
}
@@ -1025,9 +1023,8 @@ weechat_aspell_buffer_closed_cb (const void *pointer, void *data,
*/
int
-weechat_aspell_debug_libs_cb (const void *pointer, void *data,
- const char *signal,
- const char *type_data, void *signal_data)
+spell_debug_libs_cb (const void *pointer, void *data, const char *signal,
+ const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) pointer;
@@ -1039,16 +1036,16 @@ weechat_aspell_debug_libs_cb (const void *pointer, void *data,
#ifdef USE_ENCHANT
#ifdef HAVE_ENCHANT_GET_VERSION
weechat_printf (NULL, " %s: enchant %s",
- ASPELL_PLUGIN_NAME, enchant_get_version ());
+ SPELL_PLUGIN_NAME, enchant_get_version ());
#else
- weechat_printf (NULL, " %s: enchant (?)", ASPELL_PLUGIN_NAME);
+ weechat_printf (NULL, " %s: enchant (?)", SPELL_PLUGIN_NAME);
#endif /* HAVE_ENCHANT_GET_VERSION */
#else
#ifdef HAVE_ASPELL_VERSION_STRING
weechat_printf (NULL, " %s: aspell %s",
- ASPELL_PLUGIN_NAME, aspell_version_string ());
+ SPELL_PLUGIN_NAME, aspell_version_string ());
#else
- weechat_printf (NULL, " %s: aspell (?)", ASPELL_PLUGIN_NAME);
+ weechat_printf (NULL, " %s: aspell (?)", SPELL_PLUGIN_NAME);
#endif /* HAVE_ASPELL_VERSION_STRING */
#endif /* USE_ENCHANT */
@@ -1060,27 +1057,26 @@ weechat_aspell_debug_libs_cb (const void *pointer, void *data,
*/
int
-weechat_aspell_config_change_nick_completer_cb (const void *pointer, void *data,
- const char *option,
- const char *value)
+spell_config_change_nick_completer_cb (const void *pointer, void *data,
+ const char *option, const char *value)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) option;
- if (aspell_nick_completer)
- free (aspell_nick_completer);
+ if (spell_nick_completer)
+ free (spell_nick_completer);
- aspell_nick_completer = weechat_string_strip (value, 0, 1, " ");
- aspell_len_nick_completer =
- (aspell_nick_completer) ? strlen (aspell_nick_completer) : 0;
+ spell_nick_completer = weechat_string_strip (value, 0, 1, " ");
+ spell_len_nick_completer =
+ (spell_nick_completer) ? strlen (spell_nick_completer) : 0;
return WEECHAT_RC_OK;
}
/*
- * Initializes aspell plugin.
+ * Initializes spell plugin.
*/
int
@@ -1099,17 +1095,17 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
return WEECHAT_RC_ERROR;
#endif /* USE_ENCHANT */
- if (!weechat_aspell_speller_init ())
+ if (!spell_speller_init ())
return WEECHAT_RC_ERROR;
- if (!weechat_aspell_config_init ())
+ if (!spell_config_init ())
return WEECHAT_RC_ERROR;
- weechat_aspell_config_read ();
+ spell_config_read ();
- weechat_aspell_command_init ();
+ spell_command_init ();
- weechat_aspell_completion_init ();
+ spell_completion_init ();
/*
* callback for spell checking input text
@@ -1117,26 +1113,26 @@ 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, NULL);
+ &spell_modifier_cb, NULL, NULL);
- weechat_aspell_bar_item_init ();
+ spell_bar_item_init ();
- weechat_aspell_info_init ();
+ spell_info_init ();
weechat_hook_signal ("buffer_switch",
- &weechat_aspell_buffer_switch_cb, NULL, NULL);
+ &spell_buffer_switch_cb, NULL, NULL);
weechat_hook_signal ("window_switch",
- &weechat_aspell_window_switch_cb, NULL, NULL);
+ &spell_window_switch_cb, NULL, NULL);
weechat_hook_signal ("buffer_closed",
- &weechat_aspell_buffer_closed_cb, NULL, NULL);
+ &spell_buffer_closed_cb, NULL, NULL);
weechat_hook_signal ("debug_libs",
- &weechat_aspell_debug_libs_cb, NULL, NULL);
+ &spell_debug_libs_cb, NULL, NULL);
weechat_hook_config ("weechat.completion.nick_completer",
- &weechat_aspell_config_change_nick_completer_cb,
+ &spell_config_change_nick_completer_cb,
NULL, NULL);
/* manually call callback to initialize */
- weechat_aspell_config_change_nick_completer_cb (
+ spell_config_change_nick_completer_cb (
NULL, NULL, "weechat.completion.nick_completer",
weechat_config_string (
weechat_config_get ("weechat.completion.nick_completer")));
@@ -1145,7 +1141,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
}
/*
- * Ends aspell plugin.
+ * Ends spell plugin.
*/
int
@@ -1154,18 +1150,18 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
/* make C compiler happy */
(void) plugin;
- weechat_aspell_config_write ();
- weechat_aspell_config_free ();
+ spell_config_write ();
+ spell_config_free ();
- weechat_aspell_speller_end ();
+ spell_speller_end ();
#ifdef USE_ENCHANT
/* release enchant broker */
enchant_broker_free (broker);
#endif /* USE_ENCHANT */
- if (aspell_nick_completer)
- free (aspell_nick_completer);
+ if (spell_nick_completer)
+ free (spell_nick_completer);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/aspell/weechat-aspell.h b/src/plugins/spell/spell.h
index e209c0168..8625ea7db 100644
--- a/src/plugins/aspell/weechat-aspell.h
+++ b/src/plugins/spell/spell.h
@@ -18,8 +18,8 @@
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_ASPELL_H
-#define WEECHAT_PLUGIN_ASPELL_H
+#ifndef WEECHAT_PLUGIN_SPELL_H
+#define WEECHAT_PLUGIN_SPELL_H
#ifdef USE_ENCHANT
#include <enchant.h>
@@ -27,10 +27,10 @@
#include <aspell.h>
#endif /* USE_ENCHANT */
-#define weechat_plugin weechat_aspell_plugin
-#define ASPELL_PLUGIN_NAME "aspell"
+#define weechat_plugin weechat_spell_plugin
+#define SPELL_PLUGIN_NAME "spell"
-struct t_aspell_code
+struct t_spell_code
{
char *code;
char *name;
@@ -40,13 +40,13 @@ struct t_aspell_code
extern EnchantBroker *broker;
#endif /* USE_ENCHANT */
-extern struct t_weechat_plugin *weechat_aspell_plugin;
-extern int aspell_enabled;
-extern struct t_aspell_code aspell_langs[];
-extern struct t_aspell_code aspell_countries[];
+extern struct t_weechat_plugin *weechat_spell_plugin;
+extern int spell_enabled;
+extern struct t_spell_code spell_langs[];
+extern struct t_spell_code spell_countries[];
-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);
+extern char *spell_build_option_name (struct t_gui_buffer *buffer);
+extern const char *spell_get_dict_with_buffer_name (const char *name);
+extern const char *spell_get_dict (struct t_gui_buffer *buffer);
-#endif /* WEECHAT_PLUGIN_ASPELL_H */
+#endif /* WEECHAT_PLUGIN_SPELL_H */