vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 50c552a49e190c8dc3fe172fcb6c293e56f92f5d
parent bcfb7c66e12d86cd8fe95d3eac14b50bc223e589
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 21 May 2016 00:13:02 +0200

vis-lua: add window.viewport range

Diffstat:
MREADME.md | 1+
Mvis-lua.c | 7+++++++
2 files changed, 8 insertions(+), 0 deletions(-)

diff --git 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 @@ -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;