From 2562e602c999fd683b03e882f5ad8aa33935242e Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Fri, 19 May 2017 01:38:58 +0200 Subject: [PATCH] Add settings for spell checking. --- doc/vimb.1 | 12 ++++++++++++ src/setting.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/doc/vimb.1 b/doc/vimb.1 index 3c199e8..3dd694f 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -1033,6 +1033,18 @@ For example, if a user presses the Right key, heuristics determine whether there is an element they might be trying to reach towards the right, and if there are multiple elements, which element they probably want. .TP +.B spell-checking (bool) +Enable or disable the spell checking feature. +.TP +.B spell-checking-languages (string) +Set comma separated list of spell checking languages to be used for spell +checking. +.br +The locale string typically is in the form lang_COUNTRY, where lang is an +ISO-639 language code, and COUNTRY is an ISO-3166 country code. For instance, +sv_FI for Swedish as written in Finland or pt_BR for Portuguese as written in +Brazil. +.TP .B status-bar (bool) Indicates if the status bar should be shown. .TP diff --git a/src/setting.c b/src/setting.c index 44edadd..de33832 100644 --- a/src/setting.c +++ b/src/setting.c @@ -61,6 +61,8 @@ static int user_style(Client *c, const char *name, DataType type, void *value, v static int statusbar(Client *c, const char *name, DataType type, void *value, void *data); static int tls_policy(Client *c, const char *name, DataType type, void *value, void *data); static int webkit(Client *c, const char *name, DataType type, void *value, void *data); +static int webkit_spell_checking(Client *c, const char *name, DataType type, void *value, void *data); +static int webkit_spell_checking_language(Client *c, const char *name, DataType type, void *value, void *data); extern struct Vimb vb; @@ -150,6 +152,9 @@ void setting_init(Client *c) /* TODO should be global and not overwritten by a new client */ setting_add(c, "closed-max-items", TYPE_INTEGER, &i, internal, 0, &vb.config.closed_max); setting_add(c, "x-hint-command", TYPE_CHAR, &":o ;", NULL, 0, NULL); + setting_add(c, "spell-checking", TYPE_BOOLEAN, &off, webkit_spell_checking, 0, NULL); + setting_add(c, "spell-checking-languages", TYPE_CHAR, &"en_US", webkit_spell_checking_language, FLAG_LIST|FLAG_NODUP, NULL); + #ifdef FEATURE_GUI_STYLE_VIMB2_COMPAT /* gui style settings vimb2 compatibility */ @@ -713,3 +718,26 @@ static int webkit(Client *c, const char *name, DataType type, void *value, void } return CMD_SUCCESS; } + +static int webkit_spell_checking(Client *c, const char *name, DataType type, void *value, void *data) +{ + gboolean enabled = *((gboolean*)value); + + webkit_web_context_set_spell_checking_enabled( + webkit_web_context_get_default(), + enabled); + + return CMD_SUCCESS; +} + +static int webkit_spell_checking_language(Client *c, const char *name, DataType type, void *value, void *data) +{ + char **languages = g_strsplit((char*)value, ",", -1); + + webkit_web_context_set_spell_checking_languages( + webkit_web_context_get_default(), + (const char * const *)languages); + g_strfreev(languages); + + return CMD_SUCCESS; +} -- 2.20.1