From 5d9cf02bc9993e076c883f67e3c19bde745540ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 17 Feb 2016 14:42:13 +0100 Subject: [PATCH] vis-lua: expose mode constants to lua --- vis-lua.c | 30 ++++++++++++++++++++++++++++++ vis.h | 2 -- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/vis-lua.c b/vis-lua.c index b6b46683d..2b79bf18f 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -379,6 +379,36 @@ static int vis_index(lua_State *L) { obj_ref_new(L, vis->windows, "vis.window"); return 1; } + + if (strcmp(key, "MODE_NORMAL") == 0) { + lua_pushunsigned(L, VIS_MODE_NORMAL); + return 1; + } + + if (strcmp(key, "MODE_OPERATOR_PENDING") == 0) { + lua_pushunsigned(L, VIS_MODE_OPERATOR_PENDING); + return 1; + } + + if (strcmp(key, "MODE_VISUAL") == 0) { + lua_pushunsigned(L, VIS_MODE_VISUAL); + return 1; + } + + if (strcmp(key, "MODE_VISUAL_LINE") == 0) { + lua_pushunsigned(L, VIS_MODE_VISUAL_LINE); + return 1; + } + + if (strcmp(key, "MODE_INSERT") == 0) { + lua_pushunsigned(L, VIS_MODE_INSERT); + return 1; + } + + if (strcmp(key, "MODE_REPLACE") == 0) { + lua_pushunsigned(L, VIS_MODE_REPLACE); + return 1; + } } return index_common(L); diff --git a/vis.h b/vis.h index 560e4d9e4..19cdb4358 100644 --- a/vis.h +++ b/vis.h @@ -114,8 +114,6 @@ void vis_exit(Vis*, int status); /* emergency exit, print given message, perform minimal ui cleanup and exit process */ void vis_die(Vis*, const char *msg, ...) __attribute__((noreturn)); -/* user facing modes are: NORMAL, VISUAL, VISUAL_LINE, INSERT, REPLACE. - * the others should be considered as implementation details (TODO: do not expose them?) */ enum VisMode { VIS_MODE_NORMAL, VIS_MODE_OPERATOR_PENDING,