1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[exmode] ; is delimiter for macro commands . Refs #196

For example:
set macro.0 = "set ui.show_title_bar = 0;set ui.show_status_bar = 0;redraw"
This commit is contained in:
Witold Filipczyk 2022-11-22 16:41:41 +01:00
parent 294732babc
commit 4d1d4f173d

View File

@ -112,8 +112,7 @@ exmode_exec(struct session *ses, char buffer[INPUT_LINE_BUFFER_SIZE])
void
try_exmode_exec(struct session *ses, const char *val)
{
char *command;
char *args;
char *next;
struct string res;
struct string inp;
struct string what = INIT_STRING("\\\"", 2);
@ -128,25 +127,44 @@ try_exmode_exec(struct session *ses, const char *val)
}
add_to_string(&inp, val);
string_replace(&res, &inp, &what, &replace);
next = res.source;
command = res.source;
args = command;
int i;
while (1) {
char *command, *args;
while (*command == ':') command++;
command = args = next;
if (!*command) {
goto out;
}
while (*command == ':') command++;
skip_nonspace(args);
if (*args) *args++ = 0;
for (i = 0; exmode_handlers[i]; i++) {
if (exmode_handlers[i](ses, command, args))
if (!*command) {
break;
}
while (*args && !isspace((unsigned char)(*args)) && *args != ';') args++;
if (*args == ';') {
*args = 0;
next = args + 1;
} else {
if (*args) *args++ = 0;
next = args;
for (int quote = 0; *next; next++) {
if (*next == '"') {
quote = !quote;
continue;
}
if (*next == ';' && !quote) {
*next++ = 0;
break;
}
}
}
for (int i = 0; exmode_handlers[i]; i++) {
if (exmode_handlers[i](ses, command, args))
break;
}
}
out:
done_string(&inp);
done_string(&res);
}