Commit fb5ef91a13646ac7f834a44ddd68b087d8c6afa7
1 parent
4435f231
Exists in
master
and in
5 other branches
Iniciando implementação da função "recortar"
Showing
7 changed files
with
67 additions
and
15 deletions
Show diff stats
src/include/lib3270.h
src/include/v3270.h
... | ... | @@ -153,10 +153,10 @@ |
153 | 153 | V3270_SELECT_MAX |
154 | 154 | } V3270_SELECT_FORMAT; |
155 | 155 | |
156 | - LIB3270_EXPORT const gchar * v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode); | |
156 | + LIB3270_EXPORT const gchar * v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut); | |
157 | 157 | LIB3270_EXPORT const gchar * v3270_copy_append(GtkWidget *widget); |
158 | 158 | |
159 | - LIB3270_EXPORT const gchar * v3270_get_selected_text(GtkWidget *widget); | |
159 | + LIB3270_EXPORT const gchar * v3270_get_selected_text(GtkWidget *widget, gboolean cut); | |
160 | 160 | LIB3270_EXPORT const gchar * v3270_get_copy(GtkWidget *widget); |
161 | 161 | LIB3270_EXPORT gchar * v3270_get_text(GtkWidget *widget,int offset, int len); |
162 | 162 | LIB3270_EXPORT gchar * v3270_get_region(GtkWidget *widget, gint start_pos, gint end_pos, gboolean all); | ... | ... |
src/lib3270/selection.c
... | ... | @@ -527,6 +527,19 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) |
527 | 527 | return get_text(hSession,0); |
528 | 528 | } |
529 | 529 | |
530 | +LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) | |
531 | +{ | |
532 | + if(!hSession->selected || hSession->select.start == hSession->select.end) | |
533 | + return NULL; | |
534 | + | |
535 | + if(!lib3270_connected(hSession)) | |
536 | + return NULL; | |
537 | + | |
538 | + | |
539 | + return NULL; | |
540 | +} | |
541 | + | |
542 | + | |
530 | 543 | LIB3270_EXPORT int lib3270_get_selection_bounds(H3270 *hSession, int *start, int *end) |
531 | 544 | { |
532 | 545 | int first, last; | ... | ... |
src/pw3270/actions.c
... | ... | @@ -113,7 +113,7 @@ static void reload_action(GtkAction *action, GtkWidget *widget) |
113 | 113 | v3270_reload(widget); |
114 | 114 | } |
115 | 115 | |
116 | -static void copy_action(GtkAction *action, GtkWidget *widget) | |
116 | +static void do_copy(GtkAction *action, GtkWidget *widget, gboolean cut) | |
117 | 117 | { |
118 | 118 | V3270_SELECT_FORMAT mode = V3270_SELECT_TEXT; |
119 | 119 | const gchar * str = (const gchar *) g_object_get_data(G_OBJECT(action),"format"); |
... | ... | @@ -143,7 +143,17 @@ static void copy_action(GtkAction *action, GtkWidget *widget) |
143 | 143 | } |
144 | 144 | |
145 | 145 | trace_action(action,widget); |
146 | - v3270_copy(widget,mode); | |
146 | + v3270_copy(widget,mode,cut); | |
147 | +} | |
148 | + | |
149 | +static void copy_action(GtkAction *action, GtkWidget *widget) | |
150 | +{ | |
151 | + do_copy(action, widget, FALSE); | |
152 | +} | |
153 | + | |
154 | +static void cut_action(GtkAction *action, GtkWidget *widget) | |
155 | +{ | |
156 | + do_copy(action, widget, TRUE); | |
147 | 157 | } |
148 | 158 | |
149 | 159 | static void append_action(GtkAction *action, GtkWidget *widget) |
... | ... | @@ -559,7 +569,17 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
559 | 569 | callback = cbk; |
560 | 570 | action_type = ACTION_TYPE_TABLE; |
561 | 571 | id = ui_get_bool_attribute("append",names,values,FALSE) ? 1 : 0; |
562 | - nm = g_strconcat(id == 0 ? "copy" : "append",ui_get_attribute("format",names,values),NULL); | |
572 | + nm = g_strconcat(id == 0 ? "copy" : "copyappend",ui_get_attribute("format",names,values),NULL); | |
573 | + } | |
574 | + else if(!g_ascii_strcasecmp(name,"cut")) | |
575 | + { | |
576 | + static const GCallback cbk[] = { G_CALLBACK(cut_action), | |
577 | + G_CALLBACK(cut_action) | |
578 | + }; | |
579 | + callback = cbk; | |
580 | + action_type = ACTION_TYPE_TABLE; | |
581 | + id = ui_get_bool_attribute("append",names,values,FALSE) ? 1 : 0; | |
582 | + nm = g_strconcat(id == 0 ? "cut" : "cutappend",ui_get_attribute("format",names,values),NULL); | |
563 | 583 | } |
564 | 584 | else if(!g_ascii_strcasecmp(name,"select")) |
565 | 585 | { | ... | ... |
src/pw3270/dialog.c
... | ... | @@ -421,7 +421,7 @@ |
421 | 421 | widget, |
422 | 422 | N_( "Save selection to file" ), |
423 | 423 | N_( "Can't save selection to file\n%s" ), |
424 | - v3270_get_selected_text(widget)); | |
424 | + v3270_get_selected_text(widget,FALSE)); | |
425 | 425 | } |
426 | 426 | |
427 | 427 | void save_copy_action(GtkAction *action, GtkWidget *widget) | ... | ... |
src/pw3270/v3270/selection.c
... | ... | @@ -103,7 +103,7 @@ gchar * v3270_get_text(GtkWidget *widget, int offset, int len) |
103 | 103 | * |
104 | 104 | * @return NULL if error, otherwise the selected buffer contents (release with g_free). |
105 | 105 | * |
106 | - */ | |
106 | + */ /* | |
107 | 107 | static gchar * v3270_get_selected(v3270 *widget) |
108 | 108 | { |
109 | 109 | gchar *text = lib3270_get_selected(widget->host); |
... | ... | @@ -116,10 +116,23 @@ static gchar * v3270_get_selected(v3270 *widget) |
116 | 116 | return NULL; |
117 | 117 | } |
118 | 118 | |
119 | -const gchar * v3270_get_selected_text(GtkWidget *widget) | |
119 | +static gchar * v3270_cut_selected(v3270 *widget) | |
120 | 120 | { |
121 | - v3270 *terminal; | |
122 | - gchar *text; | |
121 | + gchar *text = lib3270_cut_selected(widget->host); | |
122 | + if(text) | |
123 | + { | |
124 | + gchar *str = g_strdup(text); | |
125 | + lib3270_free(text); | |
126 | + return str; | |
127 | + } | |
128 | + return NULL; | |
129 | +} | |
130 | +*/ | |
131 | + | |
132 | +const gchar * v3270_get_selected_text(GtkWidget *widget, gboolean cut) | |
133 | +{ | |
134 | + v3270 * terminal; | |
135 | + char * text; | |
123 | 136 | |
124 | 137 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); |
125 | 138 | |
... | ... | @@ -131,7 +144,10 @@ const gchar * v3270_get_selected_text(GtkWidget *widget) |
131 | 144 | terminal->clipboard = NULL; |
132 | 145 | } |
133 | 146 | |
134 | - text = v3270_get_selected(terminal); | |
147 | + if(cut) | |
148 | + text = lib3270_cut_selected(terminal->host); | |
149 | + else | |
150 | + text = lib3270_get_selected(terminal->host); | |
135 | 151 | |
136 | 152 | if(!text) |
137 | 153 | { |
... | ... | @@ -217,7 +233,7 @@ const gchar * v3270_get_selected_text(GtkWidget *widget) |
217 | 233 | |
218 | 234 | terminal->clipboard = g_convert(text, -1, "UTF-8", lib3270_get_charset(terminal->host), NULL, NULL, NULL); |
219 | 235 | |
220 | - g_free(text); | |
236 | + lib3270_free(text); | |
221 | 237 | |
222 | 238 | |
223 | 239 | return terminal->clipboard; |
... | ... | @@ -246,7 +262,7 @@ const gchar * v3270_copy_append(GtkWidget *widget) |
246 | 262 | terminal = GTK_V3270(widget); |
247 | 263 | |
248 | 264 | if(!terminal->clipboard) |
249 | - return v3270_get_selected_text(widget); | |
265 | + return v3270_get_selected_text(widget,FALSE); | |
250 | 266 | |
251 | 267 | str = lib3270_get_selected(terminal->host); |
252 | 268 | |
... | ... | @@ -271,7 +287,7 @@ const gchar * v3270_copy_append(GtkWidget *widget) |
271 | 287 | return terminal->clipboard; |
272 | 288 | } |
273 | 289 | |
274 | -const gchar * v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode) | |
290 | +const gchar * v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut) | |
275 | 291 | { |
276 | 292 | const gchar * text; |
277 | 293 | GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD); |
... | ... | @@ -280,7 +296,7 @@ const gchar * v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode) |
280 | 296 | |
281 | 297 | GTK_V3270(widget)->table = (mode == V3270_SELECT_TABLE ? 1 : 0); |
282 | 298 | |
283 | - text = v3270_get_selected_text(widget); | |
299 | + text = v3270_get_selected_text(widget,cut); | |
284 | 300 | |
285 | 301 | if(text) |
286 | 302 | { | ... | ... |
ui/99debug.xml
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | <menubar name='topmenu'> |
33 | 33 | |
34 | 34 | <menu name='EditMenu' label='_Edit' > |
35 | + <menuitem action='cut' append='no' format='text' key='<ctrl>x' icon='cut' group='selection' label='Cut' /> | |
35 | 36 | <menuitem action='copyashtml' label='Copy as HTML' /> |
36 | 37 | </menu> |
37 | 38 | ... | ... |