feat: Add /spellcheck list command

To list all available dictionaries.

Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
Michael Vetter
2026-03-26 23:08:58 +01:00
parent 4922366366
commit ed2fdf88ac
5 changed files with 51 additions and 0 deletions

View File

@@ -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");

View File

@@ -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.")

View File

@@ -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);