tag: introduce geti() to get tag with numbers as index
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
9959169bb0
commit
6cfa589f03
10
awful.lua
10
awful.lua
|
@ -136,7 +136,7 @@ end
|
|||
local function tag_selectedlist(s)
|
||||
local idx = 1
|
||||
local screen = s or mouse.screen_get()
|
||||
local tags = tag.get(screen)
|
||||
local tags = tag.geti(screen)
|
||||
local vtags = {}
|
||||
for i, t in pairs(tags) do
|
||||
if t:isselected() then
|
||||
|
@ -210,15 +210,13 @@ local function tag_viewnone()
|
|||
end
|
||||
|
||||
local function tag_viewidx(r)
|
||||
local tags = tag.get(mouse.screen_get())
|
||||
local tags = tag.geti(mouse.screen_get())
|
||||
local sel = tag_selected()
|
||||
local i = 1
|
||||
tag_viewnone()
|
||||
for name, t in pairs(tags) do
|
||||
for i, t in ipairs(tags) do
|
||||
if t == sel then
|
||||
tags[array_boundandcycle(tags, i + r)]:view(true)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -247,7 +245,7 @@ end
|
|||
local function client_movetotag(target, c)
|
||||
local sel = c or client.focus_get();
|
||||
local tags = tag.get(mouse.screen_get())
|
||||
for i, t in pairs(tags) do
|
||||
for k, t in pairs(tags) do
|
||||
sel:tag(t, false)
|
||||
end
|
||||
sel:tag(target, true)
|
||||
|
|
32
tag.c
32
tag.c
|
@ -282,7 +282,7 @@ luaA_tag_add(lua_State *L)
|
|||
*
|
||||
* \luastack
|
||||
* \lparam A screen number.
|
||||
* \lreturn A table with all tags from the screen specified.
|
||||
* \lreturn A table with all tags from the screen specified, indexed by tag name.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_get(lua_State *L)
|
||||
|
@ -303,6 +303,33 @@ luaA_tag_get(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/** Get all tags from a screen.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lparam A screen number.
|
||||
* \lreturn A table with all tags from the screen specified, ordered and indexed
|
||||
* by number.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_geti(lua_State *L)
|
||||
{
|
||||
int i = 1, screen = luaL_checknumber(L, 1) - 1;
|
||||
tag_t *tag;
|
||||
|
||||
luaA_checkscreen(screen);
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
|
||||
{
|
||||
luaA_tag_userdata_new(tag);
|
||||
lua_rawseti(L, -2, i++);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Create a new tag.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
|
@ -581,7 +608,8 @@ DO_LUA_EQ(tag_t, tag, "tag")
|
|||
const struct luaL_reg awesome_tag_methods[] =
|
||||
{
|
||||
{ "new", luaA_tag_new },
|
||||
{ "get", luaA_tag_get},
|
||||
{ "get", luaA_tag_get },
|
||||
{ "geti", luaA_tag_geti },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
const struct luaL_reg awesome_tag_meta[] =
|
||||
|
|
Loading…
Reference in New Issue