Commit cab7a83b37e80071a4c6eb3cdb23b51711cf5642
1 parent
3a46fe56
Exists in
master
and in
5 other branches
Implementando metodo para setar o clipboard em rexx
Showing
7 changed files
with
44 additions
and
27 deletions
Show diff stats
src/plugins/rx3270/pluginmain.cc
| ... | ... | @@ -105,6 +105,7 @@ |
| 105 | 105 | char * get_copy(void); |
| 106 | 106 | |
| 107 | 107 | char * get_clipboard(void); |
| 108 | + int set_clipboard(const char *text); | |
| 108 | 109 | |
| 109 | 110 | protected: |
| 110 | 111 | |
| ... | ... | @@ -281,6 +282,12 @@ |
| 281 | 282 | return gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); |
| 282 | 283 | } |
| 283 | 284 | |
| 285 | + int plugin::set_clipboard(const char *text) | |
| 286 | + { | |
| 287 | + gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); | |
| 288 | + return 0; | |
| 289 | + } | |
| 290 | + | |
| 284 | 291 | void plugin::free(void *ptr) |
| 285 | 292 | { |
| 286 | 293 | g_free(ptr); | ... | ... |
src/plugins/rx3270/rexx_methods.cc
| ... | ... | @@ -481,3 +481,13 @@ RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr) |
| 481 | 481 | return context->String(""); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | +RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text) | |
| 485 | +{ | |
| 486 | + rx3270 * hSession = (rx3270 *) sessionPtr; | |
| 487 | + | |
| 488 | + if(hSession) | |
| 489 | + return hSession->set_clipboard(text); | |
| 490 | + | |
| 491 | + return -1; | |
| 492 | +} | |
| 493 | + | ... | ... |
src/plugins/rx3270/rx3270.cc
src/plugins/rx3270/rx3270.cls
| ... | ... | @@ -80,6 +80,7 @@ |
| 80 | 80 | ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection" |
| 81 | 81 | |
| 82 | 82 | ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" |
| 83 | +::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard" | |
| 83 | 84 | |
| 84 | 85 | ::method waitForStringAt |
| 85 | 86 | use arg row, col, key, timeout | ... | ... |
src/plugins/rx3270/rx3270.h
| ... | ... | @@ -113,6 +113,7 @@ |
| 113 | 113 | REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); |
| 114 | 114 | REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); |
| 115 | 115 | REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); |
| 116 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); | |
| 116 | 117 | REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); |
| 117 | 118 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); |
| 118 | 119 | REXX_METHOD_PROTOTYPE(rx3270_method_input_text); |
| ... | ... | @@ -195,6 +196,7 @@ |
| 195 | 196 | virtual char * get_copy(void); |
| 196 | 197 | |
| 197 | 198 | virtual char * get_clipboard(void); |
| 199 | + virtual int set_clipboard(const char *text); | |
| 198 | 200 | |
| 199 | 201 | }; |
| 200 | 202 | ... | ... |
src/plugins/rx3270/rxapimain.cc
| ... | ... | @@ -151,6 +151,7 @@ RexxMethodEntry rx3270_methods[] = |
| 151 | 151 | REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ), |
| 152 | 152 | REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), |
| 153 | 153 | REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), |
| 154 | + REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), | |
| 154 | 155 | |
| 155 | 156 | REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), |
| 156 | 157 | REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), | ... | ... |
src/plugins/rx3270/sample/clipboard.rex
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | return 0 |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | - text = host~GetClipboard() | |
| 16 | + text = strip(host~GetClipboard()) | |
| 17 | 17 | if text = "" then |
| 18 | 18 | do |
| 19 | 19 | say "Clipboard is empty" |
| ... | ... | @@ -38,45 +38,36 @@ |
| 38 | 38 | |
| 39 | 39 | field_len = host~GetFieldLen() |
| 40 | 40 | |
| 41 | - if length(text) < field_len then | |
| 41 | + s = strip(left(text,field_len)) | |
| 42 | + p = lastpos(" ",s) | |
| 43 | + | |
| 44 | + select | |
| 45 | + when length(text) < field_len then | |
| 42 | 46 | do |
| 43 | - /* Text is smaller than field, just insert it */ | |
| 44 | - host~input(text) | |
| 47 | + s = strip(text) | |
| 48 | + text = "" | |
| 45 | 49 | end |
| 46 | - else | |
| 50 | + | |
| 51 | + when p = 0 then | |
| 47 | 52 | do |
| 48 | - /* Text is bigger than field, split ... */ | |
| 49 | 53 | s = strip(left(text,field_len)) |
| 50 | - p = lastpos(" ",s) | |
| 51 | - if p = 0 then | |
| 52 | - do | |
| 53 | - s = strip(left(text,field_len)) | |
| 54 | - text = substr(text,field_len+1) | |
| 55 | - end | |
| 56 | - else | |
| 57 | - do | |
| 58 | - s = strip(left(text,p)) | |
| 59 | - text = strip(substr(text,p+1)) | |
| 60 | - end | |
| 61 | - | |
| 62 | - /* ... and justify */ | |
| 63 | - | |
| 64 | - /* TODO */ | |
| 65 | - | |
| 66 | - /* Insert new string */ | |
| 67 | - host~input(s) | |
| 54 | + text = substr(text,field_len+1) | |
| 55 | + end | |
| 68 | 56 | |
| 57 | + otherwise | |
| 58 | + s = strip(left(text,p)) | |
| 59 | + text = strip(substr(text,p+1)) | |
| 69 | 60 | end |
| 70 | 61 | |
| 71 | - say text | |
| 62 | + /* Insert new string */ | |
| 63 | + host~input(s) | |
| 72 | 64 | |
| 73 | 65 | if next <= cursor then |
| 74 | 66 | do |
| 75 | 67 | /* Next field is before the original position */ |
| 76 | - leave | |
| 68 | + return 0 | |
| 77 | 69 | end |
| 78 | 70 | |
| 79 | - text = "" | |
| 80 | 71 | end |
| 81 | 72 | |
| 82 | 73 | return 0 | ... | ... |