Add synchronous API to get selection text 23/67523/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 27 Apr 2016 06:46:04 +0000 (15:46 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 27 Apr 2016 06:46:04 +0000 (15:46 +0900)
Change-Id: I1732b11a8d53911126f421a399e11275a7b40d3c

src/sclconnection-isf.cpp
src/sclconnection-isf.h
src/sclconnection.cpp
src/sclconnection.h
src/sclcore.cpp
src/sclcore.h
src/sclcoreimpl.cpp
src/sclcoreimpl.h

index f4dbdfef9e950a02a145b3ce45b4c000d54e5c9a..5bb30a3942e751ea1c3e3de4efb9065e5423fa7c 100644 (file)
@@ -1008,14 +1008,25 @@ void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid)
 void CSCLConnectionISF::set_selection(sclint start, sclint end)
 {
     if (m_initialized) {
-       m_helper_agent.set_selection(start, end);
+        m_helper_agent.set_selection(start, end);
     }
 }
 
 void CSCLConnectionISF::send_private_command(const sclchar *command)
 {
     if (m_initialized) {
-       m_helper_agent.send_private_command(command);
+        m_helper_agent.send_private_command(command);
+    }
+}
+
+void CSCLConnectionISF::get_selection_text(sclchar **text)
+{
+    if (m_initialized) {
+        scim::String selection_text;
+        m_helper_agent.get_selection(selection_text);
+
+        if (text)
+            *text = strdup(selection_text.c_str());
     }
 }
 
index bdce63ebe0c6e83a527c1f297e789ecbfa6ee5a5..0d8bd5bbb331e73be08314e162708969594ea4ce 100644 (file)
@@ -84,6 +84,7 @@ public:
     void set_selection(sclint start, sclint end);
     void send_private_command(const char *command);
     void get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor);
+    void get_selection_text(sclchar **text);
 private:
     sclboolean m_initialized;
 
index 2ab7aa1b3cceb7a9167d0750f2d8bdb7577ce028..6a7b6e21efafdf6745e66f5535ae3da55ec833e5 100644 (file)
@@ -335,3 +335,10 @@ void CSCLConnection::send_private_command(const sclchar *command)
         m_impl->send_private_command(command);
     }
 }
+
+void CSCLConnection::get_selection_text(sclchar **text)
+{
+    if (m_impl) {
+        m_impl->get_selection_text(text);
+    }
+}
index a8a63885928913b6719d1fb209d79690dc2bcedf..806c4da467859da713e4bc498e7876a971493281 100644 (file)
@@ -84,6 +84,7 @@ public:
     virtual void set_selection(sclint start, sclint end);
     virtual void send_private_command(const sclchar *command);
     virtual void get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor);
+    virtual void get_selection_text(sclchar **text);
 protected:
     std::string m_backend_identifier;
 
index 001488cc8ab78e866af010a66ed2308710459c34..2749ee2912e0aebe157eeeab2cea78dcc3a417ec 100644 (file)
@@ -336,3 +336,10 @@ void CSCLCore::send_private_command(const sclchar *command)
         m_impl->send_private_command(command);
     }
 }
+
+void CSCLCore::get_selection_text(sclchar **text) const
+{
+    if (m_impl) {
+        m_impl->get_selection_text(text);
+    }
+}
index d560553bad468ceb9f1783906974ead33d8d2e97..3a5d909d87670e36782ec8232c4c9ae473569e20 100644 (file)
@@ -352,6 +352,13 @@ public:
      * @param[out] cursor The cursor position.
      */
     void get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const;
+
+    /**
+     * @brief Get the selected text.
+     *
+     * @param[out] text The surrounding text.
+     */
+    void get_selection_text(sclchar **text) const;
 private:
     CSCLCoreImpl *m_impl;
 };
index 8c2da0cea24bfbc749aaec06190ee5ccc17ac8b6..f5d55914681ac4fcefc8187c2d85482f1ff534d9 100644 (file)
@@ -352,3 +352,8 @@ void CSCLCoreImpl::send_private_command(const sclchar *command)
 {
     m_connection.send_private_command(command);
 }
+
+void CSCLCoreImpl::get_selection_text(sclchar **text)
+{
+    m_connection.get_selection_text(text);
+}
\ No newline at end of file
index 4df078228f46f7d068c66ed7c20ba2f4c82cc3c4..78c84bebe58fb91846f02abaca6ac04550616558 100644 (file)
@@ -102,6 +102,7 @@ public:
     void set_selection(sclint start, sclint end);
     void send_private_command(const sclchar *command);
     void get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor);
+    void get_selection_text(sclchar **text);
 
 private:
     ISCLCoreEventCallback *m_event_callback;