mirror of
https://github.com/weechat/weechat.git
synced 2026-07-10 11:43:13 +02:00
aspell: rename option aspell.look.color to aspell.color.misspelled, add option aspell.color.suggestions
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "weechat-aspell.h"
|
||||
#include "weechat-aspell-config.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -67,8 +68,9 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_buffer *buffer;
|
||||
const char *suggestions, *pos;
|
||||
char str_delim[128], *suggestions2;
|
||||
const char *ptr_suggestions, *pos;
|
||||
char **suggestions, *suggestions2;
|
||||
int i, num_suggestions, length;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -83,22 +85,45 @@ weechat_aspell_bar_item_suggest (void *data, struct t_gui_bar_item *item,
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
if (buffer)
|
||||
{
|
||||
suggestions = weechat_buffer_get_string (buffer,
|
||||
"localvar_aspell_suggest");
|
||||
if (suggestions)
|
||||
ptr_suggestions = weechat_buffer_get_string (buffer,
|
||||
"localvar_aspell_suggest");
|
||||
if (ptr_suggestions)
|
||||
{
|
||||
pos = strchr (suggestions, ':');
|
||||
pos = strchr (ptr_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 (pos, "/", str_delim);
|
||||
if (suggestions2)
|
||||
return suggestions2;
|
||||
pos = ptr_suggestions;
|
||||
suggestions = weechat_string_split (pos, "/", 0, 0, &num_suggestions);
|
||||
if (suggestions)
|
||||
{
|
||||
length = 64 + 1;
|
||||
for (i = 0; i < num_suggestions; i++)
|
||||
{
|
||||
length += strlen (suggestions[i]) + 64;
|
||||
}
|
||||
suggestions2 = malloc (length);
|
||||
if (suggestions2)
|
||||
{
|
||||
suggestions2[0] = '\0';
|
||||
strcat (suggestions2,
|
||||
weechat_color (weechat_config_string (weechat_aspell_config_color_suggestions)));
|
||||
for (i = 0; i < num_suggestions; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
strcat (suggestions2, weechat_color ("bar_delim"));
|
||||
strcat (suggestions2, "/");
|
||||
strcat (suggestions2,
|
||||
weechat_color (weechat_config_string (weechat_aspell_config_color_suggestions)));
|
||||
}
|
||||
strcat (suggestions2, suggestions[i]);
|
||||
}
|
||||
weechat_string_free_split (suggestions);
|
||||
return suggestions2;
|
||||
}
|
||||
weechat_string_free_split (suggestions);
|
||||
}
|
||||
return strdup (pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,10 @@ struct t_config_section *weechat_aspell_config_section_dict = NULL;
|
||||
|
||||
int weechat_aspell_config_loading = 0;
|
||||
|
||||
/* aspell config, look section */
|
||||
/* aspell config, color section */
|
||||
|
||||
struct t_config_option *weechat_aspell_config_look_color;
|
||||
struct t_config_option *weechat_aspell_config_color_misspelled;
|
||||
struct t_config_option *weechat_aspell_config_color_suggestions;
|
||||
|
||||
/* aspell config, check section */
|
||||
|
||||
@@ -419,8 +420,8 @@ weechat_aspell_config_init ()
|
||||
if (!weechat_aspell_config_file)
|
||||
return 0;
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "look",
|
||||
/* color */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "color",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
@@ -431,11 +432,16 @@ weechat_aspell_config_init ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_aspell_config_look_color = weechat_config_new_option (
|
||||
weechat_aspell_config_color_misspelled = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"color", "color",
|
||||
N_("color used for misspelled words"),
|
||||
"misspelled", "color",
|
||||
N_("text color for misspelled words (input bar)"),
|
||||
NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
weechat_aspell_config_color_suggestions = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"suggestions", "color",
|
||||
N_("text color for suggestions on a misspelled word (status bar)"),
|
||||
NULL, 0, 0, "default", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* check */
|
||||
ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check",
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
#define ASPELL_CONFIG_NAME "aspell"
|
||||
|
||||
|
||||
extern struct t_config_option *weechat_aspell_config_look_color;
|
||||
extern struct t_config_option *weechat_aspell_config_color_misspelled;
|
||||
extern struct t_config_option *weechat_aspell_config_color_suggestions;
|
||||
|
||||
extern struct t_config_option *weechat_aspell_config_check_commands;
|
||||
extern struct t_config_option *weechat_aspell_config_check_default_dict;
|
||||
|
||||
@@ -621,7 +621,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier,
|
||||
|
||||
color_normal = weechat_color ("bar_fg");
|
||||
length_color_normal = strlen (color_normal);
|
||||
color_error = weechat_color (weechat_config_string (weechat_aspell_config_look_color));
|
||||
color_error = weechat_color (weechat_config_string (weechat_aspell_config_color_misspelled));
|
||||
length_color_error = strlen (color_error);
|
||||
|
||||
length = strlen (string);
|
||||
|
||||
Reference in New Issue
Block a user