Changes between Initial Version and Version 1 of WK2-EFLTextCheckerApiTutorial

Dec 21, 2012 2:22:00 AM (10 years ago)



  • WK2-EFLTextCheckerApiTutorial

    v1 v1  
     1== Introduction ==
     3Text Checker feature allows to check spelling in the editable areas for example, input fields, text areas and content editable. Functions:
     4 * check spelling of text (while typing to the input element),
     5 * get suggestions for the misspelled word (through the context menu),
     6 * learn/ignore the misspelled word (through the context menu).
     7There is one text checker object per application and it's disabled by default.
     9== Enabling text checker feature ==
     11If application wants to use the feature, API from ewk_settings.h should be used:
     16The client is able to query whether spellchecker continuous spell checking is enabled. Here is an example:
     18Eina_Bool enabled = ewk_settings_continuous_spell_checking_enabled_get();
     21== Languages support ==
     22By default, WebKit2-EFL performs spell checking based on the default OS language. If the client prefers to use a specific language, he has an opportunity to change it by following API:
     24const char lang[] = "en_US";
     28The client is able to verify the typed text with multi languages support. The languages that are involved in spell checking can be given with comma separated values. Here is an example:
     30const char langs[] = "en_US,ko,pl";
     34The number of the languages is not limited. But please be aware that loading multiple dictionaries may slow down your application.
     35There is a possibility to retrieve a list of dictionaries that are supported/installed by OS. Here is an example:
     37Eina_List *available_langs = ewk_settings_spell_checking_available_languages_get();
     38if (!available_langs)
     39    return;
     41Eina_List *it= NULL;
     42void *dict = NULL;
     43EINA_LIST_FOREACH(available_langs, it, dict)
     44    printf("%s\n", (const char*) dict);
     47The client is responsible for destroying the list and its items after use. Here is an example:
     49EINA_LIST_FREE(available_langs, dict)
     50    eina_stringshare_del((const char*) dict); 
     53The client can get a list of dictionaries that have been already loaded and are in use to perform spellchecking. Here is an example:
     55Eina_List *loaded_langs = ewk_settings_spell_checking_languages_get();
     56if (!loaded_langs)
     57   return;
     59Eina_List *it= NULL;
     60void *dict = NULL;
     61EINA_LIST_FOREACH(loaded_langs, it, dict)
     62   printf("%s\n", (const char*) dict);
     65The client is responsible for destroying the list and its items after use. Here is an example:
     67EINA_LIST_FREE(loaded_langs, dict)
     68    eina_stringshare_del((const char*) dict); 
     71== Notification about setting change ==
     73There is a callback function used to notify the client when the continuous spell checking setting was changed by WebKit. Specifying of this callback is needed if the application wants to receive notifications once WebKit changes this setting. If the application is not interested, this callback is not set. Changing of this setting at the WebKit level can be made as a result of modifying options in a Context Menu by a user. Here is an example:
     77// Callback definition.
     78static void setting_change(Eina_Bool enabled) {                                                                     
     79    printf("The continuous spell checking setting has been changed to %d\n", enabled);
     83    ...
     84    // Callback registration.
     85    ewk_settings_continuous_spell_checking_change_cb_set(setting_change);
     89== Overwrite the default text checker implementation by the client ==
     91The default WebKit text checker implementation is based on the Enchant library ( It doesn't ensure grammar checking. Application is able to overwrite it by defining its own implementation and setting appropriate callback functions. To overwrite the default text checker implementation API from ewk_text_checker.h can be used.
     92Here is an example of overwriting the implementation of check spelling of the given text:
     94// Callback definition.
     95static void spelling_check(uint64_t tag, const char* text, int32_t* misspelling_location, int32_t* misspelling_length) {
     96    printf("WebKit is requesting to check spelling for: %s\", text);
     97    // We assume that the text is spelled correctly.
     98    *misspelling_location = -1;
     99    *misspelling_length = 0;
     103    ...
     104    // Callback registration.
     105    ewk_text_checker_string_spelling_check_cb_set(spelling_check);
     109More examples of overwriting the text checker implementation can be found at
     111==  More detailed information ==
     112You can find the unit tests of text checker API here:
     114There are more test cases and examples of usage. WebKit-EFL's bots are building and testing text checker API. You can check their results here:
     116Text checker documentation and its API can be found at:
     117 * ewk_text_checker.h (
     118 * ewk_settings.h (
     120== Help, issues ==
     122For issues with the text checker, please contact:
     123 * Grzegorz Czajkowski - g.czajkowski (at)
     124 * Michal Roj (m.roj (at)