tag.move(i, t):
move tag 't', or tag.selected(), to index 'i' in the current
screen's tags table.
Signed-off-by: Perry Hargrave <[email protected]>
---
lib/awful/tag.lua.in | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 429a56d..03070ba 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -82,6 +82,28 @@ function delete(target_tag, fallback_tag)
target_tag.screen = nil
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)
+ local target_tag = target_tag or selected()
+ local scr = target_tag.screen
+ local tmp_tags = capi.screen[scr]:tags()
+
+ if (not new_index) or (new_index < 1) or (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
+
+ table.insert(tmp_tags, new_index, target_tag)
+ capi.screen[scr]:tags(tmp_tags)
+end
+
--- Create a set of tags and attach it to a screen.
-- @param names The tag name, in a table
-- @param screen The tag screen, or 1 if not set.
--
1.7.1
--
To unsubscribe, send mail to [email protected].