Confparse: Improve section stuff: Section work like this now: [secname] option = "pwet" [/secname]
This commit is contained in:
@@ -531,10 +531,6 @@ init_conf(void)
|
|||||||
func_list = emalloc(LEN(tmp_func_list), sizeof(func_name_list_t));
|
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));
|
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_misc_section(get_sec(file, "misc"));
|
||||||
conf_bar_section(get_sec(file, "bar"));
|
conf_bar_section(get_sec(file, "bar"));
|
||||||
conf_root_section(get_sec(file, "root"));
|
conf_root_section(get_sec(file, "root"));
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ get_sec(char *src, char *name)
|
|||||||
else
|
else
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
|
|
||||||
free(sec);
|
free_secname(sec);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ char*
|
|||||||
get_nsec(char *src, char *name, int n)
|
get_nsec(char *src, char *name, int n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *ret, *buf, *secn;
|
char *ret, *buf, **sec;
|
||||||
char *buf2;
|
char *buf2;
|
||||||
|
|
||||||
if(!src)
|
if(!src)
|
||||||
@@ -113,17 +113,16 @@ get_nsec(char *src, char *name, int n)
|
|||||||
if(!n)
|
if(!n)
|
||||||
return get_sec(src, name);
|
return get_sec(src, name);
|
||||||
|
|
||||||
secn = emalloc((strlen(name) + 2), sizeof(char));
|
sec = secname(name);
|
||||||
sprintf(secn, "%c%s%c", SEC_DEL_S, name, SEC_DEL_E);
|
|
||||||
|
|
||||||
buf = erase_delim_content(src);
|
buf = erase_delim_content(src);
|
||||||
buf2 = erase_sec_content(buf);
|
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);
|
ret = get_sec(src + strlen(src) - strlen(buf), name);
|
||||||
|
|
||||||
free(secn);
|
free_secname(sec);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -132,24 +131,20 @@ int
|
|||||||
get_size_sec(char *src, char *name)
|
get_size_sec(char *src, char *name)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *secn, *buf;
|
char **sec, *buf;
|
||||||
|
|
||||||
if(!src || !name)
|
if(!src || !name)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
secn = emalloc(strlen(name), sizeof(char));
|
sec = secname(name);
|
||||||
sprintf(secn, "%c%s%c", SEC_DEL_S, name, SEC_DEL_E);
|
|
||||||
|
|
||||||
buf = erase_sec_content(src);
|
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 */
|
free_secname(sec);
|
||||||
for(; ret % 2; --ret);
|
|
||||||
|
|
||||||
free(secn);
|
return ret;
|
||||||
|
|
||||||
return ret / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opt_type
|
opt_type
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ char *opt_srch(char *buf, char *opt);
|
|||||||
opt_type str_to_opt(char *str);
|
opt_type str_to_opt(char *str);
|
||||||
char *clean_value(char *str);
|
char *clean_value(char *str);
|
||||||
char **secname(char *name);
|
char **secname(char *name);
|
||||||
|
void free_secname(char **secname);
|
||||||
|
|
||||||
/* confparse.c */
|
/* confparse.c */
|
||||||
char *file_to_str(char *path);
|
char *file_to_str(char *path);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ erase_sec_content(char *buf)
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char *p, *str, *name, *ret;
|
char *p, *str, *name, *ret;
|
||||||
char *sname;
|
char **sec;
|
||||||
|
|
||||||
if(!buf || !(str = erase_delim_content(buf)))
|
if(!buf || !(str = erase_delim_content(buf)))
|
||||||
return NULL;
|
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(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(; str[i] && str[i] != SEC_DEL_S; ++i);
|
||||||
for(j = 0; str[i] && str[i - 1] != SEC_DEL_E; name[j++] = str[i++]);
|
for(j = 0; str[i] && str[i] != SEC_DEL_E; name[j++] = str[i++]);
|
||||||
name[j] = '\0';
|
++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++] = ' ');
|
for(++i; i < strlen(ret) - strlen(p); ret[i++] = ' ');
|
||||||
else
|
else
|
||||||
return ret;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_secname(sec);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,3 +185,19 @@ secname(char *name)
|
|||||||
|
|
||||||
return ret;
|
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]
|
[tag]
|
||||||
name = "one"
|
name = "one"
|
||||||
screen = 1
|
screen = 0
|
||||||
mwfact = 0.65
|
mwfact = 0.65
|
||||||
nmaster = 1
|
nmaster = 1
|
||||||
layout = "tile_right"
|
layout = "tile_right"
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
command = "exec"
|
command = "exec"
|
||||||
[/set_launcher]
|
[/set_launcher]
|
||||||
|
|
||||||
[/set_launcher]
|
[set_launcher]
|
||||||
name = "launcher_ssh"
|
name = "launcher_ssh"
|
||||||
prompt = "ssh to: "
|
prompt = "ssh to: "
|
||||||
command = "urxvt -e ssh"
|
command = "urxvt -e ssh"
|
||||||
@@ -164,89 +164,89 @@
|
|||||||
|
|
||||||
[keys]
|
[keys]
|
||||||
# Reload the configuration of wmfs.
|
# 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.
|
# 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.
|
# Kill the selected client.
|
||||||
[key] mod = {"Alt"} key = "q" func = "client_kill" [key]
|
[key] mod = {"Alt"} key = "q" func = "client_kill" [/key]
|
||||||
|
|
||||||
# Quit wmfs.
|
# 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.
|
# 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.
|
# 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
|
# 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.
|
# 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.
|
# 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
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
# 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.
|
#Launchers.
|
||||||
[key] mod = {"Alt"} key = "p" func = "launcher" cmd = "launcher_exec" [key]
|
[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", "Shift"} key = "p" func = "launcher" cmd = "launcher_ssh" [/key]
|
||||||
|
|
||||||
# Set the tag x.
|
# Set the tag x.
|
||||||
[key] mod = {"Alt"} key = "F1" func = "tag" cmd = "1" [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 = "F2" func = "tag" cmd = "2" [/key]
|
||||||
[key] mod = {"Alt"} key = "F3" func = "tag" cmd = "3" [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 = "F4" func = "tag" cmd = "4" [/key]
|
||||||
[key] mod = {"Alt"} key = "F5" func = "tag" cmd = "5" [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 = "F6" func = "tag" cmd = "6" [/key]
|
||||||
[key] mod = {"Alt"} key = "F7" func = "tag" cmd = "7" [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 = "F8" func = "tag" cmd = "8" [/key]
|
||||||
[key] mod = {"Alt"} key = "F9" func = "tag" cmd = "9" [key]
|
[key] mod = {"Alt"} key = "F9" func = "tag" cmd = "9" [/key]
|
||||||
|
|
||||||
# Transfert selected client to x.
|
# Transfert selected client to x.
|
||||||
[key] mod = {"Alt", "Shift"} key = "F1" func = "tag_transfert" cmd ="1" [key]
|
[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 = "F2" func = "tag_transfert" cmd ="2" [/key]
|
||||||
[key] mod = {"Alt", "Shift"} key = "F3" func = "tag_transfert" cmd ="3" [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 = "F4" func = "tag_transfert" cmd ="4" [/key]
|
||||||
[key] mod = {"Alt", "Shift"} key = "F5" func = "tag_transfert" cmd ="5" [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 = "F6" func = "tag_transfert" cmd ="6" [/key]
|
||||||
[key] mod = {"Alt", "Shift"} key = "F7" func = "tag_transfert" cmd ="7" [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 = "F8" func = "tag_transfert" cmd ="8" [/key]
|
||||||
[key] mod = {"Alt", "Shift"} key = "F9" func = "tag_transfert" cmd ="9" [key]
|
[key] mod = {"Alt", "Shift"} key = "F9" func = "tag_transfert" cmd ="9" [/key]
|
||||||
[keys]
|
[/keys]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user