Skip to content

Commit

Permalink
Serve viewport dimensions through view_width and view_height
Browse files Browse the repository at this point in the history
These values are useful for calculating terminal positions.
  • Loading branch information
dther committed Apr 25, 2024
1 parent e4ad016 commit 099f50f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions vis-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,14 @@ static const struct luaL_Reg registers_funcs[] = {
* Viewport currently being displayed.
* @tfield Range viewport
*/
/***
* Viewport height, accounting for window decorations.
* @tfield int view_height
*/
/***
* Viewport width, accounting for window decorations.
* @tfield int view_width
*/
/***
* The window width.
* @tfield int width
Expand Down Expand Up @@ -1872,6 +1880,16 @@ static int window_index(lua_State *L) {
return 1;
}

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

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

if (strcmp(key, "width") == 0) {
lua_pushunsigned(L, vis_window_width_get(win));
return 1;
Expand Down

0 comments on commit 099f50f

Please sign in to comment.