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 function tag_selectedlist(s)
|
||||||
local idx = 1
|
local idx = 1
|
||||||
local screen = s or mouse.screen_get()
|
local screen = s or mouse.screen_get()
|
||||||
local tags = tag.get(screen)
|
local tags = tag.geti(screen)
|
||||||
local vtags = {}
|
local vtags = {}
|
||||||
for i, t in pairs(tags) do
|
for i, t in pairs(tags) do
|
||||||
if t:isselected() then
|
if t:isselected() then
|
||||||
|
@ -210,15 +210,13 @@ local function tag_viewnone()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tag_viewidx(r)
|
local function tag_viewidx(r)
|
||||||
local tags = tag.get(mouse.screen_get())
|
local tags = tag.geti(mouse.screen_get())
|
||||||
local sel = tag_selected()
|
local sel = tag_selected()
|
||||||
local i = 1
|
|
||||||
tag_viewnone()
|
tag_viewnone()
|
||||||
for name, t in pairs(tags) do
|
for i, t in ipairs(tags) do
|
||||||
if t == sel then
|
if t == sel then
|
||||||
tags[array_boundandcycle(tags, i + r)]:view(true)
|
tags[array_boundandcycle(tags, i + r)]:view(true)
|
||||||
end
|
end
|
||||||
i = i + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -247,7 +245,7 @@ end
|
||||||
local function client_movetotag(target, c)
|
local function client_movetotag(target, c)
|
||||||
local sel = c or client.focus_get();
|
local sel = c or client.focus_get();
|
||||||
local tags = tag.get(mouse.screen_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)
|
sel:tag(t, false)
|
||||||
end
|
end
|
||||||
sel:tag(target, true)
|
sel:tag(target, true)
|
||||||
|
|
30
tag.c
30
tag.c
|
@ -282,7 +282,7 @@ luaA_tag_add(lua_State *L)
|
||||||
*
|
*
|
||||||
* \luastack
|
* \luastack
|
||||||
* \lparam A screen number.
|
* \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
|
static int
|
||||||
luaA_tag_get(lua_State *L)
|
luaA_tag_get(lua_State *L)
|
||||||
|
@ -303,6 +303,33 @@ luaA_tag_get(lua_State *L)
|
||||||
return 1;
|
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.
|
/** Create a new tag.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
*
|
*
|
||||||
|
@ -582,6 +609,7 @@ const struct luaL_reg awesome_tag_methods[] =
|
||||||
{
|
{
|
||||||
{ "new", luaA_tag_new },
|
{ "new", luaA_tag_new },
|
||||||
{ "get", luaA_tag_get },
|
{ "get", luaA_tag_get },
|
||||||
|
{ "geti", luaA_tag_geti },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
const struct luaL_reg awesome_tag_meta[] =
|
const struct luaL_reg awesome_tag_meta[] =
|
||||||
|
|
Loading…
Reference in New Issue