From 5166e81e794c0faa80742ad6806745b13b967a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 19 Mar 2017 14:05:32 +0100 Subject: vis: add infrastructure for user specified operators --- vis-core.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'vis-core.h') diff --git a/vis-core.h b/vis-core.h index f182e2a..9cc26f3 100644 --- a/vis-core.h +++ b/vis-core.h @@ -37,7 +37,7 @@ struct Mode { bool visual; /* whether text selection is possible in this mode */ }; -typedef struct { +struct OperatorContext { int count; /* how many times should the command be executed? */ Register *reg; /* always non-NULL, set to a default register */ Filerange range; /* which part of the file should be affected by the operator */ @@ -45,12 +45,14 @@ typedef struct { size_t newpos; /* new position after motion or EPOS if none given */ bool linewise; /* should the changes always affect whole lines? */ const Arg *arg; /* arbitrary arguments */ -} OperatorContext; + void *context; /* used by user-registered operators */ +}; typedef struct { /* operator logic, returns new cursor position, if EPOS is * the cursor is disposed (except if it is the primary one) */ - size_t (*func)(Vis*, Text*, OperatorContext*); + VisOperatorFunction *func; + void *context; } Operator; typedef struct { /* Motion implementation, takes a cursor postion and returns a new one */ @@ -200,6 +202,7 @@ struct Vis { Array actions_user; /* dynamically allocated editor actions */ lua_State *lua; /* lua context used for syntax highligthing */ VisEvent *event; + Array operators; Array motions; Array textobjects; Array bindings; -- cgit v1.2.3