## STAGING
* registrar doesnt match open windows when new file created and is then opened for edit or line number
-* fetch should stuff match strings in environment variables instead of evaling
* implement a mini-sed command to standardize scripts across platforms without relying on sed
* registrar should remove invalid windows from registry when detected
* tide should re-register with the registrar when a new registrar is launched
[ScrollFg] = 0xF0F0E5, /* Scroll region foreground */
[VerBdr] = 0x909047, /* Vertical border */
[HorBdr] = 0x000000, /* Horizontal border */
-
};
#ifdef FETCH_RULES
(Rule[]){ /* Match URLS and open them with the browser */
{ ISSET, "BROWSER", NULL },
{ MATCHES, "data", "^(https?|ftp)://.*" },
- { LAUNCH, "$BROWSER \"$0\"", NULL },
+ { LAUNCH, "$BROWSER \"$M0\"", NULL },
{ COMPLETE, NULL, NULL }
},
(Rule[]){ /* Open files with addresses in the editor */
{ MATCHES, "data", "^([^:]+):([0-9]+)" },
- { ISFILE, "$1", NULL },
- { LAUNCH, "edit \"$0\"", NULL },
+ { ISFILE, "$M1", NULL },
+ { LAUNCH, "edit \"$M0\"", NULL },
{ COMPLETE, NULL, NULL }
},
(Rule[]){ /* If it's an existing text file, open it with editor */
/******************************************************************************/
char* getvar(char* val) {
- if (strlen(val) == 1 && isdigit(*val))
- val = Matches[*val - '0'];
- else
- val = getenv(val);
+ val = getenv(val);
return (val ? val : "");
}
regmatch_t matches[10] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
if (regcomp(®ex, patt, REG_EXTENDED) == 0) {
var = getvar(var);
- memset(Matches, 0, sizeof(Matches));
int err = regexec(®ex, var, nelem(matches), matches, 0);
for (int i = 0; i < 10 && matches[i].rm_so >= 0; i++) {
- Matches[i] = strndup(var+matches[i].rm_so, matches[i].rm_eo-matches[i].rm_so);
+ char* matchval = strndup(var+matches[i].rm_so, matches[i].rm_eo-matches[i].rm_so);
+ setenv((char[]){ 'M', ('0' + i), 0 }, matchval, 1);
+ free(matchval);
}
return (err == 0);
}
}
void runcmd(char* cmd) {
- char* shellcmd[] = { getvar("SHELL"), "-c", NULL, NULL };
+ char* shellcmd[] = { getvar("SHELL"), "-c", cmd, NULL };
if (!shellcmd[0]) shellcmd[0] = "/bin/sh";
- shellcmd[2] = eval(cmd);
_exit(execvp(shellcmd[0], shellcmd));
}