3
0
mirror of https://github.com/britzl/monarch.git synced 2025-09-27 10:02:21 +02:00

Added monarch.top() and bottom()

This commit is contained in:
Björn Ritzl
2018-06-04 13:56:45 +02:00
parent 0fdfb6fd11
commit 66b1f7ca2e
3 changed files with 65 additions and 1 deletions

View File

@@ -491,6 +491,25 @@ function M.get_stack()
return s
end
--- Get the screen on top of the stack
-- @param offset Optional offset from the top of the stack, (eg -1 for the previous screen)
-- @return Id of the requested screen
function M.top(offset)
local screen = stack[#stack + (offset or 0)]
return screen and screen.id
end
--- Get the screen at the bottom of the stack
-- @param offset Optional offset from the bottom of the stack
-- @return Id of the requested screen
function M.bottom(offset)
local screen = stack[1 + (offset or 0)]
return screen and screen.id
end
function M.dump_stack()
local s = ""
for i, screen in ipairs(stack) do