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:
Perry Hargrave 2010-05-28 16:39:18 -07:00 committed by Julien Danjou
parent 7b60f84fd0
commit 77e39a5f07
1 changed files with 14 additions and 0 deletions

View File

@ -259,6 +259,20 @@ function viewidx(i, screen)
capi.screen[screen]:emit_signal("tag::history::update") capi.screen[screen]:emit_signal("tag::history::update")
end 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). --- View next tag. This is the same as tag.viewidx(1).
-- @param screen The screen number. -- @param screen The screen number.
function viewnext(screen) function viewnext(screen)