diff --git a/src/include/lib3270/selection.h b/src/include/lib3270/selection.h index 9d86a89..e90ae34 100644 --- a/src/include/lib3270/selection.h +++ b/src/include/lib3270/selection.h @@ -148,6 +148,6 @@ * @param end_offset : End offset. * */ - LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end); + LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end); #endif // LIB3270_SELECTION_H_INCLUDED diff --git a/src/lib3270/macros.c b/src/lib3270/macros.c index ecf63ff..5631162 100644 --- a/src/lib3270/macros.c +++ b/src/lib3270/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/src/lib3270/selection.c b/src/lib3270/selection.c index 3db20fd..4e5d670 100644 --- a/src/lib3270/selection.c +++ b/src/lib3270/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) diff --git a/src/pw3270/v3270/macros.c b/src/pw3270/v3270/macros.c index da44c56..149674b 100644 --- a/src/pw3270/v3270/macros.c +++ b/src/pw3270/v3270/macros.c @@ -47,6 +47,12 @@ return 0; } + static int v3270_macro_clearsel(GtkWidget *widget, int argc, const char **argv) + { + v3270_clear_clipboard(widget); + return 0; + } + static int run_macro(GtkWidget *widget, int argc, const char **argv) { #define V3270_MACRO( name ) { #name, v3270_macro_ ## name } @@ -59,6 +65,7 @@ { V3270_MACRO( copy ), V3270_MACRO( append ), + V3270_MACRO( clearsel ), }; int f; -- libgit2 0.21.2