[vte] terminal: Use an enum class for selection type



commit d6ac3668272a7bdaf65b47243af8ba900231af0b
Author: Christian Persch <chpe src gnome org>
Date:   Mon Nov 18 22:42:22 2019 +0100

    terminal: Use an enum class for selection type

 src/vte.cc         | 20 ++++++++++----------
 src/vteinternal.hh | 18 +++++++++---------
 2 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 4e289207..b577e517 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -5194,7 +5194,7 @@ Terminal::resolve_selection_endpoint(vte::grid::halfcoords const& rowcolhalf, bo
                 col = std::clamp (col, 0L, m_column_count);
         } else {
                 switch (m_selection_type) {
-                case selection_type_char:
+                case SelectionType::eCHAR:
                         /* Find the nearest actual character boundary, taking CJKs and TABs into account.
                          * If at least halfway through the first unused cell, or over the right margin
                          * then wrap to the beginning of the next line.
@@ -5242,7 +5242,7 @@ Terminal::resolve_selection_endpoint(vte::grid::halfcoords const& rowcolhalf, bo
                         }
                         break;
 
-                case selection_type_word:
+                case SelectionType::eWORD:
                         /* Initialization for the cumbersome cases where the click didn't occur over an 
actual used cell. */
                         rowdata = find_row_data(row);
                         if (col < 0) {
@@ -5371,7 +5371,7 @@ Terminal::resolve_selection_endpoint(vte::grid::halfcoords const& rowcolhalf, bo
                         }
                         break;
 
-                case selection_type_line:
+                case SelectionType::eLINE:
                         if (!after) {
                                 /* Back up as far as we can go. */
                                 while (row > 0 &&
@@ -6742,10 +6742,10 @@ Terminal::confine_coordinates(long *xp,
  */
 void
 Terminal::start_selection (vte::view::coords const& pos,
-                           enum vte_selection_type type)
+                           SelectionType type)
 {
        if (m_selection_block_mode)
-               type = selection_type_char;
+               type = SelectionType::eCHAR;
 
         /* Need to ensure the ringview is updated. */
         ringview_update();
@@ -6934,7 +6934,7 @@ Terminal::widget_motion_notify(GdkEventMotion *event)
                                return true;
 
                         start_selection(vte::view::coords(m_mouse_last_position.x, m_mouse_last_position.y),
-                                        selection_type_char);
+                                        SelectionType::eCHAR);
                }
 
                if (m_selecting &&
@@ -7076,12 +7076,12 @@ Terminal::widget_button_press(GdkEventButton *event)
                case 1:
                         if (m_will_select_after_threshold) {
                                 start_selection(pos,
-                                                selection_type_char);
+                                                SelectionType::eCHAR);
                                handled = true;
                        }
                         if ((m_mouse_handled_buttons & 1) != 0) {
                                 start_selection(pos,
-                                                selection_type_word);
+                                                SelectionType::eWORD);
                                handled = true;
                        }
                        break;
@@ -7100,7 +7100,7 @@ Terminal::widget_button_press(GdkEventButton *event)
                case 1:
                         if ((m_mouse_handled_buttons & 1) != 0) {
                                 start_selection(pos,
-                                                selection_type_line);
+                                                SelectionType::eLINE);
                                handled = true;
                        }
                        break;
@@ -10167,7 +10167,7 @@ Terminal::select_text(vte::grid::column_t start_col,
 {
        deselect_all();
 
-       m_selection_type = selection_type_char;
+       m_selection_type = SelectionType::eCHAR;
        m_selecting_had_delta = true;
         m_selection_resolved.set ({ start_row, start_col },
                                   { end_row, end_col });
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 5b6888a0..6a17efa9 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -134,12 +134,6 @@ public:
         } saved;
 };
 
-enum vte_selection_type {
-        selection_type_char,
-        selection_type_word,
-        selection_type_line
-};
-
 /* Until the selection can be generated on demand, let's not enable this on stable */
 #include "vte/vteversion.h"
 #if (VTE_MINOR_VERSION % 2) == 0
@@ -299,6 +293,12 @@ private:
                 eALL_MOTION_TRACKING,
         };
 
+        enum class SelectionType {
+               eCHAR,
+               eWORD,
+               eLINE,
+        };
+
 protected:
 
         /* NOTE: This needs to be kept in sync with the public VteCursorBlinkMode enum */
@@ -455,8 +455,8 @@ public:
         gboolean m_selecting;
         gboolean m_will_select_after_threshold;
         gboolean m_selecting_had_delta;
-        bool m_selection_block_mode{false};  // FIXMEegmont move it into a 4th value in vte_selection_type?
-        enum vte_selection_type m_selection_type;
+        bool m_selection_block_mode{false};  // FIXMEegmont move it into a 4th value in SelectionType?
+        SelectionType m_selection_type{SelectionType::eCHAR};
         vte::grid::halfcoords m_selection_origin, m_selection_last;  /* BiDi: logical in normal modes, 
visual in m_selection_block_mode */
         vte::grid::span m_selection_resolved;
 
@@ -1058,7 +1058,7 @@ public:
                                     GArray* attrs);
 
         void start_selection(vte::view::coords const& pos,
-                             enum vte_selection_type type);
+                             SelectionType type);
         bool maybe_end_selection();
 
         void select_all();


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