diff --git a/src/include/clipboard.h b/src/include/clipboard.h index e254e0c..55e54c0 100644 --- a/src/include/clipboard.h +++ b/src/include/clipboard.h @@ -45,7 +45,7 @@ CLIPBOARD_TYPE_TEXT, CLIPBOARD_TYPE_CSV, CLIPBOARD_TYPE_HTML, - CLIPBOARD_TYPE_V3270_UNPROTECTED + CLIPBOARD_TYPE_V3270_FORMATTED }; /// @brief Column from selection. diff --git a/src/include/terminal.h b/src/include/terminal.h index c727b74..0398b3c 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -120,13 +120,14 @@ G_BEGIN_DECLS typedef enum _V3270SelectionOption { - V3270_SELECTION_PLAIN_TEXT = 0x0000, ///< @brief Uses only plain text. - V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. - V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. + V3270_SELECTION_PLAIN_TEXT = 0x0000, ///< @brief Uses only plain text. + V3270_SELECTION_FONT_FAMILY = 0x0001, ///< @brief Inform font-family. + V3270_SELECTION_COLORS = 0x0002, ///< @brief Inform terminal colors. + V3270_SELECTION_NON_BREAKABLE_SPACE = 0x0004, ///< @brief Use non breakable spaces. } V3270SelectionOption; - #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS) + #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS|V3270_SELECTION_NON_BREAKABLE_SPACE) /*--[ Globals ]--------------------------------------------------------------------------------------*/ diff --git a/src/selection/html.c b/src/selection/html.c index e5d2344..836800d 100644 --- a/src/selection/html.c +++ b/src/selection/html.c @@ -128,7 +128,7 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all } else { - g_string_append(string," "); + g_string_append(string,((options & V3270_SELECTION_NON_BREAKABLE_SPACE) ? " " : " ")); } src++; diff --git a/src/selection/linux/copy.c b/src/selection/linux/copy.c index 31d75fb..72e3c8f 100644 --- a/src/selection/linux/copy.c +++ b/src/selection/linux/copy.c @@ -91,7 +91,7 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa } break; - case CLIPBOARD_TYPE_V3270_UNPROTECTED: + case CLIPBOARD_TYPE_V3270_FORMATTED: { g_autofree gchar *data = v3270_get_copy_as_data_block(terminal); gtk_selection_data_set( @@ -131,12 +131,12 @@ void v3270_update_system_clipboard(GtkWidget *widget) gtk_target_list_add_text_targets(list, CLIPBOARD_TYPE_TEXT); - if(terminal->selection.options != V3270_SELECTION_PLAIN_TEXT) + if((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) == 0) { static const GtkTargetEntry targets[] = { - { "text/csv", 0, CLIPBOARD_TYPE_CSV }, - { "text/html", 0, CLIPBOARD_TYPE_HTML }, - { "application/x-v3270-unprotected", 0, CLIPBOARD_TYPE_V3270_UNPROTECTED }, + { "text/csv", 0, CLIPBOARD_TYPE_CSV }, + { "text/html", 0, CLIPBOARD_TYPE_HTML }, + { "application/x-v3270-formatted", 0, CLIPBOARD_TYPE_V3270_FORMATTED }, }; gtk_target_list_add_table(list, targets, G_N_ELEMENTS(targets)); diff --git a/src/selection/windows/copy.c b/src/selection/windows/copy.c index 79fc9fa..72e3c8f 100644 --- a/src/selection/windows/copy.c +++ b/src/selection/windows/copy.c @@ -91,7 +91,7 @@ static void clipboard_get(G_GNUC_UNUSED GtkClipboard *clipboard, GtkSelectionDa } break; - case CLIPBOARD_TYPE_V3270_UNPROTECTED: + case CLIPBOARD_TYPE_V3270_FORMATTED: { g_autofree gchar *data = v3270_get_copy_as_data_block(terminal); gtk_selection_data_set( @@ -127,19 +127,24 @@ void v3270_update_system_clipboard(GtkWidget *widget) // // Reference: https://cpp.hotexamples.com/examples/-/-/g_list_insert_sorted/cpp-g_list_insert_sorted-function-examples.html // - static const GtkTargetEntry internal_targets[] = { - { "text/csv", 0, CLIPBOARD_TYPE_CSV }, - { "text/html", 0, CLIPBOARD_TYPE_HTML }, - { "application/x-v3270-unprotected", 0, CLIPBOARD_TYPE_V3270_UNPROTECTED }, - }; - - GtkTargetList * list = gtk_target_list_new(internal_targets, G_N_ELEMENTS(internal_targets)); - GtkTargetEntry * targets; - int n_targets; + GtkTargetList * list = gtk_target_list_new(NULL,0); gtk_target_list_add_text_targets(list, CLIPBOARD_TYPE_TEXT); - targets = gtk_target_table_new_from_list(list, &n_targets); + if((terminal->selection.options & V3270_SELECTION_PLAIN_TEXT) == 0) + { + static const GtkTargetEntry targets[] = { + { "text/csv", 0, CLIPBOARD_TYPE_CSV }, + { "text/html", 0, CLIPBOARD_TYPE_HTML }, + { "application/x-v3270-formatted", 0, CLIPBOARD_TYPE_V3270_FORMATTED }, + }; + + gtk_target_list_add_table(list, targets, G_N_ELEMENTS(targets)); + + } + + int n_targets; + GtkTargetEntry * targets = gtk_target_table_new_from_list(list, &n_targets); #ifdef DEBUG { diff --git a/src/terminal/widget.c b/src/terminal/widget.c index 981dd2f..a1daaef 100644 --- a/src/terminal/widget.c +++ b/src/terminal/widget.c @@ -202,7 +202,7 @@ static void v3270_class_init(v3270Class *klass) gobject_class->finalize = finalize; // Atoms - klass->clipboard_formatted = gdk_atom_intern_static_string("application/x-v3270-unprotected"); + klass->clipboard_formatted = gdk_atom_intern_static_string("application/x-v3270-formatted"); // Widget methods widget_class->realize = v3270_realize; -- libgit2 0.21.2