Commit c28dbb001398128a3356c1d62796a21c775979e2
1 parent
90abdceb
Exists in
master
and in
5 other branches
Expandingo plugin rexx
Showing
12 changed files
with
317 additions
and
15 deletions
Show diff stats
src/include/lib3270.h
... | ... | @@ -509,18 +509,17 @@ |
509 | 509 | */ |
510 | 510 | LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr); |
511 | 511 | |
512 | - LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, int row, int col); | |
513 | - | |
514 | 512 | /** |
515 | - * Move cursor | |
513 | + * Set cursor position. | |
516 | 514 | * |
517 | 515 | * @param h Session handle. |
518 | - * @param dir Direction to move | |
519 | - * @param sel Non zero to move and selected to the current cursor position | |
516 | + * @param row New cursor row. | |
517 | + * @param col New cursor col. | |
518 | + * | |
519 | + * @return last cursor address. | |
520 | 520 | * |
521 | - * @return 0 if the movement can be done, non zero if failed. | |
522 | 521 | */ |
523 | - LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); | |
522 | + LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, int row, int col); | |
524 | 523 | |
525 | 524 | /** |
526 | 525 | * get cursor address. |
... | ... | @@ -532,6 +531,18 @@ |
532 | 531 | */ |
533 | 532 | LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h); |
534 | 533 | |
534 | + | |
535 | + /** | |
536 | + * Move cursor | |
537 | + * | |
538 | + * @param h Session handle. | |
539 | + * @param dir Direction to move | |
540 | + * @param sel Non zero to move and selected to the current cursor position | |
541 | + * | |
542 | + * @return 0 if the movement can be done, non zero if failed. | |
543 | + */ | |
544 | + LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); | |
545 | + | |
535 | 546 | /** |
536 | 547 | * Print page |
537 | 548 | * | ... | ... |
src/plugins/dbus3270/gobject.c
... | ... | @@ -222,6 +222,23 @@ void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar * |
222 | 222 | g_free(text); |
223 | 223 | } |
224 | 224 | |
225 | +void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context) | |
226 | +{ | |
227 | + gchar * text; | |
228 | + H3270 * hSession = pw3270_dbus_get_session_handle(object); | |
229 | + | |
230 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
231 | + if(pw3270_dbus_check_valid_state(object,context)) | |
232 | + return; | |
233 | + | |
234 | + text = g_convert_with_fallback(utftext,-1,lib3270_get_charset(hSession),"UTF-8","?",NULL,NULL,NULL); | |
235 | + | |
236 | + dbus_g_method_return(context,lib3270_emulate_input(hSession,(const char *) text,-1,1)); | |
237 | + | |
238 | + g_free(text); | |
239 | +} | |
240 | + | |
241 | + | |
225 | 242 | void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context) |
226 | 243 | { |
227 | 244 | gchar * text; |
... | ... | @@ -282,6 +299,18 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus |
282 | 299 | dbus_g_method_return(context,lib3270_set_cursor_position(pw3270_dbus_get_session_handle(object),row,col)); |
283 | 300 | } |
284 | 301 | |
302 | + void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context) | |
303 | + { | |
304 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
305 | + dbus_g_method_return(context,lib3270_set_cursor_address(pw3270_dbus_get_session_handle(object),addr)); | |
306 | + } | |
307 | + | |
308 | + void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context) | |
309 | + { | |
310 | + trace("%s object=%p context=%p",__FUNCTION__,object,context); | |
311 | + dbus_g_method_return(context,lib3270_get_cursor_address(pw3270_dbus_get_session_handle(object))); | |
312 | + } | |
313 | + | |
285 | 314 | void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context) |
286 | 315 | { |
287 | 316 | trace("%s object=%p context=%p",__FUNCTION__,object,context); | ... | ... |
src/plugins/dbus3270/pw3270dbus.xml
... | ... | @@ -44,6 +44,10 @@ |
44 | 44 | <arg type="i" name="key" direction="in" /> |
45 | 45 | <arg type="i" name="result" direction="out" /> |
46 | 46 | </method> |
47 | + <method name="input"> | |
48 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
49 | + <arg type="s" name="text" direction="in" /> | |
50 | + </method> | |
47 | 51 | <method name="setTextAt"> |
48 | 52 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
49 | 53 | <arg type="i" name="row" direction="in" /> |
... | ... | @@ -80,6 +84,15 @@ |
80 | 84 | <arg type="i" name="col" direction="in" /> |
81 | 85 | <arg type="i" name="result" direction="out" /> |
82 | 86 | </method> |
87 | + <method name="setCursorAddress"> | |
88 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
89 | + <arg type="i" name="addr" direction="in" /> | |
90 | + <arg type="i" name="result" direction="out" /> | |
91 | + </method> | |
92 | + <method name="getCursorAddress"> | |
93 | + <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> | |
94 | + <arg type="i" name="addr" direction="out" /> | |
95 | + </method> | |
83 | 96 | <method name="setToggle"> |
84 | 97 | <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> |
85 | 98 | <arg type="i" name="id" direction="in" /> | ... | ... |
src/plugins/dbus3270/service.h
... | ... | @@ -76,7 +76,11 @@ |
76 | 76 | void pw3270_dbus_is_connected(PW3270Dbus *object, DBusGMethodInvocation *context); |
77 | 77 | void pw3270_dbus_is_ready(PW3270Dbus *object, DBusGMethodInvocation *context); |
78 | 78 | void pw3270_dbus_in_tn3270_e(PW3270Dbus *object, DBusGMethodInvocation *context); |
79 | + | |
79 | 80 | void pw3270_dbus_set_cursor_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context); |
81 | + void pw3270_dbus_set_cursor_address(PW3270Dbus *object, int addr, DBusGMethodInvocation *context); | |
82 | + void pw3270_dbus_get_cursor_address(PW3270Dbus *object, DBusGMethodInvocation *context); | |
83 | + | |
80 | 84 | void pw3270_dbus_set_toggle(PW3270Dbus *object, int id, int value, DBusGMethodInvocation *context); |
81 | 85 | |
82 | 86 | void pw3270_dbus_wait_for_ready(PW3270Dbus *object, int timeout, DBusGMethodInvocation *context); |
... | ... | @@ -91,6 +95,7 @@ |
91 | 95 | void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); |
92 | 96 | void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); |
93 | 97 | void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); |
98 | + void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); | |
94 | 99 | |
95 | 100 | G_END_DECLS |
96 | 101 | ... | ... |
src/plugins/rx3270/local.cc
... | ... | @@ -72,8 +72,11 @@ |
72 | 72 | char * get_text_at(int row, int col, size_t sz); |
73 | 73 | int cmp_text_at(int row, int col, const char *text); |
74 | 74 | int set_text_at(int row, int col, const char *str); |
75 | + int emulate_input(const char *str); | |
75 | 76 | |
76 | 77 | int set_cursor_position(int row, int col); |
78 | + int set_cursor_addr(int addr); | |
79 | + int get_cursor_addr(void); | |
77 | 80 | |
78 | 81 | int set_toggle(LIB3270_TOGGLE ix, bool value); |
79 | 82 | |
... | ... | @@ -106,6 +109,9 @@ |
106 | 109 | int (*_set_toggle)(H3270 *h, LIB3270_TOGGLE ix, int value); |
107 | 110 | int (*_get_field_start)(H3270 *h, int baddr); |
108 | 111 | int (*_get_field_len)(H3270 *h, int baddr); |
112 | + int (*_set_cursor_addr)(H3270 *h, int addr); | |
113 | + int (*_get_cursor_addr)(H3270 *h); | |
114 | + int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting); | |
109 | 115 | |
110 | 116 | #ifdef WIN32 |
111 | 117 | HMODULE hModule; |
... | ... | @@ -235,6 +241,9 @@ dynamic::dynamic() |
235 | 241 | { (void **) & _set_toggle, "lib3270_set_toggle" }, |
236 | 242 | { (void **) & _get_field_start, "lib3270_get_field_start" }, |
237 | 243 | { (void **) & _get_field_len, "lib3270_get_field_len" }, |
244 | + { (void **) & _set_cursor_addr, "lib3270_set_cursor_address" }, | |
245 | + { (void **) & _get_cursor_addr, "lib3270_get_cursor_address" }, | |
246 | + { (void **) & _emulate_input, "lib3270_emulate_input" }, | |
238 | 247 | |
239 | 248 | }; |
240 | 249 | |
... | ... | @@ -533,3 +542,23 @@ int dynamic::get_field_len(int baddr) |
533 | 542 | return -1; |
534 | 543 | } |
535 | 544 | |
545 | +int dynamic::set_cursor_addr(int addr) | |
546 | +{ | |
547 | + if(hModule) | |
548 | + return _set_cursor_addr(hSession,addr); | |
549 | + return -1; | |
550 | +} | |
551 | + | |
552 | +int dynamic::get_cursor_addr(void) | |
553 | +{ | |
554 | + if(hModule) | |
555 | + return _get_cursor_addr(hSession); | |
556 | + return -1; | |
557 | +} | |
558 | + | |
559 | +int dynamic::emulate_input(const char *str) | |
560 | +{ | |
561 | + if(hModule) | |
562 | + return _emulate_input(hSession,str,-1,1); | |
563 | + return -1; | |
564 | +} | ... | ... |
src/plugins/rx3270/pluginmain.cc
... | ... | @@ -87,6 +87,9 @@ |
87 | 87 | int set_text_at(int row, int col, const char *str); |
88 | 88 | |
89 | 89 | int set_cursor_position(int row, int col); |
90 | + int set_cursor_addr(int addr); | |
91 | + int get_cursor_addr(void); | |
92 | + int emulate_input(const char *str); | |
90 | 93 | |
91 | 94 | int set_toggle(LIB3270_TOGGLE ix, bool value); |
92 | 95 | |
... | ... | @@ -282,6 +285,21 @@ |
282 | 285 | g_free(ptr); |
283 | 286 | } |
284 | 287 | |
288 | + int plugin::set_cursor_addr(int addr) | |
289 | + { | |
290 | + return lib3270_set_cursor_address(hSession,addr); | |
291 | + } | |
292 | + | |
293 | + int plugin::get_cursor_addr(void) | |
294 | + { | |
295 | + return lib3270_get_cursor_address(hSession); | |
296 | + } | |
297 | + | |
298 | + int plugin::emulate_input(const char *str) | |
299 | + { | |
300 | + return lib3270_emulate_input(hSession, str, -1, 1); | |
301 | + } | |
302 | + | |
285 | 303 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) |
286 | 304 | { |
287 | 305 | trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); |
... | ... | @@ -336,10 +354,10 @@ |
336 | 354 | GTK_DIALOG_DESTROY_WITH_PARENT, |
337 | 355 | GTK_MESSAGE_ERROR, |
338 | 356 | GTK_BUTTONS_CANCEL, |
339 | - "%s", _( "Can't start script" )); | |
357 | + _( "Can't start %s script" ), "rexx" ); | |
340 | 358 | |
341 | 359 | gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" )); |
342 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",_( "Can't create rexx interpreter instance" )); | |
360 | + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),_( "Can't create %s interpreter instance" ), "rexx"); | |
343 | 361 | |
344 | 362 | gtk_dialog_run(GTK_DIALOG (dialog)); |
345 | 363 | gtk_widget_destroy(dialog); |
... | ... | @@ -383,13 +401,14 @@ |
383 | 401 | GTK_DIALOG_DESTROY_WITH_PARENT, |
384 | 402 | GTK_MESSAGE_ERROR, |
385 | 403 | GTK_BUTTONS_CANCEL, |
386 | - "%s", _( "Rexx script failed" )); | |
404 | + _( "%s script failed" ), "Rexx" ); | |
387 | 405 | |
388 | 406 | gtk_window_set_title(GTK_WINDOW(dialog),_( "Rexx error" )); |
389 | 407 | |
390 | 408 | gtk_message_dialog_format_secondary_text( |
391 | 409 | GTK_MESSAGE_DIALOG(dialog), |
392 | - _( "Rexx error %d: %s\n%s" ), | |
410 | + _( "%s error %d: %s\n%s" ), | |
411 | + "Rexx", | |
393 | 412 | (int) condition.code, |
394 | 413 | threadContext->CString(condition.errortext), |
395 | 414 | threadContext->CString(condition.message) |
... | ... | @@ -471,7 +490,7 @@ extern "C" |
471 | 490 | gtk_file_filter_add_pattern(filter[f],list[f].pattern); |
472 | 491 | } |
473 | 492 | |
474 | - filename = pw3270_get_filename(widget,"rexx","script",filter,_( "Select Rexx script to run" )); | |
493 | + filename = pw3270_get_filename(widget,"rexx","script",filter,_( "Select script to run" )); | |
475 | 494 | |
476 | 495 | if(filename) |
477 | 496 | { | ... | ... |
src/plugins/rx3270/remote.cc
... | ... | @@ -65,10 +65,13 @@ |
65 | 65 | char * get_text_at(int row, int col, size_t sz); |
66 | 66 | int cmp_text_at(int row, int col, const char *text); |
67 | 67 | int set_text_at(int row, int col, const char *str); |
68 | + int emulate_input(const char *str); | |
68 | 69 | |
69 | 70 | int wait_for_text_at(int row, int col, const char *key, int timeout); |
70 | 71 | |
71 | 72 | int set_cursor_position(int row, int col); |
73 | + int set_cursor_addr(int addr); | |
74 | + int get_cursor_addr(void); | |
72 | 75 | |
73 | 76 | int set_toggle(LIB3270_TOGGLE ix, bool value); |
74 | 77 | |
... | ... | @@ -799,6 +802,44 @@ int remote::set_text_at(int row, int col, const char *str) |
799 | 802 | return -1; |
800 | 803 | } |
801 | 804 | |
805 | +int remote::emulate_input(const char *str) | |
806 | +{ | |
807 | +#if defined(WIN32) | |
808 | + | |
809 | + if(hPipe != INVALID_HANDLE_VALUE) | |
810 | + { | |
811 | + size_t len = strlen(str); | |
812 | + struct hllapi_packet_emulate_input * query; | |
813 | + struct hllapi_packet_result response; | |
814 | + DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+len; | |
815 | + | |
816 | + query = (struct hllapi_packet_emulate_input *) malloc(cbSize); | |
817 | + query->packet_id = HLLAPI_PACKET_EMULATE_INPUT; | |
818 | + query->len = len; | |
819 | + query->pasting = 1; | |
820 | + strcpy(query->text,str); | |
821 | + | |
822 | + TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
823 | + | |
824 | + free(query); | |
825 | + | |
826 | + return response.rc; | |
827 | + } | |
828 | + | |
829 | +#elif defined(HAVE_DBUS) | |
830 | + | |
831 | + DBusMessage * msg = create_message("input"); | |
832 | + if(msg) | |
833 | + { | |
834 | + dbus_message_append_args(msg, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID); | |
835 | + return get_intval(call(msg)); | |
836 | + } | |
837 | + | |
838 | +#endif | |
839 | + | |
840 | + return -1; | |
841 | +} | |
842 | + | |
802 | 843 | int remote::set_cursor_position(int row, int col) |
803 | 844 | { |
804 | 845 | #if defined(WIN32) |
... | ... | @@ -1031,3 +1072,56 @@ char * remote::get_text(int baddr, size_t len) |
1031 | 1072 | #warning IMPLEMENTAR |
1032 | 1073 | return NULL; |
1033 | 1074 | } |
1075 | + | |
1076 | +int remote::set_cursor_addr(int addr) | |
1077 | +{ | |
1078 | +#if defined(WIN32) | |
1079 | + | |
1080 | + if(hPipe != INVALID_HANDLE_VALUE) | |
1081 | + { | |
1082 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_LEN, (unsigned short) addr }; | |
1083 | + struct hllapi_packet_result response; | |
1084 | + DWORD cbSize = sizeof(query); | |
1085 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
1086 | + return response.rc; | |
1087 | + } | |
1088 | + | |
1089 | +#elif defined(HAVE_DBUS) | |
1090 | + | |
1091 | + dbus_int32_t k = (dbus_int32_t) addr; | |
1092 | + | |
1093 | + DBusMessage * msg = create_message("setCursorAddress"); | |
1094 | + if(msg) | |
1095 | + { | |
1096 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
1097 | + return get_intval(call(msg)); | |
1098 | + } | |
1099 | + | |
1100 | +#endif | |
1101 | + | |
1102 | + return -1; | |
1103 | +} | |
1104 | + | |
1105 | +int remote::get_cursor_addr(void) | |
1106 | +{ | |
1107 | +#if defined(WIN32) | |
1108 | + | |
1109 | + if(hPipe != INVALID_HANDLE_VALUE) | |
1110 | + { | |
1111 | + struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR }; | |
1112 | + struct hllapi_packet_result response; | |
1113 | + DWORD cbSize = sizeof(query); | |
1114 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
1115 | + return response.rc; | |
1116 | + } | |
1117 | + | |
1118 | +#elif defined(HAVE_DBUS) | |
1119 | + | |
1120 | + return query_intval("getCursorAddress"); | |
1121 | + | |
1122 | +#else | |
1123 | + | |
1124 | + return -1; | |
1125 | + | |
1126 | +#endif | |
1127 | +} | ... | ... |
src/plugins/rx3270/rexx_methods.cc
... | ... | @@ -145,6 +145,22 @@ RexxMethod3(int, rx3270_method_set_cursor, CSELF, sessionPtr, int, row, int, col |
145 | 145 | return hSession->set_cursor_position(row,col); |
146 | 146 | } |
147 | 147 | |
148 | +RexxMethod1(int, rx3270_method_get_cursor_addr, CSELF, sessionPtr) | |
149 | +{ | |
150 | + rx3270 *hSession = (rx3270 *) sessionPtr; | |
151 | + if(!hSession) | |
152 | + return -1; | |
153 | + return hSession->get_cursor_addr(); | |
154 | +} | |
155 | + | |
156 | +RexxMethod2(int, rx3270_method_set_cursor_addr, CSELF, sessionPtr, int, addr) | |
157 | +{ | |
158 | + rx3270 *hSession = (rx3270 *) sessionPtr; | |
159 | + if(!hSession) | |
160 | + return -1; | |
161 | + return hSession->set_cursor_addr(addr); | |
162 | +} | |
163 | + | |
148 | 164 | RexxMethod1(int, rx3270_method_enter, CSELF, sessionPtr) |
149 | 165 | { |
150 | 166 | rx3270 *hSession = (rx3270 *) sessionPtr; |
... | ... | @@ -206,6 +222,21 @@ RexxMethod4(int, rx3270_method_set_text_at, CSELF, sessionPtr, int, row, int, co |
206 | 222 | return -1; |
207 | 223 | } |
208 | 224 | |
225 | +RexxMethod2(int, rx3270_method_input_text, CSELF, sessionPtr, CSTRING, text) | |
226 | +{ | |
227 | + rx3270 * session = (rx3270 *) sessionPtr; | |
228 | + | |
229 | + if(session) | |
230 | + { | |
231 | + char * str = session->get_3270_string(text); | |
232 | + int rc = session->emulate_input(str); | |
233 | + free(str); | |
234 | + return rc; | |
235 | + } | |
236 | + | |
237 | + return -1; | |
238 | +} | |
239 | + | |
209 | 240 | RexxMethod4(int, rx3270_method_cmp_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key) |
210 | 241 | { |
211 | 242 | int rc = 0; |
... | ... | @@ -363,6 +394,7 @@ RexxMethod3(RexxStringObject, rx3270_method_get_text, CSELF, sessionPtr, OPTIONA |
363 | 394 | return context->String(""); |
364 | 395 | } |
365 | 396 | |
397 | + | |
366 | 398 | RexxMethod2(int, rx3270_method_get_field_len, CSELF, sessionPtr, OPTIONAL_int, baddr) |
367 | 399 | { |
368 | 400 | rx3270 *hSession = (rx3270 *) sessionPtr; |
... | ... | @@ -376,7 +408,7 @@ RexxMethod2(int, rx3270_method_get_field_start, CSELF, sessionPtr, OPTIONAL_int, |
376 | 408 | rx3270 *hSession = (rx3270 *) sessionPtr; |
377 | 409 | if(!hSession) |
378 | 410 | return -1; |
379 | - return hSession->get_field_start(baddr); | |
411 | + return hSession->get_field_start(baddr)+1; | |
380 | 412 | } |
381 | 413 | |
382 | 414 | RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr) | ... | ... |
src/plugins/rx3270/rx3270.cls
... | ... | @@ -50,6 +50,8 @@ |
50 | 50 | ::METHOD WAITFORREADY EXTERNAL "LIBRARY rx3270 rx3270_method_wait_for_ready" |
51 | 51 | |
52 | 52 | ::METHOD SETCURSOR EXTERNAL "LIBRARY rx3270 rx3270_method_set_cursor" |
53 | +::METHOD GETCURSORADDR EXTERNAL "LIBRARY rx3270 rx3270_method_get_cursor_addr" | |
54 | +::METHOD SETCURSORADDR EXTERNAL "LIBRARY rx3270 rx3270_method_set_cursor_addr" | |
53 | 55 | |
54 | 56 | ::METHOD ENTER EXTERNAL "LIBRARY rx3270 rx3270_method_enter" |
55 | 57 | ::METHOD PFKEY EXTERNAL "LIBRARY rx3270 rx3270_method_pfkey" |
... | ... | @@ -63,7 +65,10 @@ |
63 | 65 | ::METHOD GETTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_get_text_at" |
64 | 66 | ::METHOD SETTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_set_text_at" |
65 | 67 | ::METHOD CMPTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_cmp_text_at" |
68 | + | |
66 | 69 | ::METHOD GET EXTERNAL "LIBRARY rx3270 rx3270_method_get_text" |
70 | +::METHOD INPUT EXTERNAL "LIBRARY rx3270 rx3270_method_input_text" | |
71 | + | |
67 | 72 | ::METHOD WAITFORTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_wait_for_text_at" |
68 | 73 | ::METHOD TEST EXTERNAL "LIBRARY rx3270 rx3270_method_test" |
69 | 74 | ... | ... |
src/plugins/rx3270/rx3270.h
... | ... | @@ -93,6 +93,8 @@ |
93 | 93 | REXX_METHOD_PROTOTYPE(rx3270_method_is_ready); |
94 | 94 | REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_ready); |
95 | 95 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor); |
96 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); | |
97 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); | |
96 | 98 | REXX_METHOD_PROTOTYPE(rx3270_method_enter); |
97 | 99 | REXX_METHOD_PROTOTYPE(rx3270_method_pfkey); |
98 | 100 | REXX_METHOD_PROTOTYPE(rx3270_method_pakey); REXX_METHOD_PROTOTYPE(rx3270_method_get_text); |
... | ... | @@ -110,7 +112,9 @@ |
110 | 112 | REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); |
111 | 113 | REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); |
112 | 114 | REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); |
113 | - | |
115 | + REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); | |
116 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); | |
117 | + REXX_METHOD_PROTOTYPE(rx3270_method_input_text); | |
114 | 118 | |
115 | 119 | /*---[ Globals ]---------------------------------------------------------------------------------------------*/ |
116 | 120 | |
... | ... | @@ -166,7 +170,11 @@ |
166 | 170 | virtual int wait(int seconds) = 0; |
167 | 171 | virtual int wait_for_ready(int seconds) = 0; |
168 | 172 | virtual int wait_for_text_at(int row, int col, const char *key, int timeout); |
173 | + | |
169 | 174 | virtual int set_cursor_position(int row, int col) = 0; |
175 | + virtual int set_cursor_addr(int addr) = 0; | |
176 | + virtual int get_cursor_addr(void) = 0; | |
177 | + | |
170 | 178 | virtual int set_toggle(LIB3270_TOGGLE ix, bool value) = 0; |
171 | 179 | |
172 | 180 | virtual int enter(void) = 0; |
... | ... | @@ -176,6 +184,7 @@ |
176 | 184 | virtual char * get_text_at(int row, int col, size_t sz) = 0; virtual char * get_text(int baddr, size_t len) = 0; |
177 | 185 | virtual int cmp_text_at(int row, int col, const char *text) = 0; |
178 | 186 | virtual int set_text_at(int row, int col, const char *str) = 0; |
187 | + virtual int emulate_input(const char *str) = 0; | |
179 | 188 | |
180 | 189 | virtual int get_field_start(int baddr = -1) = 0; |
181 | 190 | virtual int get_field_len(int baddr = -1) = 0; | ... | ... |
src/plugins/rx3270/rxapimain.cc
... | ... | @@ -129,6 +129,8 @@ RexxMethodEntry rx3270_methods[] = |
129 | 129 | REXX_METHOD(rx3270_method_is_ready, rx3270_method_is_ready ), |
130 | 130 | REXX_METHOD(rx3270_method_wait_for_ready, rx3270_method_wait_for_ready ), |
131 | 131 | REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor ), |
132 | + REXX_METHOD(rx3270_method_set_cursor, rx3270_method_get_cursor_addr ), | |
133 | + REXX_METHOD(rx3270_method_set_cursor, rx3270_method_set_cursor_addr ), | |
132 | 134 | REXX_METHOD(rx3270_method_enter, rx3270_method_enter ), |
133 | 135 | REXX_METHOD(rx3270_method_pfkey, rx3270_method_pfkey ), |
134 | 136 | REXX_METHOD(rx3270_method_pakey, rx3270_method_pakey ), |
... | ... | @@ -149,6 +151,10 @@ RexxMethodEntry rx3270_methods[] = |
149 | 151 | REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), |
150 | 152 | REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), |
151 | 153 | |
154 | + REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), | |
155 | + REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), | |
156 | + REXX_METHOD(rx3270_method_input_text, rx3270_method_input_text ), | |
157 | + | |
152 | 158 | REXX_LAST_METHOD() |
153 | 159 | }; |
154 | 160 | ... | ... |
src/plugins/rx3270/sample/clipboard.rex
... | ... | @@ -7,6 +7,12 @@ |
7 | 7 | |
8 | 8 | host = .rx3270~new("") |
9 | 9 | |
10 | + if host~connected() = 0 then | |
11 | + do | |
12 | + say "Disconnected from host" | |
13 | + return 0 | |
14 | + end | |
15 | + | |
10 | 16 | text = host~GetClipboard() |
11 | 17 | if text = "" then |
12 | 18 | do |
... | ... | @@ -14,8 +20,52 @@ |
14 | 20 | return 0 |
15 | 21 | end |
16 | 22 | |
17 | - say "["||text||"]" | |
23 | + if host~WaitForReady(60) <> 0 then | |
24 | + do | |
25 | + say "Timeout waiting for host" | |
26 | + return 0 | |
27 | + end | |
28 | + | |
29 | + while text <> "" | |
30 | + do | |
18 | 31 | |
32 | + host~SetCursorAddr(host~GetFieldStart()) | |
33 | + field_len = host~GetFieldLen() | |
34 | + | |
35 | + if length(text) < field_len then | |
36 | + do | |
37 | + /* Text is smaller than field, just insert it */ | |
38 | + host~input(text) | |
39 | + end | |
40 | + else | |
41 | + do | |
42 | + /* Text is bigger than field, split ... */ | |
43 | + s = strip(left(text,field_len)) | |
44 | + p = lastpos(" ",s) | |
45 | + if p = 0 then | |
46 | + do | |
47 | + s = strip(left(text,field_len)) | |
48 | + text = substr(text,field_len+1) | |
49 | + end | |
50 | + else | |
51 | + do | |
52 | + s = strip(left(text,p)) | |
53 | + text = strip(substr(text,p+1)) | |
54 | + end | |
55 | + | |
56 | + /* ... and justify */ | |
57 | + | |
58 | + /* TODO */ | |
59 | + | |
60 | + /* Insert new string */ | |
61 | + host~input(s) | |
62 | + | |
63 | + end | |
64 | + | |
65 | + say text | |
66 | + | |
67 | + text = "" | |
68 | + end | |
19 | 69 | |
20 | 70 | return 0 |
21 | 71 | ... | ... |