aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--vis-lua.c7
2 files changed, 8 insertions, 0 deletions
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;