diff options
| author | Rudy Dellomas III <dther@dther.xyz> | 2024-04-23 15:33:13 +1000 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2024-04-25 07:55:28 -0600 |
| commit | 1fc175627f3afe938be0b5daa6a864b281725fec (patch) | |
| tree | 13d7fe0dc4654ec934f59437561ed3248e026550 | |
| parent | ad03feb0857c39d74a476432bcc5b0d4207f175d (diff) | |
| download | vis-1fc175627f3afe938be0b5daa6a864b281725fec.tar.gz vis-1fc175627f3afe938be0b5daa6a864b281725fec.tar.xz | |
lua: Report viewport lines and bytes in one table
This will break all plugins which currently use Win.viewport.
| -rw-r--r-- | lua/vis-std.lua | 2 | ||||
| -rw-r--r-- | vis-lua.c | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/lua/vis-std.lua b/lua/vis-std.lua index 5dd13eb..1fe93a9 100644 --- a/lua/vis-std.lua +++ b/lua/vis-std.lua @@ -54,7 +54,7 @@ vis.events.subscribe(vis.events.WIN_HIGHLIGHT, function(win) if not lexer then return end -- TODO: improve heuristic for initial style - local viewport = win.viewport + local viewport = win.viewport.bytes if not viewport then return end local horizon_max = win.horizon or 32768 local horizon = viewport.start < horizon_max and viewport.start or horizon_max @@ -1831,7 +1831,10 @@ static const struct luaL_Reg registers_funcs[] = { /*** * Viewport currently being displayed. - * @tfield Range viewport + * Changing these values will not move the viewport. + * @table viewport + * @tfield Range bytes + * @tfield Range lines */ /*** * The window width. @@ -1867,8 +1870,18 @@ static int window_index(lua_State *L) { const char *key = lua_tostring(L, 2); if (strcmp(key, "viewport") == 0) { - Filerange r = view_viewport_get(win->view); - pushrange(L, &r); + Filerange b = view_viewport_get(win->view); + Filerange l; + l.start = view_lines_first(win->view)->lineno; + l.end = view_lines_last(win->view)->lineno; + + lua_createtable(L, 0, 2); + lua_pushstring(L, "bytes"); + pushrange(L, &b); + lua_settable(L, -3); + lua_pushstring(L, "lines"); + pushrange(L, &l); + lua_settable(L, -3); return 1; } |
