diff --git a/src/include/terminal.h b/src/include/terminal.h index 4953609..e8072ea 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -49,6 +49,7 @@ G_BEGIN_DECLS V3270_SETTING_HOST_TYPE, V3270_SETTING_CRL_PROTOCOL, V3270_SETTING_TERMINAL_COLORS, + V3270_SETTING_SELECTION_OPTIONS, V3270_SETTING_COUNT ///< @brief Number of setting properties. } V3270_SETTING; @@ -116,6 +117,16 @@ G_BEGIN_DECLS #define KEY_FLAG_ALT 0x0002 #endif // !WIN32 + 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. + + } V3270SelectionOption; + + #define V3270_SELECTION_DEFAULT (V3270_SELECTION_FONT_FAMILY|V3270_SELECTION_COLORS) + /*--[ Globals ]--------------------------------------------------------------------------------------*/ struct v3270_ssl_status_msg @@ -149,10 +160,11 @@ G_BEGIN_DECLS struct { - int baddr; ///< @brief Selection address. - GdkAtom target; ///< @brief A GdkAtom which identifies the clipboard to use. GDK_SELECTION_CLIPBOARD gives the default clipboard. - V3270_COPY_MODE format; ///< @brief Copy mode. - GList * blocks; ///< @brief Selection blocks. + int baddr; ///< @brief Selection address. + GdkAtom target; ///< @brief A GdkAtom which identifies the clipboard to use. GDK_SELECTION_CLIPBOARD gives the default clipboard. + V3270_COPY_MODE format; ///< @brief Copy mode. + GList * blocks; ///< @brief Selection blocks. + V3270SelectionOption options; ///< @brief Selection options. } selection; diff --git a/src/selection/html.c b/src/selection/html.c index 9999ae7..0e39f2f 100644 --- a/src/selection/html.c +++ b/src/selection/html.c @@ -53,17 +53,24 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all { const GList * element = selection; GString * string = g_string_new(""); - gchar * bgColor = gdk_rgba_to_string(terminal->color+V3270_COLOR_BACKGROUND); + gchar * bgColor; gchar * fgColor; - g_string_append_printf( - string, - "
", - terminal->font.family, - bgColor - ); + g_string_append(string,"
selection.options & V3270_SELECTION_FONT_FAMILY) + { + g_string_append_printf(string,";font-family:%s,monospace",terminal->font.family); + } + + if(terminal->selection.options & V3270_SELECTION_COLORS) + { + bgColor = gdk_rgba_to_string(terminal->color+V3270_COLOR_BACKGROUND); + g_string_append_printf(string,";background-color:%s",bgColor); + g_free(bgColor); + } + + g_string_append(string,"\">"); while(element) { @@ -71,17 +78,20 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all unsigned int row, col, src = 0; unsigned short flags = block->contents[0].attribute.visual; - get_element_colors(terminal,flags,&fgColor,&bgColor); + if(terminal->selection.options & V3270_SELECTION_COLORS) + { + get_element_colors(terminal,flags,&fgColor,&bgColor); - g_string_append_printf( - string, - "", - bgColor, - fgColor - ); + g_string_append_printf( + string, + "", + bgColor, + fgColor + ); - g_free(bgColor); - g_free(fgColor); + g_free(bgColor); + g_free(fgColor); + } #ifdef DEBUG g_string_append_c(string,'\n'); @@ -95,18 +105,20 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all { flags = block->contents[src].attribute.visual; - get_element_colors(terminal,flags,&fgColor,&bgColor); - - g_string_append_printf( - string, - "", - bgColor, - fgColor - ); + if(terminal->selection.options & V3270_SELECTION_COLORS) + { + get_element_colors(terminal,flags,&fgColor,&bgColor); - g_free(bgColor); - g_free(fgColor); + g_string_append_printf( + string, + "", + bgColor, + fgColor + ); + g_free(bgColor); + g_free(fgColor); + } } @@ -128,7 +140,10 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all #endif // DEBUG } - g_string_append(string,""); + if(terminal->selection.options & V3270_SELECTION_COLORS) + { + g_string_append(string,""); + } element = g_list_next(element); } @@ -139,6 +154,8 @@ static gchar * get_as_div(v3270 * terminal, const GList *selection, gboolean all g_string_append(string,"
"); + debug("\n%s\n------------> %u",string->str,(unsigned int) terminal->selection.options); + return g_string_free(string,FALSE); } diff --git a/src/selection/linux/copy.c b/src/selection/linux/copy.c index 56648a6..580fd83 100644 --- a/src/selection/linux/copy.c +++ b/src/selection/linux/copy.c @@ -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) + { + 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 }, + }; + + 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/actions/scroll.c b/src/terminal/actions/scroll.c index 56b443a..b976f14 100644 --- a/src/terminal/actions/scroll.c +++ b/src/terminal/actions/scroll.c @@ -39,9 +39,12 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ // Callback for compatibility with the old application. -static void activate_action(GtkWidget *terminal, GtkAction *action) +static void activate_action(GtkWidget G_GNUC_UNUSED(*terminal), GtkAction *action) { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" gtk_action_activate(action); + #pragma GCC diagnostic pop } LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action) diff --git a/src/terminal/keyfile.c b/src/terminal/keyfile.c index f037658..bafb6bb 100644 --- a/src/terminal/keyfile.c +++ b/src/terminal/keyfile.c @@ -189,6 +189,8 @@ return; } + debug("%s(%s)",__FUNCTION__,name); + GValue value = G_VALUE_INIT; g_value_init(&value, pspec->value_type); diff --git a/src/terminal/properties/get.c b/src/terminal/properties/get.c index 2211e56..671f396 100644 --- a/src/terminal/properties/get.c +++ b/src/terminal/properties/get.c @@ -139,6 +139,10 @@ } break; + case V3270_PROPERTY_SELECTION_OPTIONS: + g_value_set_uint(value,(guint) window->selection.options); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); diff --git a/src/terminal/properties/init.c b/src/terminal/properties/init.c index a4a414a..9bb3bdd 100644 --- a/src/terminal/properties/init.c +++ b/src/terminal/properties/init.c @@ -224,6 +224,26 @@ klass->properties.settings[V3270_SETTING_TERMINAL_COLORS] ); + // Clipboard options + klass->properties.settings[V3270_SETTING_SELECTION_OPTIONS] = + g_param_spec_uint( + "selection_flags", + "selection_flags", + _("Flags to cut&paste"), + 0, + G_MAXUINT, + V3270_SELECTION_DEFAULT, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_SELECTION_OPTIONS, + klass->properties.settings[V3270_SETTING_SELECTION_OPTIONS] + ); + + + // // Create dynamic properties // diff --git a/src/terminal/properties/private.h b/src/terminal/properties/private.h index ee4d204..bd7e178 100644 --- a/src/terminal/properties/private.h +++ b/src/terminal/properties/private.h @@ -48,17 +48,18 @@ enum _v3270_internal_property { - V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget. - V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard. - V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name. - V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect. - V3270_PROPERTY_REMAP_FILE = 6, ///< @brief Path of the remap file. - V3270_PROPERTY_DYNAMIC_SPACING = 7, ///< @brief Toggle dynamic font spacing. - V3270_PROPERTY_LU_NAMES = 8, ///< @brief The LU names list. - V3270_PROPERTY_TRACE = 9, ///< @brief Is the trace widget active? - V3270_PROPERTY_TERMINAL_COLORS = 10, ///< @brief Terminal colors. + V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget. + V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard. + V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name. + V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect. + V3270_PROPERTY_REMAP_FILE = 6, ///< @brief Path of the remap file. + V3270_PROPERTY_DYNAMIC_SPACING = 7, ///< @brief Toggle dynamic font spacing. + V3270_PROPERTY_LU_NAMES = 8, ///< @brief The LU names list. + V3270_PROPERTY_TRACE = 9, ///< @brief Is the trace widget active? + V3270_PROPERTY_TERMINAL_COLORS = 10, ///< @brief Terminal colors. + V3270_PROPERTY_SELECTION_OPTIONS = 11, - V3270_PROPERTY_DYNAMIC = 11 ///< @brief Id of the first LIB3270 internal property. + V3270_PROPERTY_DYNAMIC = 12 ///< @brief Id of the first LIB3270 internal property. }; G_GNUC_INTERNAL void v3270_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); diff --git a/src/terminal/properties/set.c b/src/terminal/properties/set.c index a9343b3..f89d222 100644 --- a/src/terminal/properties/set.c +++ b/src/terminal/properties/set.c @@ -138,6 +138,10 @@ v3270_set_colors(GTK_WIDGET(object),g_value_get_string(value)); break; + case V3270_PROPERTY_SELECTION_OPTIONS: + GTK_V3270(object)->selection.options = (V3270SelectionOption) g_value_get_uint(value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); diff --git a/src/terminal/widget.c b/src/terminal/widget.c index aca8dcb..dde9203 100644 --- a/src/terminal/widget.c +++ b/src/terminal/widget.c @@ -499,6 +499,7 @@ static void v3270_init(v3270 *widget) // Setup clipboard. widget->selection.target = GDK_SELECTION_CLIPBOARD; + widget->selection.options = V3270_SELECTION_DEFAULT; // Reset timer widget->activity.timestamp = time(0); -- libgit2 0.21.2