From 1d2005c82f19f2094ffb57394832754160b9bbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 21 May 2016 00:13:02 +0200 Subject: vis-lua: add window.viewport range --- README.md | 1 + vis-lua.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 19fe88b..a27c982 100644 --- a/README.md +++ b/README.md @@ -619,6 +619,7 @@ At this time there exists no API stability guarantees. - `map(mode, key, function)` map a Lua function to `key` in `mode`, local to the given window - `style_define(id, style)` where `id` is a constant and `style` a string - `style(id, start, end)` apply style to file range, will be cleared after every redraw + - `viewport` a range denoting the currently visible area of the window - `cursor` - `line` (1 based), `col` (1 based) - `to(line, col)` diff --git a/vis-lua.c b/vis-lua.c index 749abaa..1988075 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -594,6 +594,13 @@ static int window_index(lua_State *L) { if (lua_isstring(L, 2)) { const char *key = lua_tostring(L, 2); + + if (strcmp(key, "viewport") == 0) { + Filerange r = win ? view_viewport_get(win->view) : text_range_empty(); + pushrange(L, &r); + return 1; + } + if (strcmp(key, "file") == 0) { obj_ref_new(L, win->file, "vis.file"); return 1; -- cgit v1.2.3