From 6e811eaa4ff2134882145938a2ff799bde7e7a2b Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 5 Dec 2019 15:25:18 -0300 Subject: [PATCH] Adding method to get "paste-next" state. --- src/core/paste.c | 8 ++++++++ src/core/properties/boolean.c | 8 ++++++++ src/include/lib3270/selection.h | 16 ++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/core/paste.c b/src/core/paste.c index d451e28..bf91d73 100644 --- a/src/core/paste.c +++ b/src/core/paste.c @@ -413,6 +413,14 @@ LIB3270_EXPORT int lib3270_paste_text(H3270 *hSession, const unsigned char *str) return 0; } +LIB3270_EXPORT int lib3270_can_paste_next(const H3270 *hSession) +{ + if(!(lib3270_is_connected(hSession) && hSession->paste_buffer)) + return 0; + + return strlen(hSession->paste_buffer); +} + LIB3270_EXPORT int lib3270_paste_next(H3270 *hSession) { char * ptr; diff --git a/src/core/properties/boolean.c b/src/core/properties/boolean.c index 471b9e6..0a6be7f 100644 --- a/src/core/properties/boolean.c +++ b/src/core/properties/boolean.c @@ -38,6 +38,7 @@ #include #include #include + #include int lib3270_is_starting(const H3270 *hSession) { @@ -149,6 +150,13 @@ }, { + .name = "can_paste_next", // Property name. + .description = N_( "Still have text to paste" ), // Property description. + .get = lib3270_can_paste_next, // Get value. + .set = NULL // Set value. + }, + + { .name = "starting", // Property name. .description = N_( "Is starting (no first screen)?" ), // Property description. .get = lib3270_is_starting, // Get value. diff --git a/src/include/lib3270/selection.h b/src/include/lib3270/selection.h index 55fceae..665bcc0 100644 --- a/src/include/lib3270/selection.h +++ b/src/include/lib3270/selection.h @@ -117,14 +117,26 @@ /** * @brief Paste remaining string. * - * @param h Session handle. + * @param hSession Session handle. * * @see lib3270_paste_text. * * @return Non 0 if there's more to paste. * */ - LIB3270_EXPORT int lib3270_paste_next(H3270 *h); + LIB3270_EXPORT int lib3270_paste_next(H3270 *hSession); + + /** + * @brief Check if can paste next. + * + * @param hSession Session handle. + * + * @see lib3270_paste_next. + * + * @return Non 0 if there's more to paste. + * + */ + LIB3270_EXPORT int lib3270_can_paste_next(const H3270 *hSession); /** * @brief Move selected box 1 char in the selected direction. -- libgit2 0.21.2