Add ime_get_selected_text API for getting selected text 31/149231/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 12 Sep 2017 02:17:28 +0000 (11:17 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 13 Sep 2017 02:27:22 +0000 (11:27 +0900)
Change-Id: I436301569f9e6bca3459ba193ade28747562d9d7
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
include/inputmethod.h
src/inputmethod.cpp

index 11b51f3fd4d186ec92d3984eb173947bc0a39e59..a6dccc3754a45b856685deacbb2d88887663105f 100644 (file)
@@ -1664,6 +1664,27 @@ int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, i
  */
 int ime_set_selection(int start, int end);
 
+/**
+ * @brief Gets the selected text synchronously.
+ *
+ * @remarks @a text must be released using free().
+ *
+ * @since_tizen 4.0
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @param[out] text The selected text
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #IME_ERROR_NONE No error
+ * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
+ * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet
+ */
+EXPORT_API int ime_get_selected_text(char **text);
+
 /**
  * @brief This API returns the pointer of input panel main window.
  *
index 2f36cf30120f86833502d004173c3a7632b480c9..99fa9e7ad3c754ca9dc1c7ef79dae023d48b8756 100644 (file)
@@ -1246,6 +1246,31 @@ EXPORT_API int ime_set_selection(int start, int end)
     return IME_ERROR_NONE;
 }
 
+EXPORT_API int ime_get_selected_text(char **text)
+{
+    ime_error_e retVal = IME_ERROR_NONE;
+
+    if (!text) {
+        LOGW("IME_ERROR_INVALID_PARAMETER");
+        return IME_ERROR_INVALID_PARAMETER;
+    }
+
+    if (!g_running) {
+        LOGW("IME_ERROR_NOT_RUNNING");
+        return IME_ERROR_NOT_RUNNING;
+    }
+
+    retVal = _check_privilege();
+    if (retVal != IME_ERROR_NONE) {
+        LOGE("_check_privilege returned %d.", retVal);
+        return retVal;
+    }
+
+    g_core.get_selection_text(text);
+
+    return IME_ERROR_NONE;
+}
+
 EXPORT_API Evas_Object* ime_get_main_window(void)
 {
     ime_error_e retVal = IME_ERROR_NONE;