Skip to content

Commit

Permalink
lua: Move height and width to viewport table and add info to Lua docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dther committed Apr 25, 2024
1 parent a9c8470 commit 4c099ea
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -1833,16 +1833,10 @@ static const struct luaL_Reg registers_funcs[] = {
* Viewport currently being displayed.
* Changing these values will not move the viewport.
* @table viewport
* @tfield Range bytes
* @tfield Range lines
*/
/***
* Viewport height, accounting for window decorations.
* @tfield int view_height
*/
/***
* Viewport width, accounting for window decorations.
* @tfield int view_width
* @tfield Range bytes file bytes, from 0, at the start and end of the viewport
* @tfield Range lines file lines, from 1, at the top and bottom of the viewport
* @tfield int height lines in viewport, accounting for window decoration
* @tfield int width columns in viewport, accounting for window decoration
*/
/***
* The window width.
Expand Down Expand Up @@ -1883,23 +1877,19 @@ static int window_index(lua_State *L) {
l.start = view_lines_first(win->view)->lineno;
l.end = view_lines_last(win->view)->lineno;

lua_createtable(L, 0, 2);
lua_createtable(L, 0, 4);
lua_pushstring(L, "bytes");
pushrange(L, &b);
lua_settable(L, -3);
lua_pushstring(L, "lines");
pushrange(L, &l);
lua_settable(L, -3);
return 1;
}

if (strcmp(key, "view_width") == 0) {
lua_pushstring(L, "width");
lua_pushunsigned(L, view_width_get(win->view));
return 1;
}

if (strcmp(key, "view_height") == 0) {
lua_settable(L, -3);
lua_pushstring(L, "height");
lua_pushunsigned(L, view_height_get(win->view));
lua_settable(L, -3);
return 1;
}

Expand Down

0 comments on commit 4c099ea

Please sign in to comment.