Commit 4a81c5c92cbbe34a9e3c18e2f81a462b62760aa1
1 parent
438e78f7
Exists in
master
and in
1 other branch
Iniciando implementação da função "recortar"
Showing
1 changed file
with
25 additions
and
9 deletions
Show diff stats
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 | { | ... | ... |