tag.lua: getidx() returns index of tag
tag.getidx(t): Return the index of 't' in the screen[]:tags() table. Return 'nil' if 't' is not found. Signed-off-by: Perry Hargrave <perry.hargrave@gmail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
7b60f84fd0
commit
77e39a5f07
|
@ -259,6 +259,20 @@ function viewidx(i, screen)
|
|||
capi.screen[screen]:emit_signal("tag::history::update")
|
||||
end
|
||||
|
||||
--- Get a tag's index in the screen[]:tags() table.
|
||||
-- @param query_tag The tag object to find. [selected()]
|
||||
-- @return The index of the tag, nil if the tag is not found.
|
||||
function getidx(query_tag)
|
||||
local query_tag = query_tag or selected()
|
||||
if query_tag == nil then return end
|
||||
|
||||
for i, t in ipairs(capi.screen[query_tag.screen]:tags()) do
|
||||
if t == query_tag then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- View next tag. This is the same as tag.viewidx(1).
|
||||
-- @param screen The screen number.
|
||||
function viewnext(screen)
|
||||
|
|
Loading…
Reference in New Issue