Commit dc7daf835b593165be5a7681285645d4cb0ab597
1 parent
57a0af32
Exists in
master
and in
1 other branch
Small fixes in the clipboard management.
Showing
6 changed files
with
29 additions
and
23 deletions
Show diff stats
src/include/clipboard.h
src/include/terminal.h
| ... | ... | @@ -120,13 +120,14 @@ G_BEGIN_DECLS |
| 120 | 120 | |
| 121 | 121 | typedef enum _V3270SelectionOption { |
| 122 | 122 | |
| 123 | - V3270_SELECTION_PLAIN_TEXT = 0x0000, ///< @brief Uses only plain text. | |
| 124 | - V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. | |
| 125 | - V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. | |
| 123 | + V3270_SELECTION_PLAIN_TEXT = 0x0000, ///< @brief Uses only plain text. | |
| 124 | + V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. | |
| 125 | + V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. | |
| 126 | + V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces. | |
| 126 | 127 | |
| 127 | 128 | } V3270SelectionOption; |
| 128 | 129 | |
| 129 | - #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS) | |
| 130 | + #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS|V3270_SELECTION_NON_BREAKABLE_SPACE) | |
| 130 | 131 | |
| 131 | 132 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
| 132 | 133 | ... | ... |
src/selection/html.c
| ... | ... | @@ -128,7 +128,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all |
| 128 | 128 | } |
| 129 | 129 | else |
| 130 | 130 | { |
| 131 | - g_string_append(string," "); | |
| 131 | + g_string_append(string,((options & V3270_SELECTION_NON_BREAKABLE_SPACE) ? " " : " ")); | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | src++; | ... | ... |
src/selection/linux/copy.c
| ... | ... | @@ -91,7 +91,7 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa |
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | |
| 94 | - case CLIPBOARD_TYPE_V3270_UNPROTECTED: | |
| 94 | + case CLIPBOARD_TYPE_V3270_FORMATTED: | |
| 95 | 95 | { |
| 96 | 96 | g_autofree gchar *data = v3270_get_copy_as_data_block(terminal); |
| 97 | 97 | gtk_selection_data_set( |
| ... | ... | @@ -131,12 +131,12 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
| 131 | 131 | |
| 132 | 132 | gtk_target_list_add_text_targets(list, CLIPBOARD_TYPE_TEXT); |
| 133 | 133 | |
| 134 | - if(terminal->selection.options != V3270_SELECTION_PLAIN_TEXT) | |
| 134 | + if((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) == 0) | |
| 135 | 135 | { |
| 136 | 136 | static const GtkTargetEntry targets[] = { |
| 137 | - { "text/csv", 0, CLIPBOARD_TYPE_CSV }, | |
| 138 | - { "text/html", 0, CLIPBOARD_TYPE_HTML }, | |
| 139 | - { "application/x-v3270-unprotected", 0, CLIPBOARD_TYPE_V3270_UNPROTECTED }, | |
| 137 | + { "text/csv", 0, CLIPBOARD_TYPE_CSV }, | |
| 138 | + { "text/html", 0, CLIPBOARD_TYPE_HTML }, | |
| 139 | + { "application/x-v3270-formatted", 0, CLIPBOARD_TYPE_V3270_FORMATTED }, | |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | 142 | gtk_target_list_add_table(list, targets, G_N_ELEMENTS(targets)); | ... | ... |
src/selection/windows/copy.c
| ... | ... | @@ -91,7 +91,7 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa |
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | |
| 94 | - case CLIPBOARD_TYPE_V3270_UNPROTECTED: | |
| 94 | + case CLIPBOARD_TYPE_V3270_FORMATTED: | |
| 95 | 95 | { |
| 96 | 96 | g_autofree gchar *data = v3270_get_copy_as_data_block(terminal); |
| 97 | 97 | gtk_selection_data_set( |
| ... | ... | @@ -127,19 +127,24 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
| 127 | 127 | // |
| 128 | 128 | // Reference: https://cpp.hotexamples.com/examples/-/-/g_list_insert_sorted/cpp-g_list_insert_sorted-function-examples.html |
| 129 | 129 | // |
| 130 | - static const GtkTargetEntry internal_targets[] = { | |
| 131 | - { "text/csv", 0, CLIPBOARD_TYPE_CSV }, | |
| 132 | - { "text/html", 0, CLIPBOARD_TYPE_HTML }, | |
| 133 | - { "application/x-v3270-unprotected", 0, CLIPBOARD_TYPE_V3270_UNPROTECTED }, | |
| 134 | - }; | |
| 135 | - | |
| 136 | - GtkTargetList * list = gtk_target_list_new(internal_targets, G_N_ELEMENTS(internal_targets)); | |
| 137 | - GtkTargetEntry * targets; | |
| 138 | - int n_targets; | |
| 130 | + GtkTargetList * list = gtk_target_list_new(NULL,0); | |
| 139 | 131 | |
| 140 | 132 | gtk_target_list_add_text_targets(list, CLIPBOARD_TYPE_TEXT); |
| 141 | 133 | |
| 142 | - targets = gtk_target_table_new_from_list(list, &n_targets); | |
| 134 | + if((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) == 0) | |
| 135 | + { | |
| 136 | + static const GtkTargetEntry targets[] = { | |
| 137 | + { "text/csv", 0, CLIPBOARD_TYPE_CSV }, | |
| 138 | + { "text/html", 0, CLIPBOARD_TYPE_HTML }, | |
| 139 | + { "application/x-v3270-formatted", 0, CLIPBOARD_TYPE_V3270_FORMATTED }, | |
| 140 | + }; | |
| 141 | + | |
| 142 | + gtk_target_list_add_table(list, targets, G_N_ELEMENTS(targets)); | |
| 143 | + | |
| 144 | + } | |
| 145 | + | |
| 146 | + int n_targets; | |
| 147 | + GtkTargetEntry * targets = gtk_target_table_new_from_list(list, &n_targets); | |
| 143 | 148 | |
| 144 | 149 | #ifdef DEBUG |
| 145 | 150 | { | ... | ... |
src/terminal/widget.c
| ... | ... | @@ -202,7 +202,7 @@ static void v3270_class_init(v3270Class *klass) |
| 202 | 202 | gobject_class->finalize = finalize; |
| 203 | 203 | |
| 204 | 204 | // Atoms |
| 205 | - klass->clipboard_formatted = gdk_atom_intern_static_string("application/x-v3270-unprotected"); | |
| 205 | + klass->clipboard_formatted = gdk_atom_intern_static_string("application/x-v3270-formatted"); | |
| 206 | 206 | |
| 207 | 207 | // Widget methods |
| 208 | 208 | widget_class->realize = v3270_realize; | ... | ... |