diff options
author | Christian Persch <chpe@src.gnome.org> | 2022-03-07 20:27:16 +0100 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2022-03-07 20:27:16 +0100 |
commit | f5f15e67492ac61ebe664c5ea12377eedb41f112 (patch) | |
tree | 0b7156ba7a8433314a48966e4a734b29e89fbc67 /src | |
parent | eee2c051235f26fedbbaa57d2ac41d8367f9bcca (diff) | |
download | gnome-terminal-f5f15e67492ac61ebe664c5ea12377eedb41f112.tar.gz |
all: Insert text as paste
Use new API vte_terminal_paste_text() to insert text.
Diffstat (limited to 'src')
-rw-r--r-- | src/terminal-screen.cc | 30 | ||||
-rw-r--r-- | src/terminal-screen.hh | 6 | ||||
-rw-r--r-- | src/terminal-window.cc | 2 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/terminal-screen.cc b/src/terminal-screen.cc index e1e8529e..a023aba7 100644 --- a/src/terminal-screen.cc +++ b/src/terminal-screen.cc @@ -1939,7 +1939,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)) { @@ -1947,7 +1947,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) { @@ -2006,7 +2006,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]); } @@ -2034,7 +2034,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]); } @@ -2305,3 +2305,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); |