feat: add spellcheck highlighting support

Introduce optional spellcheck highlighting in the input window using
the Enchant-2 library.

```
/spellcheck on
/spellcheck lang en_US
```

New theme color `input.misspelled`.

Fixes: https://github.com/profanity-im/profanity/issues/183
Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
Michael Vetter
2026-03-26 22:37:06 +01:00
parent 88b80c33ef
commit 4922366366
17 changed files with 335 additions and 0 deletions

View File

@@ -54,6 +54,7 @@
#include "tools/plugin_download.h"
#include "tools/bookmark_ignore.h"
#include "tools/editor.h"
#include "tools/spellcheck.h"
#include "plugins/plugins.h"
#include "ui/inputwin.h"
#include "ui/ui.h"
@@ -6560,6 +6561,37 @@ cmd_splash(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
gboolean
cmd_spellcheck(ProfWin* window, const char* const command, gchar** args)
{
#ifdef HAVE_SPELLCHECK
if (g_strcmp0(args[0], "on") == 0) {
prefs_set_boolean(PREF_SPELLCHECK_ENABLE, TRUE);
cons_show("Spellcheck enabled.");
} 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], "lang") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
} else {
if (spellcheck_set_lang(args[1])) {
prefs_set_string(PREF_SPELLCHECK_LANG, args[1]);
cons_show("Spellcheck language set to: %s", args[1]);
} else {
cons_show("Failed to set spellcheck language to: %s. Is the dictionary installed?", args[1]);
}
}
} else {
cons_bad_cmd_usage(command);
}
#else
cons_show("Profanity was built without spellcheck support.");
#endif
return TRUE;
}
gboolean
cmd_autoconnect(ProfWin* window, const char* const command, gchar** args)
{