mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
Aspell plugin is born again
This commit is contained in:
@@ -31,13 +31,13 @@ IF(NOT DISABLE_ALIAS)
|
||||
ADD_SUBDIRECTORY( alias )
|
||||
ENDIF(NOT DISABLE_ALIAS)
|
||||
|
||||
IF(ENABLE_ASPELL)
|
||||
IF(NOT DISABLE_ASPELL)
|
||||
# Check for aspell libraries
|
||||
FIND_PACKAGE(Aspell)
|
||||
IF(ASPELL_FOUND)
|
||||
ADD_SUBDIRECTORY( aspell )
|
||||
ENDIF(ASPELL_FOUND)
|
||||
ENDIF(ENABLE_ASPELL)
|
||||
ENDIF(NOT DISABLE_ASPELL)
|
||||
|
||||
IF(NOT DISABLE_CHARSET)
|
||||
# Check for iconv support.
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
ADD_LIBRARY(aspell MODULE aspell.c aspell.h)
|
||||
ADD_LIBRARY(aspell MODULE
|
||||
aspell.c aspell.h
|
||||
aspell-config.c aspell-config.h
|
||||
aspell-speller.c aspell-speller.h)
|
||||
SET_TARGET_PROPERTIES(aspell PROPERTIES PREFIX "")
|
||||
|
||||
IF(ASPELL_FOUND)
|
||||
|
||||
@@ -20,6 +20,11 @@ libdir = ${weechat_libdir}/plugins
|
||||
|
||||
lib_LTLIBRARIES = aspell.la
|
||||
|
||||
aspell_la_SOURCES = aspell.c aspell.h
|
||||
aspell_la_SOURCES = aspell.c \
|
||||
aspell.h \
|
||||
aspell-config.c \
|
||||
aspell-config.h \
|
||||
aspell-speller.c \
|
||||
aspell-speller.h
|
||||
aspell_la_LDFLAGS = -module
|
||||
aspell_la_LIBADD = $(ASPELL_LFLAGS)
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* aspell-config.c: aspell configuration options */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "aspell.h"
|
||||
#include "aspell-config.h"
|
||||
#include "aspell-speller.h"
|
||||
|
||||
|
||||
struct t_config_file *weechat_aspell_config_file = NULL;
|
||||
struct t_config_section *weechat_aspell_config_section_dict = NULL;
|
||||
|
||||
/* aspell config, look section */
|
||||
|
||||
struct t_config_option *weechat_aspell_config_look_color;
|
||||
|
||||
/* 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_real_time;
|
||||
struct t_config_option *weechat_aspell_config_check_word_min_length;
|
||||
|
||||
|
||||
char **weechat_aspell_commands_to_check = NULL;
|
||||
int weechat_aspell_count_commands_to_check = 0;
|
||||
int *weechat_aspell_length_commands_to_check = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_change_commands: called when list of commands is
|
||||
* changed
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_aspell_config_change_commands (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
char *value;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (weechat_aspell_commands_to_check)
|
||||
{
|
||||
weechat_string_free_exploded (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_explode (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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_change_default_dict: called when default dictionary
|
||||
* is changed
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_aspell_config_change_default_dict (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
weechat_aspell_create_spellers (weechat_current_buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_create_option: set a dictionary for a buffer
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_config_create_option (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) 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, 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",
|
||||
_("comma separated list of dictionaries to use on this buffer"),
|
||||
NULL, 0, 0, value, NULL, 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_aspell_create_spellers (weechat_current_buffer);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_get_dict: get a dictionary list 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);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_set_dict: set a dictionary list for a buffer
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_config_set_dict (const char *name, const char *value)
|
||||
{
|
||||
return weechat_aspell_config_create_option (NULL,
|
||||
weechat_aspell_config_file,
|
||||
weechat_aspell_config_section_dict,
|
||||
name,
|
||||
value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_init: init aspell configuration file
|
||||
* return: 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
|
||||
NULL, NULL);
|
||||
if (!weechat_aspell_config_file)
|
||||
return 0;
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "look",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_aspell_config_look_color = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"color", "color",
|
||||
N_("color used for mispelled words"),
|
||||
NULL, 0, 0, "lightred", 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);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
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, NULL, &weechat_aspell_config_change_commands, 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 explicitely enabled it)"),
|
||||
NULL, 0, 0, "",
|
||||
NULL, NULL, &weechat_aspell_config_change_default_dict, 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, 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, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict",
|
||||
1, 1,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
NULL, NULL,
|
||||
&weechat_aspell_config_create_option, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_aspell_config_section_dict = ptr_section;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_read: read aspell configuration file
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_config_read ()
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = weechat_config_read (weechat_aspell_config_file);
|
||||
if (rc == WEECHAT_CONFIG_READ_OK)
|
||||
{
|
||||
weechat_aspell_config_change_commands (NULL,
|
||||
weechat_aspell_config_check_commands);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_config_write: write aspell configuration file
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_config_write ()
|
||||
{
|
||||
return weechat_config_write (weechat_aspell_config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* aspell_config_free: free aspell configuration
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_aspell_config_free ()
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
|
||||
if (weechat_aspell_commands_to_check)
|
||||
weechat_string_free_exploded (weechat_aspell_commands_to_check);
|
||||
if (weechat_aspell_length_commands_to_check)
|
||||
free (weechat_aspell_length_commands_to_check);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_ASPELL_CONFIG_H
|
||||
#define __WEECHAT_ASPELL_CONFIG_H 1
|
||||
|
||||
#define ASPELL_CONFIG_NAME "aspell"
|
||||
|
||||
|
||||
extern struct t_config_option *weechat_aspell_config_look_color;
|
||||
|
||||
extern struct t_config_option *weechat_aspell_config_check_default_dict;
|
||||
extern struct t_config_option *weechat_aspell_config_check_real_time;
|
||||
extern struct t_config_option *weechat_aspell_config_check_word_min_length;
|
||||
|
||||
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 /* aspell-config.h */
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* aspell-speller.c: speller management for aspell plugin */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "aspell.h"
|
||||
#include "aspell-speller.h"
|
||||
|
||||
|
||||
struct t_aspell_speller *weechat_aspell_spellers = NULL;
|
||||
struct t_aspell_speller *last_weechat_aspell_speller = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* weechat_aspell_speller_exists: return 1 if an aspell dict exists for a lang,
|
||||
* 0 otherwise
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_aspell_speller_exists (const char *lang)
|
||||
{
|
||||
struct AspellConfig *config;
|
||||
AspellDictInfoList *list;
|
||||
AspellDictInfoEnumeration *el;
|
||||
const AspellDictInfo *dict;
|
||||
int rc;
|
||||
|
||||
rc = 0;
|
||||
|
||||
config = new_aspell_config ();
|
||||
list = get_aspell_dict_info_list (config);
|
||||
el = aspell_dict_info_list_elements (list);
|
||||
|
||||
while ((dict = aspell_dict_info_enumeration_next (el)))
|
||||
{
|
||||
if (strcmp (dict->name, lang) == 0)
|
||||
{
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete_aspell_dict_info_enumeration (el);
|
||||
delete_aspell_config (config);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_speller_check_dictionaries: check dictionaries (called when
|
||||
* user creates/changes dictionaries
|
||||
* for a buffer)
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_aspell_speller_check_dictionaries (const char *dict_list)
|
||||
{
|
||||
char **argv;
|
||||
int argc, i;
|
||||
|
||||
if (dict_list)
|
||||
{
|
||||
argv = weechat_string_explode (dict_list, ",", 0, 0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
if (!weechat_aspell_speller_exists (argv[i]))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s: warning: dictionary \"%s\" is not "
|
||||
"available on your system"),
|
||||
ASPELL_PLUGIN_NAME, argv[i]);
|
||||
}
|
||||
}
|
||||
weechat_string_free_exploded (argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_speller_search: search a speller
|
||||
*/
|
||||
|
||||
struct t_aspell_speller *
|
||||
weechat_aspell_speller_search (const char *lang)
|
||||
{
|
||||
struct t_aspell_speller *ptr_speller;
|
||||
|
||||
for (ptr_speller = weechat_aspell_spellers; ptr_speller;
|
||||
ptr_speller = ptr_speller->next_speller)
|
||||
{
|
||||
if (strcmp (ptr_speller->lang, lang) == 0)
|
||||
return ptr_speller;
|
||||
}
|
||||
|
||||
/* no speller found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_speller_new: create and add a new speller instance
|
||||
*/
|
||||
|
||||
struct t_aspell_speller *
|
||||
weechat_aspell_speller_new (const char *lang)
|
||||
{
|
||||
struct t_aspell_speller *new_speller;
|
||||
AspellConfig *config;
|
||||
AspellCanHaveError *ret;
|
||||
|
||||
if (!lang)
|
||||
return NULL;
|
||||
|
||||
if (aspell_debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: creating new speller for lang \"%s\"",
|
||||
ASPELL_PLUGIN_NAME, lang);
|
||||
}
|
||||
|
||||
/* create a speller instance for the newly created cell */
|
||||
config = new_aspell_config();
|
||||
aspell_config_replace (config, "lang", lang);
|
||||
|
||||
ret = new_aspell_speller (config);
|
||||
|
||||
if (aspell_error (ret) != 0)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s%s: error: %s",
|
||||
weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
|
||||
aspell_error_message (ret));
|
||||
delete_aspell_config (config);
|
||||
delete_aspell_can_have_error (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create and add a new speller cell */
|
||||
new_speller = malloc (sizeof (*new_speller));
|
||||
if (!new_speller)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: not enough memory to create new speller"),
|
||||
weechat_prefix ("error"), ASPELL_PLUGIN_NAME);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_speller->speller = to_aspell_speller (ret);
|
||||
new_speller->lang = strdup (lang);
|
||||
|
||||
/* add speller to list */
|
||||
new_speller->prev_speller = last_weechat_aspell_speller;
|
||||
new_speller->next_speller = NULL;
|
||||
if (weechat_aspell_spellers)
|
||||
last_weechat_aspell_speller->next_speller = new_speller;
|
||||
else
|
||||
weechat_aspell_spellers = new_speller;
|
||||
last_weechat_aspell_speller = new_speller;
|
||||
|
||||
/* free config */
|
||||
delete_aspell_config (config);
|
||||
|
||||
return new_speller;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_speller_free: remove a speller instance
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_aspell_speller_free (struct t_aspell_speller *speller)
|
||||
{
|
||||
if (!speller)
|
||||
return;
|
||||
|
||||
if (aspell_debug)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"%s: removing speller for lang \"%s\"",
|
||||
ASPELL_PLUGIN_NAME, speller->lang);
|
||||
}
|
||||
|
||||
/* free data */
|
||||
if (speller->speller)
|
||||
{
|
||||
aspell_speller_save_all_word_lists (speller->speller);
|
||||
delete_aspell_speller (speller->speller);
|
||||
}
|
||||
if (speller->lang)
|
||||
free (speller->lang);
|
||||
|
||||
/* remove speller from list */
|
||||
if (speller->prev_speller)
|
||||
(speller->prev_speller)->next_speller = speller->next_speller;
|
||||
if (speller->next_speller)
|
||||
(speller->next_speller)->prev_speller = speller->prev_speller;
|
||||
if (weechat_aspell_spellers == speller)
|
||||
weechat_aspell_spellers = speller->next_speller;
|
||||
if (last_weechat_aspell_speller == speller)
|
||||
last_weechat_aspell_speller = speller->prev_speller;
|
||||
|
||||
free (speller);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_aspell_speller_free_all: free all spellers
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_aspell_speller_free_all ()
|
||||
{
|
||||
while (weechat_aspell_spellers)
|
||||
{
|
||||
weechat_aspell_speller_free (weechat_aspell_spellers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_ASPELL_SPELLER_H
|
||||
#define __WEECHAT_ASPELL_SPELLER_H 1
|
||||
|
||||
struct t_aspell_speller
|
||||
{
|
||||
AspellSpeller *speller; /* aspell speller */
|
||||
char *lang; /* language */
|
||||
|
||||
struct t_aspell_speller *prev_speller; /* pointer to next speller */
|
||||
struct t_aspell_speller *next_speller; /* pointer to previous speller */
|
||||
};
|
||||
|
||||
extern struct t_aspell_speller *weechat_aspell_spellers;
|
||||
|
||||
extern int weechat_aspell_speller_exists (const char *lang);
|
||||
extern struct t_aspell_speller *weechat_aspell_speller_search (const char *lang);
|
||||
extern void weechat_aspell_speller_check_dictionaries (const char *dict_list);
|
||||
extern struct t_aspell_speller *weechat_aspell_speller_new (const char *lang);
|
||||
extern void weechat_aspell_speller_free (struct t_aspell_speller *speller);
|
||||
extern void weechat_aspell_speller_free_all ();
|
||||
|
||||
#endif /* aspell-speller.h */
|
||||
+832
-1256
File diff suppressed because it is too large
Load Diff
+10
-162
@@ -16,180 +16,28 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* weechat-aspell.h: Aspell plugin support for WeeChat */
|
||||
|
||||
#ifndef __WEECHAT_ASPELL_H
|
||||
#define __WEECHAT_ASPELL_H 1
|
||||
|
||||
#include <aspell.h>
|
||||
|
||||
#define _PLUGIN_OPTION_WORD_SIZE 2
|
||||
#define _PLUGIN_OPTION_CHECK_SYNC 0
|
||||
#define _PLUGIN_OPTION_COLOR "red"
|
||||
#define weechat_plugin weechat_aspell_plugin
|
||||
#define ASPELL_PLUGIN_NAME "aspell"
|
||||
|
||||
typedef struct aspell_speller_t
|
||||
{
|
||||
AspellSpeller *speller;
|
||||
char *lang;
|
||||
int refs;
|
||||
|
||||
struct aspell_speller_t *prev_speller;
|
||||
struct aspell_speller_t *next_speller;
|
||||
} aspell_speller_t;
|
||||
|
||||
typedef struct aspell_config_t
|
||||
{
|
||||
char *server;
|
||||
char *channel;
|
||||
aspell_speller_t *speller;
|
||||
|
||||
struct aspell_config_t *prev_config;
|
||||
struct aspell_config_t *next_config;
|
||||
} aspell_config_t;
|
||||
|
||||
typedef struct aspell_options_t
|
||||
{
|
||||
int word_size;
|
||||
int check_sync;
|
||||
int color;
|
||||
char *color_name;
|
||||
} aspell_options_t;
|
||||
|
||||
typedef struct iso_langs_t
|
||||
struct t_aspell_code
|
||||
{
|
||||
char *code;
|
||||
char *name;
|
||||
} iso_langs_t;
|
||||
|
||||
typedef struct iso_countries_t
|
||||
{
|
||||
char *code;
|
||||
char *name;
|
||||
} iso_countries_t;
|
||||
|
||||
typedef struct cmds_keep_t
|
||||
{
|
||||
char *cmd;
|
||||
int len;
|
||||
} cmds_keep_t;
|
||||
|
||||
/* aspell supported langs 2006-05-27 */
|
||||
iso_langs_t langs_avail[] =
|
||||
{
|
||||
{ "af", "Afrikaans"},
|
||||
{ "am", "Amharic"},
|
||||
{ "az", "Azerbaijani"},
|
||||
{ "be", "Belarusian"},
|
||||
{ "bg", "Bulgarian"},
|
||||
{ "bn", "Bengali"},
|
||||
{ "br", "Breton"},
|
||||
{ "ca", "Catalan"},
|
||||
{ "cs", "Czech"},
|
||||
{ "csb", "Kashubian"},
|
||||
{ "cy", "Welsh"},
|
||||
{ "da", "Danish"},
|
||||
{ "de", "German"},
|
||||
{ "el", "Greek Modern"},
|
||||
{ "en", "English"},
|
||||
{ "eo", "Esperanto"},
|
||||
{ "es", "Spanish"},
|
||||
{ "et", "Estonian"},
|
||||
{ "fa", "Persian"},
|
||||
{ "fi", "Finnish"},
|
||||
{ "fo", "Faroese"},
|
||||
{ "fr", "French"},
|
||||
{ "ga", "Irish"},
|
||||
{ "gd", "Gaelic"},
|
||||
{ "gl", "Galician"},
|
||||
{ "gu", "Gujarati"},
|
||||
{ "gv", "Manx"},
|
||||
{ "he", "Hebrew"},
|
||||
{ "hi", "Hiligaynon"},
|
||||
{ "hr", "Croatian"},
|
||||
{ "hsb", "Upper Sorbian"},
|
||||
{ "hu", "Hungarian"},
|
||||
{ "ia", "Interlingua"},
|
||||
{ "id", "Indonesian"},
|
||||
{ "is", "Icelandic"},
|
||||
{ "it", "Italian"},
|
||||
{ "ku", "Kurdish"},
|
||||
{ "la", "Latin"},
|
||||
{ "lt", "Lithuanian"},
|
||||
{ "lv", "Latvian"},
|
||||
{ "mg", "Malagasy"},
|
||||
{ "mi", "Maori"},
|
||||
{ "mk", "Macedonian"},
|
||||
{ "mn", "Mongolian"},
|
||||
{ "mr", "Marathi"},
|
||||
{ "ms", "Malay"},
|
||||
{ "mt", "Maltese"},
|
||||
{ "nb", "Norwegian Bokmal"},
|
||||
{ "nds", "Saxon Low"},
|
||||
{ "nl", "Flemish"},
|
||||
{ "nn", "Norwegian Nynorsk"},
|
||||
{ "no", "Norwegian"},
|
||||
{ "ny", "Nyanja"},
|
||||
{ "or", "Oriya"},
|
||||
{ "pa", "Panjabi"},
|
||||
{ "pl", "Polish"},
|
||||
{ "pt", "Portuguese"},
|
||||
{ "qu", "Quechua"},
|
||||
{ "ro", "Romanian"},
|
||||
{ "ru", "Russian"},
|
||||
{ "rw", "Kinyarwanda"},
|
||||
{ "sc", "Sardinian"},
|
||||
{ "sk", "Slovak"},
|
||||
{ "sl", "Slovenian"},
|
||||
{ "sr", "Serbian"},
|
||||
{ "sv", "Swedish"},
|
||||
{ "sw", "Swahili"},
|
||||
{ "ta", "Tamil"},
|
||||
{ "te", "Telugu"},
|
||||
{ "tet", "Tetum"},
|
||||
{ "tl", "Tagalog"},
|
||||
{ "tn", "Tswana"},
|
||||
{ "tr", "Turkish"},
|
||||
{ "uk", "Ukrainian"},
|
||||
{ "uz", "Uzbek"},
|
||||
{ "vi", "Vietnamese"},
|
||||
{ "wa", "Walloon"},
|
||||
{ "yi", "Yiddish"},
|
||||
{ "zu", "Zulu"},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
||||
iso_countries_t countries_avail[] =
|
||||
{
|
||||
{ "AT", "Austria" },
|
||||
{ "BR", "Brazil" },
|
||||
{ "CA", "Canada" },
|
||||
{ "CH", "Switzerland" },
|
||||
{ "DE", "Germany" },
|
||||
{ "FR", "France" },
|
||||
{ "GB", "Great Britain" },
|
||||
{ "PT", "Portugal" },
|
||||
{ "SK", "Slovakia" },
|
||||
{ "US", "United States of America" },
|
||||
{ NULL, NULL}
|
||||
};
|
||||
extern int aspell_debug;
|
||||
|
||||
/* internal or irc commands to be use with spellchecking */
|
||||
cmds_keep_t cmd_tokeep[] =
|
||||
{
|
||||
{ "/builtin ", 9 },
|
||||
{ "/ame " , 5 },
|
||||
{ "/amsg " , 6 },
|
||||
{ "/away " , 6 },
|
||||
{ "/cycle " , 7 },
|
||||
{ "/kick " , 6 },
|
||||
{ "/kickban " , 9 },
|
||||
{ "/me " , 4 },
|
||||
{ "/notice " , 8 },
|
||||
{ "/part " , 6 },
|
||||
{ "/query " , 7 },
|
||||
{ "/quit " , 6 },
|
||||
{ "/topic " , 7 },
|
||||
{ NULL, 0}
|
||||
};
|
||||
extern struct t_weechat_plugin *weechat_aspell_plugin;
|
||||
|
||||
extern struct t_aspell_code langs_avail[];
|
||||
extern struct t_aspell_code countries_avail[];
|
||||
|
||||
extern void weechat_aspell_create_spellers (struct t_gui_buffer *buffer);
|
||||
|
||||
#endif /* aspell.h */
|
||||
|
||||
@@ -354,7 +354,7 @@ charset_decode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"charset: debug: using 'decode' charset: %s "
|
||||
"(modifier='%s', modifier_data='%s', string='%s')",
|
||||
"(modifier=\"%s\", modifier_data=\"%s\", string=\"%s\")",
|
||||
charset, modifier, modifier_data, string);
|
||||
}
|
||||
if (charset && charset[0])
|
||||
@@ -383,7 +383,7 @@ charset_encode_cb (void *data, const char *modifier, const char *modifier_data,
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
"charset: debug: using 'encode' charset: %s "
|
||||
"(modifier='%s', modifier_data='%s', string='%s')",
|
||||
"(modifier=\"%s\", modifier_data=\"%s\", string=\"%s\")",
|
||||
charset, modifier, modifier_data, string);
|
||||
}
|
||||
if (charset && charset[0])
|
||||
@@ -407,11 +407,11 @@ charset_set (struct t_config_section *section, const char *type,
|
||||
value) > 0)
|
||||
{
|
||||
if (value && value[0])
|
||||
weechat_printf (NULL, _("Charset: %s, %s => %s"),
|
||||
type, name, value);
|
||||
weechat_printf (NULL, "%s: %s, %s => %s",
|
||||
CHARSET_PLUGIN_NAME, type, name, value);
|
||||
else
|
||||
weechat_printf (NULL, _("Charset: %s, %s: removed"),
|
||||
type, name);
|
||||
weechat_printf (NULL, _("%s: %s, %s: removed"),
|
||||
CHARSET_PLUGIN_NAME, type, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ demo_printf_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
|
||||
if (argc > 1)
|
||||
weechat_printf (buffer,
|
||||
"demo_printf: '%s'", argv_eol[1]);
|
||||
"demo_printf: \"%s\"", argv_eol[1]);
|
||||
else
|
||||
{
|
||||
weechat_printf (buffer,
|
||||
@@ -121,7 +121,7 @@ demo_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
|
||||
|
||||
weechat_printf (buffer,
|
||||
"buffer_input_data_cb: buffer = %x (%s), "
|
||||
"input_data = '%s'",
|
||||
"input_data = \"%s\"",
|
||||
buffer,
|
||||
weechat_buffer_get_string (buffer, "name"),
|
||||
input_data);
|
||||
@@ -372,7 +372,7 @@ demo_signal_cb (void *data, const char *signal, const char *type_data,
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("demo_signal: signal: %s, type_data: %s, "
|
||||
"signal_data: '%s'"),
|
||||
"signal_data: \"%s\""),
|
||||
signal, type_data, (char *)signal_data);
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
|
||||
@@ -2795,7 +2795,7 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
{
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL,
|
||||
_("Servers with '%s':"),
|
||||
_("Servers with \"%s\":"),
|
||||
server_name);
|
||||
}
|
||||
one_server_found = 1;
|
||||
|
||||
@@ -230,9 +230,9 @@ irc_ignore_free (struct t_irc_ignore *ignore)
|
||||
|
||||
/* remove filter from filters list */
|
||||
if (ignore->prev_ignore)
|
||||
ignore->prev_ignore->next_ignore = ignore->next_ignore;
|
||||
(ignore->prev_ignore)->next_ignore = ignore->next_ignore;
|
||||
if (ignore->next_ignore)
|
||||
ignore->next_ignore->prev_ignore = ignore->prev_ignore;
|
||||
(ignore->next_ignore)->prev_ignore = ignore->prev_ignore;
|
||||
if (irc_ignore_list == ignore)
|
||||
irc_ignore_list = ignore->next_ignore;
|
||||
if (last_irc_ignore == ignore)
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#define LOGGER_CONFIG_NAME "logger"
|
||||
|
||||
|
||||
extern struct t_config_file *logger_config_file;
|
||||
|
||||
extern struct t_config_option *logger_config_look_backlog;
|
||||
|
||||
extern struct t_config_option *logger_config_file_auto_log;
|
||||
|
||||
@@ -179,7 +179,7 @@ script_ptr2str (void *pointer)
|
||||
if (!pointer)
|
||||
return strdup ("");
|
||||
|
||||
snprintf (pointer_str, sizeof (pointer_str) - 1,
|
||||
snprintf (pointer_str, sizeof (pointer_str),
|
||||
"0x%x", (unsigned int)pointer);
|
||||
|
||||
return strdup (pointer_str);
|
||||
|
||||
Reference in New Issue
Block a user