From: Jihoon Kim Date: Tue, 26 Apr 2016 02:29:11 +0000 (+0900) Subject: Add synchronous API to get surrounding text X-Git-Tag: submit/tizen/20160426.060359~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5698366bc58852662f4d3db24832c993221fe426;p=platform%2Fcore%2Fuifw%2Flibscl-core.git Add synchronous API to get surrounding text Change-Id: I4f83a0b96a65584bdf180b74d31464fcb0868501 --- diff --git a/src/sclconnection-isf.cpp b/src/sclconnection-isf.cpp index 5d2f74c..f4dbdfe 100644 --- a/src/sclconnection-isf.cpp +++ b/src/sclconnection-isf.cpp @@ -949,6 +949,17 @@ void CSCLConnectionISF::get_surrounding_text(const sclchar *ic_uuid, sclint maxl } } +void CSCLConnectionISF::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) +{ + if (m_initialized) { + scim::String surrounding_text; + m_helper_agent.get_surrounding_text(maxlen_before, maxlen_after, surrounding_text, cursor); + + if (text) + *text = strdup(surrounding_text.c_str()); + } +} + void CSCLConnectionISF::delete_surrounding_text(sclint offset, sclint len) const { if (m_initialized) { diff --git a/src/sclconnection-isf.h b/src/sclconnection-isf.h index 26781a5..bdce63e 100644 --- a/src/sclconnection-isf.h +++ b/src/sclconnection-isf.h @@ -83,6 +83,7 @@ public: void get_keyboard_ise(const sclchar *uuid); 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); private: sclboolean m_initialized; diff --git a/src/sclconnection.cpp b/src/sclconnection.cpp index fba5e8f..2ab7aa1 100644 --- a/src/sclconnection.cpp +++ b/src/sclconnection.cpp @@ -273,6 +273,13 @@ void CSCLConnection::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_ } } +void CSCLConnection::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) +{ + if (m_impl) { + m_impl->get_surrounding_text(maxlen_before, maxlen_after, text, cursor); + } +} + void CSCLConnection::delete_surrounding_text(sclint offset, sclint len) const { if (m_impl) { diff --git a/src/sclconnection.h b/src/sclconnection.h index c6cb71e..a8a6388 100644 --- a/src/sclconnection.h +++ b/src/sclconnection.h @@ -83,6 +83,7 @@ public: virtual void get_keyboard_ise(const sclchar *uuid); 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); protected: std::string m_backend_identifier; diff --git a/src/sclcore.cpp b/src/sclcore.cpp index 7fa21c2..001488c 100644 --- a/src/sclcore.cpp +++ b/src/sclcore.cpp @@ -242,6 +242,13 @@ void CSCLCore::get_surrounding_text(const sclchar *ic_uuid, sclint maxlen_before } } +void CSCLCore::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const +{ + if (m_impl) { + m_impl->get_surrounding_text(maxlen_before, maxlen_after, text, cursor); + } +} + void CSCLCore::delete_surrounding_text(sclint offset, sclint len) const { if (m_impl) { diff --git a/src/sclcore.h b/src/sclcore.h index 7669d40..d560553 100644 --- a/src/sclcore.h +++ b/src/sclcore.h @@ -249,7 +249,7 @@ public: void update_geometry(sclint x, sclint y, sclint width, sclint height); /** - * @brief Request to get surrounding text. + * @brief Request to get surrounding text asynchronously. * * @param[in] ic_uuid The helper ISE UUID. * @param[in] maxlen_before The max length of before. @@ -343,6 +343,15 @@ public: void send_private_command(const sclchar *command); + /** + * @brief Request to get surrounding text synchronously. + * + * @param[in] maxlen_before The max length of before. + * @param[in] maxlen_after The max length of after. + * @param[out] text The surrounding text. + * @param[out] cursor The cursor position. + */ + void get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) const; private: CSCLCoreImpl *m_impl; }; diff --git a/src/sclcoreimpl.cpp b/src/sclcoreimpl.cpp index 84a6935..8c2da0c 100644 --- a/src/sclcoreimpl.cpp +++ b/src/sclcoreimpl.cpp @@ -232,6 +232,11 @@ void CSCLCoreImpl::get_surrounding_text(const sclchar* ic_uuid, sclint maxlen_be m_connection.get_surrounding_text(ic_uuid, maxlen_before, maxlen_after); } +void CSCLCoreImpl::get_surrounding_text(sclint maxlen_before, sclint maxlen_after, sclchar **text, int &cursor) +{ + m_connection.get_surrounding_text(maxlen_before, maxlen_after, text, cursor); +} + void CSCLCoreImpl::delete_surrounding_text(sclint offset, sclint len) const { m_connection.delete_surrounding_text(offset, len); diff --git a/src/sclcoreimpl.h b/src/sclcoreimpl.h index 40d774a..4df0782 100644 --- a/src/sclcoreimpl.h +++ b/src/sclcoreimpl.h @@ -101,6 +101,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); private: ISCLCoreEventCallback *m_event_callback;