From eb9067bee6f1cacd5222b0c018acaacdd6160677 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 29 Jul 2019 14:18:38 -0300 Subject: [PATCH] Adding option to get the entire terminal window as selection. --- src/include/lib3270/selection.h | 3 ++- src/selection/get.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/include/lib3270/selection.h b/src/include/lib3270/selection.h index 8c9b665..05a1a8e 100644 --- a/src/include/lib3270/selection.h +++ b/src/include/lib3270/selection.h @@ -190,11 +190,12 @@ * * @param hSession Session handle. * @param cut Non zero to clear selected contents. + * @param all Non zero to get entire terminal, zero to get only the selected rectangle. * * @return NULL on error (sets errno), pointer to a rectangle containing the selected area (release it with lib3270_free). * */ - LIB3270_EXPORT lib3270_selection * lib3270_get_selection(H3270 *hSession, int cut); + LIB3270_EXPORT lib3270_selection * lib3270_get_selection(H3270 *hSession, int cut, int all); /** * @brief Get bitmasked flag for the current selection. diff --git a/src/selection/get.c b/src/selection/get.c index 56c71e5..4481b3c 100644 --- a/src/selection/get.c +++ b/src/selection/get.c @@ -144,11 +144,21 @@ LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) return lib3270_get_selected_text(hSession,0,LIB3270_SELECTION_CUT); } -LIB3270_EXPORT lib3270_selection * lib3270_get_selection(H3270 *hSession, int cut) +LIB3270_EXPORT lib3270_selection * lib3270_get_selection(H3270 *hSession, int cut, int all) { + if(check_online_session(hSession)) + return NULL; + // Get block size unsigned int row, col, width, height; - if(lib3270_get_selection_rectangle(hSession, &row, &col, &width, &height)) + + if(all) + { + row = col = 0; + width = lib3270_get_width(hSession); + height = lib3270_get_height(hSession); + } + else if(lib3270_get_selection_rectangle(hSession, &row, &col, &width, &height)) { return NULL; } -- libgit2 0.21.2