criteria: reset on semicolon separation
This matches i3's behavior of only retaining criteria across comma separated commands. When separating commands with a semicolon, the criteria is reset and allows for new criteria to be set, if desired.
This commit is contained in:
parent
190546fd31
commit
f0f5de9a9e
|
@ -227,28 +227,31 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
|
||||||
|
|
||||||
head = exec;
|
head = exec;
|
||||||
do {
|
do {
|
||||||
// Extract criteria (valid for this command list only).
|
|
||||||
config->handler_context.using_criteria = false;
|
|
||||||
if (*head == '[') {
|
|
||||||
char *error = NULL;
|
|
||||||
struct criteria *criteria = criteria_parse(head, &error);
|
|
||||||
if (!criteria) {
|
|
||||||
list_add(res_list, cmd_results_new(CMD_INVALID, "%s", error));
|
|
||||||
free(error);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
views = criteria_get_views(criteria);
|
|
||||||
head += strlen(criteria->raw);
|
|
||||||
criteria_destroy(criteria);
|
|
||||||
config->handler_context.using_criteria = true;
|
|
||||||
// Skip leading whitespace
|
|
||||||
for (; isspace(*head); ++head) {}
|
|
||||||
}
|
|
||||||
// Split command list
|
// Split command list
|
||||||
cmdlist = argsep(&head, ";");
|
cmdlist = argsep(&head, ";");
|
||||||
for (; isspace(*cmdlist); ++cmdlist) {}
|
|
||||||
do {
|
do {
|
||||||
// Split commands
|
// Skip leading whitespace
|
||||||
|
for (; isspace(*cmdlist); ++cmdlist) {}
|
||||||
|
// Extract criteria (valid for this command chain only).
|
||||||
|
config->handler_context.using_criteria = false;
|
||||||
|
if (*cmdlist == '[') {
|
||||||
|
char *error = NULL;
|
||||||
|
struct criteria *criteria = criteria_parse(cmdlist, &error);
|
||||||
|
if (!criteria) {
|
||||||
|
list_add(res_list,
|
||||||
|
cmd_results_new(CMD_INVALID, "%s", error));
|
||||||
|
free(error);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
list_free(views);
|
||||||
|
views = criteria_get_views(criteria);
|
||||||
|
cmdlist += strlen(criteria->raw);
|
||||||
|
criteria_destroy(criteria);
|
||||||
|
config->handler_context.using_criteria = true;
|
||||||
|
// Skip leading whitespace
|
||||||
|
for (; isspace(*cmdlist); ++cmdlist) {}
|
||||||
|
}
|
||||||
|
// Split command chain into commands
|
||||||
cmd = argsep(&cmdlist, ",");
|
cmd = argsep(&cmdlist, ",");
|
||||||
for (; isspace(*cmd); ++cmd) {}
|
for (; isspace(*cmd); ++cmd) {}
|
||||||
if (strcmp(cmd, "") == 0) {
|
if (strcmp(cmd, "") == 0) {
|
||||||
|
|
|
@ -45,7 +45,8 @@ the bindsym command.
|
||||||
Commands are split into several arguments using spaces. You can enclose
|
Commands are split into several arguments using spaces. You can enclose
|
||||||
arguments with quotation marks (*"..."* or *'...'*) to add spaces to a single
|
arguments with quotation marks (*"..."* or *'...'*) to add spaces to a single
|
||||||
argument. You may also run several commands in order by separating each with
|
argument. You may also run several commands in order by separating each with
|
||||||
*,* or *;*.
|
*,* or *;*. Criteria is retained across commands separated by *,*, but will be
|
||||||
|
reset (and allow for new criteria, if desired) for commands separated by a *;*.
|
||||||
|
|
||||||
Throughout the documentation, *|* is used to distinguish between arguments for
|
Throughout the documentation, *|* is used to distinguish between arguments for
|
||||||
which you may only select one. *[...]* is used for optional arguments, and
|
which you may only select one. *[...]* is used for optional arguments, and
|
||||||
|
@ -753,7 +754,9 @@ A criteria is a string in the form of, for example:
|
||||||
|
|
||||||
The string contains one or more (space separated) attribute/value pairs. They
|
The string contains one or more (space separated) attribute/value pairs. They
|
||||||
are used by some commands to choose which views to execute actions on. All
|
are used by some commands to choose which views to execute actions on. All
|
||||||
attributes must match for the criteria to match.
|
attributes must match for the criteria to match. Criteria is retained across
|
||||||
|
commands separated by a *,*, but will be reset (and allow for new criteria, if
|
||||||
|
desired) for commands separated by a *;*.
|
||||||
|
|
||||||
Criteria may be used with either the *for_window* or *assign* commands to
|
Criteria may be used with either the *for_window* or *assign* commands to
|
||||||
specify operations to perform on new views. A criteria may also be used to
|
specify operations to perform on new views. A criteria may also be used to
|
||||||
|
|
Loading…
Reference in a new issue