Confparse: Improve section stuff: Section work like this now: [secname] option = "pwet" [/secname]
This commit is contained in:
parent
a5a5126082
commit
6db79e381d
@ -531,10 +531,6 @@ init_conf(void)
|
||||
func_list = emalloc(LEN(tmp_func_list), sizeof(func_name_list_t));
|
||||
memcpy(func_list, tmp_func_list, LEN(tmp_func_list) * sizeof(func_name_list_t));
|
||||
|
||||
printf("-> %s\n", erase_sec_content(" [pwet] tagada = prout hihi=tralalère [uh] wpwer [/uh] [uh] pwefvbg [/uh] [/pwet] "));
|
||||
|
||||
return;
|
||||
|
||||
conf_misc_section(get_sec(file, "misc"));
|
||||
conf_bar_section(get_sec(file, "bar"));
|
||||
conf_root_section(get_sec(file, "root"));
|
||||
|
||||
@ -92,7 +92,7 @@ get_sec(char *src, char *name)
|
||||
else
|
||||
ret = NULL;
|
||||
|
||||
free(sec);
|
||||
free_secname(sec);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -101,7 +101,7 @@ char*
|
||||
get_nsec(char *src, char *name, int n)
|
||||
{
|
||||
int i;
|
||||
char *ret, *buf, *secn;
|
||||
char *ret, *buf, **sec;
|
||||
char *buf2;
|
||||
|
||||
if(!src)
|
||||
@ -113,17 +113,16 @@ get_nsec(char *src, char *name, int n)
|
||||
if(!n)
|
||||
return get_sec(src, name);
|
||||
|
||||
secn = emalloc((strlen(name) + 2), sizeof(char));
|
||||
sprintf(secn, "%c%s%c", SEC_DEL_S, name, SEC_DEL_E);
|
||||
sec = secname(name);
|
||||
|
||||
buf = erase_delim_content(src);
|
||||
buf2 = erase_sec_content(buf);
|
||||
|
||||
for(i = 0; i < (n * 2) && (buf = strstr(buf, secn)); ++i, buf += strlen(secn));
|
||||
for(i = 0; i < n && (buf = strstr(buf, sec[SecStart])); ++i, buf += strlen(sec[SecStart]));
|
||||
|
||||
ret = get_sec(src + strlen(src) - strlen(buf), name);
|
||||
|
||||
free(secn);
|
||||
free_secname(sec);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -132,24 +131,20 @@ int
|
||||
get_size_sec(char *src, char *name)
|
||||
{
|
||||
int ret;
|
||||
char *secn, *buf;
|
||||
char **sec, *buf;
|
||||
|
||||
if(!src || !name)
|
||||
return 0;
|
||||
|
||||
secn = emalloc(strlen(name), sizeof(char));
|
||||
sprintf(secn, "%c%s%c", SEC_DEL_S, name, SEC_DEL_E);
|
||||
sec = secname(name);
|
||||
|
||||
buf = erase_sec_content(src);
|
||||
|
||||
for(ret = 0; (buf = strstr(buf, secn)); ++ret, buf += strlen(secn));
|
||||
for(ret = 0; (buf = strstr(buf, sec[SecStart])); ++ret, buf += strlen(sec[SecStart]));
|
||||
|
||||
/* If a section is not closed */
|
||||
for(; ret % 2; --ret);
|
||||
free_secname(sec);
|
||||
|
||||
free(secn);
|
||||
|
||||
return ret / 2;
|
||||
return ret;
|
||||
}
|
||||
|
||||
opt_type
|
||||
|
||||
@ -68,6 +68,7 @@ char *opt_srch(char *buf, char *opt);
|
||||
opt_type str_to_opt(char *str);
|
||||
char *clean_value(char *str);
|
||||
char **secname(char *name);
|
||||
void free_secname(char **secname);
|
||||
|
||||
/* confparse.c */
|
||||
char *file_to_str(char *path);
|
||||
|
||||
@ -67,7 +67,7 @@ erase_sec_content(char *buf)
|
||||
{
|
||||
int i, j;
|
||||
char *p, *str, *name, *ret;
|
||||
char *sname;
|
||||
char **sec;
|
||||
|
||||
if(!buf || !(str = erase_delim_content(buf)))
|
||||
return NULL;
|
||||
@ -77,19 +77,23 @@ erase_sec_content(char *buf)
|
||||
for(i = 1, name = _strdup(str + i); strchr(str + i, SEC_DEL_S); ++i, name = _strdup(str + i))
|
||||
{
|
||||
for(; str[i] && str[i] != SEC_DEL_S; ++i);
|
||||
for(j = 0; str[i] && str[i - 1] != SEC_DEL_E; name[j++] = str[i++]);
|
||||
name[j] = '\0';
|
||||
for(j = 0; str[i] && str[i] != SEC_DEL_E; name[j++] = str[i++]);
|
||||
++name;
|
||||
name[j - 1] = '\0';
|
||||
|
||||
sname = emalloc(strlen(name) + 1, sizeof(char));
|
||||
if(*name == '/')
|
||||
continue;
|
||||
|
||||
sprintf(sname, "[/%s]", name);
|
||||
sec = secname(name);
|
||||
|
||||
if((p = strstr(str + i, sname)))
|
||||
if((p = strstr(str + i, sec[SecEnd])))
|
||||
for(++i; i < strlen(ret) - strlen(p); ret[i++] = ' ');
|
||||
else
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
|
||||
free_secname(sec);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -181,3 +185,19 @@ secname(char *name)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
free_secname(char **secname)
|
||||
{
|
||||
if(!secname || LEN(secname) != SecLast)
|
||||
return;
|
||||
|
||||
if(secname[SecStart])
|
||||
free(secname[SecStart]);
|
||||
if(secname[SecEnd])
|
||||
free(secname[SecEnd]);
|
||||
|
||||
free(secname);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
86
wmfsrc_new
86
wmfsrc_new
@ -51,7 +51,7 @@
|
||||
|
||||
[tag]
|
||||
name = "one"
|
||||
screen = 1
|
||||
screen = 0
|
||||
mwfact = 0.65
|
||||
nmaster = 1
|
||||
layout = "tile_right"
|
||||
@ -155,7 +155,7 @@
|
||||
command = "exec"
|
||||
[/set_launcher]
|
||||
|
||||
[/set_launcher]
|
||||
[set_launcher]
|
||||
name = "launcher_ssh"
|
||||
prompt = "ssh to: "
|
||||
command = "urxvt -e ssh"
|
||||
@ -164,89 +164,89 @@
|
||||
|
||||
[keys]
|
||||
# Reload the configuration of wmfs.
|
||||
[key] mod = {"Alt", "Control"} key = "r" func = "reload" [key]
|
||||
[key] mod = {"Alt", "Control"} key = "r" func = "reload" [/key]
|
||||
|
||||
# Open a terminal.
|
||||
[key] mod = {"Control"} key = "Return" func = "spawn" cmd = term [key]
|
||||
[key] mod = {"Control"} key = "Return" func = "spawn" cmd = term [/key]
|
||||
|
||||
# Kill the selected client.
|
||||
[key] mod = {"Alt"} key = "q" func = "client_kill" [key]
|
||||
[key] mod = {"Alt"} key = "q" func = "client_kill" [/key]
|
||||
|
||||
# Quit wmfs.
|
||||
[key] mod = {"Control", "Alt", "Shift"} key = "q" func = "quit" [key]
|
||||
[key] mod = {"Control", "Alt", "Shift"} key = "q" func = "quit" [/key]
|
||||
|
||||
# Swap current client with the next.
|
||||
[key] mod = {"Alt"} key = "t" func = "client_swap_next" [key]
|
||||
[key] mod = {"Alt"} key = "t" func = "client_swap_next" [/key]
|
||||
|
||||
# Swap current client with the previous.
|
||||
[key] mod = {"Alt", "Shift"} key = "t" func = "client_swap_prev" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "t" func = "client_swap_prev" [/key]
|
||||
|
||||
# Toggle maximum the selected client
|
||||
[key] mod = {"Alt"} key = "m" func = "toggle_max" [key]
|
||||
[key] mod = {"Alt"} key = "m" func = "toggle_max" [/key]
|
||||
|
||||
# Toggle free the selected client.
|
||||
[key] mod = {"Alt"} key = "f" func = "toggle_free" [key]
|
||||
[key] mod = {"Alt"} key = "f" func = "toggle_free" [/key]
|
||||
|
||||
# Toggle the position of the infobar.
|
||||
[key] mod = {"Alt"} key = "b" func = "toggle_infobar_position" [key]
|
||||
[key] mod = {"Alt"} key = "b" func = "toggle_infobar_position" [/key]
|
||||
|
||||
# Toggle the resizehint of the current tag/screen
|
||||
[key] mod = {"Shift", "Control"} key = "r" func = "toggle_resizehint" [key]
|
||||
[key] mod = {"Shift", "Control"} key = "r" func = "toggle_resizehint" [/key]
|
||||
|
||||
# Select the next client.
|
||||
[key] mod = {"Alt"} key = "Tab" func = "client_next" [key]
|
||||
[key] mod = {"Alt"} key = "Tab" func = "client_next" [/key]
|
||||
|
||||
# Select the previous client.
|
||||
[key] mod = {"Alt","Shift"} key = "Tab" func = "client_prev" [key]
|
||||
[key] mod = {"Alt","Shift"} key = "Tab" func = "client_prev" [/key]
|
||||
|
||||
# Select the next tag.
|
||||
[key] mod = {"Control"} key = "Right" func = "tag_next" [key]
|
||||
[key] mod = {"Control"} key = "Right" func = "tag_next" [/key]
|
||||
|
||||
# Select the previous tag.
|
||||
[key] mod = {"Control"} key = "Left" func = "tag_prev" [key]
|
||||
[key] mod = {"Control"} key = "Left" func = "tag_prev" [/key]
|
||||
|
||||
# Set the next layout.
|
||||
[key] mod = {"Alt"} key = "space" func = "layout_next" [key]
|
||||
[key] mod = {"Alt"} key = "space" func = "layout_next" [/key]
|
||||
|
||||
# Set the previous layout.
|
||||
[key] mod = {"Alt", "Shift"} key = "space" func = "layout_prev" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "space" func = "layout_prev" [/key]
|
||||
|
||||
# Increase mwfact.
|
||||
[key] mod = {"Alt"} key = "l" func = "set_mwfact" cmd = "+0.025" [key]
|
||||
[key] mod = {"Alt"} key = "l" func = "set_mwfact" cmd = "+0.025" [/key]
|
||||
|
||||
# Decrease mwfact.
|
||||
[key] mod = {"Alt"} key = "h" func = "set_mwfact" cmd = "-0.025" [key]
|
||||
[key] mod = {"Alt"} key = "h" func = "set_mwfact" cmd = "-0.025" [/key]
|
||||
|
||||
# Increase nmaster.
|
||||
[key] mod = {"Alt"} key = "d" func = "set_nmaster" cmd = "+1" [key]
|
||||
[key] mod = {"Alt"} key = "d" func = "set_nmaster" cmd = "+1" [/key]
|
||||
|
||||
# Decease nmaster.
|
||||
[key] mod = {"Alt", "Shift"} key = "d" func = "set_nmaster" cmd = "-1" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "d" func = "set_nmaster" cmd = "-1" [/key]
|
||||
|
||||
#Launchers.
|
||||
[key] mod = {"Alt"} key = "p" func = "launcher" cmd = "launcher_exec" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "p" func = "launcher" cmd = "launcher_ssh" [key]
|
||||
[key] mod = {"Alt"} key = "p" func = "launcher" cmd = "launcher_exec" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "p" func = "launcher" cmd = "launcher_ssh" [/key]
|
||||
|
||||
# Set the tag x.
|
||||
[key] mod = {"Alt"} key = "F1" func = "tag" cmd = "1" [key]
|
||||
[key] mod = {"Alt"} key = "F2" func = "tag" cmd = "2" [key]
|
||||
[key] mod = {"Alt"} key = "F3" func = "tag" cmd = "3" [key]
|
||||
[key] mod = {"Alt"} key = "F4" func = "tag" cmd = "4" [key]
|
||||
[key] mod = {"Alt"} key = "F5" func = "tag" cmd = "5" [key]
|
||||
[key] mod = {"Alt"} key = "F6" func = "tag" cmd = "6" [key]
|
||||
[key] mod = {"Alt"} key = "F7" func = "tag" cmd = "7" [key]
|
||||
[key] mod = {"Alt"} key = "F8" func = "tag" cmd = "8" [key]
|
||||
[key] mod = {"Alt"} key = "F9" func = "tag" cmd = "9" [key]
|
||||
[key] mod = {"Alt"} key = "F1" func = "tag" cmd = "1" [/key]
|
||||
[key] mod = {"Alt"} key = "F2" func = "tag" cmd = "2" [/key]
|
||||
[key] mod = {"Alt"} key = "F3" func = "tag" cmd = "3" [/key]
|
||||
[key] mod = {"Alt"} key = "F4" func = "tag" cmd = "4" [/key]
|
||||
[key] mod = {"Alt"} key = "F5" func = "tag" cmd = "5" [/key]
|
||||
[key] mod = {"Alt"} key = "F6" func = "tag" cmd = "6" [/key]
|
||||
[key] mod = {"Alt"} key = "F7" func = "tag" cmd = "7" [/key]
|
||||
[key] mod = {"Alt"} key = "F8" func = "tag" cmd = "8" [/key]
|
||||
[key] mod = {"Alt"} key = "F9" func = "tag" cmd = "9" [/key]
|
||||
|
||||
# Transfert selected client to x.
|
||||
[key] mod = {"Alt", "Shift"} key = "F1" func = "tag_transfert" cmd ="1" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F2" func = "tag_transfert" cmd ="2" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F3" func = "tag_transfert" cmd ="3" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F4" func = "tag_transfert" cmd ="4" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F5" func = "tag_transfert" cmd ="5" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F6" func = "tag_transfert" cmd ="6" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F7" func = "tag_transfert" cmd ="7" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F8" func = "tag_transfert" cmd ="8" [key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F9" func = "tag_transfert" cmd ="9" [key]
|
||||
[keys]
|
||||
[key] mod = {"Alt", "Shift"} key = "F1" func = "tag_transfert" cmd ="1" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F2" func = "tag_transfert" cmd ="2" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F3" func = "tag_transfert" cmd ="3" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F4" func = "tag_transfert" cmd ="4" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F5" func = "tag_transfert" cmd ="5" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F6" func = "tag_transfert" cmd ="6" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F7" func = "tag_transfert" cmd ="7" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F8" func = "tag_transfert" cmd ="8" [/key]
|
||||
[key] mod = {"Alt", "Shift"} key = "F9" func = "tag_transfert" cmd ="9" [/key]
|
||||
[/keys]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user