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 <[email protected]>
---
 lib/awful/tag.lua.in |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 03070ba..9046eda 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -312,6 +312,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)
-- 
1.7.1


-- 
To unsubscribe, send mail to [email protected].

Reply via email to