1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-08 10:43:13 +02:00

aspell: add bar item "aspell_dict" (dictionary used on current buffer)

This commit is contained in:
Nils Görs
2012-10-06 17:16:49 +02:00
committed by Sebastien Helleu
parent 5443ae4cae
commit 668cda2684
10 changed files with 168 additions and 12 deletions
+1
View File
@@ -7,6 +7,7 @@ v0.4.0-dev, 2012-10-06
Version 0.4.0 (under dev!)
--------------------------
* aspell: add bar item "aspell_dict" (dictionary used on current buffer)
* irc: remove unneeded server disconnect when server buffer is closed and server
is already disconnected
* relay: add missing "ssl." in output of /relay listrelay
+1
View File
@@ -174,6 +174,7 @@ Plugins
| alias-info.c | Info and infolists from alias plugin
| aspell/ | Aspell plugin
| weechat-aspell.c | Main aspell functions
| weechat-aspell-bar-item.c | Aspell bar items
| weechat-aspell-config.c | Aspell config options
| weechat-aspell-speller.c | Spellers management
| charset/ | Charset plugin
+2
View File
@@ -101,6 +101,8 @@
./src/plugins/alias/alias-info.h
./src/plugins/aspell/weechat-aspell.c
./src/plugins/aspell/weechat-aspell.h
./src/plugins/aspell/weechat-aspell-bar-item.c
./src/plugins/aspell/weechat-aspell-bar-item.h
./src/plugins/aspell/weechat-aspell-config.c
./src/plugins/aspell/weechat-aspell-config.h
./src/plugins/aspell/weechat-aspell-speller.c
+2
View File
@@ -102,6 +102,8 @@ SET(WEECHAT_SOURCES
./src/plugins/alias/alias-info.h
./src/plugins/aspell/weechat-aspell.c
./src/plugins/aspell/weechat-aspell.h
./src/plugins/aspell/weechat-aspell-bar-item.c
./src/plugins/aspell/weechat-aspell-bar-item.h
./src/plugins/aspell/weechat-aspell-config.c
./src/plugins/aspell/weechat-aspell-config.h
./src/plugins/aspell/weechat-aspell-speller.c
+1
View File
@@ -20,6 +20,7 @@
ADD_LIBRARY(aspell MODULE
weechat-aspell.c weechat-aspell.h
weechat-aspell-bar-item.c weechat-aspell-bar-item.h
weechat-aspell-config.c weechat-aspell-config.h
weechat-aspell-speller.c weechat-aspell-speller.h)
SET_TARGET_PROPERTIES(aspell PROPERTIES PREFIX "")
+2
View File
@@ -26,6 +26,8 @@ lib_LTLIBRARIES = aspell.la
aspell_la_SOURCES = weechat-aspell.c \
weechat-aspell.h \
weechat-aspell-bar-item.c \
weechat-aspell-bar-item.h \
weechat-aspell-config.c \
weechat-aspell-config.h \
weechat-aspell-speller.c \
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2012 Nils Görs <weechatter@arcor.de>
* Copyright (C) 2012 Sebastien 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 <http://www.gnu.org/licenses/>.
*/
/*
* weechat-aspell-bar-item.c: bar items for aspell plugin
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../weechat-plugin.h"
#include "weechat-aspell.h"
/*
* weechat_aspell_bar_item_dict: bar item with aspell dictionary used on
* current buffer
*/
char *
weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
struct t_gui_buffer *buffer;
const char *dict_list;
/* make C compiler happy */
(void) data;
(void) item;
if (!window)
window = weechat_current_window ();
buffer = weechat_window_get_pointer (window, "buffer");
if (buffer)
{
dict_list = weechat_aspell_get_dict (buffer);
if (dict_list)
return strdup (dict_list);
}
return NULL;
}
/*
* weechat_aspell_bar_item_init: initialize aspell bar items
*/
void
weechat_aspell_bar_item_init ()
{
weechat_bar_item_new ("aspell_dict", &weechat_aspell_bar_item_dict, NULL);
}
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2012 Nils Görs <weechatter@arcor.de>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_ASPELL_BAR_ITEM_H
#define __WEECHAT_ASPELL_BAR_ITEM_H 1
extern void weechat_aspell_bar_item_init ();
#endif /* __WEECHAT_ASPELL_BAR_ITEM_H */
+62 -12
View File
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org>
* Copyright (C) 2006-2012 Sebastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2012 Nils Görs <weechatter@arcor.de>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -31,6 +32,7 @@
#include "../weechat-plugin.h"
#include "weechat-aspell.h"
#include "weechat-aspell-bar-item.h"
#include "weechat-aspell-config.h"
#include "weechat-aspell-speller.h"
@@ -332,26 +334,27 @@ weechat_aspell_create_spellers (struct t_gui_buffer *buffer)
char **argv;
int argc, i;
if (buffer)
if (!buffer)
return;
dict_list = weechat_aspell_get_dict (buffer);
if (!weechat_aspell_spellers_already_ok (dict_list))
{
dict_list = weechat_aspell_get_dict (buffer);
if (!weechat_aspell_spellers_already_ok (dict_list))
weechat_aspell_speller_free_all ();
if (dict_list)
{
weechat_aspell_speller_free_all ();
if (dict_list)
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
if (argv)
{
argv = weechat_string_split (dict_list, ",", 0, 0, &argc);
if (argv)
for (i = 0; i < argc; i++)
{
for (i = 0; i < argc; i++)
{
weechat_aspell_speller_new (argv[i]);
}
weechat_string_free_split (argv);
weechat_aspell_speller_new (argv[i]);
}
weechat_string_free_split (argv);
}
}
}
weechat_bar_item_update ("aspell_dict");
}
/*
@@ -1029,6 +1032,46 @@ weechat_aspell_completion_langs_cb (void *data, const char *completion_item,
return WEECHAT_RC_OK;
}
/*
* weechat_aspell_buffer_switch_cb: called on "buffer_switch" signal
*/
int
weechat_aspell_buffer_switch_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
/* refresh bar item "aspell_dict" (for root bars) */
weechat_bar_item_update ("aspell_dict");
return WEECHAT_RC_OK;
}
/*
* weechat_aspell_window_switch_cb: called on "window_switch" signal
*/
int
weechat_aspell_window_switch_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
/* refresh bar item "aspell_dict" (for root bars) */
weechat_bar_item_update ("aspell_dict");
return WEECHAT_RC_OK;
}
/*
* weechat_plugin_init : init aspell plugin
*/
@@ -1095,6 +1138,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_hook_modifier ("500|input_text_display",
&weechat_aspell_modifier_cb, NULL);
weechat_aspell_bar_item_init ();
weechat_hook_signal ("buffer_switch",
&weechat_aspell_buffer_switch_cb, NULL);
weechat_hook_signal ("window_switch",
&weechat_aspell_window_switch_cb, NULL);
return WEECHAT_RC_OK;
}
+1
View File
@@ -36,5 +36,6 @@ extern struct t_weechat_plugin *weechat_aspell_plugin;
extern int aspell_enabled;
extern void weechat_aspell_create_spellers (struct t_gui_buffer *buffer);
extern const char *weechat_aspell_get_dict (struct t_gui_buffer *buffer);
#endif /* __WEECHAT_ASPELL_H */