Commit 42e6c7b28f07d1ed322fa296d88532295a437370

Authored by perry.werneck@gmail.com
1 parent 2f61dc6f

Acertando suporte a scripts rexx (incluindo funções que faltavam), testando méto…

…dos para verificação se um ponto da tela é editável
src/classlib/local.cc
@@ -147,6 +147,7 @@ @@ -147,6 +147,7 @@
147 int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting); 147 int (*_emulate_input)(H3270 *session, const char *s, int len, int pasting);
148 int (*_get_next_unprotected)(H3270 *hSession, int baddr0); 148 int (*_get_next_unprotected)(H3270 *hSession, int baddr0);
149 int (*_get_is_protected)(H3270 *hSession, int baddr); 149 int (*_get_is_protected)(H3270 *hSession, int baddr);
  150 + int (*_get_is_protected_at)(H3270 *hSession, int row, int col);
150 void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); 151 void (*_popup_va)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list);
151 void * (*_free)(void *); 152 void * (*_free)(void *);
152 const char * (*_get_display_charset)(H3270 *hSession); 153 const char * (*_get_display_charset)(H3270 *hSession);
@@ -206,6 +207,7 @@ @@ -206,6 +207,7 @@
206 { (void **) & _emulate_input, "lib3270_emulate_input" }, 207 { (void **) & _emulate_input, "lib3270_emulate_input" },
207 { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" }, 208 { (void **) & _get_next_unprotected, "lib3270_get_next_unprotected" },
208 { (void **) & _get_is_protected, "lib3270_get_is_protected" }, 209 { (void **) & _get_is_protected, "lib3270_get_is_protected" },
  210 + { (void **) & _get_is_protected_at, "lib3270_get_is_protected_at" },
209 { (void **) & _popup_va, "lib3270_popup_va" }, 211 { (void **) & _popup_va, "lib3270_popup_va" },
210 { (void **) & _free, "lib3270_free" }, 212 { (void **) & _free, "lib3270_free" },
211 { (void **) & _get_display_charset, "lib3270_get_display_charset" }, 213 { (void **) & _get_display_charset, "lib3270_get_display_charset" },
@@ -401,6 +403,11 @@ @@ -401,6 +403,11 @@
401 return _get_is_protected(hSession,baddr); 403 return _get_is_protected(hSession,baddr);
402 } 404 }
403 405
  406 + int get_is_protected_at(int row, int col)
  407 + {
  408 + return _get_is_protected_at(hSession,row,col);
  409 + }
  410 +
404 int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) 411 int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
405 { 412 {
406 va_list args; 413 va_list args;
src/classlib/remote.cc
@@ -1257,6 +1257,36 @@ @@ -1257,6 +1257,36 @@
1257 1257
1258 } 1258 }
1259 1259
  1260 + int get_is_protected_at(int row,int col)
  1261 + {
  1262 +#if defined(WIN32)
  1263 +
  1264 + struct hllapi_packet_query_at query = { HLLAPI_PACKET_IS_PROTECTED_AT, (unsigned short) row, (unsigned short) col, 0 };
  1265 +
  1266 + return query_intval((void *) &query, sizeof(query));
  1267 +
  1268 +#elif defined(HAVE_DBUS)
  1269 +
  1270 + dbus_int32_t r = (dbus_int32_t) row;
  1271 + dbus_int32_t c = (dbus_int32_t) col;
  1272 +
  1273 + DBusMessage * msg = create_message("getIsProtectedAt");
  1274 + if(msg)
  1275 + {
  1276 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INVALID);
  1277 + return get_intval(call(msg));
  1278 + }
  1279 +
  1280 + return -1;
  1281 +
  1282 +#else
  1283 +
  1284 + return -1;
  1285 +
  1286 +#endif
  1287 +
  1288 + }
  1289 +
1260 1290
1261 int set_host_charset(const char *charset) 1291 int set_host_charset(const char *charset)
1262 { 1292 {
src/include/lib3270.h
@@ -935,11 +935,20 @@ @@ -935,11 +935,20 @@
935 LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0); 935 LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0);
936 936
937 /** 937 /**
938 - * @brief Check if the screen position is unprotected. 938 + * @brief Check if the screen position is protected.
939 * 939 *
940 */ 940 */
941 LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr0); 941 LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr0);
942 942
  943 + /**
  944 + * Get Check if the screen position is protected.
  945 + *
  946 + * @param h Session Handle.
  947 + * @param row Desired row.
  948 + * @param col Desired col.
  949 + *
  950 + */
  951 + LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col);
943 952
944 /** 953 /**
945 * Get address of the first blank. 954 * Get address of the first blank.
@@ -1017,6 +1026,7 @@ @@ -1017,6 +1026,7 @@
1017 LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession); 1026 LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession);
1018 1027
1019 LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr); 1028 LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr);
  1029 + LIB3270_EXPORT int lib3270_is_protected_at(H3270 *h, unsigned int row, unsigned int col);
1020 1030
1021 /** 1031 /**
1022 * Alloc/Realloc memory buffer. 1032 * Alloc/Realloc memory buffer.
src/include/pw3270/class.h
@@ -220,7 +220,9 @@ @@ -220,7 +220,9 @@
220 virtual int get_field_start(int baddr = -1) = 0; 220 virtual int get_field_start(int baddr = -1) = 0;
221 virtual int get_field_len(int baddr = -1) = 0; 221 virtual int get_field_len(int baddr = -1) = 0;
222 virtual int get_next_unprotected(int baddr = -1) = 0; 222 virtual int get_next_unprotected(int baddr = -1) = 0;
  223 +
223 virtual int get_is_protected(int baddr = -1) = 0; 224 virtual int get_is_protected(int baddr = -1) = 0;
  225 + virtual int get_is_protected_at(int row, int col) = 0;
224 226
225 // Clipboard management 227 // Clipboard management
226 virtual int set_copy(const char *text); 228 virtual int set_copy(const char *text);
src/java/plugin.cc
@@ -238,6 +238,10 @@ @@ -238,6 +238,10 @@
238 return lib3270_is_protected(hSession,baddr); 238 return lib3270_is_protected(hSession,baddr);
239 } 239 }
240 240
  241 + int get_is_protected_at(int row, int col) {
  242 + return lib3270_is_protected_at(hSession,row,col);
  243 + }
  244 +
241 int set_copy(const char *text) { 245 int set_copy(const char *text) {
242 v3270_set_copy(GTK_WIDGET(lib3270_get_user_data(hSession)),text); 246 v3270_set_copy(GTK_WIDGET(lib3270_get_user_data(hSession)),text);
243 return 0; 247 return 0;
src/lib3270/ctlr.c
@@ -612,6 +612,11 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0) @@ -612,6 +612,11 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0)
612 return 0; 612 return 0;
613 } 613 }
614 614
  615 +LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, int row, int col) {
  616 + CHECK_SESSION_HANDLE(h);
  617 + return lib3270_get_is_protected(h, ((row-1) * h->cols) + (col-1));
  618 +}
  619 +
615 LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr) 620 LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr)
616 { 621 {
617 CHECK_SESSION_HANDLE(hSession); 622 CHECK_SESSION_HANDLE(hSession);
@@ -621,7 +626,7 @@ LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr) @@ -621,7 +626,7 @@ LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr)
621 626
622 int faddr = find_field_attribute(hSession,baddr); 627 int faddr = find_field_attribute(hSession,baddr);
623 628
624 - return FA_IS_PROTECTED(hSession->ea_buf[faddr].fa); 629 + return FA_IS_PROTECTED(hSession->ea_buf[faddr].fa) ? 1 : 0;
625 } 630 }
626 631
627 632
src/plugins/rx3270/pluginmain.cc
@@ -127,6 +127,7 @@ @@ -127,6 +127,7 @@
127 int get_field_len(int baddr = -1); 127 int get_field_len(int baddr = -1);
128 int get_next_unprotected(int baddr = -1); 128 int get_next_unprotected(int baddr = -1);
129 int get_is_protected(int baddr = -1); 129 int get_is_protected(int baddr = -1);
  130 + int get_is_protected_at(int row, int col);
130 131
131 int set_copy(const char *text); 132 int set_copy(const char *text);
132 string get_copy(void); 133 string get_copy(void);
@@ -726,6 +727,16 @@ extern "C" @@ -726,6 +727,16 @@ extern "C"
726 return lib3270_get_next_unprotected(hSession,baddr); 727 return lib3270_get_next_unprotected(hSession,baddr);
727 } 728 }
728 729
  730 + int plugin::get_is_protected(int baddr)
  731 + {
  732 + return lib3270_get_is_protected(hSession,baddr);
  733 + }
  734 +
  735 + int plugin::get_is_protected_at(int row, int col)
  736 + {
  737 + return lib3270_get_is_protected_at(hSession,row,col);
  738 + }
  739 +
729 int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) 740 int plugin::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...)
730 { 741 {
731 va_list args; 742 va_list args;
src/plugins/rx3270/rexx_methods.cc
@@ -467,6 +467,7 @@ RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL @@ -467,6 +467,7 @@ RexxMethod2(int, rx3270_method_get_next_unprotected, CSELF, sessionPtr, OPTIONAL
467 467
468 RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int, baddr) 468 RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int, baddr)
469 { 469 {
  470 +
470 session *hSession = (session *) sessionPtr; 471 session *hSession = (session *) sessionPtr;
471 if(!hSession) 472 if(!hSession)
472 return -1; 473 return -1;
@@ -474,6 +475,17 @@ RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int @@ -474,6 +475,17 @@ RexxMethod2(int, rx3270_method_get_is_protected, CSELF, sessionPtr, OPTIONAL_int
474 return hSession->get_is_protected(baddr); 475 return hSession->get_is_protected(baddr);
475 } 476 }
476 477
  478 +RexxMethod3(int, rx3270_method_get_is_protected_at, CSELF, sessionPtr, int, row, int, col)
  479 +{
  480 +
  481 + session *hSession = (session *) sessionPtr;
  482 + if(!hSession)
  483 + return -1;
  484 +
  485 + return hSession->get_is_protected_at(row,col);
  486 +}
  487 +
  488 +
477 RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr) 489 RexxMethod1(RexxStringObject, rx3270_method_get_selection, CSELF, sessionPtr)
478 { 490 {
479 try 491 try
src/plugins/rx3270/rx3270.cls
@@ -83,6 +83,7 @@ @@ -83,6 +83,7 @@
83 ::METHOD GETFIELDLEN EXTERNAL "LIBRARY rx3270 rx3270_method_get_field_len" 83 ::METHOD GETFIELDLEN EXTERNAL "LIBRARY rx3270 rx3270_method_get_field_len"
84 ::METHOD GETNEXTUNPROTECTED EXTERNAL "LIBRARY rx3270 rx3270_method_get_next_unprotected" 84 ::METHOD GETNEXTUNPROTECTED EXTERNAL "LIBRARY rx3270 rx3270_method_get_next_unprotected"
85 ::METHOD GETISPROTECTED EXTERNAL "LIBRARY rx3270 rx3270_method_get_is_protected" 85 ::METHOD GETISPROTECTED EXTERNAL "LIBRARY rx3270 rx3270_method_get_is_protected"
  86 +::METHOD GETISPROTECTEDAT EXTERNAL "LIBRARY rx3270 rx3270_method_get_is_protected_at"
86 87
87 ::METHOD GETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_get_selection" 88 ::METHOD GETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_get_selection"
88 ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection" 89 ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection"
src/plugins/rx3270/rx3270.h
@@ -91,6 +91,9 @@ @@ -91,6 +91,9 @@
91 REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL); 91 REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseEOL);
92 REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput); 92 REXX_TYPED_ROUTINE_PROTOTYPE(rx3270EraseInput);
93 93
  94 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtected);
  95 + REXX_TYPED_ROUTINE_PROTOTYPE(rx3270IsProtectedAt);
  96 +
94 REXX_METHOD_PROTOTYPE(rx3270_method_version); 97 REXX_METHOD_PROTOTYPE(rx3270_method_version);
95 REXX_METHOD_PROTOTYPE(rx3270_method_revision); 98 REXX_METHOD_PROTOTYPE(rx3270_method_revision);
96 REXX_METHOD_PROTOTYPE(rx3270_method_init); 99 REXX_METHOD_PROTOTYPE(rx3270_method_init);
@@ -125,6 +128,7 @@ @@ -125,6 +128,7 @@
125 REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start); 128 REXX_METHOD_PROTOTYPE(rx3270_method_get_field_start);
126 REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected); 129 REXX_METHOD_PROTOTYPE(rx3270_method_get_next_unprotected);
127 REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected); 130 REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected);
  131 + REXX_METHOD_PROTOTYPE(rx3270_method_get_is_protected_at);
128 REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); 132 REXX_METHOD_PROTOTYPE(rx3270_method_get_selection);
129 REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); 133 REXX_METHOD_PROTOTYPE(rx3270_method_set_selection);
130 REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); 134 REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard);
src/plugins/rx3270/rxapimain.cc
@@ -119,12 +119,14 @@ RexxRoutineEntry rx3270_functions[] = @@ -119,12 +119,14 @@ RexxRoutineEntry rx3270_functions[] =
119 REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL), 119 REXX_TYPED_ROUTINE(rx3270EraseEOL, rx3270EraseEOL),
120 REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput), 120 REXX_TYPED_ROUTINE(rx3270EraseInput, rx3270EraseInput),
121 121
  122 + REXX_TYPED_ROUTINE(rx3270Erase, rx3270IsProtected),
  123 + REXX_TYPED_ROUTINE(rx3270Erase, rx3270IsProtectedAt),
  124 +
122 REXX_TYPED_ROUTINE(ebc2asc, ebc2asc), 125 REXX_TYPED_ROUTINE(ebc2asc, ebc2asc),
123 REXX_TYPED_ROUTINE(asc2ebc, asc2ebc), 126 REXX_TYPED_ROUTINE(asc2ebc, asc2ebc),
124 127
125 128
126 // rx3270Popup 129 // rx3270Popup
127 -  
128 REXX_LAST_METHOD() 130 REXX_LAST_METHOD()
129 }; 131 };
130 132
@@ -164,11 +166,20 @@ RexxMethodEntry rx3270_methods[] = @@ -164,11 +166,20 @@ RexxMethodEntry rx3270_methods[] =
164 REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ), 166 REXX_METHOD(rx3270_method_get_field_len, rx3270_method_get_field_len ),
165 REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ), 167 REXX_METHOD(rx3270_method_get_field_start, rx3270_method_get_field_start ),
166 REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ), 168 REXX_METHOD(rx3270_method_get_next_unprotected, rx3270_method_get_next_unprotected ),
  169 +
  170 + REXX_METHOD(rx3270_method_get_is_protected, rx3270_method_get_is_protected ),
  171 + REXX_METHOD(rx3270_method_get_is_protected_at, rx3270_method_get_is_protected_at ),
  172 +
167 REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ), 173 REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ),
168 REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), 174 REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ),
169 REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), 175 REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ),
170 REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), 176 REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ),
171 177
  178 + REXX_METHOD(rx3270_method_erase, rx3270_method_erase ),
  179 + REXX_METHOD(rx3270_method_erase_eof, rx3270_method_erase_eof ),
  180 + REXX_METHOD(rx3270_method_erase_eol, rx3270_method_erase_eol ),
  181 + REXX_METHOD(rx3270_method_erase_input, rx3270_method_erase_input ),
  182 +
172 REXX_METHOD(rx3270_method_popup, rx3270_method_popup ), 183 REXX_METHOD(rx3270_method_popup, rx3270_method_popup ),
173 REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ), 184 REXX_METHOD(rx3270_method_get_filename, rx3270_method_get_filename ),
174 185
src/plugins/rx3270/sample/protected.rex 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +/*
  2 + * Sample rexx code to get host charset
  3 + */
  4 +
  5 + host = .rx3270~new("")
  6 +
  7 + say "Posição 19,39: "||host~getIsProtectedAt(19,39)
  8 + say "Posição 20,39: "||host~getIsProtectedAt(20,39)
  9 +
  10 + return 0
  11 +
  12 +::requires "rx3270.cls"
src/plugins/rx3270/typed_routines.cc
@@ -279,3 +279,30 @@ RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz) @@ -279,3 +279,30 @@ RexxRoutine2(RexxStringObject, ebc2asc, CSTRING, str, OPTIONAL_int, sz)
279 return context->String(""); 279 return context->String("");
280 } 280 }
281 281
  282 +RexxRoutine1(int, rx3270IsProtected, int, baddr)
  283 +{
  284 + try
  285 + {
  286 + return session::get_default()->get_is_protected(baddr);
  287 + }
  288 + catch(std::exception &e)
  289 + {
  290 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
  291 + }
  292 +
  293 + return -1;
  294 +}
  295 +
  296 +RexxRoutine2(int, rx3270IsProtectedAt, int, row, int, col)
  297 +{
  298 + try
  299 + {
  300 + return session::get_default()->get_is_protected_at(row,col);
  301 + }
  302 + catch(std::exception &e)
  303 + {
  304 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
  305 + }
  306 +
  307 + return -1;
  308 +}