[vte] widget: Add function to get the selected text



commit ac653330b065b26c0be74429bfe7e15ee8f565b3
Author: Christian Persch <chpe gnome org>
Date:   Tue Dec 1 19:36:34 2015 +0100

    widget: Add function to get the selected text

 src/vte.cc         |   34 ++++++++++++++++------------------
 src/vteinternal.hh |    2 ++
 2 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index d882187..3625ce5 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -4009,15 +4009,7 @@ next_match:
                 * by this insertion. */
                if (m_has_selection) {
                         //FIXMEchpe: this is atrocious
-                       char *selection = get_text(m_selection_start.row,
-                                                   0,
-                                                   m_selection_end.row,
-                                                   m_column_count,
-                                                   true /* wrap */,
-                                                   false /* include trailing whitespace */,
-                                                   vte_cell_is_selected, nullptr,
-                                                   nullptr,
-                                                   nullptr);
+                       char *selection = get_selected_text();
                        if ((selection == NULL) ||
                            (m_selection_text[VTE_SELECTION_PRIMARY] == NULL) ||
                            (strcmp(selection, m_selection_text[VTE_SELECTION_PRIMARY]) != 0)) {
@@ -6220,6 +6212,20 @@ VteTerminalPrivate::get_text_displayed_a11y(bool wrap,
                         attributes);
 }
 
+char *
+VteTerminalPrivate::get_selected_text(GArray *attributes)
+{
+       return get_text(m_selection_start.row,
+                        0,
+                        m_selection_end.row,
+                        m_column_count,
+                        true /* wrap */,
+                        false /* include trailing whitespace */,
+                        vte_cell_is_selected, nullptr,
+                        attributes,
+                        nullptr);
+}
+
 /*
  * Compares the visual attributes of a VteCellAttr for equality, but ignores
  * attributes that tend to change from character to character or are otherwise
@@ -6398,15 +6404,7 @@ VteTerminalPrivate::widget_copy(VteSelection sel)
 
        /* Chuck old selected text and retrieve the newly-selected text. */
        g_free(m_selection_text[sel]);
-       m_selection_text[sel] = get_text(m_selection_start.row,
-                                         0,
-                                         m_selection_end.row,
-                                         m_column_count,
-                                         true /* wrap */,
-                                         false /* include trailing whitespace */,
-                                         vte_cell_is_selected, nullptr,
-                                         attributes,
-                                         nullptr);
+       m_selection_text[sel] = get_selected_text(attributes);
 #ifdef HTML_SELECTION
        g_free(m_selection_html[sel]);
        m_selection_html[sel] =
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 8c05367..e56b3b8 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -631,6 +631,8 @@ public:
                                          gpointer data,
                                          GArray *attributes);
 
+        char *get_selected_text(GArray *attributes = nullptr);
+
         void start_selection(long x,
                              long y,
                              enum vte_selection_type selection_type);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]