Commit 6058ed375c612ef6636023d45953635d506b3916
1 parent
a3fa3e57
Exists in
master
and in
5 other branches
Melhorando funcionamento da classe java.
Showing
4 changed files
with
32 additions
and
2 deletions
Show diff stats
src/classlib/session.cc
@@ -216,7 +216,7 @@ | @@ -216,7 +216,7 @@ | ||
216 | iterate(false); | 216 | iterate(false); |
217 | while(time(0) < end) | 217 | while(time(0) < end) |
218 | { | 218 | { |
219 | - trace("Aguardar %d segundos",(int) (end - time(0))); | 219 | + trace("Aguardar %d segundos por \"%s\" @%d,%d (%s)",(int) (end - time(0)),key,row,col,get_text_at(row,col,strlen(key)).c_str()); |
220 | 220 | ||
221 | int rc = wait_for_ready(end - time(0)); | 221 | int rc = wait_for_ready(end - time(0)); |
222 | if(rc) { | 222 | if(rc) { |
@@ -231,6 +231,8 @@ | @@ -231,6 +231,8 @@ | ||
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | + trace("Tela:\n%s\n", ((string) *this).c_str()); | ||
235 | + | ||
234 | return ETIMEDOUT; | 236 | return ETIMEDOUT; |
235 | } | 237 | } |
236 | 238 |
src/include/pw3270/class.h
@@ -173,7 +173,7 @@ | @@ -173,7 +173,7 @@ | ||
173 | virtual int iterate(bool wait = true) = 0; | 173 | virtual int iterate(bool wait = true) = 0; |
174 | 174 | ||
175 | // Get/Set/Test without charset translation | 175 | // Get/Set/Test without charset translation |
176 | - virtual string get_text(int baddr, size_t len) = 0; | 176 | + virtual string get_text(int baddr = 0, size_t len = 1) = 0; |
177 | virtual string get_text_at(int row, int col, size_t sz) = 0; | 177 | virtual string get_text_at(int row, int col, size_t sz) = 0; |
178 | virtual int set_text_at(int row, int col, const char *str) = 0; | 178 | virtual int set_text_at(int row, int col, const char *str) = 0; |
179 | virtual int cmp_text_at(int row, int col, const char *text) = 0; | 179 | virtual int cmp_text_at(int row, int col, const char *text) = 0; |
@@ -194,6 +194,10 @@ | @@ -194,6 +194,10 @@ | ||
194 | int wait_for_string_at(int row, int col, const char *key, int timeout); | 194 | int wait_for_string_at(int row, int col, const char *key, int timeout); |
195 | int input_string(const char *str); | 195 | int input_string(const char *str); |
196 | 196 | ||
197 | + inline operator string() { | ||
198 | + return get_string(); | ||
199 | + } | ||
200 | + | ||
197 | // Cursor management | 201 | // Cursor management |
198 | virtual int set_cursor_position(int row, int col) = 0; | 202 | virtual int set_cursor_position(int row, int col) = 0; |
199 | virtual int set_cursor_addr(int addr) = 0; | 203 | virtual int set_cursor_addr(int addr) = 0; |
src/java/getset.cc
@@ -35,6 +35,24 @@ | @@ -35,6 +35,24 @@ | ||
35 | using namespace std; | 35 | using namespace std; |
36 | using namespace PW3270_NAMESPACE; | 36 | using namespace PW3270_NAMESPACE; |
37 | 37 | ||
38 | +JNIEXPORT jstring JNICALL Java_pw3270_terminal_toString(JNIEnv *env, jobject obj) { | ||
39 | + | ||
40 | + string str; | ||
41 | + | ||
42 | + try { | ||
43 | + | ||
44 | + str = java::getHandle(env,obj)->get_string(); | ||
45 | + | ||
46 | + } catch(std::exception &e) { | ||
47 | + | ||
48 | + env->ThrowNew(env->FindClass("java/lang/Exception"), e.what()); | ||
49 | + | ||
50 | + } | ||
51 | + | ||
52 | + return env->NewStringUTF(str.c_str()); | ||
53 | + | ||
54 | +} | ||
55 | + | ||
38 | JNIEXPORT jstring JNICALL Java_pw3270_terminal_get_1string(JNIEnv *env, jobject obj, jint baddr, jint len) { | 56 | JNIEXPORT jstring JNICALL Java_pw3270_terminal_get_1string(JNIEnv *env, jobject obj, jint baddr, jint len) { |
39 | 57 | ||
40 | string str; | 58 | string str; |
src/java/terminal.java
@@ -434,6 +434,12 @@ public class terminal | @@ -434,6 +434,12 @@ public class terminal | ||
434 | public native void log(String msg); | 434 | public native void log(String msg); |
435 | 435 | ||
436 | /** | 436 | /** |
437 | + * Get Screen contents. | ||
438 | + * | ||
439 | + */ | ||
440 | + public native String toString(); | ||
441 | + | ||
442 | + /** | ||
437 | * Get connection SSL state | 443 | * Get connection SSL state |
438 | * | 444 | * |
439 | * @return State of SSL connection (0 = Unsafe, 1 = Valid CA, 2 = Invalid CA or self-signed, 3 = Negotiating, 4 = Undefined) | 445 | * @return State of SSL connection (0 = Unsafe, 1 = Valid CA, 2 = Invalid CA or self-signed, 3 = Negotiating, 4 = Undefined) |