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,6 +105,7 @@ | ||
105 | char * get_copy(void); | 105 | char * get_copy(void); |
106 | 106 | ||
107 | char * get_clipboard(void); | 107 | char * get_clipboard(void); |
108 | + int set_clipboard(const char *text); | ||
108 | 109 | ||
109 | protected: | 110 | protected: |
110 | 111 | ||
@@ -281,6 +282,12 @@ | @@ -281,6 +282,12 @@ | ||
281 | return gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); | 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 | void plugin::free(void *ptr) | 291 | void plugin::free(void *ptr) |
285 | { | 292 | { |
286 | g_free(ptr); | 293 | g_free(ptr); |
src/plugins/rx3270/rexx_methods.cc
@@ -481,3 +481,13 @@ RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr) | @@ -481,3 +481,13 @@ RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr) | ||
481 | return context->String(""); | 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
@@ -188,6 +188,11 @@ char * rx3270::get_clipboard(void) | @@ -188,6 +188,11 @@ char * rx3270::get_clipboard(void) | ||
188 | return NULL; | 188 | return NULL; |
189 | } | 189 | } |
190 | 190 | ||
191 | +int rx3270::set_clipboard(const char *text) | ||
192 | +{ | ||
193 | + return EINVAL; | ||
194 | +} | ||
195 | + | ||
191 | void rx3270::free(void *ptr) | 196 | void rx3270::free(void *ptr) |
192 | { | 197 | { |
193 | free(ptr); | 198 | free(ptr); |
src/plugins/rx3270/rx3270.cls
@@ -80,6 +80,7 @@ | @@ -80,6 +80,7 @@ | ||
80 | ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection" | 80 | ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection" |
81 | 81 | ||
82 | ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" | 82 | ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" |
83 | +::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard" | ||
83 | 84 | ||
84 | ::method waitForStringAt | 85 | ::method waitForStringAt |
85 | use arg row, col, key, timeout | 86 | use arg row, col, key, timeout |
src/plugins/rx3270/rx3270.h
@@ -113,6 +113,7 @@ | @@ -113,6 +113,7 @@ | ||
113 | REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); | 113 | REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); |
114 | REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); | 114 | REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); |
115 | REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); | 115 | REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); |
116 | + REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); | ||
116 | REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); | 117 | REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); |
117 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); | 118 | REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); |
118 | REXX_METHOD_PROTOTYPE(rx3270_method_input_text); | 119 | REXX_METHOD_PROTOTYPE(rx3270_method_input_text); |
@@ -195,6 +196,7 @@ | @@ -195,6 +196,7 @@ | ||
195 | virtual char * get_copy(void); | 196 | virtual char * get_copy(void); |
196 | 197 | ||
197 | virtual char * get_clipboard(void); | 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,6 +151,7 @@ RexxMethodEntry rx3270_methods[] = | ||
151 | REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ), | 151 | REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ), |
152 | REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), | 152 | REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), |
153 | REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), | 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 | REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), | 156 | REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), |
156 | REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), | 157 | REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), |
src/plugins/rx3270/sample/clipboard.rex
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | return 0 | 13 | return 0 |
14 | end | 14 | end |
15 | 15 | ||
16 | - text = host~GetClipboard() | 16 | + text = strip(host~GetClipboard()) |
17 | if text = "" then | 17 | if text = "" then |
18 | do | 18 | do |
19 | say "Clipboard is empty" | 19 | say "Clipboard is empty" |
@@ -38,45 +38,36 @@ | @@ -38,45 +38,36 @@ | ||
38 | 38 | ||
39 | field_len = host~GetFieldLen() | 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 | do | 46 | do |
43 | - /* Text is smaller than field, just insert it */ | ||
44 | - host~input(text) | 47 | + s = strip(text) |
48 | + text = "" | ||
45 | end | 49 | end |
46 | - else | 50 | + |
51 | + when p = 0 then | ||
47 | do | 52 | do |
48 | - /* Text is bigger than field, split ... */ | ||
49 | s = strip(left(text,field_len)) | 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 | end | 60 | end |
70 | 61 | ||
71 | - say text | 62 | + /* Insert new string */ |
63 | + host~input(s) | ||
72 | 64 | ||
73 | if next <= cursor then | 65 | if next <= cursor then |
74 | do | 66 | do |
75 | /* Next field is before the original position */ | 67 | /* Next field is before the original position */ |
76 | - leave | 68 | + return 0 |
77 | end | 69 | end |
78 | 70 | ||
79 | - text = "" | ||
80 | end | 71 | end |
81 | 72 | ||
82 | return 0 | 73 | return 0 |