aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-21 21:05:42 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-21 21:05:42 +0200
commita29382ea5d52f3bf3668b13dfe9a5d39c4769031 (patch)
treed7e8797802cd7ee627e1172c00b6d059633c0637
parente9bef20a8ad89d304fe3e8fafa00056d22de2326 (diff)
downloadsciteco-a29382ea5d52f3bf3668b13dfe9a5d39c4769031.tar.gz
GTK/Win32: include trailing null byte in gtk_selection_data_set_text()
* This API behaves very strangely and differently compared to UNIX/X11. When getting, it returns a trailing null for all clipboard contents (unless the clipboard is empty) and when setting, we apparently have to include it as well. At least since we cut it off when getting. Even more strangely, setting without the trailing null did work when pasting in external apps. (How they know when it's safe to throw away the trailing null is mysterious.) * In other words, this fixes X~G~.
-rw-r--r--src/interface-gtk/interface.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c
index 8cf0aab..3121b05 100644
--- a/src/interface-gtk/interface.c
+++ b/src/interface-gtk/interface.c
@@ -655,7 +655,12 @@ static void
teco_interface_clipboard_provide(GtkClipboard *clipboard, GtkSelectionData *selection, guint info, gpointer userdata)
{
GString *str = userdata;
- gtk_selection_data_set_text(selection, str->str, str->len);
+ gint len = str->len;
+#ifdef G_OS_WIN32
+ /* include trailing null byte */
+ len++;
+#endif
+ gtk_selection_data_set_text(selection, str->str, len);
}
static void