summaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2015-11-24 10:56:29 -0500
committerDrew DeVault <[email protected]>2015-11-24 10:56:29 -0500
commit8ad8ceeeb92ca6609bc40974a8c528b593251566 (patch)
tree4f706f14f54c2f250c8bb2d720072b9443ea7777 /sway/commands.c
parente7c0573a980938a5174bc647faf41f24fa523b0b (diff)
parentdb92920cf9bcdd0008ba446df4d7249e7902373a (diff)
Merge pull request #250 from sce/initial_support_for_criteria_strings
Initial support for criteria strings
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f6d56bb4..42105d5f 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1401,17 +1401,34 @@ struct cmd_results *handle_command(char *_exec) {
head = exec;
do {
- // Handle criteria
+ // Extract criteria (valid for this command list only).
+ criteria = NULL;
if (*head == '[') {
+ ++head;
criteria = argsep(&head, "]");
if (head) {
++head;
// TODO handle criteria
} else {
- results = cmd_results_new(CMD_INVALID, NULL, "Unmatched [");
+ if (!results) {
+ results = cmd_results_new(CMD_INVALID, criteria, "Unmatched [");
+ }
+ goto cleanup;
}
// Skip leading whitespace
head += strspn(head, whitespace);
+
+ // TODO: it will yield unexpected results to execute commands
+ // (on any view) that where meant for certain views only.
+ if (!results) {
+ int len = strlen(criteria) + strlen(head) + 4;
+ char *tmp = malloc(len);
+ snprintf(tmp, len, "[%s] %s", criteria, head);
+ results = cmd_results_new(CMD_INVALID, tmp,
+ "Can't handle criteria string: Refusing to execute command");
+ free(tmp);
+ }
+ goto cleanup;
}
// Split command list
cmdlist = argsep(&head, ";");