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 f4dbdfe..5bb30a3 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 bdce63e..0d8bd5b 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 2ab7aa1..6a7b6e2 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 a8a6388..806c4da 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 001488c..2749ee2 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 d560553..3a5d909 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 8c2da0c..f5d5591 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 4df0782..78c84be 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;