diff --git a/src/include/lib3270/selection.h b/src/include/lib3270/selection.h index d8ca777..96f645a 100644 --- a/src/include/lib3270/selection.h +++ b/src/include/lib3270/selection.h @@ -183,4 +183,12 @@ */ LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end); + /** + * @brief Erase selected inputs. + * + * @param hSession Session handle. + * + */ + LIB3270_EXPORT int lib3270_erase_selected(H3270 *hSession); + #endif // LIB3270_SELECTION_H_INCLUDED diff --git a/src/lib3270/paste.c b/src/lib3270/paste.c index 628e579..1fa2362 100644 --- a/src/lib3270/paste.c +++ b/src/lib3270/paste.c @@ -108,7 +108,7 @@ if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE)) { baddr = hSession->cursor_addr; - while(BA_TO_COL(baddr) < lmargin) + while(BA_TO_COL(baddr) < ((unsigned int) lmargin)) { baddr = ROWCOL_TO_BA(BA_TO_ROW(baddr), lmargin); if (!ever) @@ -151,7 +151,7 @@ data->qtd++; - if(BA_TO_ROW(hSession->cursor_addr) != data->row) + if(BA_TO_ROW(hSession->cursor_addr) != ((unsigned int) data->row)) { trace("Row changed from %d to %d",data->row,BA_TO_ROW(hSession->cursor_addr)); if(!remargin(hSession,data->orig_col)) diff --git a/src/lib3270/private.h b/src/lib3270/private.h index dc8b146..74351aa 100644 --- a/src/lib3270/private.h +++ b/src/lib3270/private.h @@ -735,8 +735,10 @@ LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); #ifdef SSL_ENABLE_CRL_CHECK LIB3270_INTERNAL int lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message); LIB3270_INTERNAL int lib3270_check_X509_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message); - #endif // SSL_ENABLE_CRL_CHECK + /// @brief Clear element at adress. + LIB3270_INTERNAL void clear_chr(H3270 *hSession, int baddr); + #endif diff --git a/src/lib3270/selection/get.c b/src/lib3270/selection/get.c index 30d038d..4d97a75 100644 --- a/src/lib3270/selection/get.c +++ b/src/lib3270/selection/get.c @@ -35,7 +35,7 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ -static void clear_chr(H3270 *hSession, int baddr) +void clear_chr(H3270 *hSession, int baddr) { hSession->text[baddr].chr = ' '; diff --git a/src/lib3270/selection/selection.c b/src/lib3270/selection/selection.c index 6e57909..617f0ea 100644 --- a/src/lib3270/selection/selection.c +++ b/src/lib3270/selection/selection.c @@ -33,6 +33,7 @@ #include #include #include "3270ds.h" + #include "kybdc.h" /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -431,3 +432,30 @@ LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int return 0; } +LIB3270_EXPORT int lib3270_erase_selected(H3270 *hSession) +{ + FAIL_IF_NOT_ONLINE(hSession); + + if (hSession->kybdlock) + { + enq_action(hSession, lib3270_erase_selected); + return 0; + } + + unsigned int baddr = 0; + unsigned char fa = 0; + + for(baddr = 0; baddr < lib3270_get_length(hSession); baddr++) + { + if(hSession->ea_buf[baddr].fa) { + fa = hSession->ea_buf[baddr].fa; + } + + if( (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) && !FA_IS_PROTECTED(fa)) + { + clear_chr(hSession,baddr); + } + } + + return -1; +} -- libgit2 0.21.2