diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 9df75e9..c8184f9 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1150,7 +1150,6 @@ */ LIB3270_EXPORT int lib3270_field_length(H3270 *h, int baddr); - /** * @brief Get a terminal character and attribute. * @@ -1165,6 +1164,28 @@ LIB3270_EXPORT int lib3270_get_element(H3270 *h, int baddr, unsigned char *c, unsigned short *attr); /** + * @brief Check if the informed addr is marked as selected. + * + * @param h Session Handle. + * @param baddr Element address ((element_row*cols)+element_col) + * + * @return >0 zero if element is selected, 0 if not, -1 if fails (sets errno). + * + */ + LIB3270_EXPORT int lib3270_is_selected(H3270 *hSession, int baddr); + + /** + * @brief Get attribute at the requested ADDR. + * + * @param h Session Handle. + * @param baddr Element address ((element_row*cols)+element_col) + * + * @return Attribute of the required address or -1 if failed. + * + */ + LIB3270_EXPORT LIB3270_ATTR lib3270_get_attribute_at_address(H3270 *hSession, int baddr); + + /** * Get field region * * @param h Session handle. diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 3206c5a..049e4e8 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -93,6 +93,33 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att session->cbk.update(session,baddr,c,attr,baddr == session->cursor_addr); } +LIB3270_EXPORT LIB3270_ATTR lib3270_get_attribute_at_address(H3270 *hSession, int baddr) +{ + if(check_online_session(hSession)) + return (LIB3270_ATTR) -1; + + if(!hSession->text || baddr < 0 || baddr > (hSession->rows*hSession->cols)) + { + errno = EINVAL; + return (LIB3270_ATTR) -1; + } + + return hSession->text[baddr].attr; +} + +LIB3270_EXPORT int lib3270_is_selected(H3270 *hSession, int baddr) +{ + FAIL_IF_NOT_ONLINE(hSession); + + if(!hSession->text || baddr < 0 || baddr > (hSession->rows*hSession->cols)) + { + errno = EINVAL; + return -1; + } + + return (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) != 0; +} + LIB3270_EXPORT int lib3270_get_element(H3270 *hSession, int baddr, unsigned char *c, unsigned short *attr) { FAIL_IF_NOT_ONLINE(hSession); -- libgit2 0.21.2