From e0151b42a6cd27f48ca72e811eb2d6ddc72e65cb Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Wed, 16 Mar 2011 21:59:39 +0100 Subject: [PATCH] aspell: fix spellers used after switch of window (bug #32811) --- ChangeLog | 1 + src/plugins/aspell/weechat-aspell.c | 39 ++++++++++------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index f000f901c..2ba70c757 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,6 +36,7 @@ Version 0.3.5 (under dev!) being added with command "/color") * core: allow background for nick colors (using ":") * api: add new function buffer_match_list +* aspell: fix spellers used after switch of window (bug #32811) * irc: add new options irc.look.buffer_switch_autojoin and irc.look.buffer_switch_join (task #8542, task #10506) * irc: add new option irc.look.smart_filter_nick diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/aspell/weechat-aspell.c index 86cf99c1d..cd37a86b5 100644 --- a/src/plugins/aspell/weechat-aspell.c +++ b/src/plugins/aspell/weechat-aspell.c @@ -43,6 +43,8 @@ WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE); struct t_weechat_plugin *weechat_aspell_plugin = NULL; +struct t_gui_buffer *aspell_buffer_spellers = NULL; + char *aspell_last_modifier_string = NULL; /* last str. received by modifier */ char *aspell_last_modifier_result = NULL; /* last str. built by modifier */ @@ -337,24 +339,6 @@ weechat_aspell_create_spellers (struct t_gui_buffer *buffer) } } -/* - * weechat_aspell_buffer_switch_cb: callback for "buffer_switch" signel - */ - -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; - - weechat_aspell_create_spellers (signal_data); - - return WEECHAT_RC_OK; -} - /* * weechat_aspell_iso_to_lang: convert an aspell iso lang code in its english * full name @@ -674,7 +658,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, struct t_gui_buffer *buffer; char *result, *ptr_string, *pos_space, *ptr_end, save_end; const char *color_normal, *color_error; - int utf8_char_int, char_size; + int buffer_has_changed, utf8_char_int, char_size; int length, index_result, length_word, word_ok; int length_color_normal, length_color_error, rc; @@ -690,6 +674,14 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, return NULL; buffer = (struct t_gui_buffer *)value; + + buffer_has_changed = 0; + if (buffer != aspell_buffer_spellers) + { + weechat_aspell_create_spellers (buffer); + aspell_buffer_spellers = buffer; + buffer_has_changed = 1; + } if (!weechat_aspell_spellers) return NULL; @@ -704,7 +696,8 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, * same (for example user just change cursor position, or input text is * refreshed with same content) */ - if (aspell_last_modifier_string + if (!buffer_has_changed + && aspell_last_modifier_string && (strcmp (string, aspell_last_modifier_string) == 0)) { return (aspell_last_modifier_result) ? @@ -986,10 +979,6 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) N_("list of supported langs for aspell"), &weechat_aspell_completion_langs_cb, NULL); - /* callback for buffer_switch */ - weechat_hook_signal ("buffer_switch", - &weechat_aspell_buffer_switch_cb, NULL); - /* * callback for spell checking input text * we use a low priority here, so that other modifiers "input_text_display" @@ -998,8 +987,6 @@ 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_create_spellers (weechat_current_buffer ()); - return WEECHAT_RC_OK; }