From d815268ee4c64a5c6134ee43968d0685eaac4d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 21 Apr 2016 22:33:18 +0200 Subject: vis-lua: implement vis:message(msg) --- README.md | 3 ++- vis-lua.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index de79e8c..253f5c9 100644 --- a/README.md +++ b/README.md @@ -588,7 +588,8 @@ At this time there exists no API stability guarantees. - `win` currently focused window - `windows()` iterator - `command(cmd)` - - `info(msg)` + - `info(msg)` display a single line message + - `message(msg)` display an arbitrarily long message - `open(filename)` - `textobject_register(function)` register a Lua function as a text object, returns associated `id` or `-1` - `textobject(id)` select/execute a text object diff --git a/vis-lua.c b/vis-lua.c index d2a6bf0..a17ef3d 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -334,13 +334,22 @@ static int command(lua_State *L) { static int info(lua_State *L) { Vis *vis = obj_ref_check(L, 1, "vis"); - if (!vis) { - lua_pushnil(L); - return 1; + if (vis) { + const char *msg = luaL_checkstring(L, 2); + vis_info_show(vis, "%s", msg); } - const char *msg = luaL_checkstring(L, 2); - vis_info_show(vis, "%s", msg); - return 0; + lua_pushboolean(L, vis != NULL); + return 1; +} + +static int message(lua_State *L) { + Vis *vis = obj_ref_check(L, 1, "vis"); + if (vis) { + const char *msg = luaL_checkstring(L, 2); + vis_message_show(vis, msg); + } + lua_pushboolean(L, vis != NULL); + return 1; } static int open(lua_State *L) { @@ -564,6 +573,7 @@ static const struct luaL_Reg vis_lua[] = { { "windows", windows }, { "command", command }, { "info", info }, + { "message", message }, { "open", open }, { "map", map }, { "motion", motion }, -- cgit v1.2.3