From 44ff1f95ecc14521fb2a1cec67a628140fc46598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 17 Feb 2016 20:59:26 +0100 Subject: Add infrastructure to add custom motion functions A motion function can be registered with vis_motion_register(...) the returned id (if non negative) can then be used as an argument to vis_motion(...) --- vis-core.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'vis-core.h') diff --git a/vis-core.h b/vis-core.h index a201828..b1330c7 100644 --- a/vis-core.h +++ b/vis-core.h @@ -8,6 +8,7 @@ #include "text-regex.h" #include "map.h" #include "ring-buffer.h" +#include "array.h" /* a mode contains a set of key bindings which are currently valid. * @@ -59,6 +60,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); + size_t (*user)(Vis*, Win*, void*, size_t pos); enum { LINEWISE = VIS_MOTIONTYPE_LINEWISE, /* should the covered range be extended to whole lines? */ CHARWISE = VIS_MOTIONTYPE_CHARWISE, /* scrolls window content until position is visible */ @@ -66,6 +68,7 @@ typedef struct { /* Motion implementation, takes a cursor postion and returns a IDEMPOTENT = 1 << 3, /* does the returned postion remain the same if called multiple times? */ JUMP = 1 << 4, } type; + void *data; } Movement; typedef struct { @@ -165,6 +168,7 @@ struct Vis { Map *actions; /* registered editor actions / special keys commands */ lua_State *lua; /* lua context used for syntax highligthing */ VisEvent *event; + Array motions; }; /** stuff used by multiple of the vis-* files */ -- cgit v1.2.3