awful.tag.move(new_index, target_tag):
given an integer, 'new_index' move the 'target_tag' or selected() to
the 'new_index' in screen[s]:tags() table
this function does nothing unless:
0 < new_index < #screen[s]:tags()
---
lib/awful/tag.lua.in | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 749a76f..6d03add 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -76,6 +76,31 @@ function new(names, screen, layout)
return tags
end
+--- Move a tag to an absolute position in the screen[]:tags() table
+-- @param new_index Integer absolute position in the table to insert
+function move(new_index, target_tag)
+ -- lua indexing begins at one
+ if not new_index or new_index < 1 then return end
+ local target_tag = target_tag or selected()
+
+ local scr = target_tag.screen
+ local tmp_tags = capi.screen[scr]:tags()
+
+ -- can't push a tag past the end either
+ if new_index > #tmp_tags then return end
+
+ for i, t in ipairs(tmp_tags) do
+ if t == target_tag then
+ table.remove(tmp_tags, i)
+ break
+ end
+ end
+
+ -- for i, t in pairs(screen[target_tag.screen
+ table.insert(tmp_tags, new_index, target_tag)
+ capi.screen[scr]:tags(tmp_tags)
+end
+
--- Delete a tag
-- @param target_tag Optional tag object to delete, [tag.selected()]
function delete(target_tag)
--
1.7.0.1
--
To unsubscribe, send mail to [email protected].