From 14fd8fadb5a25dc7ee8ed97a9f423cfaceb35cac Mon Sep 17 00:00:00 2001 From: Perry Hargrave Date: Fri, 28 May 2010 16:39:18 -0700 Subject: [PATCH] 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 Signed-off-by: Julien Danjou --- lib/awful/tag.lua.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index e2dc3b5a..e28b94ef 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -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)