diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index 92980ac..1fc5c38 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -105,6 +105,7 @@ char * get_copy(void); char * get_clipboard(void); + int set_clipboard(const char *text); protected: @@ -281,6 +282,12 @@ return gtk_clipboard_wait_for_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD)); } + int plugin::set_clipboard(const char *text) + { + gtk_clipboard_set_text(gtk_widget_get_clipboard(pw3270_get_toplevel(),GDK_SELECTION_CLIPBOARD),(gchar *) text, -1); + return 0; + } + void plugin::free(void *ptr) { g_free(ptr); diff --git a/src/plugins/rx3270/rexx_methods.cc b/src/plugins/rx3270/rexx_methods.cc index 34b4665..0e2da28 100644 --- a/src/plugins/rx3270/rexx_methods.cc +++ b/src/plugins/rx3270/rexx_methods.cc @@ -481,3 +481,13 @@ RexxMethod1(RexxStringObject, rx3270_method_get_clipboard, CSELF, sessionPtr) return context->String(""); } +RexxMethod2(int, rx3270_method_set_clipboard, CSELF, sessionPtr, CSTRING, text) +{ + rx3270 * hSession = (rx3270 *) sessionPtr; + + if(hSession) + return hSession->set_clipboard(text); + + return -1; +} + diff --git a/src/plugins/rx3270/rx3270.cc b/src/plugins/rx3270/rx3270.cc index 407141e..11a4a0f 100644 --- a/src/plugins/rx3270/rx3270.cc +++ b/src/plugins/rx3270/rx3270.cc @@ -188,6 +188,11 @@ char * rx3270::get_clipboard(void) return NULL; } +int rx3270::set_clipboard(const char *text) +{ + return EINVAL; +} + void rx3270::free(void *ptr) { free(ptr); diff --git a/src/plugins/rx3270/rx3270.cls b/src/plugins/rx3270/rx3270.cls index 99c74a2..1d06096 100644 --- a/src/plugins/rx3270/rx3270.cls +++ b/src/plugins/rx3270/rx3270.cls @@ -80,6 +80,7 @@ ::METHOD SETSELECTION EXTERNAL "LIBRARY rx3270 rx3270_method_set_selection" ::METHOD GETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_get_clipboard" +::METHOD SETCLIPBOARD EXTERNAL "LIBRARY rx3270 rx3270_method_set_clipboard" ::method waitForStringAt use arg row, col, key, timeout diff --git a/src/plugins/rx3270/rx3270.h b/src/plugins/rx3270/rx3270.h index bd96d06..1ae606a 100644 --- a/src/plugins/rx3270/rx3270.h +++ b/src/plugins/rx3270/rx3270.h @@ -113,6 +113,7 @@ REXX_METHOD_PROTOTYPE(rx3270_method_get_selection); REXX_METHOD_PROTOTYPE(rx3270_method_set_selection); REXX_METHOD_PROTOTYPE(rx3270_method_get_clipboard); + REXX_METHOD_PROTOTYPE(rx3270_method_set_clipboard); REXX_METHOD_PROTOTYPE(rx3270_method_get_cursor_addr); REXX_METHOD_PROTOTYPE(rx3270_method_set_cursor_addr); REXX_METHOD_PROTOTYPE(rx3270_method_input_text); @@ -195,6 +196,7 @@ virtual char * get_copy(void); virtual char * get_clipboard(void); + virtual int set_clipboard(const char *text); }; diff --git a/src/plugins/rx3270/rxapimain.cc b/src/plugins/rx3270/rxapimain.cc index 159184e..98592ec 100644 --- a/src/plugins/rx3270/rxapimain.cc +++ b/src/plugins/rx3270/rxapimain.cc @@ -151,6 +151,7 @@ RexxMethodEntry rx3270_methods[] = REXX_METHOD(rx3270_method_get_selection, rx3270_method_get_selection ), REXX_METHOD(rx3270_method_set_selection, rx3270_method_set_selection ), REXX_METHOD(rx3270_method_get_clipboard, rx3270_method_get_clipboard ), + REXX_METHOD(rx3270_method_set_clipboard, rx3270_method_set_clipboard ), REXX_METHOD(rx3270_method_get_cursor_addr, rx3270_method_get_cursor_addr ), REXX_METHOD(rx3270_method_set_cursor_addr, rx3270_method_set_cursor_addr ), diff --git a/src/plugins/rx3270/sample/clipboard.rex b/src/plugins/rx3270/sample/clipboard.rex index 625d8af..3f7b96d 100644 --- a/src/plugins/rx3270/sample/clipboard.rex +++ b/src/plugins/rx3270/sample/clipboard.rex @@ -13,7 +13,7 @@ return 0 end - text = host~GetClipboard() + text = strip(host~GetClipboard()) if text = "" then do say "Clipboard is empty" @@ -38,45 +38,36 @@ field_len = host~GetFieldLen() - if length(text) < field_len then + s = strip(left(text,field_len)) + p = lastpos(" ",s) + + select + when length(text) < field_len then do - /* Text is smaller than field, just insert it */ - host~input(text) + s = strip(text) + text = "" end - else + + when p = 0 then do - /* Text is bigger than field, split ... */ s = strip(left(text,field_len)) - p = lastpos(" ",s) - if p = 0 then - do - s = strip(left(text,field_len)) - text = substr(text,field_len+1) - end - else - do - s = strip(left(text,p)) - text = strip(substr(text,p+1)) - end - - /* ... and justify */ - - /* TODO */ - - /* Insert new string */ - host~input(s) + text = substr(text,field_len+1) + end + otherwise + s = strip(left(text,p)) + text = strip(substr(text,p+1)) end - say text + /* Insert new string */ + host~input(s) if next <= cursor then do /* Next field is before the original position */ - leave + return 0 end - text = "" end return 0 -- libgit2 0.21.2