From ae7795327928efbe34288cce45b5547d0371b22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 16 Apr 2016 12:40:58 +0200 Subject: vis-lua: add vis.mode property --- README.md | 1 + vis-lua.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index c7b7d5f..bf06725 100644 --- a/README.md +++ b/README.md @@ -570,6 +570,7 @@ At this time there exists no API stability guarantees. - `vis` - `MODE_NORMAL`, `MODE_OPERATOR_PENDING`, `MODE_INSERT`, `MODE_REPLACE`, `MODE_VISUAL`, `MODE_VISUAL_LINE` mode constants + - `mode` current mode (one of the above constants) - `lexers` LPeg lexer support module - `events` hooks - `start()` diff --git a/vis-lua.c b/vis-lua.c index 4b484b2..4b6c2d4 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -444,6 +444,11 @@ static int vis_index(lua_State *L) { return 1; } + if (strcmp(key, "mode") == 0) { + lua_pushunsigned(L, vis->mode->id); + return 1; + } + if (strcmp(key, "MODE_NORMAL") == 0) { lua_pushunsigned(L, VIS_MODE_NORMAL); return 1; -- cgit v1.2.3