tag: stop checking for tag duplication and be less picky, only warn user
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d4bfaa8598
commit
025b64ee44
34
tag.c
34
tag.c
|
@ -363,22 +363,6 @@ luaA_tag_index(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a screen by its name.
|
|
||||||
* \param screen The screen to look into.
|
|
||||||
* \param name The name.
|
|
||||||
*/
|
|
||||||
static tag_t *
|
|
||||||
tag_getbyname(int screen, const char *name)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
tag_array_t *tags = &globalconf.screens[screen].tags;
|
|
||||||
|
|
||||||
for(i = 0; i < tags->len; i++)
|
|
||||||
if(!a_strcmp(name, tags->tab[i]->name))
|
|
||||||
return tags->tab[i];
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tag newindex.
|
/** Tag newindex.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
|
@ -397,10 +381,6 @@ luaA_tag_newindex(lua_State *L)
|
||||||
{
|
{
|
||||||
case A_TK_NAME:
|
case A_TK_NAME:
|
||||||
buf = luaL_checklstring(L, 3, &len);
|
buf = luaL_checklstring(L, 3, &len);
|
||||||
if((*tag)->screen != SCREEN_UNDEF)
|
|
||||||
if(tag_getbyname((*tag)->screen, (*tag)->name) != *tag)
|
|
||||||
luaL_error(L, "a tag with the name `%s' is already on screen %d",
|
|
||||||
buf, (*tag)->screen);
|
|
||||||
p_delete(&(*tag)->name);
|
p_delete(&(*tag)->name);
|
||||||
a_iso2utf8(&(*tag)->name, buf, len);
|
a_iso2utf8(&(*tag)->name, buf, len);
|
||||||
break;
|
break;
|
||||||
|
@ -417,13 +397,7 @@ luaA_tag_newindex(lua_State *L)
|
||||||
tag_remove_from_screen(*tag);
|
tag_remove_from_screen(*tag);
|
||||||
|
|
||||||
if(screen != SCREEN_UNDEF)
|
if(screen != SCREEN_UNDEF)
|
||||||
{
|
|
||||||
if(tag_getbyname(screen, (*tag)->name))
|
|
||||||
luaL_error(L, "a tag with the name `%s' is already on screen %d",
|
|
||||||
(*tag)->name, screen);
|
|
||||||
|
|
||||||
tag_append_to_screen(*tag, &globalconf.screens[screen]);
|
tag_append_to_screen(*tag, &globalconf.screens[screen]);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case A_TK_LAYOUT:
|
case A_TK_LAYOUT:
|
||||||
buf = luaL_checkstring(L, 3);
|
buf = luaL_checkstring(L, 3);
|
||||||
|
@ -431,7 +405,7 @@ luaA_tag_newindex(lua_State *L)
|
||||||
if(l)
|
if(l)
|
||||||
(*tag)->layout = l;
|
(*tag)->layout = l;
|
||||||
else
|
else
|
||||||
luaL_error(L, "unknown layout: %s", buf);
|
luaA_warn(L, "unknown layout: %s", buf);
|
||||||
break;
|
break;
|
||||||
case A_TK_SELECTED:
|
case A_TK_SELECTED:
|
||||||
if((*tag)->screen != SCREEN_UNDEF)
|
if((*tag)->screen != SCREEN_UNDEF)
|
||||||
|
@ -442,21 +416,21 @@ luaA_tag_newindex(lua_State *L)
|
||||||
if(d > 0 && d < 1)
|
if(d > 0 && d < 1)
|
||||||
(*tag)->mwfact = d;
|
(*tag)->mwfact = d;
|
||||||
else
|
else
|
||||||
luaL_error(L, "bad value, must be between 0 and 1");
|
luaA_warn(L, "bad value, must be between 0 and 1");
|
||||||
break;
|
break;
|
||||||
case A_TK_NMASTER:
|
case A_TK_NMASTER:
|
||||||
i = luaL_checknumber(L, 3);
|
i = luaL_checknumber(L, 3);
|
||||||
if(i >= 0)
|
if(i >= 0)
|
||||||
(*tag)->nmaster = i;
|
(*tag)->nmaster = i;
|
||||||
else
|
else
|
||||||
luaL_error(L, "bad value, must be greater than 0");
|
luaA_warn(L, "bad value, must be greater than 0");
|
||||||
break;
|
break;
|
||||||
case A_TK_NCOL:
|
case A_TK_NCOL:
|
||||||
i = luaL_checknumber(L, 3);
|
i = luaL_checknumber(L, 3);
|
||||||
if(i >= 1)
|
if(i >= 1)
|
||||||
(*tag)->ncol = i;
|
(*tag)->ncol = i;
|
||||||
else
|
else
|
||||||
luaL_error(L, "bad value, must be greater than 1");
|
luaA_warn(L, "bad value, must be greater than 1");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue