diff --git a/api.h b/api.h
index 3b7fd74..eebb3c4 100644
--- a/api.h
+++ b/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/ctlr.c b/ctlr.c
index 4ddb39b..7dde932 100644
--- a/ctlr.c
+++ b/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/lib3270.cbp b/lib3270.cbp
index 0f891c7..3875529 100644
--- a/lib3270.cbp
+++ b/lib3270.cbp
@@ -7,8 +7,8 @@
-
-
+
+
@@ -21,8 +21,8 @@
-
-
+
+
@@ -35,8 +35,8 @@
-
-
+
+
@@ -53,10 +53,12 @@
-
-
+
+
-
+
+
+
diff --git a/screenc.h b/screenc.h
index fbc3fa0..4a3d29e 100644
--- a/screenc.h
+++ b/screenc.h
@@ -27,7 +27,6 @@
#define screen_80() /* */
-LIB3270_INTERNAL void ring_bell(void);
LIB3270_INTERNAL void screen_erase(H3270 *session);
LIB3270_INTERNAL void screen_changed(H3270 *session, int bstart, int bend);
LIB3270_INTERNAL int screen_init(H3270 *session);
diff --git a/selection.c b/selection.c
index 412792f..cb37a70 100644
--- a/selection.c
+++ b/selection.c
@@ -178,7 +178,6 @@ LIB3270_EXPORT void lib3270_clear_selection(H3270 *session)
}
-
LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr)
{
CHECK_SESSION_HANDLE(session);
@@ -195,3 +194,40 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr)
}
+LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr)
+{
+ int pos, len;
+
+ CHECK_SESSION_HANDLE(session);
+
+ for(pos = baddr; pos > 0 && !isspace(ea_buf[pos].chr);pos--);
+ session->selected.begin = pos;
+
+ len = session->rows * session->cols;
+ for(pos = baddr; pos < len && !isspace(ea_buf[pos].chr);pos++);
+ session->selected.end = pos;
+
+ update_selected_region(session);
+}
+
+LIB3270_EXPORT int lib3270_select_field(H3270 *session, int baddr)
+{
+ int start;
+
+ CHECK_SESSION_HANDLE(session);
+
+ start = lib3270_field_addr(session,baddr);
+
+ if(start < 0)
+ {
+ ring_bell();
+ return -1;
+ }
+
+ session->selected.begin = start;
+ session->selected.end = start + lib3270_field_length(session,start);
+
+ update_selected_region(session);
+
+ return 0;
+}
--
libgit2 0.21.2