Commit 057233e1f21337281df2f208c56e916edcd54e6d
1 parent
b35da6da
Exists in
master
and in
1 other branch
Finishing the new "save" dialog.
Showing
6 changed files
with
35 additions
and
32 deletions
Show diff stats
src/dialogs/save/save.c
| ... | ... | @@ -335,6 +335,9 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon |
| 335 | 335 | switch(dialog->mode) |
| 336 | 336 | { |
| 337 | 337 | case LIB3270_CONTENT_ALL: |
| 338 | + dynamic = g_new0(GList,1); | |
| 339 | + dynamic->data = (gpointer) lib3270_get_selection(v3270_get_session(dialog->terminal),0,1); | |
| 340 | + selection = dynamic; | |
| 338 | 341 | break; |
| 339 | 342 | |
| 340 | 343 | case LIB3270_CONTENT_COPY: |
| ... | ... | @@ -343,7 +346,7 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon |
| 343 | 346 | |
| 344 | 347 | case LIB3270_CONTENT_SELECTED: |
| 345 | 348 | dynamic = g_new0(GList,1); |
| 346 | - dynamic->data = (gpointer) lib3270_get_selection(v3270_get_session(dialog->terminal),0); | |
| 349 | + dynamic->data = (gpointer) lib3270_get_selection(v3270_get_session(dialog->terminal),0,0); | |
| 347 | 350 | selection = dynamic; |
| 348 | 351 | break; |
| 349 | 352 | |
| ... | ... | @@ -366,15 +369,15 @@ static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIcon |
| 366 | 369 | switch(gtk_combo_box_get_active(GTK_COMBO_BOX(dialog->format))) |
| 367 | 370 | { |
| 368 | 371 | case 0: // "Plain text" |
| 369 | - text = v3270_get_selection_as_text(GTK_V3270(dialog->terminal), selection, encoding); | |
| 372 | + text = v3270_get_selection_as_text(GTK_V3270(dialog->terminal), selection, encoding, dialog->mode == LIB3270_CONTENT_ALL); | |
| 370 | 373 | break; |
| 371 | 374 | |
| 372 | 375 | case 1: // "Comma-separated values (CSV)" |
| 373 | - text = v3270_get_selection_as_table(GTK_V3270(dialog->terminal),selection,";",encoding); | |
| 376 | + text = v3270_get_selection_as_table(GTK_V3270(dialog->terminal),selection,";",encoding, dialog->mode == LIB3270_CONTENT_ALL); | |
| 374 | 377 | break; |
| 375 | 378 | |
| 376 | 379 | case 2: // "HyperText Markup Language (HTML)" |
| 377 | - text = v3270_get_selection_as_html_div(GTK_V3270(dialog->terminal),selection,encoding); | |
| 380 | + text = v3270_get_selection_as_html_div(GTK_V3270(dialog->terminal),selection,encoding, dialog->mode == LIB3270_CONTENT_ALL); | |
| 378 | 381 | break; |
| 379 | 382 | |
| 380 | 383 | default: | ... | ... |
src/include/clipboard.h
| ... | ... | @@ -87,13 +87,13 @@ |
| 87 | 87 | |
| 88 | 88 | G_GNUC_INTERNAL void v3270_update_system_clipboard(GtkWidget *widget); |
| 89 | 89 | G_GNUC_INTERNAL const char * v3270_update_selected_text(GtkWidget *widget, gboolean cut); |
| 90 | - G_GNUC_INTERNAL GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection); | |
| 90 | + G_GNUC_INTERNAL GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection, gboolean all); | |
| 91 | 91 | |
| 92 | 92 | /// @brief Get contents. |
| 93 | - G_GNUC_INTERNAL gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, const gchar *encoding); | |
| 94 | - G_GNUC_INTERNAL gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, const gchar *delimiter, const gchar *encoding); | |
| 95 | - G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding); | |
| 96 | - G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding); | |
| 93 | + G_GNUC_INTERNAL gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all); | |
| 94 | + G_GNUC_INTERNAL gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, const gchar *delimiter, const gchar *encoding, gboolean all); | |
| 95 | + G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all); | |
| 96 | + G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all); | |
| 97 | 97 | |
| 98 | 98 | G_GNUC_INTERNAL const GList * v3270_get_selection_blocks(GtkWidget *widget); |
| 99 | 99 | ... | ... |
src/selection/copy.c
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | |
| 33 | 33 | static void do_copy(v3270 *terminal, gboolean cut) |
| 34 | 34 | { |
| 35 | - lib3270_selection * selection = lib3270_get_selection(terminal->host,cut); | |
| 35 | + lib3270_selection * selection = lib3270_get_selection(terminal->host,cut,0); | |
| 36 | 36 | |
| 37 | 37 | if(selection) |
| 38 | 38 | { | ... | ... |
src/selection/html.c
| ... | ... | @@ -49,7 +49,7 @@ static void get_element_colors(v3270 * terminal, unsigned short attr, gchar **fg |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /// @brief Get formatted contents as HTML DIV. |
| 52 | -static gchar * get_as_div(v3270 * terminal, const GList *selection) | |
| 52 | +static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all) | |
| 53 | 53 | { |
| 54 | 54 | const GList * element = selection; |
| 55 | 55 | GString * string = g_string_new(""); |
| ... | ... | @@ -110,7 +110,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection) |
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if(block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED && !isspace(block->contents[src].chr)) | |
| 113 | + if( (block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED || all) && !isspace(block->contents[src].chr)) | |
| 114 | 114 | { |
| 115 | 115 | g_string_append_c(string,block->contents[src].chr); |
| 116 | 116 | } |
| ... | ... | @@ -144,7 +144,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection) |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /// @brief Get formatted contents as HTML TABLE. |
| 147 | -static gchar * get_as_table(v3270 * terminal, const GList *selection) | |
| 147 | +static gchar * get_as_table(v3270 * terminal, const GList *selection, gboolean all) | |
| 148 | 148 | { |
| 149 | 149 | const GList * element = selection; |
| 150 | 150 | GString * string = g_string_new("<table><tbody>"); |
| ... | ... | @@ -155,7 +155,7 @@ static gchar * get_as_table(v3270 * terminal, const GList *selection) |
| 155 | 155 | GList * column; |
| 156 | 156 | |
| 157 | 157 | // Get contents |
| 158 | - GList * columns = v3270_getColumns_from_selection(terminal, selection); | |
| 158 | + GList * columns = v3270_getColumns_from_selection(terminal, selection, all); | |
| 159 | 159 | |
| 160 | 160 | while(element) |
| 161 | 161 | { |
| ... | ... | @@ -214,15 +214,15 @@ static gchar * get_as_table(v3270 * terminal, const GList *selection) |
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | -gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding) | |
| 217 | +gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all) | |
| 218 | 218 | { |
| 219 | - g_autofree char * text = get_as_div(terminal, selection); | |
| 219 | + g_autofree char * text = get_as_div(terminal, selection, all); | |
| 220 | 220 | return g_convert(text, -1, (encoding ? encoding : "UTF-8"), lib3270_get_display_charset(terminal->host), NULL, NULL, NULL); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | -gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding) | |
| 223 | +gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all) | |
| 224 | 224 | { |
| 225 | - g_autofree char * text = get_as_table(terminal, selection); | |
| 225 | + g_autofree char * text = get_as_table(terminal, selection, all); | |
| 226 | 226 | return g_convert(text, -1, (encoding ? encoding : "UTF-8"), lib3270_get_display_charset(terminal->host), NULL, NULL, NULL); |
| 227 | 227 | } |
| 228 | 228 | |
| ... | ... | @@ -230,8 +230,8 @@ gchar * v3270_get_copy_as_html(v3270 * terminal, const gchar *encoding) |
| 230 | 230 | { |
| 231 | 231 | |
| 232 | 232 | if(terminal->selection.format == V3270_SELECT_TABLE) |
| 233 | - return v3270_get_selection_as_html_table(terminal, terminal->selection.blocks, encoding); | |
| 233 | + return v3270_get_selection_as_html_table(terminal, terminal->selection.blocks, encoding, FALSE); | |
| 234 | 234 | |
| 235 | - return v3270_get_selection_as_html_div(terminal, terminal->selection.blocks, encoding); | |
| 235 | + return v3270_get_selection_as_html_div(terminal, terminal->selection.blocks, encoding, FALSE); | |
| 236 | 236 | |
| 237 | 237 | } | ... | ... |
src/selection/table.c
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 35 | 35 | |
| 36 | 36 | /// @brief Check if column has data. |
| 37 | -static gboolean hasDataOnColumn(v3270 * terminal, unsigned int col, const GList *selection) | |
| 37 | +static gboolean hasDataOnColumn(v3270 * terminal, unsigned int col, const GList *selection, gboolean all) | |
| 38 | 38 | { |
| 39 | 39 | while(selection) |
| 40 | 40 | { |
| ... | ... | @@ -47,7 +47,7 @@ static gboolean hasDataOnColumn(v3270 * terminal, unsigned int col, const GList |
| 47 | 47 | |
| 48 | 48 | for(row = 0; row < block->bounds.height; row++) |
| 49 | 49 | { |
| 50 | - if( (block->contents[pos].attribute.visual & LIB3270_ATTR_SELECTED) && !isspace(block->contents[pos].chr)) | |
| 50 | + if( ((block->contents[pos].attribute.visual & LIB3270_ATTR_SELECTED) || all) && !isspace(block->contents[pos].chr)) | |
| 51 | 51 | { |
| 52 | 52 | return TRUE; |
| 53 | 53 | } |
| ... | ... | @@ -63,7 +63,7 @@ static gboolean hasDataOnColumn(v3270 * terminal, unsigned int col, const GList |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /// @brief Get column list. |
| 66 | -GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection) | |
| 66 | +GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection, gboolean all) | |
| 67 | 67 | { |
| 68 | 68 | unsigned int col = 0; |
| 69 | 69 | GList *rc = NULL; |
| ... | ... | @@ -73,7 +73,7 @@ GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection |
| 73 | 73 | // debug("col(%u): %s", col, hasDataOnColumn(terminal,col) ? "yes" : "no"); |
| 74 | 74 | |
| 75 | 75 | // Get first column. |
| 76 | - while(!hasDataOnColumn(terminal,col,selection)) { | |
| 76 | + while(!hasDataOnColumn(terminal,col,selection,all)) { | |
| 77 | 77 | if(col >= lib3270_get_width(terminal->host)) |
| 78 | 78 | return rc; |
| 79 | 79 | col++; |
| ... | ... | @@ -85,7 +85,7 @@ GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection |
| 85 | 85 | rc = g_list_append(rc,columndescription); |
| 86 | 86 | |
| 87 | 87 | // Get width. |
| 88 | - while(hasDataOnColumn(terminal,col++,selection)) { | |
| 88 | + while(hasDataOnColumn(terminal,col++,selection,all)) { | |
| 89 | 89 | columndescription->width++; |
| 90 | 90 | if(col >= lib3270_get_width(terminal->host)) |
| 91 | 91 | return rc; |
| ... | ... | @@ -96,11 +96,11 @@ GList * v3270_getColumns_from_selection(v3270 * terminal, const GList *selection |
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | -gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, const gchar *delimiter, const gchar *encoding) | |
| 99 | +gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, const gchar *delimiter, const gchar *encoding, gboolean all) | |
| 100 | 100 | { |
| 101 | 101 | GString * string = g_string_new(""); |
| 102 | 102 | |
| 103 | - GList * columns = v3270_getColumns_from_selection(terminal, selection); | |
| 103 | + GList * columns = v3270_getColumns_from_selection(terminal, selection, all); | |
| 104 | 104 | |
| 105 | 105 | debug("columns=%p",columns); |
| 106 | 106 | |
| ... | ... | @@ -136,7 +136,7 @@ gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, c |
| 136 | 136 | memset(line,' ',width); |
| 137 | 137 | for(col=0; col<block->bounds.width; col++) |
| 138 | 138 | { |
| 139 | - if(block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED) | |
| 139 | + if((block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED) || all) | |
| 140 | 140 | { |
| 141 | 141 | line[block->bounds.col+col] = block->contents[src].chr; |
| 142 | 142 | } |
| ... | ... | @@ -170,6 +170,6 @@ gchar * v3270_get_selection_as_table(v3270 * terminal, const GList *selection, c |
| 170 | 170 | /// @brief Get formatted contents as single text. |
| 171 | 171 | gchar * v3270_get_copy_as_table(v3270 * terminal, const gchar *delimiter, const gchar *encoding) |
| 172 | 172 | { |
| 173 | - return v3270_get_selection_as_table(terminal, terminal->selection.blocks, delimiter, encoding); | |
| 173 | + return v3270_get_selection_as_table(terminal, terminal->selection.blocks, delimiter, encoding, FALSE); | |
| 174 | 174 | } |
| 175 | 175 | ... | ... |
src/selection/text.c
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 34 | 34 | |
| 35 | 35 | /// @brief Get formatted contents as single text. |
| 36 | -gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, const gchar *encoding) | |
| 36 | +gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all) | |
| 37 | 37 | { |
| 38 | 38 | GString * string = g_string_new(""); |
| 39 | 39 | |
| ... | ... | @@ -46,7 +46,7 @@ gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, co |
| 46 | 46 | { |
| 47 | 47 | for(col=0; col<block->bounds.width; col++) |
| 48 | 48 | { |
| 49 | - if(block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED) | |
| 49 | + if( (block->contents[src].attribute.visual & LIB3270_ATTR_SELECTED) || all ) | |
| 50 | 50 | g_string_append_c(string,block->contents[src].chr); |
| 51 | 51 | |
| 52 | 52 | src++; |
| ... | ... | @@ -68,7 +68,7 @@ gchar * v3270_get_copy_as_text(v3270 * terminal, const gchar *encoding) |
| 68 | 68 | { |
| 69 | 69 | if(terminal->selection.format == V3270_SELECT_TABLE) |
| 70 | 70 | return v3270_get_copy_as_table(terminal,"\t",encoding); |
| 71 | - return v3270_get_selection_as_text(terminal, terminal->selection.blocks, encoding); | |
| 71 | + return v3270_get_selection_as_text(terminal, terminal->selection.blocks, encoding, FALSE); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | LIB3270_EXPORT void v3270_input_text(GtkWidget *widget, const gchar *text, const gchar *encoding) | ... | ... |