[vte] lib: Rename type
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] lib: Rename type
- Date: Sat, 28 Nov 2015 21:59:35 +0000 (UTC)
commit 30e7f46f911f0c84e32e2057052d167dd01351ef
Author: Christian Persch <chpe gnome org>
Date: Sat Nov 28 22:58:32 2015 +0100
lib: Rename type
src/vte.cc | 4 ++--
src/vteinternal.hh | 6 +-----
src/vtetypes.cc | 32 ++++++++++++++++++++++++++++++++
src/vtetypes.hh | 22 ++++++++++++++++++++++
4 files changed, 57 insertions(+), 7 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 3b98f15..1ff4319 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -6741,7 +6741,7 @@ VteTerminalPrivate::extend_selection(long x,
{
long residual;
long row;
- struct selection_event_coords *origin, *last, *start, *end;
+ vte::view::coords *origin, *last, *start, *end;
VteVisualPosition old_start, old_end, *sc, *ec, *so, *eo;
gboolean invalidate_selected = FALSE;
gboolean had_selection;
@@ -6846,7 +6846,7 @@ VteTerminalPrivate::extend_selection(long x,
/* Sort x using row cell coordinates */
if ((m_selection_block_mode || sc->row == ec->row) && (start->x > end->x)) {
- struct selection_event_coords *tmp;
+ vte::view::coords *tmp;
tmp = start;
start = end;
end = tmp;
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index f149593..43f9e92 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -180,10 +180,6 @@ typedef enum {
LAST_VTE_TARGET
} VteSelectionTarget;
-struct selection_event_coords {
- long x, y;
-};
-
struct vte_scrolling_region {
int start, end;
};
@@ -275,7 +271,7 @@ public:
gboolean selecting_had_delta;
gboolean selection_block_mode;
enum vte_selection_type selection_type;
- struct selection_event_coords selection_origin, selection_last;
+ vte::view::coords selection_origin, selection_last;
VteVisualPosition selection_start, selection_end;
/* Clipboard data information. */
diff --git a/src/vtetypes.cc b/src/vtetypes.cc
index 298e7d2..92b2a18 100644
--- a/src/vtetypes.cc
+++ b/src/vtetypes.cc
@@ -29,6 +29,9 @@ static_assert(sizeof(vte::grid::coords) == 2 * sizeof(long), "vte::grid::coords
static_assert(std::is_pod<vte::grid::span>::value, "vte::grid::span not POD");
static_assert(sizeof(vte::grid::span) == 4 * sizeof(long), "vte::grid::span size wrong");
+static_assert(std::is_pod<vte::view::coords>::value, "vte::view::coords not POD");
+static_assert(sizeof(vte::view::coords) == 2 * sizeof(vte::view::coord_t), "vte::view::coords size wrong");
+
static_assert(std::is_pod<vte::color::rgb>::value, "vte::color::rgb not POD");
static_assert(sizeof(vte::color::rgb) == sizeof(PangoColor), "vte::color::rgb size wrong");
@@ -255,6 +258,34 @@ test_grid_span (void)
}
static void
+test_view_coords (void)
+{
+ /* Default constructor */
+ vte::view::coords p1;
+
+ /* Construction and assignment */
+ vte::view::coords p2(256, 512);
+
+ /* Comparision operators */
+
+ vte::view::coords p3 = p2;
+ vte::view::coords p4(1024, 2048);
+ vte::view::coords p5 = p4;
+
+ g_assert_true(p3 == p2);
+ g_assert_false(p3 != p2);
+ g_assert_true(p3 != p4);
+ g_assert_false(p3 == p4);
+
+ /* Swap */
+
+ p5.swap(p3);
+ g_assert_true(p3 == p4);
+ g_assert_true(p5 == p2);
+}
+
+
+static void
test_color_rgb (void)
{
}
@@ -267,6 +298,7 @@ main(int argc, char *argv[])
g_test_add_func("/vte/c++/grid/coords", test_grid_coords);
g_test_add_func("/vte/c++/grid/span", test_grid_span);
g_test_add_func("/vte/c++/color/rgb", test_color_rgb);
+ g_test_add_func("/vte/c++/view/coords", test_view_coords);
return g_test_run();
}
diff --git a/src/vtetypes.hh b/src/vtetypes.hh
index 3b2a7c0..94e6ef0 100644
--- a/src/vtetypes.hh
+++ b/src/vtetypes.hh
@@ -85,6 +85,28 @@ namespace grid {
} /* namespace grid */
+
+namespace view {
+
+ /* FIXMEchpe: actually 32-bit int would be sufficient here */
+ typedef long coord_t;
+
+ struct coords {
+ public:
+ coords() = default;
+ coords(coord_t x_, coord_t y_) : x(x_), y(y_) { }
+
+ inline bool operator == (coords const& rhs) const { return x == rhs.x && y == rhs.y; }
+ inline bool operator != (coords const& rhs) const { return x != rhs.x || y != rhs.y; }
+
+ void swap(coords &rhs) { coords tmp = rhs; rhs = *this; *this = tmp; }
+ public:
+ coord_t x;
+ coord_t y;
+};
+
+} /* namespace view */
+
namespace color {
/* 24-bit (8 bit per channel) packed colour */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]