Commit 925acbf87ecfe2ab76681ffb12b332eb5e4458eb
1 parent
5a3042e8
Exists in
master
and in
5 other branches
Implementando métodos para que um script rexx possa alterar o clipboard salvo
Showing
7 changed files
with
80 additions
and
0 deletions
Show diff stats
src/include/lib3270.h
@@ -960,6 +960,7 @@ | @@ -960,6 +960,7 @@ | ||
960 | LIB3270_EXPORT void * lib3270_malloc(int len); | 960 | LIB3270_EXPORT void * lib3270_malloc(int len); |
961 | LIB3270_EXPORT void * lib3270_realloc(void *p, int len); | 961 | LIB3270_EXPORT void * lib3270_realloc(void *p, int len); |
962 | LIB3270_EXPORT void * lib3270_replace(void **p, void *ptr); | 962 | LIB3270_EXPORT void * lib3270_replace(void **p, void *ptr); |
963 | + LIB3270_EXPORT void * lib3270_strdup(const char *str); | ||
963 | 964 | ||
964 | /** | 965 | /** |
965 | * Release allocated memory. | 966 | * Release allocated memory. |
src/include/pw3270/v3270.h
@@ -172,6 +172,7 @@ | @@ -172,6 +172,7 @@ | ||
172 | LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget); | 172 | LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget); |
173 | LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut); | 173 | LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut); |
174 | LIB3270_EXPORT gchar * v3270_get_copy(GtkWidget *widget); | 174 | LIB3270_EXPORT gchar * v3270_get_copy(GtkWidget *widget); |
175 | + LIB3270_EXPORT void v3270_set_copy(GtkWidget *widget, const gchar *text); | ||
175 | 176 | ||
176 | LIB3270_EXPORT int v3270_run_script(GtkWidget *widget, const gchar *script); | 177 | LIB3270_EXPORT int v3270_run_script(GtkWidget *widget, const gchar *script); |
177 | 178 |
src/lib3270/util.c
@@ -929,6 +929,21 @@ LIB3270_EXPORT void * lib3270_malloc(int len) | @@ -929,6 +929,21 @@ LIB3270_EXPORT void * lib3270_malloc(int len) | ||
929 | return r; | 929 | return r; |
930 | } | 930 | } |
931 | 931 | ||
932 | +LIB3270_EXPORT void * lib3270_strdup(const char *str) | ||
933 | +{ | ||
934 | + char *r; | ||
935 | + | ||
936 | + r = strdup(str); | ||
937 | + if (r == (char *)NULL) | ||
938 | + { | ||
939 | + Error(NULL,"Out of memory in %s",__FUNCTION__); | ||
940 | + return 0; | ||
941 | + } | ||
942 | + | ||
943 | + return r; | ||
944 | +} | ||
945 | + | ||
946 | + | ||
932 | LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...) | 947 | LIB3270_EXPORT char * lib3270_get_resource_string(H3270 *hSession, const char *first_element, ...) |
933 | { | 948 | { |
934 | #ifdef ANDROID | 949 | #ifdef ANDROID |
src/plugins/rx3270/pluginmain.cc
@@ -94,6 +94,9 @@ | @@ -94,6 +94,9 @@ | ||
94 | int get_field_start(int baddr = -1); | 94 | int get_field_start(int baddr = -1); |
95 | int get_field_len(int baddr = -1); | 95 | int get_field_len(int baddr = -1); |
96 | 96 | ||
97 | + int set_copy(const char *text); | ||
98 | + char * get_copy(void); | ||
99 | + | ||
97 | private: | 100 | private: |
98 | H3270 *hSession; | 101 | H3270 *hSession; |
99 | 102 | ||
@@ -244,6 +247,17 @@ | @@ -244,6 +247,17 @@ | ||
244 | return lib3270_get_field_len(hSession,baddr); | 247 | return lib3270_get_field_len(hSession,baddr); |
245 | } | 248 | } |
246 | 249 | ||
250 | + int plugin::set_copy(const char *text) | ||
251 | + { | ||
252 | + v3270_set_copy(GTK_WIDGET(lib3270_get_widget(hSession)),text); | ||
253 | + return 0; | ||
254 | + } | ||
255 | + | ||
256 | + char * plugin::get_copy(void) | ||
257 | + { | ||
258 | + return v3270_get_copy(GTK_WIDGET(lib3270_get_widget(hSession))); | ||
259 | + } | ||
260 | + | ||
247 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) | 261 | static int REXXENTRY Rexx_IO_exit(RexxExitContext *context, int exitnumber, int subfunction, PEXIT parmBlock) |
248 | { | 262 | { |
249 | trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); | 263 | trace("%s call with ExitNumber: %d Subfunction: %d",__FUNCTION__,(int) exitnumber, (int) subfunction); |
src/plugins/rx3270/rx3270.cc
@@ -154,6 +154,17 @@ void rx3270::set_plugin(void) | @@ -154,6 +154,17 @@ void rx3270::set_plugin(void) | ||
154 | plugin = true; | 154 | plugin = true; |
155 | } | 155 | } |
156 | 156 | ||
157 | +int rx3270::set_copy(const char *text) | ||
158 | +{ | ||
159 | + return EINVAL; | ||
160 | +} | ||
161 | + | ||
162 | +char * rx3270::get_copy(void) | ||
163 | +{ | ||
164 | + errno = EINVAL; | ||
165 | + return NULL; | ||
166 | +} | ||
167 | + | ||
157 | 168 | ||
158 | 169 | ||
159 | 170 |
src/plugins/rx3270/rx3270.h
@@ -171,6 +171,9 @@ | @@ -171,6 +171,9 @@ | ||
171 | virtual int get_field_start(int baddr = -1) = 0; | 171 | virtual int get_field_start(int baddr = -1) = 0; |
172 | virtual int get_field_len(int baddr = -1) = 0; | 172 | virtual int get_field_len(int baddr = -1) = 0; |
173 | 173 | ||
174 | + virtual int set_copy(const char *text); | ||
175 | + virtual char * get_copy(void); | ||
176 | + | ||
174 | }; | 177 | }; |
175 | 178 | ||
176 | rx3270 * create_lib3270_instance(void); | 179 | rx3270 * create_lib3270_instance(void); |
src/pw3270/v3270/selection.c
@@ -244,6 +244,41 @@ gchar * v3270_get_copy(GtkWidget *widget) | @@ -244,6 +244,41 @@ gchar * v3270_get_copy(GtkWidget *widget) | ||
244 | return NULL; | 244 | return NULL; |
245 | } | 245 | } |
246 | 246 | ||
247 | +void v3270_set_copy(GtkWidget *widget, const gchar *text) | ||
248 | +{ | ||
249 | + v3270 * terminal; | ||
250 | + gchar * isotext; | ||
251 | + | ||
252 | + g_return_if_fail(GTK_IS_V3270(widget)); | ||
253 | + | ||
254 | + terminal = GTK_V3270(widget); | ||
255 | + v3270_clear_clipboard(terminal); | ||
256 | + | ||
257 | + if(!text) | ||
258 | + { | ||
259 | + /* No string, signal clipboard clear and return */ | ||
260 | + g_signal_emit(widget,v3270_widget_signal[SIGNAL_CLIPBOARD], 0, FALSE); | ||
261 | + return; | ||
262 | + } | ||
263 | + | ||
264 | + /* Received text, replace the selection buffer */ | ||
265 | + terminal->table = 0; | ||
266 | + isotext = g_convert(text, -1, lib3270_get_charset(terminal->host), "UTF-8", NULL, NULL, NULL); | ||
267 | + | ||
268 | + if(!isotext) | ||
269 | + { | ||
270 | + /* No string, signal clipboard clear and return */ | ||
271 | + g_signal_emit(widget,v3270_widget_signal[SIGNAL_CLIPBOARD], 0, FALSE); | ||
272 | + return; | ||
273 | + } | ||
274 | + | ||
275 | + terminal->selection.text = lib3270_strdup(isotext); | ||
276 | + | ||
277 | + g_free(isotext); | ||
278 | + | ||
279 | + g_signal_emit(widget,v3270_widget_signal[SIGNAL_CLIPBOARD], 0, TRUE); | ||
280 | +} | ||
281 | + | ||
247 | static void update_system_clipboard(GtkWidget *widget) | 282 | static void update_system_clipboard(GtkWidget *widget) |
248 | { | 283 | { |
249 | if(GTK_V3270(widget)->selection.text) | 284 | if(GTK_V3270(widget)->selection.text) |