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.1 KiB
Lua

--[[
/*
* IMPORTS
*/
--]]
local api = vim.api
local libmodal_api = require('libmodal/src/utils/api')
--[[
/*
* MODULE
*/
--]]
local WindowState = {['TYPE'] = 'libmodal-window-state'}
local height = 'winheight'
local width = 'winwidth'
4 years ago
--[[
/*
* META `WindowState`
*/
--]]
4 years ago
local _metaWindowState = require('libmodal/src/classes').new(WindowState.TYPE)
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)
libmodal_api.nvim_redraw()
4 years ago
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