mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
aspell: add options to control delimiters in suggestions (closes #940)
New options: - aspell.color.suggestion_delimiter_dict - aspell.color.suggestion_delimiter_word - aspell.look.suggestion_delimiter_dict - aspell.look.suggestion_delimiter_word Option renamed: - aspell.color.suggestions -> aspell.color.suggestion
This commit is contained in:
@@ -70,8 +70,8 @@ weechat_aspell_bar_item_suggest (const void *pointer, void *data,
|
||||
struct t_hashtable *extra_info)
|
||||
{
|
||||
const char *ptr_suggestions, *pos;
|
||||
char **suggestions, *suggestions2;
|
||||
int i, num_suggestions, length;
|
||||
char **suggestions, **suggestions2, **str_suggest;
|
||||
int i, j, num_suggestions, num_suggestions2;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -96,37 +96,61 @@ weechat_aspell_bar_item_suggest (const void *pointer, void *data,
|
||||
pos++;
|
||||
else
|
||||
pos = ptr_suggestions;
|
||||
|
||||
str_suggest = weechat_string_dyn_alloc (256);
|
||||
if (!str_suggest)
|
||||
return NULL;
|
||||
|
||||
suggestions = weechat_string_split (pos, "/", 0, 0, &num_suggestions);
|
||||
if (suggestions)
|
||||
if (!suggestions)
|
||||
goto end;
|
||||
|
||||
for (i = 0; i < num_suggestions; i++)
|
||||
{
|
||||
length = 64 + 1;
|
||||
for (i = 0; i < num_suggestions; i++)
|
||||
if (i > 0)
|
||||
{
|
||||
length += strlen (suggestions[i]) + 64;
|
||||
weechat_string_dyn_concat (
|
||||
str_suggest,
|
||||
weechat_color (
|
||||
weechat_config_string (
|
||||
weechat_aspell_config_color_suggestion_delimiter_dict)));
|
||||
weechat_string_dyn_concat (
|
||||
str_suggest,
|
||||
weechat_config_string (
|
||||
weechat_aspell_config_look_suggestion_delimiter_dict));
|
||||
}
|
||||
suggestions2 = malloc (length);
|
||||
suggestions2 = weechat_string_split (suggestions[i], ",", 0, 0,
|
||||
&num_suggestions2);
|
||||
if (suggestions2)
|
||||
{
|
||||
suggestions2[0] = '\0';
|
||||
strcat (suggestions2,
|
||||
weechat_color (weechat_config_string (weechat_aspell_config_color_suggestions)));
|
||||
for (i = 0; i < num_suggestions; i++)
|
||||
for (j = 0; j < num_suggestions2; j++)
|
||||
{
|
||||
if (i > 0)
|
||||
if (j > 0)
|
||||
{
|
||||
strcat (suggestions2, weechat_color ("bar_delim"));
|
||||
strcat (suggestions2, "/");
|
||||
strcat (suggestions2,
|
||||
weechat_color (weechat_config_string (weechat_aspell_config_color_suggestions)));
|
||||
weechat_string_dyn_concat (
|
||||
str_suggest,
|
||||
weechat_color (
|
||||
weechat_config_string (
|
||||
weechat_aspell_config_color_suggestion_delimiter_word)));
|
||||
weechat_string_dyn_concat (
|
||||
str_suggest,
|
||||
weechat_config_string (
|
||||
weechat_aspell_config_look_suggestion_delimiter_word));
|
||||
}
|
||||
strcat (suggestions2, suggestions[i]);
|
||||
weechat_string_dyn_concat (
|
||||
str_suggest,
|
||||
weechat_color (
|
||||
weechat_config_string (
|
||||
weechat_aspell_config_color_suggestion)));
|
||||
weechat_string_dyn_concat (str_suggest, suggestions2[j]);
|
||||
}
|
||||
weechat_string_free_split (suggestions);
|
||||
return suggestions2;
|
||||
weechat_string_free_split (suggestions2);
|
||||
}
|
||||
weechat_string_free_split (suggestions);
|
||||
}
|
||||
return strdup (pos);
|
||||
weechat_string_free_split (suggestions);
|
||||
|
||||
end:
|
||||
return weechat_string_dyn_free (str_suggest, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -38,7 +38,9 @@ int weechat_aspell_config_loading = 0;
|
||||
/* aspell config, color section */
|
||||
|
||||
struct t_config_option *weechat_aspell_config_color_misspelled;
|
||||
struct t_config_option *weechat_aspell_config_color_suggestions;
|
||||
struct t_config_option *weechat_aspell_config_color_suggestion;
|
||||
struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_dict;
|
||||
struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_word;
|
||||
|
||||
/* aspell config, check section */
|
||||
|
||||
@@ -50,6 +52,11 @@ struct t_config_option *weechat_aspell_config_check_real_time;
|
||||
struct t_config_option *weechat_aspell_config_check_suggestions;
|
||||
struct t_config_option *weechat_aspell_config_check_word_min_length;
|
||||
|
||||
/* aspell config, look section */
|
||||
|
||||
struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_dict;
|
||||
struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_word;
|
||||
|
||||
|
||||
char **weechat_aspell_commands_to_check = NULL;
|
||||
int weechat_aspell_count_commands_to_check = 0;
|
||||
@@ -452,12 +459,27 @@ weechat_aspell_config_init ()
|
||||
N_("text color for misspelled words (input bar)"),
|
||||
NULL, 0, 0, "lightred", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
weechat_aspell_config_color_suggestions = weechat_config_new_option (
|
||||
weechat_aspell_config_color_suggestion = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"suggestions", "color",
|
||||
N_("text color for suggestions on a misspelled word (status bar)"),
|
||||
"suggestion", "color",
|
||||
N_("text color for suggestion on a misspelled word in bar item "
|
||||
"\"aspell_suggest\""),
|
||||
NULL, 0, 0, "default", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
weechat_aspell_config_color_suggestion_delimiter_dict = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"suggestion_delimiter_dict", "color",
|
||||
N_("text color for delimiters displayed between two dictionaries "
|
||||
"in bar item \"aspell_suggest\""),
|
||||
NULL, 0, 0, "cyan", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
weechat_aspell_config_color_suggestion_delimiter_word = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"suggestion_delimiter_word", "color",
|
||||
N_("text color for delimiters displayed between two words in bar item "
|
||||
"\"aspell_suggest\""),
|
||||
NULL, 0, 0, "cyan", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* check */
|
||||
ptr_section = weechat_config_new_section (
|
||||
@@ -551,6 +573,40 @@ weechat_aspell_config_init ()
|
||||
|
||||
weechat_aspell_config_section_dict = ptr_section;
|
||||
|
||||
/* look */
|
||||
ptr_section = weechat_config_new_section (
|
||||
weechat_aspell_config_file, "look",
|
||||
0, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (weechat_aspell_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
weechat_aspell_config_look_suggestion_delimiter_dict = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"suggestion_delimiter_dict", "string",
|
||||
N_("delimiter displayed between two dictionaries in bar item "
|
||||
"\"aspell_suggest\""),
|
||||
NULL, 0, 0, " / ", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&weechat_aspell_config_change_suggestions, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
weechat_aspell_config_look_suggestion_delimiter_word = weechat_config_new_option (
|
||||
weechat_aspell_config_file, ptr_section,
|
||||
"suggestion_delimiter_word", "string",
|
||||
N_("delimiter displayed between two words in bar item "
|
||||
"\"aspell_suggest\""),
|
||||
NULL, 0, 0, ",", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&weechat_aspell_config_change_suggestions, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
/* option */
|
||||
ptr_section = weechat_config_new_section (
|
||||
weechat_aspell_config_file, "option",
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
|
||||
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_color_suggestion;
|
||||
extern struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_dict;
|
||||
extern struct t_config_option *weechat_aspell_config_color_suggestion_delimiter_word;
|
||||
|
||||
extern struct t_config_option *weechat_aspell_config_check_commands;
|
||||
extern struct t_config_option *weechat_aspell_config_check_default_dict;
|
||||
@@ -35,6 +37,9 @@ extern struct t_config_option *weechat_aspell_config_check_real_time;
|
||||
extern struct t_config_option *weechat_aspell_config_check_suggestions;
|
||||
extern struct t_config_option *weechat_aspell_config_check_word_min_length;
|
||||
|
||||
extern struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_dict;
|
||||
extern struct t_config_option *weechat_aspell_config_look_suggestion_delimiter_word;
|
||||
|
||||
extern char **weechat_aspell_commands_to_check;
|
||||
extern int weechat_aspell_count_commands_to_check;
|
||||
extern int *weechat_aspell_length_commands_to_check;
|
||||
|
||||
Reference in New Issue
Block a user