tag: add {new,}index, use it for selected
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
0d7b5a7c07
commit
f750124d5c
|
@ -71,7 +71,7 @@ for s = 1, screen.count() do
|
|||
tags[s][tagnumber]:add(s)
|
||||
end
|
||||
-- I'm sure you want to see at least one tag.
|
||||
tags[s][1]:view(true)
|
||||
tags[s][1].selected = true
|
||||
end
|
||||
-- }}}
|
||||
|
||||
|
@ -80,7 +80,7 @@ end
|
|||
mytaglist = widget({ type = "taglist", name = "mytaglist" })
|
||||
mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
|
||||
mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
|
||||
mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag:view(not tag:isselected()) end))
|
||||
mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
|
||||
mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
|
||||
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
|
||||
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
|
||||
|
@ -162,7 +162,7 @@ for i = 1, keynumber do
|
|||
function ()
|
||||
local screen = mouse.screen_get()
|
||||
if tags[screen][i] then
|
||||
tags[screen][i]:view(not tags[screen][i]:isselected())
|
||||
tags[screen][i].selected = not tags[screen][i].selected
|
||||
end
|
||||
end):add()
|
||||
keybinding({ modkey, "Shift" }, i,
|
||||
|
|
|
@ -26,6 +26,7 @@ plot_data_add
|
|||
plot_properties_set
|
||||
resize
|
||||
right
|
||||
selected
|
||||
shadow
|
||||
shadow_offset
|
||||
show
|
||||
|
|
|
@ -161,7 +161,7 @@ function P.tag.selectedlist(s)
|
|||
local tags = tag.geti(screen)
|
||||
local vtags = {}
|
||||
for i, t in pairs(tags) do
|
||||
if t:isselected() then
|
||||
if t.selected then
|
||||
vtags[#vtags + 1] = t
|
||||
end
|
||||
end
|
||||
|
@ -233,7 +233,7 @@ end
|
|||
function P.tag.viewnone(screen)
|
||||
local tags = tag.get(screen or mouse.screen_get())
|
||||
for i, t in pairs(tags) do
|
||||
t:view(false)
|
||||
t.selected = false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -246,7 +246,7 @@ function P.tag.viewidx(i, screen)
|
|||
P.tag.viewnone()
|
||||
for k, t in ipairs(tags) do
|
||||
if t == sel then
|
||||
tags[cycle(#tags, k + i)]:view(true)
|
||||
tags[cycle(#tags, k + i)].selected = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -265,7 +265,7 @@ end
|
|||
-- @param t The tag object.
|
||||
function P.tag.viewonly(t)
|
||||
P.tag.viewnone()
|
||||
t:view(true)
|
||||
t.selected = true
|
||||
end
|
||||
|
||||
--- View only a set of tags.
|
||||
|
@ -274,7 +274,7 @@ end
|
|||
function P.tag.viewmore(tags, screen)
|
||||
P.tag.viewnone(screen)
|
||||
for i, t in pairs(tags) do
|
||||
t:view(true)
|
||||
t.selected = true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
94
tag.c
94
tag.c
|
@ -333,37 +333,6 @@ luaA_tag_new(lua_State *L)
|
|||
return luaA_tag_userdata_new(L, tag);
|
||||
}
|
||||
|
||||
/** Add or remove a tag from the current view.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lvalue A tag.
|
||||
* \lparam A boolean value, true to view tag, false otherwise.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_view(lua_State *L)
|
||||
{
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
bool view = luaA_checkboolean(L, 2);
|
||||
tag_view(*tag, view);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Get the tag selection attribute.
|
||||
* \param L The Lua VM state.
|
||||
*
|
||||
* \luastack
|
||||
* \lvalue A tag.
|
||||
* \lreturn True if the tag is viewed, false otherwise.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_isselected(lua_State *L)
|
||||
{
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
lua_pushboolean(L, (*tag)->selected);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Set the tag master width factor. This value is used in various layouts to
|
||||
* determine the size of the master window.
|
||||
* \param L The Lua VM state.
|
||||
|
@ -558,6 +527,65 @@ luaA_tag_layout_set(lua_State *L)
|
|||
|
||||
}
|
||||
|
||||
/** Tag index.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_index(lua_State *L)
|
||||
{
|
||||
size_t len;
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
const char *attr;
|
||||
|
||||
lua_getmetatable(L, 1);
|
||||
lua_pushvalue(L, 2);
|
||||
lua_rawget(L, -2);
|
||||
if (!lua_isnil(L, -1))
|
||||
{
|
||||
lua_remove(L, -2);
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L, 2);
|
||||
|
||||
attr = luaL_checklstring(L, 2, &len);
|
||||
|
||||
switch(a_tokenize(attr, len))
|
||||
{
|
||||
case A_TK_SELECTED:
|
||||
lua_pushboolean(L, (*tag)->selected);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Tag newindex.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
*/
|
||||
static int
|
||||
luaA_tag_newindex(lua_State *L)
|
||||
{
|
||||
size_t len;
|
||||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
const char *attr = luaL_checklstring(L, 2, &len);
|
||||
|
||||
switch(a_tokenize(attr, len))
|
||||
{
|
||||
case A_TK_SELECTED:
|
||||
tag_view(*tag, luaA_checkboolean(L, 3));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const struct luaL_reg awesome_tag_methods[] =
|
||||
{
|
||||
{ "__call", luaA_tag_new },
|
||||
|
@ -568,8 +596,6 @@ const struct luaL_reg awesome_tag_methods[] =
|
|||
const struct luaL_reg awesome_tag_meta[] =
|
||||
{
|
||||
{ "add", luaA_tag_add },
|
||||
{ "view", luaA_tag_view },
|
||||
{ "isselected", luaA_tag_isselected },
|
||||
{ "mwfact_set", luaA_tag_mwfact_set },
|
||||
{ "mwfact_get", luaA_tag_mwfact_get },
|
||||
{ "ncol_set", luaA_tag_ncol_set },
|
||||
|
@ -580,6 +606,8 @@ const struct luaL_reg awesome_tag_meta[] =
|
|||
{ "name_set", luaA_tag_name_set },
|
||||
{ "layout_get", luaA_tag_layout_get },
|
||||
{ "layout_set", luaA_tag_layout_set },
|
||||
{ "__index", luaA_tag_index },
|
||||
{ "__newindex", luaA_tag_newindex },
|
||||
{ "__eq", luaA_tag_eq },
|
||||
{ "__gc", luaA_tag_gc },
|
||||
{ "__tostring", luaA_tag_tostring },
|
||||
|
|
Loading…
Reference in New Issue