You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nvim-libmodal/lua/libmodal/src/utils/WindowState.lua

71 lines
1.0 KiB
Lua

--[[
/*
* IMPORTS
*/
--]]
local api = require('libmodal/src/utils/api')
local classes = require('libmodal/src/classes')
--[[
/*
* MODULE
*/
--]]
local WindowState = {}
local height = 'winheight'
local width = 'winwidth'
4 years ago
--[[
/*
* META `WindowState`
*/
--]]
local _metaWindowState = classes.new({})
4 years ago
-----------------------------------
--[[ SUMMARY
* Restore the state of `self`.
]]
-----------------------------------
function _metaWindowState:restore()
api.nvim_set_option(height, self.height)
api.nvim_set_option(width, self.width)
api.nvim_redraw()
end
--[[
/*
* CLASS `WindowState`
*/
--]]
--------------------------
--[[ SUMMARY:
* Create a table representing the size of the current window.
]]
--[[ RETURNS:
* The new `WindowState`.
]]
--------------------------
function WindowState.new()
4 years ago
return setmetatable(
{
['height'] = api.nvim_get_option(height),
['width'] = api.nvim_get_option(width),
},
_metaWindowState
)
end
--[[
/*
* PUBLICIZE MODULE
*/
--]]
return WindowState