Re: [hackers][vis][PATCH] Use VisMotionType enum consistently

2015-12-20 Thread Marc André Tanner
I agree this is a bit of a mess. The current code assumes that:

  LINEWISE == VIS_MOTIONTYPE_LINEWISE &&
  CHARWISE == VIS_MOTIONTYPE_CHARWISE

and that the values are distinct from the other flags. 

However your patch is the wrong way around. The idea was to only
expose the the char / linewise properties in the public API as
the other flags are implementation details.

An improvement would probably be to initialize LINEWISE and CHARWISE
in vis-core.h with the constants from vis.h.

-- 
 Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: 10C93617



[hackers][vis][PATCH] Use VisMotionType enum consistently

2015-12-15 Thread Silvan Jegen
---
 main.c | 4 ++--
 vis-core.h | 8 +---
 vis.h  | 7 +--
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/main.c b/main.c
index a3b4023..9c99a94 100644
--- a/main.c
+++ b/main.c
@@ -1051,12 +1051,12 @@ static KeyAction vis_action[] = {
[VIS_ACTION_MOTION_CHARWISE] = {
"motion-charwise",
"Force motion to be charwise",
-   motiontype, { .i = VIS_MOTIONTYPE_CHARWISE }
+   motiontype, { .i = CHARWISE }
},
[VIS_ACTION_MOTION_LINEWISE] = {
"motion-linewise",
"Force motion to be linewise",
-   motiontype, { .i = VIS_MOTIONTYPE_LINEWISE }
+   motiontype, { .i = LINEWISE }
},
[VIS_ACTION_UNICODE_INFO] = {
"unicode-info",
diff --git a/vis-core.h b/vis-core.h
index 1ecc1b6..062a3da 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -58,13 +58,7 @@ typedef struct { /* Motion implementation, takes a cursor 
postion and returns a
size_t (*vis)(Vis*, Text*, size_t pos);
size_t (*view)(Vis*, View*);
size_t (*win)(Vis*, Win*, size_t pos);
-   enum {
-   LINEWISE  = 1 << 0,  /* should the covered range be extended to 
whole lines? */
-   CHARWISE  = 1 << 1,  /* scrolls window content until position 
is visible */
-   INCLUSIVE = 1 << 2,  /* should new position be included in 
operator range? */
-   IDEMPOTENT = 1 << 3, /* does the returned postion remain the 
same if called multiple times? */
-   JUMP = 1 << 4,
-   } type;
+   enum VisMotionType type;
 } Movement;
 
 typedef struct {
diff --git a/vis.h b/vis.h
index 4ee5a99..7f04154 100644
--- a/vis.h
+++ b/vis.h
@@ -264,8 +264,11 @@ int vis_count_get(Vis*);
 void vis_count_set(Vis*, int count);
 
 enum VisMotionType {
-   VIS_MOTIONTYPE_LINEWISE  = 1 << 0,
-   VIS_MOTIONTYPE_CHARWISE  = 1 << 1,
+   LINEWISE   = 1 << 0,  /* should the covered range be extended to whole 
lines? */
+   CHARWISE   = 1 << 1,  /* scrolls window content until position is 
visible */
+   INCLUSIVE  = 1 << 2,  /* should new position be included in operator 
range? */
+   IDEMPOTENT = 1 << 3,  /* does the returned postion remain the same if 
called multiple times? */
+   JUMP   = 1 << 4,
 };
 /* force certain motion to behave in line or character wise mode */
 void vis_motion_type(Vis *vis, enum VisMotionType);
-- 
2.6.3