[vte] widget: Deprecate vte_terminal_get_text_include_trailing_spaces()



commit 138baedc50bbbc455bbc16e76919af2d6f6d7492
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri Sep 7 23:13:37 2018 +0200

    widget: Deprecate vte_terminal_get_text_include_trailing_spaces()
    
    Also remove the include_trailing_spaces flag internally.
    
    https://gitlab.gnome.org/GNOME/vte/issues/38

 doc/reference/vte-sections.txt |  2 +-
 src/vte.cc                     | 47 ++----------------------------------------
 src/vte/vtedeprecated.h        |  6 ++++++
 src/vte/vteterminal.h          |  5 -----
 src/vteaccess.cc               |  1 -
 src/vtegtk.cc                  | 17 ++++-----------
 src/vteinternal.hh             |  3 ---
 7 files changed, 13 insertions(+), 68 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index b46e3062..532c061c 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -66,7 +66,6 @@ vte_terminal_set_mouse_autohide
 vte_terminal_get_mouse_autohide
 vte_terminal_reset
 vte_terminal_get_text
-vte_terminal_get_text_include_trailing_spaces
 vte_terminal_get_text_range
 vte_terminal_get_cursor_position
 vte_terminal_hyperlink_check_event
@@ -151,6 +150,7 @@ vte_terminal_set_geometry_hints_for_window
 vte_terminal_get_icon_title
 vte_terminal_set_encoding
 vte_terminal_get_encoding
+vte_terminal_get_text_include_trailing_spaces
 
 <SUBSECTION Private>
 VteCharAttributes
diff --git a/src/vte.cc b/src/vte.cc
index 887382a7..cdd0a0d3 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -875,7 +875,6 @@ Terminal::match_contents_refresh()
        match_contents_clear();
        GArray *array = g_array_new(FALSE, TRUE, sizeof(struct _VteCharAttributes));
         auto match_contents = get_text_displayed(true /* wrap */,
-                                                 false /* include trailing whitespace */,
                                                  array);
         m_match_contents = g_string_free(match_contents, FALSE);
        m_match_attributes = array;
@@ -5785,7 +5784,6 @@ Terminal::get_text(vte::grid::row_t start_row,
                              vte::grid::column_t end_col,
                              bool block,
                              bool wrap,
-                             bool include_trailing_spaces,
                              GArray *attributes)
 {
        const VteCell *pcell = NULL;
@@ -5807,13 +5805,8 @@ Terminal::get_text(vte::grid::row_t start_row,
         vte::grid::row_t row;
        for (row = start_row; row < end_row + 1; row++, col = next_first_column) {
                VteRowData const* row_data = find_row_data(row);
-                gsize last_empty, last_nonempty;
-                vte::grid::column_t last_emptycol, last_nonemptycol;
                 vte::grid::column_t line_last_column = (block || row == end_row) ? end_col : G_MAXLONG;
 
-               last_empty = last_nonempty = string->len;
-               last_emptycol = last_nonemptycol = -1;
-
                attr.row = row;
                attr.column = col;
                pcell = NULL;
@@ -5845,12 +5838,8 @@ Terminal::get_text(vte::grid::row_t start_row,
                                        /* Store the cell string */
                                        if (pcell->c == 0) {
                                                g_string_append_c (string, ' ');
-                                               last_empty = string->len;
-                                               last_emptycol = col;
                                        } else {
                                                _vte_unistr_append_to_string (pcell->c, string);
-                                               last_nonempty = string->len;
-                                               last_nonemptycol = col;
                                        }
 
                                        /* If we added text to the string, record its
@@ -5865,32 +5854,6 @@ Terminal::get_text(vte::grid::row_t start_row,
                        }
                }
 
-              /* If the last thing we saw was a empty, and we stopped at the
-               * right edge of the range, trim the trailing spaces
-               * off of the line. */
-               if (!include_trailing_spaces && last_empty > last_nonempty) {
-
-                       col = last_emptycol + 1;
-
-                       if (row_data != NULL) {
-                               while ((pcell = _vte_row_data_get (row_data, col))) {
-                                       col++;
-
-                                       if (pcell->attr.fragment())
-                                               continue;
-
-                                       if (pcell->c != 0)
-                                               break;
-                               }
-                       }
-                       if (pcell == NULL) {
-                               g_string_truncate(string, last_nonempty);
-                               if (attributes)
-                                       g_array_set_size(attributes, string->len);
-                               attr.column = last_nonemptycol;
-                       }
-               }
-
                /* Adjust column, in case we want to append a newline */
                 //FIXMEchpe MIN ?
                attr.column = MAX(m_column_count, attr.column + 1);
@@ -5924,12 +5887,11 @@ Terminal::get_text(vte::grid::row_t start_row,
 
 GString*
 Terminal::get_text_displayed(bool wrap,
-                                       bool include_trailing_spaces,
                                        GArray *attributes)
 {
         return get_text(first_displayed_row(), 0,
                         last_displayed_row() + 1, -1,
-                        false /* block */, wrap, include_trailing_spaces,
+                        false /* block */, wrap,
                         attributes);
 }
 
@@ -5938,12 +5900,11 @@ Terminal::get_text_displayed(bool wrap,
  */
 GString*
 Terminal::get_text_displayed_a11y(bool wrap,
-                                            bool include_trailing_spaces,
                                             GArray *attributes)
 {
         return get_text(m_screen->scroll_delta, 0,
                         m_screen->scroll_delta + m_row_count - 1 + 1, -1,
-                        false /* block */, wrap, include_trailing_spaces,
+                        false /* block */, wrap,
                         attributes);
 }
 
@@ -5956,7 +5917,6 @@ Terminal::get_selected_text(GArray *attributes)
                         m_selection_end.col,
                         m_selection_block_mode,
                         true /* wrap */,
-                        false /* include trailing whitespace */,
                         attributes);
 }
 
@@ -5971,7 +5931,6 @@ Terminal::checksum_area(vte::grid::row_t start_row,
 
         auto text = get_text(start_row, start_col, end_row, end_col,
                              true /* block */, false /* wrap */,
-                             true /* trailing whitespace */,
                              nullptr /* not interested in attributes */);
         if (text == nullptr)
                 return checksum;
@@ -10950,7 +10909,6 @@ Terminal::search_rows(pcre2_match_context_8 *match_context,
                                  end_row, -1,
                                  false /* block */,
                                  true /* wrap */,
-                                 false /* include trailing whitespace */, /* FIXMEchpe maybe do include it 
since the match may depend on it? */
                                  nullptr);
 
         int (* match_fn) (const pcre2_code_8 *,
@@ -11002,7 +10960,6 @@ Terminal::search_rows(pcre2_match_context_8 *match_context,
                             end_row, -1,
                             false /* block */,
                             true /* wrap */,
-                            false /* include trailing whitespace */, /* FIXMEchpe maybe true? */
                             attrs);
 
        ca = &g_array_index (attrs, VteCharAttributes, start);
diff --git a/src/vte/vtedeprecated.h b/src/vte/vtedeprecated.h
index e1bcecab..9763445a 100644
--- a/src/vte/vtedeprecated.h
+++ b/src/vte/vtedeprecated.h
@@ -125,6 +125,12 @@ _VTE_DEPRECATED
 _VTE_PUBLIC
 const char *vte_terminal_get_encoding(VteTerminal *terminal) _VTE_GNUC_NONNULL(1);
 
+_VTE_DEPRECATED
+_VTE_PUBLIC
+char *vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
+                                                   VteSelectionFunc is_selected,
+                                                   gpointer user_data,
+                                                   GArray *attributes) _VTE_GNUC_NONNULL(1) G_GNUC_MALLOC;
 
 G_END_DECLS
 
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index 89539cc4..b7f1f563 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -362,11 +362,6 @@ char *vte_terminal_get_text(VteTerminal *terminal,
                            gpointer user_data,
                            GArray *attributes) _VTE_GNUC_NONNULL(1) G_GNUC_MALLOC;
 _VTE_PUBLIC
-char *vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
-                                                   VteSelectionFunc is_selected,
-                                                   gpointer user_data,
-                                                   GArray *attributes) _VTE_GNUC_NONNULL(1) G_GNUC_MALLOC;
-_VTE_PUBLIC
 char *vte_terminal_get_text_range(VteTerminal *terminal,
                                  glong start_row, glong start_col,
                                  glong end_row, glong end_col,
diff --git a/src/vteaccess.cc b/src/vteaccess.cc
index 6ed00a51..b6155af1 100644
--- a/src/vteaccess.cc
+++ b/src/vteaccess.cc
@@ -284,7 +284,6 @@ vte_terminal_accessible_update_private_data_if_needed(VteTerminalAccessible *acc
 
                /* Get a new view of the uber-label. */
                priv->snapshot_text = impl->get_text_displayed_a11y(true /* wrap */,
-                                                                             true /* include trailing 
whitespace */,
                                                                              priv->snapshot_attributes);
 
                /* Get the offsets to the beginnings of each character. */
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index c4bc7331..194837f4 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -2851,7 +2851,6 @@ vte_terminal_get_text(VteTerminal *terminal,
        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
         warn_if_callback(is_selected);
         auto text = IMPL(terminal)->get_text_displayed(true /* wrap */,
-                                                       false /* include trailing whitespace */,
                                                        attributes);
         if (text == nullptr)
                 return nullptr;
@@ -2869,11 +2868,11 @@ vte_terminal_get_text(VteTerminal *terminal,
  * %NULL, characters will only be read if @is_selected returns %TRUE after being
  * passed the column and row, respectively.  A #VteCharAttributes structure
  * is added to @attributes for each byte added to the returned string detailing
- * the character's position, colors, and other characteristics. This function
- * differs from vte_terminal_get_text() in that trailing spaces at the end of
- * lines are included.
+ * the character's position, colors, and other characteristics.
  *
  * Returns: (transfer full): a newly allocated text string, or %NULL.
+ *
+ * Deprecated: 0.56: Use vte_terminal_get_text() instead.
  */
 char *
 vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
@@ -2881,14 +2880,7 @@ vte_terminal_get_text_include_trailing_spaces(VteTerminal *terminal,
                                              gpointer user_data,
                                              GArray *attributes)
 {
-       g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
-        warn_if_callback(is_selected);
-        auto text = IMPL(terminal)->get_text_displayed(true /* wrap */,
-                                                       true /* include trailing whitespace */,
-                                                       attributes);
-        if (text == nullptr)
-                return nullptr;
-        return (char*)g_string_free(text, FALSE);
+        return vte_terminal_get_text(terminal, is_selected, user_data, attributes);
 }
 
 /**
@@ -2928,7 +2920,6 @@ vte_terminal_get_text_range(VteTerminal *terminal,
                                              end_row, end_col,
                                              false /* block */,
                                              true /* wrap */,
-                                             true /* include trailing whitespace */,
                                              attributes);
         if (text == nullptr)
                 return nullptr;
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 1652ca5f..4c2d09fb 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -917,15 +917,12 @@ public:
                           vte::grid::column_t end_col,
                           bool block,
                           bool wrap,
-                          bool include_trailing_spaces,
                           GArray* attributes = nullptr);
 
         GString* get_text_displayed(bool wrap,
-                                    bool include_trailing_spaces,
                                     GArray* attributes = nullptr);
 
         GString* get_text_displayed_a11y(bool wrap,
-                                         bool include_trailing_spaces,
                                          GArray* attributes = nullptr);
 
         GString* get_selected_text(GArray* attributes = nullptr);


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