diff --git a/macros.c b/macros.c index ecf63ff..5631162 100644 --- a/macros.c +++ b/macros.c @@ -35,6 +35,7 @@ #include #include #include + #include #include #include #include "globals.h" @@ -278,6 +279,37 @@ return strdup("0"); } + LIB3270_MACRO( unselect ) + { + lib3270_unselect(hSession); + return strdup("0"); + } + + LIB3270_MACRO( select ) + { + int rc = -1; + char ret[10]; + + switch(argc) + { + case 1: // 1 argument, select all + rc = lib3270_select_all(hSession); + break; + + case 3: // 2 arguments, first and last addr + rc = lib3270_select_region(hSession,atoi(argv[1]),atoi(argv[2])); + break; + + + default: + errno = EINVAL; + return NULL; + } + + snprintf(ret,9,"%d",rc); + return strdup(ret); + + } /*--[ Macro entry point ]----------------------------------------------------------------------------*/ @@ -298,6 +330,8 @@ LIB3270_MACRO_ENTRY( pf ), LIB3270_MACRO_ENTRY( set ), LIB3270_MACRO_ENTRY( status ), + LIB3270_MACRO_ENTRY( select ), + LIB3270_MACRO_ENTRY( unselect ), {NULL, NULL} }; diff --git a/selection.c b/selection.c index 3db20fd..4e5d670 100644 --- a/selection.c +++ b/selection.c @@ -220,24 +220,25 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) } -LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end) +LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end) { int maxlen; CHECK_SESSION_HANDLE(h); if(!lib3270_connected(h)) - return; + return ENOTCONN; maxlen = (h->rows * h->cols); // Check bounds if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end) - return; + return EINVAL; do_select(h,start,end,lib3270_get_toggle(h,LIB3270_TOGGLE_RECTANGLE_SELECT)); cursor_move(h,h->select.end); + return 0; } static void do_select(H3270 *h, int start, int end, int rect) -- libgit2 0.21.2