mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 11:06:21 +00:00
feat: Add /spellcheck list command
To list all available dictionaries. Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
@@ -568,6 +568,7 @@ cmd_ac_init(void)
|
||||
|
||||
autocomplete_add(spellcheck_ac, "on");
|
||||
autocomplete_add(spellcheck_ac, "off");
|
||||
autocomplete_add(spellcheck_ac, "list");
|
||||
autocomplete_add(spellcheck_ac, "lang");
|
||||
|
||||
autocomplete_add(disco_ac, "info");
|
||||
|
||||
@@ -1458,6 +1458,7 @@ static const struct cmd_t command_defs[] = {
|
||||
CMD_TAG_UI)
|
||||
CMD_SYN(
|
||||
"/spellcheck on|off",
|
||||
"/spellcheck list",
|
||||
"/spellcheck lang <locale>")
|
||||
CMD_DESC(
|
||||
"Enable or disable spellchecking, or set the language.")
|
||||
|
||||
@@ -6571,6 +6571,24 @@ cmd_spellcheck(ProfWin* window, const char* const command, gchar** args)
|
||||
} else if (g_strcmp0(args[0], "off") == 0) {
|
||||
prefs_set_boolean(PREF_SPELLCHECK_ENABLE, FALSE);
|
||||
cons_show("Spellcheck disabled.");
|
||||
} else if (g_strcmp0(args[0], "list") == 0) {
|
||||
GList* langs = spellcheck_get_available_langs();
|
||||
if (langs == NULL) {
|
||||
cons_show("No dictionaries found. Install Enchant-compatible dictionaries (hunspell/aspell).");
|
||||
} else {
|
||||
GString* lang_str = g_string_new("");
|
||||
GList* curr = langs;
|
||||
while (curr) {
|
||||
g_string_append(lang_str, (char*)curr->data);
|
||||
if (curr->next) {
|
||||
g_string_append(lang_str, ", ");
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
cons_show("Available spellcheck dictionaries: %s", lang_str->str);
|
||||
g_string_free(lang_str, TRUE);
|
||||
g_list_free_full(langs, g_free);
|
||||
}
|
||||
} else if (g_strcmp0(args[0], "lang") == 0) {
|
||||
if (args[1] == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
|
||||
Reference in New Issue
Block a user