From: Jihoon Kim Date: Wed, 27 Apr 2016 06:46:04 +0000 (+0900) Subject: Add synchronous API to get selection text X-Git-Tag: accepted/tizen/common/20160428.144312~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4191bb6cf55e91aa7e07cec1ae8aa663a1504efe;p=platform%2Fcore%2Fuifw%2Flibscl-core.git Add synchronous API to get selection text Change-Id: I1732b11a8d53911126f421a399e11275a7b40d3c --- diff --git a/src/sclconnection-isf.cpp b/src/sclconnection-isf.cpp index f4dbdfe..5bb30a3 100644 --- a/src/sclconnection-isf.cpp +++ b/src/sclconnection-isf.cpp @@ -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()); } } diff --git a/src/sclconnection-isf.h b/src/sclconnection-isf.h index bdce63e..0d8bd5b 100644 --- a/src/sclconnection-isf.h +++ b/src/sclconnection-isf.h @@ -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; diff --git a/src/sclconnection.cpp b/src/sclconnection.cpp index 2ab7aa1..6a7b6e2 100644 --- a/src/sclconnection.cpp +++ b/src/sclconnection.cpp @@ -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); + } +} diff --git a/src/sclconnection.h b/src/sclconnection.h index a8a6388..806c4da 100644 --- a/src/sclconnection.h +++ b/src/sclconnection.h @@ -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; diff --git a/src/sclcore.cpp b/src/sclcore.cpp index 001488c..2749ee2 100644 --- a/src/sclcore.cpp +++ b/src/sclcore.cpp @@ -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); + } +} diff --git a/src/sclcore.h b/src/sclcore.h index d560553..3a5d909 100644 --- a/src/sclcore.h +++ b/src/sclcore.h @@ -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; }; diff --git a/src/sclcoreimpl.cpp b/src/sclcoreimpl.cpp index 8c2da0c..f5d5591 100644 --- a/src/sclcoreimpl.cpp +++ b/src/sclcoreimpl.cpp @@ -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 diff --git a/src/sclcoreimpl.h b/src/sclcoreimpl.h index 4df0782..78c84be 100644 --- a/src/sclcoreimpl.h +++ b/src/sclcoreimpl.h @@ -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;