Commit e4fad4b72ca91f319b0c770b595e3ac9c41559ba

Authored by Perry Werneck
1 parent c718872a
Exists in master and in 1 other branch develop

Fixing use of selection options.

src/dialogs/save/save.c
... ... @@ -386,7 +386,7 @@ static void icon_press(GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_
386 386 break;
387 387  
388 388 case 2: // "HyperText Markup Language (HTML)"
389   - text = v3270_get_selection_as_html_div(GTK_V3270(dialog->terminal),selection,encoding, dialog->mode == LIB3270_CONTENT_ALL);
  389 + text = v3270_get_selection_as_html_div(GTK_V3270(dialog->terminal),selection,encoding, dialog->mode == LIB3270_CONTENT_ALL, V3270_SELECTION_DEFAULT);
390 390 break;
391 391  
392 392 default:
... ...
src/include/clipboard.h
... ... @@ -92,8 +92,8 @@
92 92 /// @brief Get contents.
93 93 G_GNUC_INTERNAL gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all);
94 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);
  95 + G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all, const V3270SelectionOption options);
  96 + G_GNUC_INTERNAL gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all, const V3270SelectionOption options);
97 97  
98 98 G_GNUC_INTERNAL const GList * v3270_get_selection_blocks(GtkWidget *widget);
99 99  
... ...
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, gboolean all)
  52 +static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all, const V3270SelectionOption options)
53 53 {
54 54 const GList * element = selection;
55 55 GString * string = g_string_new("");
... ... @@ -58,12 +58,12 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all
58 58  
59 59 g_string_append(string,"<div style=\"padding:1em;display:inline-block");
60 60  
61   - if(terminal->selection.options & V3270_SELECTION_FONT_FAMILY)
  61 + if(options & V3270_SELECTION_FONT_FAMILY)
62 62 {
63 63 g_string_append_printf(string,";font-family:%s,monospace",terminal->font.family);
64 64 }
65 65  
66   - if(terminal->selection.options & V3270_SELECTION_COLORS)
  66 + if(options & V3270_SELECTION_COLORS)
67 67 {
68 68 bgColor = gdk_rgba_to_string(terminal->color+V3270_COLOR_BACKGROUND);
69 69 g_string_append_printf(string,";background-color:%s",bgColor);
... ... @@ -78,7 +78,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all
78 78 unsigned int row, col, src = 0;
79 79 unsigned short flags = block->contents[0].attribute.visual;
80 80  
81   - if(terminal->selection.options & V3270_SELECTION_COLORS)
  81 + if(options & V3270_SELECTION_COLORS)
82 82 {
83 83 get_element_colors(terminal,flags,&fgColor,&bgColor);
84 84  
... ... @@ -105,7 +105,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all
105 105 {
106 106 flags = block->contents[src].attribute.visual;
107 107  
108   - if(terminal->selection.options & V3270_SELECTION_COLORS)
  108 + if(options & V3270_SELECTION_COLORS)
109 109 {
110 110 get_element_colors(terminal,flags,&fgColor,&bgColor);
111 111  
... ... @@ -140,7 +140,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all
140 140 #endif // DEBUG
141 141 }
142 142  
143   - if(terminal->selection.options & V3270_SELECTION_COLORS)
  143 + if(options & V3270_SELECTION_COLORS)
144 144 {
145 145 g_string_append(string,"</span>");
146 146 }
... ... @@ -154,14 +154,12 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all
154 154  
155 155 g_string_append(string,"</div>");
156 156  
157   - debug("\n%s\n------------> %u",string->str,(unsigned int) terminal->selection.options);
158   -
159 157 return g_string_free(string,FALSE);
160 158  
161 159 }
162 160  
163 161 /// @brief Get formatted contents as HTML TABLE.
164   -static gchar * get_as_table(v3270 * terminal, const GList *selection, gboolean all)
  162 +static gchar * get_as_table(v3270 * terminal, const GList *selection, gboolean all, const V3270SelectionOption G_GNUC_UNUSED(options)) // TODO: Use options to set colors & font.
165 163 {
166 164 const GList * element = selection;
167 165 GString * string = g_string_new("<table><tbody>");
... ... @@ -231,15 +229,15 @@ static gchar * get_as_table(v3270 * terminal, const GList *selection, gboolean a
231 229  
232 230 }
233 231  
234   -gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all)
  232 +gchar * v3270_get_selection_as_html_div(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all, const V3270SelectionOption options)
235 233 {
236   - g_autofree char * text = get_as_div(terminal, selection, all);
  234 + g_autofree char * text = get_as_div(terminal, selection, all, options);
237 235 return g_convert(text, -1, (encoding ? encoding : "UTF-8"), lib3270_get_display_charset(terminal->host), NULL, NULL, NULL);
238 236 }
239 237  
240   -gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all)
  238 +gchar * v3270_get_selection_as_html_table(v3270 * terminal, const GList *selection, const gchar *encoding, gboolean all, const V3270SelectionOption options)
241 239 {
242   - g_autofree char * text = get_as_table(terminal, selection, all);
  240 + g_autofree char * text = get_as_table(terminal, selection, all, options);
243 241 return g_convert(text, -1, (encoding ? encoding : "UTF-8"), lib3270_get_display_charset(terminal->host), NULL, NULL, NULL);
244 242 }
245 243  
... ... @@ -247,8 +245,8 @@ gchar * v3270_get_copy_as_html(v3270 * terminal, const gchar *encoding)
247 245 {
248 246  
249 247 if(terminal->selection.format == V3270_COPY_TABLE)
250   - return v3270_get_selection_as_html_table(terminal, terminal->selection.blocks, encoding, FALSE);
  248 + return v3270_get_selection_as_html_table(terminal, terminal->selection.blocks, encoding, FALSE, terminal->selection.options);
251 249  
252   - return v3270_get_selection_as_html_div(terminal, terminal->selection.blocks, encoding, FALSE);
  250 + return v3270_get_selection_as_html_div(terminal, terminal->selection.blocks, encoding, FALSE, terminal->selection.options);
253 251  
254 252 }
... ...