From d1a0641a9194fabb76593e39ade1365f11473acf Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 9 Mar 2012 01:47:20 +0000 Subject: [PATCH] Implementando seleção por campo/palavra direto na biblioteca. --- src/include/lib3270/selection.h | 7 ++++--- src/lib3270/api.h | 22 +++++++++++++++++++--- src/lib3270/ctlr.c | 12 +++++------- src/lib3270/lib3270.cbp | 20 +++++++++++--------- src/lib3270/screenc.h | 1 - src/lib3270/selection.c | 38 +++++++++++++++++++++++++++++++++++++- 6 files changed, 76 insertions(+), 24 deletions(-) diff --git a/src/include/lib3270/selection.h b/src/include/lib3270/selection.h index 570263e..8d3b263 100644 --- a/src/include/lib3270/selection.h +++ b/src/include/lib3270/selection.h @@ -33,8 +33,9 @@ #define LIB3270_SELECTION_H_INCLUDED 1 - LIB3270_EXPORT void lib3270_clear_selection(H3270 *session); - LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr); - + LIB3270_EXPORT void lib3270_clear_selection(H3270 *session); + LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr); + LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr); + LIB3270_EXPORT int lib3270_select_field(H3270 *session, int baddr); #endif // LIB3270_SELECTION_H_INCLUDED diff --git a/src/lib3270/api.h b/src/lib3270/api.h index 3b7fd74..eebb3c4 100644 --- a/src/lib3270/api.h +++ b/src/lib3270/api.h @@ -383,7 +383,8 @@ const char *description; }; - LOCAL_EXTERN int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk); + // LOCAL_EXTERN int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk); + LOCAL_EXTERN void ring_bell(void); #define new_3270_session(m) lib3270_session_new(m) @@ -395,8 +396,23 @@ LOCAL_EXTERN void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); /* Set/Get screen contents */ - LOCAL_EXTERN int find_field_attribute(H3270 *session, int baddr); - LOCAL_EXTERN int find_field_length(H3270 *session, int baddr); + #define find_field_attribute(s,a) lib3270_field_addr(s,a) + #define find_field_length(s,a) find_field_length(s,a) + + /** + * Find the buffer address of the field attribute for a given buffer address. + * + * @param h Session handle. + * @param addr Buffer address of the field. + * + * @return field address or -1 if the screen isn't formatted. + * + */ + LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr); + + LIB3270_EXPORT int lib3270_field_length(H3270 *session, int baddr); + + LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr); LOCAL_EXTERN int screen_read(char *dest, int baddr, int count); LOCAL_EXTERN void Input_String(const unsigned char *str); diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index 4ddb39b..7dde932 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -320,11 +320,7 @@ static void ctlr_connect(H3270 *session, int ignored unused, void *dunno) -/* - * Find the buffer address of the field attribute for a given buffer address. - * Returns -1 if the screen isn't formatted. - */ -int find_field_attribute(H3270 *h, int baddr) +LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr) { int sbaddr; @@ -334,18 +330,20 @@ int find_field_attribute(H3270 *h, int baddr) return -1; sbaddr = baddr; - do { + do + { if (ea_buf[baddr].fa) return baddr; DEC_BA(baddr); } while (baddr != sbaddr); + return -1; } /* * Get Field width */ -int find_field_length(H3270 *h, int baddr) +int lib3270_field_length(H3270 *h, int baddr) { int saddr; int addr; diff --git a/src/lib3270/lib3270.cbp b/src/lib3270/lib3270.cbp index 0f891c7..3875529 100644 --- a/src/lib3270/lib3270.cbp +++ b/src/lib3270/lib3270.cbp @@ -7,8 +7,8 @@