Update api

This commit is contained in:
Ottatop 2023-08-14 14:35:06 -05:00
parent eb85c92164
commit dfa4c65929
2 changed files with 150 additions and 44 deletions

View file

@ -121,17 +121,32 @@ function window_module.class(win) end
---@see Window.title ---@see Window.title
function window_module.title(win) end function window_module.title(win) end
---Get `win`'s status. ---Toggle `win`'s floating status.
---
---When used on a floating window, this will change it to tiled, and vice versa.
---
---When used on a fullscreen or maximized window, this will still change its
---underlying floating/tiled status.
---@tparam Window win ---@tparam Window win
---@treturn string|nil One of `"Floating"`, `"Tiled"`, `"Fullscreen"`, `"Maximized"`, or `nil`. function window_module.toggle_floating(win) end
---@see Window.status
function window_module.status(win) end
---Set `win`'s status. ---Toggle `win`'s fullscreen status.
---
---When used on a fullscreen window, this will change the window back to
---floating or tiled.
---
---When used on a non-fullscreen window, it becomes fullscreen.
---@tparam Window win ---@tparam Window win
---@tparam string status One of `"Floating"`, `"Tiled"`, `"Fullscreen"`, or `"Maximized"`. function window_module.toggle_fullscreen(win) end
---@see Window.set_status
function window_module.set_status(win, status) end ---Toggle `win`'s maximized status.
---
---When used on a maximized window, this will change the window back to
---floating or tiled.
---
---When used on a non-maximized window, it becomes maximized.
---@tparam Window win
function window_module.toggle_maximized(win) end
---Get whether or not this window is focused. ---Get whether or not this window is focused.
--- ---
@ -145,6 +160,18 @@ function window_module.set_status(win, status) end
---@see Window.focused ---@see Window.focused
function window_module.focused(win) end function window_module.focused(win) end
---Get whether or not `win` is floating (true) or tiled (false).
---@treturn boolean|nil
function window_module.floating(win) end
---Get whether or not `win` is fullscreen.
---@treturn boolean|nil
function window_module.fullscreen(win) end
---Get whether or not `win` is maximized.
---@treturn boolean|nil
function window_module.maximized(win) end
-------------------------------------------------------- --------------------------------------------------------
---The window object. ---The window object.
@ -240,21 +267,49 @@ function window:class() end
---@see WindowModule.title ---@see WindowModule.title
function window:title() end function window:title() end
---Get this window's status. ---Toggle this window's floating status.
---@treturn string|nil One of `"Floating"`, `"Tiled"`, `"Fullscreen"`, `"Maximized"`, or `nil`. ---
---@see WindowModule.status ---When used on a floating window, this will change it to tiled, and vice versa.
function window:status() end ---
---When used on a fullscreen or maximized window, this will still change its
---Get `win`'s status. ---underlying floating/tiled status.
---@tparam Window win ---@tparam Window win
---@tparam string status One of `"Floating"`, `"Tiled"`, `"Fullscreen"`, or `"Maximized"`. function window:toggle_floating(win) end
---@see WindowModule.set_status
function window:set_status(win, status) end ---Toggle this window's fullscreen status.
---
---When used on a fullscreen window, this will change the window back to
---floating or tiled.
---
---When used on a non-fullscreen window, it becomes fullscreen.
---@tparam Window win
function window:toggle_fullscreen(win) end
---Toggle this window's maximized status.
---
---When used on a maximized window, this will change the window back to
---floating or tiled.
---
---When used on a non-maximized window, it becomes maximized.
---@tparam Window win
function window:toggle_maximized(win) end
---Get whether or not this window is focused. ---Get whether or not this window is focused.
--- ---
---@usage ---@usage
---print(window.get_focused():focused()) -- should print `true`. ---print(window.get_focused():focused()) -- should print `true`.
---@treturn boolean|nil floating `true` if it's floating, `false` if it's tiled, or nil if it doesn't exist. ---@treturn boolean|nil floating `true` if it's focused, `false` if it's tiled, or nil if it doesn't exist.
---@see WindowModule.focused ---@see WindowModule.focused
function window:focused() end function window:focused() end
---Get whether or not this window is floating (true) or tiled (false).
---@treturn boolean|nil
function window:floating() end
---Get whether or not this window is fullscreen.
---@treturn boolean|nil
function window:fullscreen() end
---Get whether or not this window is maximized.
---@treturn boolean|nil
function window:maximized() end

View file

@ -151,49 +151,55 @@ function window:title()
return window_module.title(self) return window_module.title(self)
end end
---Get this window's status. ---Get this window's floating status.
---@return boolean|nil ---@return boolean|nil
---@see WindowModule.status — The corresponding module function ---@see WindowModule.floating — The corresponding module function
function window:floating() function window:floating()
return window_module.floating(self) return window_module.floating(self)
end end
---Get this window's status. ---Get this window's fullscreen status.
---@return boolean|nil ---@return boolean|nil
---@see WindowModule.status — The corresponding module function ---@see WindowModule.fullscreen — The corresponding module function
function window:fullscreen() function window:fullscreen()
return window_module.fullscreen(self) return window_module.fullscreen(self)
end end
---Get this window's status. ---Get this window's maximized status.
---@return boolean|nil ---@return boolean|nil
---@see WindowModule.status — The corresponding module function ---@see WindowModule.maximized — The corresponding module function
function window:maximized() function window:maximized()
return window_module.maximized(self) return window_module.maximized(self)
end end
---Toggle this window's floating status.
---
---When used on a floating window, this will change it to tiled, and vice versa.
---
---When used on a fullscreen or maximized window, this will still change its
---underlying floating/tiled status.
function window:toggle_floating() function window:toggle_floating()
SendMsg({ window_module.toggle_floating(self)
ToggleFloating = {
window_id = self:id(),
},
})
end end
---Toggle this window's fullscreen status.
---
---When used on a fullscreen window, this will change the window back to
---floating or tiled.
---
---When used on a non-fullscreen window, it becomes fullscreen.
function window:toggle_fullscreen() function window:toggle_fullscreen()
SendMsg({ window_module.toggle_fullscreen(self)
ToggleFullscreen = {
window_id = self:id(),
},
})
end end
---Toggle this window's maximized status.
---
---When used on a maximized window, this will change the window back to
---floating or tiled.
---
---When used on a non-maximized window, it becomes maximized.
function window:toggle_maximized() function window:toggle_maximized()
SendMsg({ window_module.toggle_maximized(self)
ToggleMaximized = {
window_id = self:id(),
},
})
end end
---Get whether or not this window is focused. ---Get whether or not this window is focused.
@ -202,7 +208,7 @@ end
---```lua ---```lua
---print(window.get_focused():focused()) -- should print `true`. ---print(window.get_focused():focused()) -- should print `true`.
---``` ---```
---@return boolean|nil floating `true` if it's floating, `false` if it's tiled, or nil if it doesn't exist. ---@return boolean|nil
---@see WindowModule.focused — The corresponding module function ---@see WindowModule.focused — The corresponding module function
function window:focused() function window:focused()
return window_module.focused(self) return window_module.focused(self)
@ -347,6 +353,51 @@ function window_module.move_to_tag(w, name, output)
end end
end end
---Toggle `win`'s floating status.
---
---When used on a floating window, this will change it to tiled, and vice versa.
---
---When used on a fullscreen or maximized window, this will still change its
---underlying floating/tiled status.
---@param win Window
function window_module.toggle_floating(win)
SendMsg({
ToggleFloating = {
window_id = win:id(),
},
})
end
---Toggle `win`'s fullscreen status.
---
---When used on a fullscreen window, this will change the window back to
---floating or tiled.
---
---When used on a non-fullscreen window, it becomes fullscreen.
---@param win Window
function window_module.toggle_fullscreen(win)
SendMsg({
ToggleFloating = {
window_id = win:id(),
},
})
end
---Toggle `win`'s maximized status.
---
---When used on a maximized window, this will change the window back to
---floating or tiled.
---
---When used on a non-maximized window, it becomes maximized.
---@param win Window
function window_module.toggle_maximized(win)
SendMsg({
ToggleFloating = {
window_id = win:id(),
},
})
end
---Set the specified window's size. ---Set the specified window's size.
--- ---
---### Examples ---### Examples
@ -505,7 +556,7 @@ end
---Get this window's floating status. ---Get this window's floating status.
---@param win Window ---@param win Window
---@return boolean|nil ---@return boolean|nil
---@see Window.status — The corresponding object method ---@see Window.floating — The corresponding object method
function window_module.floating(win) function window_module.floating(win)
local response = Request({ local response = Request({
GetWindowProps = { GetWindowProps = {
@ -519,7 +570,7 @@ end
---Get this window's fullscreen status. ---Get this window's fullscreen status.
---@param win Window ---@param win Window
---@return boolean|nil ---@return boolean|nil
---@see Window.status — The corresponding object method ---@see Window.fullscreen — The corresponding object method
function window_module.fullscreen(win) function window_module.fullscreen(win)
local response = Request({ local response = Request({
GetWindowProps = { GetWindowProps = {
@ -534,7 +585,7 @@ end
---Get this window's maximized status. ---Get this window's maximized status.
---@param win Window ---@param win Window
---@return boolean|nil ---@return boolean|nil
---@see Window.status — The corresponding object method ---@see Window.maximized — The corresponding object method
function window_module.maximized(win) function window_module.maximized(win)
local response = Request({ local response = Request({
GetWindowProps = { GetWindowProps = {
@ -556,7 +607,7 @@ end
---end ---end
---``` ---```
---@param win Window ---@param win Window
---@return boolean|nil floating `true` if it's floating, `false` if it's tiled, or nil if it doesn't exist. ---@return boolean|nil
---@see Window.focused — The corresponding object method ---@see Window.focused — The corresponding object method
function window_module.focused(win) function window_module.focused(win)
local response = Request({ local response = Request({