From a9d34e0ffec92e2b5f1d2a560e5bc92387d561f2 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 15 Sep 2020 16:50:17 -0300 Subject: [PATCH] Debugging hllapi_get_cursor_address --- src/core/cursor.cc | 8 +------- src/testprogram/testprogram.cc | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/core/cursor.cc b/src/core/cursor.cc index 0ac1aa9..fe95e3f 100644 --- a/src/core/cursor.cc +++ b/src/core/cursor.cc @@ -86,17 +86,11 @@ try { - TN3270::Host &host = getSession(); - - if(!host.isConnected()) - return 0; - - return (DWORD) (host.getCursorAddress()+1); + return (DWORD) (getSession().getCursorAddress()+1); } catch(std::exception &e) { hllapi_lasterror = e.what(); - return -1; } diff --git a/src/testprogram/testprogram.cc b/src/testprogram/testprogram.cc index 38381d6..bb55f6a 100644 --- a/src/testprogram/testprogram.cc +++ b/src/testprogram/testprogram.cc @@ -143,19 +143,35 @@ } else if(strncasecmp(cmdline.c_str(),"cursor",6) == 0) { unsigned int row, col; + const char * arg = cmdline.c_str()+6; + + while(*arg && isspace(*arg)) + arg++; + + if(*arg) { + + switch(std::sscanf(arg,"%u,%u",&row,&col)) { + case 1: + cout << "Moving cursor to " << row << endl; + rc = hllapi_set_cursor_address((WORD) row); + break; + + case 2: + cout << "Moving cursor to " << row << "," << col << endl; + rc = hllapi_set_cursor_position((WORD) row, (WORD) col); + break; + } + + } else { + + int addr = hllapi_get_cursor_address(); + + cout << "Cursor address=" << addr << endl; - switch(std::sscanf(cmdline.c_str()+6,"%u,%u",&row,&col)) { - case 1: - cout << "Moving cursor to " << row << endl; - rc = hllapi_set_cursor_address((WORD) row); - break; - case 2: - cout << "Moving cursor to " << row << "," << col << endl; - rc = hllapi_set_cursor_position((WORD) row, (WORD) col); - break; } + } else if(strncasecmp(cmdline.c_str(),"at",2) == 0) { unsigned int row, col, len; -- libgit2 0.21.2