[vte] widget: add vte_terminal_paste
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: add vte_terminal_paste
- Date: Thu, 25 Nov 2021 00:12:07 +0000 (UTC)
commit b8cbae1a81ad879128e492d524ee55306ecf9168
Author: Zander Brown <zbrown gnome org>
Date: Wed Nov 24 12:17:14 2021 +0000
widget: add vte_terminal_paste
Allow providing an explict string to "paste"
Fix: https://gitlab.gnome.org/GNOME/vte/-/issues/2531
doc/reference/vte-sections.txt.in | 1 +
src/vte.cc | 3 +--
src/vte/vteterminal.h | 2 ++
src/vtegtk.cc | 25 +++++++++++++++++++++++++
src/vteinternal.hh | 3 +--
src/widget.cc | 2 +-
src/widget.hh | 1 +
7 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt.in b/doc/reference/vte-sections.txt.in
index 4e3a7e3e..e99fdf49 100644
--- a/doc/reference/vte-sections.txt.in
+++ b/doc/reference/vte-sections.txt.in
@@ -17,6 +17,7 @@ vte_terminal_select_all
vte_terminal_unselect_all
vte_terminal_copy_clipboard_format
vte_terminal_paste_clipboard
+vte_terminal_paste_text
vte_terminal_copy_primary
vte_terminal_paste_primary
vte_terminal_set_size
diff --git a/src/vte.cc b/src/vte.cc
index 46da6d4f..fbcb8df4 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -5479,8 +5479,7 @@ Terminal::cell_is_selected_vis(vte::grid::column_t vcol,
}
void
-Terminal::widget_clipboard_text_received(vte::platform::Clipboard const& clipboard,
- std::string_view const& data)
+Terminal::widget_clipboard_text_received(std::string_view const& data)
{
gchar *paste, *p;
gsize run;
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index c017c101..a3d240f1 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -216,6 +216,8 @@ void vte_terminal_copy_clipboard_format(VteTerminal *terminal,
_VTE_PUBLIC
void vte_terminal_paste_clipboard(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
_VTE_PUBLIC
+void vte_terminal_paste_text(VteTerminal *terminal, const char *text) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
void vte_terminal_copy_primary(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
_VTE_PUBLIC
void vte_terminal_paste_primary(VteTerminal *terminal) _VTE_CXX_NOEXCEPT _VTE_GNUC_NONNULL(1);
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index f694d99c..0e48da47 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -2779,6 +2779,31 @@ catch (...)
vte::log_exception();
}
+/**
+ * vte_terminal_paste_text:
+ * @terminal: a #VteTerminal
+ * @text: a string to paste
+ *
+ * Sends @text to the terminal's child as if retrived from the clipboard,
+ * this differs from vte_terminal_feed_child() in that it may process
+ * @text before passing it to the child (e.g. apply bracketed mode)
+ *
+ * Since: 0.70
+ */
+void
+vte_terminal_paste_text(VteTerminal *terminal, const char *text) noexcept
+try
+{
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ g_return_if_fail(text != nullptr);
+
+ WIDGET(terminal)->paste_text(text);
+}
+catch (...)
+{
+ vte::log_exception();
+}
+
/**
* vte_terminal_paste_primary:
* @terminal: a #VteTerminal
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index b75582c4..2274b026 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -894,8 +894,7 @@ public:
void widget_copy(vte::platform::ClipboardType selection,
vte::platform::ClipboardFormat format);
- void widget_clipboard_text_received(vte::platform::Clipboard const& clipboard,
- std::string_view const& text);
+ void widget_clipboard_text_received(std::string_view const& text);
std::optional<std::string_view> widget_clipboard_data_get(vte::platform::Clipboard const& clipboard,
vte::platform::ClipboardFormat format);
diff --git a/src/widget.cc b/src/widget.cc
index 3b2c9755..c3a13ab8 100644
--- a/src/widget.cc
+++ b/src/widget.cc
@@ -558,7 +558,7 @@ void
Widget::clipboard_request_received_cb(Clipboard const& clipboard,
std::string_view const& text)
{
- terminal()->widget_clipboard_text_received(clipboard, text);
+ terminal()->widget_clipboard_text_received(text);
}
void
diff --git a/src/widget.hh b/src/widget.hh
index 828f686c..f38e7af4 100644
--- a/src/widget.hh
+++ b/src/widget.hh
@@ -380,6 +380,7 @@ public:
void clipboard_set_text(ClipboardType type,
std::string_view const& str) noexcept;
+ void paste_text(std::string_view const& text) { m_terminal->widget_clipboard_text_received(text); }
void paste(vte::platform::ClipboardType type) { clipboard_request_text(type); }
void copy(vte::platform::ClipboardType type,
vte::platform::ClipboardFormat format) noexcept { m_terminal->widget_copy(type, format); }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]