Commit 7f35c50fcf6661c2b39bd6ac5a63ceaf4885afc9
1 parent
294d088e
Exists in
master
and in
5 other branches
Ajustes para que as macros tratem seleção
Showing
4 changed files
with
46 additions
and
4 deletions
Show diff stats
src/include/lib3270/selection.h
... | ... | @@ -148,6 +148,6 @@ |
148 | 148 | * @param end_offset : End offset. |
149 | 149 | * |
150 | 150 | */ |
151 | - LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end); | |
151 | + LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end); | |
152 | 152 | |
153 | 153 | #endif // LIB3270_SELECTION_H_INCLUDED | ... | ... |
src/lib3270/macros.c
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | #include <stdio.h> |
36 | 36 | #include <lib3270.h> |
37 | 37 | #include <lib3270/macros.h> |
38 | + #include <lib3270/selection.h> | |
38 | 39 | #include <stdlib.h> |
39 | 40 | #include <strings.h> |
40 | 41 | #include "globals.h" |
... | ... | @@ -278,6 +279,37 @@ |
278 | 279 | return strdup("0"); |
279 | 280 | } |
280 | 281 | |
282 | + LIB3270_MACRO( unselect ) | |
283 | + { | |
284 | + lib3270_unselect(hSession); | |
285 | + return strdup("0"); | |
286 | + } | |
287 | + | |
288 | + LIB3270_MACRO( select ) | |
289 | + { | |
290 | + int rc = -1; | |
291 | + char ret[10]; | |
292 | + | |
293 | + switch(argc) | |
294 | + { | |
295 | + case 1: // 1 argument, select all | |
296 | + rc = lib3270_select_all(hSession); | |
297 | + break; | |
298 | + | |
299 | + case 3: // 2 arguments, first and last addr | |
300 | + rc = lib3270_select_region(hSession,atoi(argv[1]),atoi(argv[2])); | |
301 | + break; | |
302 | + | |
303 | + | |
304 | + default: | |
305 | + errno = EINVAL; | |
306 | + return NULL; | |
307 | + } | |
308 | + | |
309 | + snprintf(ret,9,"%d",rc); | |
310 | + return strdup(ret); | |
311 | + | |
312 | + } | |
281 | 313 | |
282 | 314 | /*--[ Macro entry point ]----------------------------------------------------------------------------*/ |
283 | 315 | |
... | ... | @@ -298,6 +330,8 @@ |
298 | 330 | LIB3270_MACRO_ENTRY( pf ), |
299 | 331 | LIB3270_MACRO_ENTRY( set ), |
300 | 332 | LIB3270_MACRO_ENTRY( status ), |
333 | + LIB3270_MACRO_ENTRY( select ), | |
334 | + LIB3270_MACRO_ENTRY( unselect ), | |
301 | 335 | |
302 | 336 | {NULL, NULL} |
303 | 337 | }; | ... | ... |
src/lib3270/selection.c
... | ... | @@ -220,24 +220,25 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) |
220 | 220 | |
221 | 221 | } |
222 | 222 | |
223 | -LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end) | |
223 | +LIB3270_EXPORT int lib3270_select_region(H3270 *h, int start, int end) | |
224 | 224 | { |
225 | 225 | int maxlen; |
226 | 226 | |
227 | 227 | CHECK_SESSION_HANDLE(h); |
228 | 228 | |
229 | 229 | if(!lib3270_connected(h)) |
230 | - return; | |
230 | + return ENOTCONN; | |
231 | 231 | |
232 | 232 | maxlen = (h->rows * h->cols); |
233 | 233 | |
234 | 234 | // Check bounds |
235 | 235 | if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end) |
236 | - return; | |
236 | + return EINVAL; | |
237 | 237 | |
238 | 238 | do_select(h,start,end,lib3270_get_toggle(h,LIB3270_TOGGLE_RECTANGLE_SELECT)); |
239 | 239 | cursor_move(h,h->select.end); |
240 | 240 | |
241 | + return 0; | |
241 | 242 | } |
242 | 243 | |
243 | 244 | static void do_select(H3270 *h, int start, int end, int rect) | ... | ... |
src/pw3270/v3270/macros.c
... | ... | @@ -47,6 +47,12 @@ |
47 | 47 | return 0; |
48 | 48 | } |
49 | 49 | |
50 | + static int v3270_macro_clearsel(GtkWidget *widget, int argc, const char **argv) | |
51 | + { | |
52 | + v3270_clear_clipboard(widget); | |
53 | + return 0; | |
54 | + } | |
55 | + | |
50 | 56 | static int run_macro(GtkWidget *widget, int argc, const char **argv) |
51 | 57 | { |
52 | 58 | #define V3270_MACRO( name ) { #name, v3270_macro_ ## name } |
... | ... | @@ -59,6 +65,7 @@ |
59 | 65 | { |
60 | 66 | V3270_MACRO( copy ), |
61 | 67 | V3270_MACRO( append ), |
68 | + V3270_MACRO( clearsel ), | |
62 | 69 | }; |
63 | 70 | |
64 | 71 | int f; | ... | ... |