summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2022-03-07 20:27:16 +0100
committerChristian Persch <chpe@src.gnome.org>2022-03-07 20:28:02 +0100
commitedefc8cbea6ba78c4a0760fb298601e0b91b1b7a (patch)
tree76faccf3e9258a04d1e9572dd4e103e5e0e21091
parent368d3b9d4ac80924120fa63f99fdafaa58b1c4f9 (diff)
downloadgnome-terminal-edefc8cbea6ba78c4a0760fb298601e0b91b1b7a.tar.gz
all: Insert text as paste
Use new API vte_terminal_paste_text() to insert text. (cherry picked from commit f5f15e67492ac61ebe664c5ea12377eedb41f112)
-rw-r--r--meson.build2
-rw-r--r--src/terminal-screen.cc30
-rw-r--r--src/terminal-screen.hh6
-rw-r--r--src/terminal-window.cc2
4 files changed, 34 insertions, 6 deletions
diff --git a/meson.build b/meson.build
index c7af2f23..81f556ec 100644
--- a/meson.build
+++ b/meson.build
@@ -45,7 +45,7 @@ clangxx_req_version = '3.3'
# Requirements
vte_req = 'vte-2.91'
-vte_req_version = '0.63.0'
+vte_req_version = '0.67.90'
glib_req_version = '2.52.0'
glib_min_req_version = '2.52'
diff --git a/src/terminal-screen.cc b/src/terminal-screen.cc
index 44c551f5..f60b0e32 100644
--- a/src/terminal-screen.cc
+++ b/src/terminal-screen.cc
@@ -1942,7 +1942,7 @@ terminal_screen_drag_data_received (GtkWidget *widget,
terminal_util_transform_uris_to_quoted_fuse_paths (uris);
text = terminal_util_concat_uris (uris, &len);
- vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
+ terminal_screen_paste_text (screen, text, len);
}
else if (gtk_targets_include_text (&selection_data_target, 1))
{
@@ -1950,7 +1950,7 @@ terminal_screen_drag_data_received (GtkWidget *widget,
text = (char *) gtk_selection_data_get_text (selection_data);
if (text && text[0])
- vte_terminal_feed_child (VTE_TERMINAL (screen), text, strlen (text));
+ terminal_screen_paste_text (screen, text, -1);
}
else switch (info)
{
@@ -2009,7 +2009,7 @@ terminal_screen_drag_data_received (GtkWidget *widget,
terminal_util_transform_uris_to_quoted_fuse_paths (uris); /* This may replace uris[0] */
text = terminal_util_concat_uris (uris, &len);
- vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
+ terminal_screen_paste_text (screen, text, len);
g_free (text);
g_free (uris[0]);
}
@@ -2037,7 +2037,7 @@ terminal_screen_drag_data_received (GtkWidget *widget,
terminal_util_transform_uris_to_quoted_fuse_paths (uris); /* This may replace uris[0] */
text = terminal_util_concat_uris (uris, &len);
- vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
+ terminal_screen_paste_text (screen, text, len);
g_free (text);
g_free (uris[0]);
}
@@ -2308,3 +2308,25 @@ terminal_screen_get_uuid (TerminalScreen *screen)
return screen->priv->uuid;
}
+
+/**
+ * terminal_screen_paste_text:
+ * @screen:
+ * @text: a NUL-terminated string
+ * @len: length of @text, or -1
+ *
+ * Inserts @text to @terminal as if pasted.
+ */
+void
+terminal_screen_paste_text (TerminalScreen* screen,
+ char const* text,
+ gssize len)
+{
+ g_return_if_fail (text != nullptr);
+ g_return_if_fail (len >= -1);
+
+ /* This is just an API hack until vte 0.69 adds vte_terminal_paste_text_len() */
+ /* Note that @text MUST be NUL-terminated */
+
+ vte_terminal_paste_text (VTE_TERMINAL (screen), text);
+}
diff --git a/src/terminal-screen.hh b/src/terminal-screen.hh
index df59b1a5..ded6b8ca 100644
--- a/src/terminal-screen.hh
+++ b/src/terminal-screen.hh
@@ -160,6 +160,12 @@ TerminalScreenPopupInfo *terminal_screen_popup_info_ref (TerminalScreenPopupInfo
void terminal_screen_popup_info_unref (TerminalScreenPopupInfo *info);
+/* API hack */
+
+void terminal_screen_paste_text (TerminalScreen* screen,
+ char const* text,
+ gssize len);
+
G_END_DECLS
#endif /* TERMINAL_SCREEN_H */
diff --git a/src/terminal-window.cc b/src/terminal-window.cc
index 60f49500..76f18000 100644
--- a/src/terminal-window.cc
+++ b/src/terminal-window.cc
@@ -692,7 +692,7 @@ clipboard_uris_received_cb (GtkClipboard *clipboard,
terminal_util_transform_uris_to_quoted_fuse_paths (uris);
text = terminal_util_concat_uris (uris, &len);
- vte_terminal_feed_child (VTE_TERMINAL (screen), text, len);
+ terminal_screen_paste_text (screen, text, len);
}
g_weak_ref_clear (&data->screen_weak_ref);