Add a new API for set_selection in inputmethod 93/53593/7
authorsungwook79.park <sungwook79.park@samsung.com>
Tue, 8 Dec 2015 04:41:34 +0000 (13:41 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 3 May 2016 05:03:36 +0000 (22:03 -0700)
Change-Id: I955e82ba9ccb6b3be190785d19372511d112fe3d

include/inputmethod.h
src/inputmethod.cpp

index 6b38eaa..27e4d5f 100644 (file)
@@ -1599,6 +1599,26 @@ EXPORT_API int ime_delete_surrounding_text(int offset, int len);
 EXPORT_API int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, int *cursor_pos);
 
 /**
+ * @brief Requests to set selection.
+ *
+ * @since_tizen 3.0
+ *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/ime
+ *
+ * @param[in] start The start cursor position in text (in characters not bytes)
+ * @param[in] end The end cursor position in text (in characters not bytes)
+ *
+ * @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_set_selection(int start, int end);
+
+/**
  * @brief This API returns the pointer of input panel main window.
  *
  * @remarks The specific error code can be obtained using the get_last_result() method if this function returns NULL.
index f90de02..01c08e6 100644 (file)
@@ -1107,6 +1107,31 @@ int ime_get_surrounding_text(int maxlen_before, int maxlen_after, char **text, i
     return IME_ERROR_NONE;
 }
 
+int ime_set_selection(int start, int end)
+{
+    ime_error_e retVal = IME_ERROR_NONE;
+
+    if (start < 0) {
+        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.set_selection(start, end);
+
+    return IME_ERROR_NONE;
+}
+
 Evas_Object* ime_get_main_window(void)
 {
     ime_error_e retVal = IME_ERROR_NONE;