Commit 6e5a18716e354bd74414c1a5e96e0ea3c9e88c46
1 parent
1f33f14c
Exists in
master
and in
1 other branch
Working on new clipboard manager.
Showing
6 changed files
with
58 additions
and
54 deletions
Show diff stats
src/clipboard/linux/paste.c
@@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
33 | 33 | ||
34 | static void text_received(G_GNUC_UNUSED GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) | 34 | static void text_received(G_GNUC_UNUSED GtkClipboard *clipboard, const gchar *text, GtkWidget *widget) |
35 | { | 35 | { |
36 | - v3270_paste_string(widget,text,"UTF-8"); | 36 | + v3270_paste_text(widget,text,"UTF-8"); |
37 | } | 37 | } |
38 | 38 | ||
39 | LIB3270_EXPORT void v3270_paste(GtkWidget *widget) | 39 | LIB3270_EXPORT void v3270_paste(GtkWidget *widget) |
src/clipboard/selection.c
@@ -31,11 +31,13 @@ | @@ -31,11 +31,13 @@ | ||
31 | 31 | ||
32 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 32 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
33 | 33 | ||
34 | +/* | ||
34 | static const GtkTargetEntry targets[] = | 35 | static const GtkTargetEntry targets[] = |
35 | { | 36 | { |
36 | { "COMPOUND_TEXT", 0, CLIPBOARD_TYPE_TEXT }, | 37 | { "COMPOUND_TEXT", 0, CLIPBOARD_TYPE_TEXT }, |
37 | { "UTF8_STRING", 0, CLIPBOARD_TYPE_TEXT }, | 38 | { "UTF8_STRING", 0, CLIPBOARD_TYPE_TEXT }, |
38 | }; | 39 | }; |
40 | +*/ | ||
39 | 41 | ||
40 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 42 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
41 | 43 | ||
@@ -47,6 +49,8 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa | @@ -47,6 +49,8 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa | ||
47 | { | 49 | { |
48 | v3270 * widget = GTK_V3270(obj); | 50 | v3270 * widget = GTK_V3270(obj); |
49 | 51 | ||
52 | + debug("%s target=%u",__FUNCTION__,(unsigned int) target); | ||
53 | + | ||
50 | switch(target) | 54 | switch(target) |
51 | { | 55 | { |
52 | case CLIPBOARD_TYPE_TEXT: /* Get clipboard contents as text */ | 56 | case CLIPBOARD_TYPE_TEXT: /* Get clipboard contents as text */ |
@@ -157,10 +161,30 @@ void v3270_update_system_clipboard(GtkWidget *widget) | @@ -157,10 +161,30 @@ void v3270_update_system_clipboard(GtkWidget *widget) | ||
157 | { | 161 | { |
158 | GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD); | 162 | GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD); |
159 | 163 | ||
164 | + // Create target list | ||
165 | + // | ||
166 | + // Reference: https://cpp.hotexamples.com/examples/-/-/g_list_insert_sorted/cpp-g_list_insert_sorted-function-examples.html | ||
167 | + // | ||
168 | + GtkTargetList * list = gtk_target_list_new(NULL, 0); | ||
169 | + GtkTargetEntry * targets; | ||
170 | + int n_targets; | ||
171 | + | ||
172 | + gtk_target_list_add_text_targets(list, CLIPBOARD_TYPE_TEXT); | ||
173 | + targets = gtk_target_table_new_from_list(list, &n_targets); | ||
174 | + | ||
175 | +#ifdef DEBUG | ||
176 | + { | ||
177 | + int ix; | ||
178 | + for(ix = 0; ix < n_targets; ix++) { | ||
179 | + debug("target(%d)=\"%s\"",ix,targets[ix].target); | ||
180 | + } | ||
181 | + } | ||
182 | +#endif // DEBUG | ||
183 | + | ||
160 | if(gtk_clipboard_set_with_owner( | 184 | if(gtk_clipboard_set_with_owner( |
161 | clipboard, | 185 | clipboard, |
162 | targets, | 186 | targets, |
163 | - G_N_ELEMENTS(targets), | 187 | + n_targets, |
164 | (GtkClipboardGetFunc) clipboard_get, | 188 | (GtkClipboardGetFunc) clipboard_get, |
165 | (GtkClipboardClearFunc) clipboard_clear, | 189 | (GtkClipboardClearFunc) clipboard_clear, |
166 | G_OBJECT(widget) | 190 | G_OBJECT(widget) |
@@ -169,11 +193,14 @@ void v3270_update_system_clipboard(GtkWidget *widget) | @@ -169,11 +193,14 @@ void v3270_update_system_clipboard(GtkWidget *widget) | ||
169 | gtk_clipboard_set_can_store(clipboard,targets,1); | 193 | gtk_clipboard_set_can_store(clipboard,targets,1); |
170 | } | 194 | } |
171 | 195 | ||
196 | + gtk_target_table_free(targets, n_targets); | ||
197 | + gtk_target_list_unref(list); | ||
198 | + | ||
172 | g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, TRUE); | 199 | g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_CLIPBOARD], 0, TRUE); |
173 | } | 200 | } |
174 | } | 201 | } |
175 | 202 | ||
176 | -LIB3270_EXPORT void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut) | 203 | +LIB3270_EXPORT void v3270_copy_text(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut) |
177 | { | 204 | { |
178 | g_return_if_fail(GTK_IS_V3270(widget)); | 205 | g_return_if_fail(GTK_IS_V3270(widget)); |
179 | GTK_V3270(widget)->selection.format = mode; | 206 | GTK_V3270(widget)->selection.format = mode; |
src/clipboard/text.c
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | #include <clipboard.h> | 30 | #include <clipboard.h> |
31 | 31 | ||
32 | 32 | ||
33 | -LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget) | 33 | +LIB3270_EXPORT void v3270_copy_text_append(GtkWidget *widget) |
34 | { | 34 | { |
35 | v3270 * terminal; | 35 | v3270 * terminal; |
36 | char * str; | 36 | char * str; |
@@ -42,7 +42,7 @@ LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget) | @@ -42,7 +42,7 @@ LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget) | ||
42 | if(!terminal->selection.text) | 42 | if(!terminal->selection.text) |
43 | { | 43 | { |
44 | // Clipboard is empty, do a single copy | 44 | // Clipboard is empty, do a single copy |
45 | - v3270_copy(widget, V3270_SELECT_TEXT, FALSE); | 45 | + v3270_copy_text(widget, V3270_SELECT_TEXT, FALSE); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
@@ -161,7 +161,7 @@ const char * v3270_update_selected_text(GtkWidget *widget, gboolean cut) | @@ -161,7 +161,7 @@ const char * v3270_update_selected_text(GtkWidget *widget, gboolean cut) | ||
161 | 161 | ||
162 | } | 162 | } |
163 | 163 | ||
164 | -LIB3270_EXPORT void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding) | 164 | +LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget, const gchar *text, const gchar *encoding) |
165 | { | 165 | { |
166 | gchar * buffer = NULL; | 166 | gchar * buffer = NULL; |
167 | H3270 * session = v3270_get_session(widget); | 167 | H3270 * session = v3270_get_session(widget); |
src/clipboard/windows/paste.c
@@ -48,7 +48,7 @@ LIB3270_EXPORT void v3270_paste(GtkWidget *widget) | @@ -48,7 +48,7 @@ LIB3270_EXPORT void v3270_paste(GtkWidget *widget) | ||
48 | LPTSTR lptstr = GlobalLock(hglb); | 48 | LPTSTR lptstr = GlobalLock(hglb); |
49 | if (lptstr != NULL) | 49 | if (lptstr != NULL) |
50 | { | 50 | { |
51 | - v3270_paste_string(widget,lptstr,"CP1252"); | 51 | + v3270_paste_text(widget,lptstr,"CP1252"); |
52 | GlobalUnlock(hglb); | 52 | GlobalUnlock(hglb); |
53 | } | 53 | } |
54 | } | 54 | } |
src/include/v3270.h
@@ -189,8 +189,6 @@ | @@ -189,8 +189,6 @@ | ||
189 | V3270_SELECT_MAX | 189 | V3270_SELECT_MAX |
190 | } V3270_SELECT_FORMAT; | 190 | } V3270_SELECT_FORMAT; |
191 | 191 | ||
192 | - LIB3270_EXPORT void v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut); | ||
193 | - LIB3270_EXPORT void v3270_copy_append(GtkWidget *widget); | ||
194 | LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut); | 192 | LIB3270_EXPORT gchar * v3270_get_selected(GtkWidget *widget, gboolean cut); |
195 | LIB3270_EXPORT gchar * v3270_get_copy(GtkWidget *widget); | 193 | LIB3270_EXPORT gchar * v3270_get_copy(GtkWidget *widget); |
196 | LIB3270_EXPORT void v3270_set_copy(GtkWidget *widget, const gchar *text); | 194 | LIB3270_EXPORT void v3270_set_copy(GtkWidget *widget, const gchar *text); |
@@ -206,10 +204,14 @@ | @@ -206,10 +204,14 @@ | ||
206 | LIB3270_EXPORT gboolean v3270_get_selection_bounds(GtkWidget *widget, gint *start, gint *end); | 204 | LIB3270_EXPORT gboolean v3270_get_selection_bounds(GtkWidget *widget, gint *start, gint *end); |
207 | LIB3270_EXPORT void v3270_unselect(GtkWidget *widget); | 205 | LIB3270_EXPORT void v3270_unselect(GtkWidget *widget); |
208 | LIB3270_EXPORT void v3270_select_all(GtkWidget *widget); | 206 | LIB3270_EXPORT void v3270_select_all(GtkWidget *widget); |
209 | - LIB3270_EXPORT void v3270_paste(GtkWidget *widget); | ||
210 | - LIB3270_EXPORT void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding); | ||
211 | LIB3270_EXPORT void v3270_select_region(GtkWidget *widget, gint start, gint end); | 207 | LIB3270_EXPORT void v3270_select_region(GtkWidget *widget, gint start, gint end); |
212 | 208 | ||
209 | + LIB3270_EXPORT void v3270_copy_text(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut); | ||
210 | + LIB3270_EXPORT void v3270_copy_text_append(GtkWidget *widget); | ||
211 | + | ||
212 | + LIB3270_EXPORT void v3270_paste(GtkWidget *widget); | ||
213 | + LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget, const gchar *text, const gchar *encoding); | ||
214 | + | ||
213 | // Colors | 215 | // Colors |
214 | LIB3270_EXPORT void v3270_set_colors(GtkWidget *widget, const gchar *); | 216 | LIB3270_EXPORT void v3270_set_colors(GtkWidget *widget, const gchar *); |
215 | LIB3270_EXPORT void v3270_set_color_table(GdkRGBA *table, const gchar *colors); | 217 | LIB3270_EXPORT void v3270_set_color_table(GdkRGBA *table, const gchar *colors); |
src/trace/exec.c
@@ -106,49 +106,6 @@ | @@ -106,49 +106,6 @@ | ||
106 | g_value_unset(&val); | 106 | g_value_unset(&val); |
107 | return 0; | 107 | return 0; |
108 | 108 | ||
109 | - /* | ||
110 | - size_t ix; | ||
111 | - | ||
112 | - debug("%s=%s",name,value); | ||
113 | - | ||
114 | - // Check toggles | ||
115 | - for(ix = 0; ix < (size_t) LIB3270_TOGGLE_COUNT; ix++) | ||
116 | - { | ||
117 | - if(g_ascii_strcasecmp(name,lib3270_get_toggle_name((LIB3270_TOGGLE) ix)) == 0) | ||
118 | - return lib3270_set_toggle(hSession,(LIB3270_TOGGLE) ix, atoi(value)); | ||
119 | - | ||
120 | - } | ||
121 | - | ||
122 | - // Check boolean properties | ||
123 | - const LIB3270_INT_PROPERTY * bProp = lib3270_get_boolean_properties_list(); | ||
124 | - for(ix = 0; bProp[ix].name; ix++) | ||
125 | - { | ||
126 | - if(g_ascii_strcasecmp(name,bProp[ix].name) == 0 && bProp[ix].set) | ||
127 | - return bProp[ix].set(hSession,atoi(value)); | ||
128 | - | ||
129 | - } | ||
130 | - | ||
131 | - // Check integer properties | ||
132 | - const LIB3270_INT_PROPERTY * iProp = lib3270_get_int_properties_list(); | ||
133 | - for(ix = 0; iProp[ix].name; ix++) | ||
134 | - { | ||
135 | - if(g_ascii_strcasecmp(name,iProp[ix].name) == 0 && iProp[ix].set) | ||
136 | - return iProp[ix].set(hSession,atoi(value)); | ||
137 | - | ||
138 | - } | ||
139 | - | ||
140 | - // Check string properties | ||
141 | - const LIB3270_STRING_PROPERTY * sProp = lib3270_get_string_properties_list(); | ||
142 | - for(ix = 0; sProp[ix].name; ix++) | ||
143 | - { | ||
144 | - if(g_ascii_strcasecmp(name,sProp[ix].name) == 0 && sProp[ix].set) | ||
145 | - return sProp[ix].set(hSession,value); | ||
146 | - | ||
147 | - } | ||
148 | - */ | ||
149 | - | ||
150 | - return errno = ENOENT; | ||
151 | - | ||
152 | } | 109 | } |
153 | 110 | ||
154 | static int get_property(GtkWidget *widget, const gchar *name) | 111 | static int get_property(GtkWidget *widget, const gchar *name) |
@@ -217,6 +174,24 @@ | @@ -217,6 +174,24 @@ | ||
217 | return 0; | 174 | return 0; |
218 | } | 175 | } |
219 | 176 | ||
177 | + if(g_str_has_prefix(cmdline,"copy")) | ||
178 | + { | ||
179 | + gchar * arg = cmdline+4; | ||
180 | + g_strstrip(arg); | ||
181 | + | ||
182 | + if(!(*arg && g_ascii_strcasecmp(arg,"text"))) | ||
183 | + { | ||
184 | + // No argument or "text" copy text. | ||
185 | + v3270_copy_text(widget, V3270_SELECT_TEXT, FALSE); | ||
186 | + } | ||
187 | + else if(!g_ascii_strcasecmp(arg,"table")) | ||
188 | + { | ||
189 | + v3270_copy_text(widget, V3270_SELECT_TABLE, FALSE); | ||
190 | + } | ||
191 | + | ||
192 | + return 0; | ||
193 | + } | ||
194 | + | ||
220 | if(g_str_has_suffix(cmdline,"?")) | 195 | if(g_str_has_suffix(cmdline,"?")) |
221 | { | 196 | { |
222 | gchar * str = strchr(cmdline,'?'); | 197 | gchar * str = strchr(cmdline,'?'); |