diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-21 00:13:02 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-22 00:05:30 +0200 |
| commit | 1d2005c82f19f2094ffb57394832754160b9bbc6 (patch) | |
| tree | 73eec5158f8ec1340e5ddb401bbcd0177c8cf274 | |
| parent | 70641c44040751ae6ff6f3d7567448dcc2fcc061 (diff) | |
| download | vis-1d2005c82f19f2094ffb57394832754160b9bbc6.tar.gz vis-1d2005c82f19f2094ffb57394832754160b9bbc6.tar.xz | |
vis-lua: add window.viewport range
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | vis-lua.c | 7 |
2 files changed, 8 insertions, 0 deletions
@@ -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)` @@ -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; |
