Changes between Version 1 and Version 2 of WK2-EFLTextCheckerApiTutorial
- Timestamp:
- Jan 11, 2013 1:39:49 AM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WK2-EFLTextCheckerApiTutorial
v1 v2 1 == Abstract == 2 The tutorial shows the text checker API and its usage, it describes: 3 * functions provided by the text checker feature, 4 * how to enable the feature, 5 * how to set languages to be used in spell checking, 6 * how to to be notified on the text checker settings change, 7 * how to override the default text checker implementation. 8 1 9 == Introduction == 2 10 3 Text 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 (th roughthe context menu),6 * learn/ignore the misspelled word (through the context menu).7 The re is one text checker object per application and it's disabled by default.11 Text Checker feature allows to check spelling in the editable areas (such ad input fields, text areas and content editable). Functions provided by the text checker feature are as follows: 12 * check if spelling of text is correct (while typing the input text), 13 * get suggestions for the misspelled word (this is made through feature available in the context menu), 14 * learn/ignore the misspelled word (through the feature available in context menu). 15 The feature is available for [http://trac.webkit.org/wiki/EFLWebKit EFL's WebKit2 port]. There is one text checker object per application and it's disabled by default. The text checker feature is language-neutral. However, relevant dictionaries should be set to perform spelling. 8 16 9 17 == Enabling text checker feature == 10 18 11 If application wants to use the feature, API from ewk_settings.h should be used: 19 If an application wants to use this feature, the following API from ewk_settings.h should be used: 20 {{{ 21 void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable); 22 }}} 23 Here is an example how an application can enable this feature: 12 24 {{{ 13 25 ewk_settings_continuous_spell_checking_enabled_set(EINA_TRUE); 14 26 }}} 27 As a result, the text checker feature is enabled and the spell checking related functionalities are available for the user. 15 28 16 The client is able to query whether spellchecker continuous spell checking is enabled. Here is an example: 29 30 31 The user is able to query whether spellchecker continuous spell checking is enabled, the following API from ewk_settings.h should be used: 32 {{{ 33 Eina_Bool ewk_settings_continuous_spell_checking_enabled_get(void); 34 }}} 35 Here is an example of its usage: 17 36 {{{ 18 37 Eina_Bool enabled = ewk_settings_continuous_spell_checking_enabled_get(); … … 20 39 21 40 == Languages support == 22 By 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: 41 By default, WebKit2-EFL performs spell checking based on the default OS language. An arbitrary language can be set by using the following API from the ewk_settings.h: 42 {{{ 43 void ewk_settings_spell_checking_languages_set(const char *languages); 44 }}} 45 46 The example below sets English languages (US version) that will be used to perform spell checking. 23 47 {{{ 24 48 const char lang[] = "en_US"; … … 26 50 }}} 27 51 28 The 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:52 The user is able to verify the typed text with multi languages support. The languages to be used in spell checking can be given as comma separated strings. Here is an example: 29 53 {{{ 30 54 const char langs[] = "en_US,ko,pl"; 31 55 ewk_settings_spell_checking_languages_set(langs); 32 56 }}} 57 The presented example sets three languages (English, Korean and Polish) to be used in spell checking. The number of the languages is not limited. However, be aware that loading multiple dictionaries may slow down your application.[[BR]] 33 58 34 The number of the languages is not limited. But please be aware that loading multiple dictionaries may slow down your application. 35 There is a possibility to retrieve a list of dictionaries that are supported/installed by OS. Here is an example: 59 There is a possibility to retrieve a list of dictionaries that are supported/installed by OS. The following API from ewk_settings.h should be used: 60 {{{ 61 Eina_List *ewk_settings_spell_checking_available_languages_get(void); 62 }}} 63 64 Here is an example of its usage. It gets the available languages and displays them on the standard output: 36 65 {{{ 37 66 Eina_List *available_langs = ewk_settings_spell_checking_available_languages_get(); … … 62 91 printf("%s\n", (const char*) dict); 63 92 }}} 64 65 The client is responsible for destroying the list and its items after use. Here is an example: 93 The presented example gets the languages that are in use and displays them on the standard output. The client is responsible for destroying the list and its items after use. Here is an example: 66 94 {{{ 67 95 EINA_LIST_FREE(loaded_langs, dict) … … 71 99 == Notification about setting change == 72 100 73 There 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: 101 There is a callback function used to notify the user 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. The following API from ewk_settings.h can be used: 102 {{{ 103 void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb cb); 104 typedef void (*Ewk_Settings_Continuous_Spell_Checking_Change_Cb)(Eina_Bool enable); 105 }}} 74 106 75 107 The presented example registers the callback and displays a message with a new value of the continuous spell checking: 76 108 {{{ 77 109 // Callback definition. … … 87 119 }}} 88 120 89 == Over write the default text checker implementation by the client ==121 == Overdrive the default text checker implementation by the client == 90 122 91 The default WebKit text checker implementation is based on the Enchant library (http://www.abisource.com/projects/enchant/). 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. 92 Here is an example of overwriting the implementation of check spelling of the given text: 123 The default WebKit text checker implementation is based on the [http://www.abisource.com/projects/enchant/ Enchant] library. It doesn't ensure grammar checking. The application is able to override it by defining its own implementation and setting appropriate callback functions. To override the default text checker implementation API from ewk_text_checker.h can be used: 124 {{{ 125 void ewk_text_checker_string_spelling_check_cb_set(Ewk_Text_Checker_String_Spelling_Check_Cb cb); 126 typedef void (*Ewk_Text_Checker_String_Spelling_Check_Cb)(uint64_t tag, const char *text, int32_t *misspelling_location, int32_t *misspelling_length); 127 }}} 128 129 Here is an example of overriding the implementation of check spelling of the given text: 93 130 {{{ 94 131 // Callback definition. … … 107 144 }}} 108 145 109 More examples of overwriting the text checker implementation can be found at https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp146 More examples of overwriting the text checker implementation can be found [https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp here]. 110 147 111 148 == More detailed information == 112 You can find the unit tests of text checker API here: https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp.149 You can find the unit tests of text checker API [https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp here]. There are more test cases and examples of the API usage. WebKit-EFL's bots are building and testing text checker API. You can check their results [http://build.webkit.org/console?category=EFL here]. 113 150 114 There 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: http://build.webkit.org/console?category=EFL 115 116 Text checker documentation and its API can be found at: 117 * ewk_text_checker.h (https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h) 118 * ewk_settings.h (https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h) 151 The text checker documentation and its API can be found at: 152 * [https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h ewk_settings.h], 153 * [https://trac.webkit.org/browser/trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h ewk_text_checker.h]. 119 154 120 155 == Help, issues == … … 122 157 For issues with the text checker, please contact: 123 158 * Grzegorz Czajkowski - g.czajkowski (at) samsung.com 124 * Michal Roj (m.roj (at) samsung.com159 * Michal Roj - m.roj (at) samsung.com