From 2499521dc70b064007df652af8e68eaad8acbf2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 16 Apr 2016 11:50:17 +0200 Subject: vis-lua: add cursor.selection property --- vis-lua.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index 3533681..4b484b2 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -645,6 +645,22 @@ static int window_cursor_index(lua_State *L) { lua_pushunsigned(L, view_cursors_number(cur)+1); return 1; } + + if (strcmp(key, "selection") == 0) { + Filerange sel = view_cursors_selection_get(cur); + if (text_range_valid(&sel)) { + lua_createtable(L, 0, 2); + lua_pushstring(L, "start"); + lua_pushunsigned(L, sel.start); + lua_settable(L, -3); + lua_pushstring(L, "finish"); + lua_pushunsigned(L, sel.end); + lua_settable(L, -3); + } else { + lua_pushnil(L); + } + return 1; + } } return index_common(L); -- cgit v1.2.3