Commit 8717dba1ca05adf8b2a475e9d07f5350b8d61b8d

Authored by Perry Werneck
1 parent 64d1f0f8

Adding methods to get attributes from address.

Showing 2 changed files with 49 additions and 1 deletions   Show diff stats
src/include/lib3270.h
... ... @@ -1150,7 +1150,6 @@
1150 1150 */
1151 1151 LIB3270_EXPORT int lib3270_field_length(H3270 *h, int baddr);
1152 1152  
1153   -
1154 1153 /**
1155 1154 * @brief Get a terminal character and attribute.
1156 1155 *
... ... @@ -1165,6 +1164,28 @@
1165 1164 LIB3270_EXPORT int lib3270_get_element(H3270 *h, int baddr, unsigned char *c, unsigned short *attr);
1166 1165  
1167 1166 /**
  1167 + * @brief Check if the informed addr is marked as selected.
  1168 + *
  1169 + * @param h Session Handle.
  1170 + * @param baddr Element address ((element_row*cols)+element_col)
  1171 + *
  1172 + * @return >0 zero if element is selected, 0 if not, -1 if fails (sets errno).
  1173 + *
  1174 + */
  1175 + LIB3270_EXPORT int lib3270_is_selected(H3270 *hSession, int baddr);
  1176 +
  1177 + /**
  1178 + * @brief Get attribute at the requested ADDR.
  1179 + *
  1180 + * @param h Session Handle.
  1181 + * @param baddr Element address ((element_row*cols)+element_col)
  1182 + *
  1183 + * @return Attribute of the required address or -1 if failed.
  1184 + *
  1185 + */
  1186 + LIB3270_EXPORT LIB3270_ATTR lib3270_get_attribute_at_address(H3270 *hSession, int baddr);
  1187 +
  1188 + /**
1168 1189 * Get field region
1169 1190 *
1170 1191 * @param h Session handle.
... ...
src/lib3270/screen.c
... ... @@ -93,6 +93,33 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att
93 93 session->cbk.update(session,baddr,c,attr,baddr == session->cursor_addr);
94 94 }
95 95  
  96 +LIB3270_EXPORT LIB3270_ATTR lib3270_get_attribute_at_address(H3270 *hSession, int baddr)
  97 +{
  98 + if(check_online_session(hSession))
  99 + return (LIB3270_ATTR) -1;
  100 +
  101 + if(!hSession->text || baddr < 0 || baddr > (hSession->rows*hSession->cols))
  102 + {
  103 + errno = EINVAL;
  104 + return (LIB3270_ATTR) -1;
  105 + }
  106 +
  107 + return hSession->text[baddr].attr;
  108 +}
  109 +
  110 +LIB3270_EXPORT int lib3270_is_selected(H3270 *hSession, int baddr)
  111 +{
  112 + FAIL_IF_NOT_ONLINE(hSession);
  113 +
  114 + if(!hSession->text || baddr < 0 || baddr > (hSession->rows*hSession->cols))
  115 + {
  116 + errno = EINVAL;
  117 + return -1;
  118 + }
  119 +
  120 + return (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) != 0;
  121 +}
  122 +
96 123 LIB3270_EXPORT int lib3270_get_element(H3270 *hSession, int baddr, unsigned char *c, unsigned short *attr)
97 124 {
98 125 FAIL_IF_NOT_ONLINE(hSession);
... ...