mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
aspell: add signal "aspell_suggest" (sent when new suggestions are displayed)
This commit is contained in:
@@ -61,6 +61,7 @@ Version 0.4.0 (under dev!)
|
||||
hook_connect (task #11205)
|
||||
* alias: give higher priority to aliases (2000) so that they take precedence
|
||||
over an existing command
|
||||
* aspell: add signal "aspell_suggest" (sent when new suggestions are displayed)
|
||||
* aspell: add bar items "aspell_dict" (dictionary used on current buffer) and
|
||||
"aspell_suggest" (suggestions for misspelled word at cursor), add option
|
||||
aspell.check.suggestions (task #12061)
|
||||
|
||||
@@ -7513,6 +7513,11 @@ Arguments:
|
||||
|========================================
|
||||
| Plugin | Signal | Arguments | Description
|
||||
|
||||
| aspell | aspell_suggest +
|
||||
(_new in version 0.4.0_) |
|
||||
pointer: buffer |
|
||||
new suggestions for a misspelled word
|
||||
|
||||
| guile | guile_script_loaded +
|
||||
(_new in version 0.3.9_) |
|
||||
string: path to script |
|
||||
|
||||
@@ -7626,6 +7626,11 @@ Paramètres :
|
||||
|========================================
|
||||
| Extension | Signal | Paramètres | Description
|
||||
|
||||
| aspell | aspell_suggest +
|
||||
(_nouveau dans la version 0.4.0_) |
|
||||
pointeur : tampon |
|
||||
nouvelles suggestions pour un mot mal orthographié
|
||||
|
||||
| guile | guile_script_loaded +
|
||||
(_nouveau dans la version 0.3.9_) |
|
||||
chaîne: chemin vers le script |
|
||||
|
||||
@@ -7554,6 +7554,12 @@ Argomenti:
|
||||
|========================================
|
||||
| Plugin | Segnale | Argomenti | Descrizione
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| aspell | aspell_suggest +
|
||||
(_novità nella versione 0.4.0_) |
|
||||
pointer: buffer |
|
||||
new suggestions for a misspelled word
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| guile | guile_script_loaded +
|
||||
(_novità nella versione 0.3.9_) |
|
||||
|
||||
@@ -68,7 +68,7 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
|
||||
{
|
||||
struct t_gui_buffer *buffer;
|
||||
const char *suggestions;
|
||||
char str_delim[128], *suggestions2;
|
||||
char str_delim[128], *pos, *suggestions2;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -87,14 +87,19 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
|
||||
"localvar_aspell_suggest");
|
||||
if (suggestions)
|
||||
{
|
||||
pos = strchr (suggestions, ':');
|
||||
if (pos)
|
||||
pos++;
|
||||
else
|
||||
pos = suggestions;
|
||||
snprintf (str_delim, sizeof (str_delim),
|
||||
"%s/%s",
|
||||
weechat_color ("bar_delim"),
|
||||
weechat_color ("bar_fg"));
|
||||
suggestions2 = weechat_string_replace (suggestions, "/", str_delim);
|
||||
suggestions2 = weechat_string_replace (pos, "/", str_delim);
|
||||
if (suggestions2)
|
||||
return suggestions2;
|
||||
return strdup (suggestions);
|
||||
return strdup (pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -747,6 +747,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;
|
||||
char *word_for_suggestions, *old_suggestions, *suggestions;
|
||||
char *word_and_suggestions;
|
||||
const char *color_normal, *color_error, *ptr_suggestions;
|
||||
int buffer_has_changed, utf8_char_int, char_size;
|
||||
int length, index_result, length_word, word_ok;
|
||||
@@ -987,8 +988,21 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
suggestions = weechat_aspell_get_suggestions (word_for_suggestions);
|
||||
if (suggestions)
|
||||
{
|
||||
weechat_buffer_set (buffer, "localvar_set_aspell_suggest",
|
||||
suggestions);
|
||||
length = strlen (word_for_suggestions) + 1 /* ":" */
|
||||
+ strlen (suggestions) + 1;
|
||||
word_and_suggestions = malloc (length);
|
||||
if (word_and_suggestions)
|
||||
{
|
||||
snprintf (word_and_suggestions, length, "%s:%s",
|
||||
word_for_suggestions, suggestions);
|
||||
weechat_buffer_set (buffer, "localvar_set_aspell_suggest",
|
||||
word_and_suggestions);
|
||||
free (word_and_suggestions);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_buffer_set (buffer, "localvar_del_aspell_suggest", "");
|
||||
}
|
||||
free (suggestions);
|
||||
}
|
||||
else
|
||||
@@ -1002,7 +1016,10 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
weechat_buffer_set (buffer, "localvar_del_aspell_suggest", "");
|
||||
}
|
||||
|
||||
/* if suggestions have changed, update the bar item */
|
||||
/*
|
||||
* if suggestions have changed, update the bar item
|
||||
* and send signal "aspell_suggest"
|
||||
*/
|
||||
ptr_suggestions = weechat_buffer_get_string (buffer,
|
||||
"localvar_aspell_suggest");
|
||||
if ((old_suggestions && !ptr_suggestions)
|
||||
@@ -1011,6 +1028,8 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
&& (strcmp (old_suggestions, ptr_suggestions) != 0)))
|
||||
{
|
||||
weechat_bar_item_update ("aspell_suggest");
|
||||
weechat_hook_signal_send ("aspell_suggest",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
if (old_suggestions)
|
||||
free (old_suggestions);
|
||||
|
||||
Reference in New Issue
Block a user