From 5f8647abb4ab4e0ebafd2997fbdbbffc1ffe57ff Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Thu, 21 Nov 2019 12:41:29 -0300 Subject: [PATCH] Fixing "\n" at the end of text copy. --- src/selection/text.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/selection/text.c b/src/selection/text.c index f37a190..884a5a4 100644 --- a/src/selection/text.c +++ b/src/selection/text.c @@ -53,6 +53,7 @@ gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, co src++; } + g_string_append_c(string,'\n'); } selection = g_list_next(selection); @@ -60,6 +61,13 @@ gchar * v3270_get_selection_as_text(v3270 * terminal, const GList *selection, co g_autofree char * text = g_string_free(string,FALSE); + // Remove ending CR. + { + size_t length = strlen(text); + if(length > 1 && text[length-1] == '\n') // The '\n' isn't really necessary but... + text[length-1] = 0; + } + return g_convert(text, -1, (encoding ? encoding : "UTF-8"), lib3270_get_display_charset(terminal->host), NULL, NULL, NULL); } @@ -138,31 +146,6 @@ gchar * v3270_convert_to_3270_charset(GtkWidget *widget, const gchar *text, cons } - /* - // Still failing, convert line by line - { - size_t f; - gchar **ln = g_strsplit(text,"\n",-1); - - for(f=0;ln[f];f++) - { - GError *error = NULL; - gchar *str = g_convert(ln[f], -1, charset, encoding, NULL, NULL, error); - - if(!str) - { - g_strfreev(ln); - return NULL; - } - - g_free(str); - - } - g_strfreev(ln); - - } - */ - // Can't convert, use fallbacks return g_convert_with_fallback( text, -- libgit2 0.21.2