diff options
-rw-r--r-- | include/commands.h | 2 | ||||
-rw-r--r-- | sway/commands.c | 33 | ||||
-rw-r--r-- | sway/config.c | 2 |
3 files changed, 30 insertions, 7 deletions
diff --git a/include/commands.h b/include/commands.h index f291e7cb..52d56e4a 100644 --- a/include/commands.h +++ b/include/commands.h | |||
@@ -41,7 +41,7 @@ struct cmd_results *handle_command(char *command); | |||
41 | * | 41 | * |
42 | * Do not use this under normal conditions. | 42 | * Do not use this under normal conditions. |
43 | */ | 43 | */ |
44 | struct cmd_results *config_command(char *command); | 44 | struct cmd_results *config_command(char *command, enum cmd_status block); |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Allocates a cmd_results object. | 47 | * Allocates a cmd_results object. |
diff --git a/sway/commands.c b/sway/commands.c index 307196a3..8a087af8 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1463,15 +1463,38 @@ static struct cmd_handler handlers[] = { | |||
1463 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, | 1463 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, |
1464 | }; | 1464 | }; |
1465 | 1465 | ||
1466 | static struct cmd_handler bar_handlers[] = { | ||
1467 | { "binding_mode_indicator", NULL }, | ||
1468 | { "bindsym", NULL }, | ||
1469 | { "colors", NULL }, | ||
1470 | { "font", NULL }, | ||
1471 | { "hidden_state", NULL }, | ||
1472 | { "id", NULL }, | ||
1473 | { "mode", NULL }, | ||
1474 | { "modifier", NULL }, | ||
1475 | { "output", NULL }, | ||
1476 | { "position", NULL }, | ||
1477 | { "seperator_symbol", NULL }, | ||
1478 | { "status_command", NULL }, | ||
1479 | { "strip_workspace_numbers", NULL }, | ||
1480 | { "tray_output", NULL }, | ||
1481 | { "tray_padding", NULL }, | ||
1482 | { "workspace_buttons", NULL }, | ||
1483 | }; | ||
1484 | |||
1466 | static int handler_compare(const void *_a, const void *_b) { | 1485 | static int handler_compare(const void *_a, const void *_b) { |
1467 | const struct cmd_handler *a = _a; | 1486 | const struct cmd_handler *a = _a; |
1468 | const struct cmd_handler *b = _b; | 1487 | const struct cmd_handler *b = _b; |
1469 | return strcasecmp(a->command, b->command); | 1488 | return strcasecmp(a->command, b->command); |
1470 | } | 1489 | } |
1471 | 1490 | ||
1472 | static struct cmd_handler *find_handler(char *line) { | 1491 | static struct cmd_handler *find_handler(char *line, enum cmd_status block) { |
1492 | struct cmd_handler *h = handlers; | ||
1493 | if (block == CMD_BLOCK_BAR) { | ||
1494 | h = bar_handlers; | ||
1495 | } | ||
1473 | struct cmd_handler d = { .command=line }; | 1496 | struct cmd_handler d = { .command=line }; |
1474 | struct cmd_handler *res = bsearch(&d, handlers, | 1497 | struct cmd_handler *res = bsearch(&d, h, |
1475 | sizeof(handlers) / sizeof(struct cmd_handler), | 1498 | sizeof(handlers) / sizeof(struct cmd_handler), |
1476 | sizeof(struct cmd_handler), handler_compare); | 1499 | sizeof(struct cmd_handler), handler_compare); |
1477 | return res; | 1500 | return res; |
@@ -1537,7 +1560,7 @@ struct cmd_results *handle_command(char *_exec) { | |||
1537 | if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) { | 1560 | if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) { |
1538 | strip_quotes(argv[1]); | 1561 | strip_quotes(argv[1]); |
1539 | } | 1562 | } |
1540 | struct cmd_handler *handler = find_handler(argv[0]); | 1563 | struct cmd_handler *handler = find_handler(argv[0], CMD_BLOCK_END); |
1541 | if (!handler) { | 1564 | if (!handler) { |
1542 | if (results) { | 1565 | if (results) { |
1543 | free_cmd_results(results); | 1566 | free_cmd_results(results); |
@@ -1574,7 +1597,7 @@ struct cmd_results *handle_command(char *_exec) { | |||
1574 | // be chained together) | 1597 | // be chained together) |
1575 | // 4) handle_command handles all state internally while config_command has some | 1598 | // 4) handle_command handles all state internally while config_command has some |
1576 | // state handled outside (notably the block mode, in read_config) | 1599 | // state handled outside (notably the block mode, in read_config) |
1577 | struct cmd_results *config_command(char *exec) { | 1600 | struct cmd_results *config_command(char *exec, enum cmd_status block) { |
1578 | struct cmd_results *results = NULL; | 1601 | struct cmd_results *results = NULL; |
1579 | int argc; | 1602 | int argc; |
1580 | char **argv = split_args(exec, &argc); | 1603 | char **argv = split_args(exec, &argc); |
@@ -1589,7 +1612,7 @@ struct cmd_results *config_command(char *exec) { | |||
1589 | results = cmd_results_new(CMD_BLOCK_END, NULL, NULL); | 1612 | results = cmd_results_new(CMD_BLOCK_END, NULL, NULL); |
1590 | goto cleanup; | 1613 | goto cleanup; |
1591 | } | 1614 | } |
1592 | struct cmd_handler *handler = find_handler(argv[0]); | 1615 | struct cmd_handler *handler = find_handler(argv[0], block); |
1593 | if (!handler) { | 1616 | if (!handler) { |
1594 | char *input = argv[0] ? argv[0] : "(empty)"; | 1617 | char *input = argv[0] ? argv[0] : "(empty)"; |
1595 | results = cmd_results_new(CMD_INVALID, input, "Unknown/invalid command"); | 1618 | results = cmd_results_new(CMD_INVALID, input, "Unknown/invalid command"); |
diff --git a/sway/config.c b/sway/config.c index 59e6e476..21507c59 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -224,7 +224,7 @@ bool read_config(FILE *file, bool is_active) { | |||
224 | if (line[0] == '#') { | 224 | if (line[0] == '#') { |
225 | continue; | 225 | continue; |
226 | } | 226 | } |
227 | struct cmd_results *res = config_command(line); | 227 | struct cmd_results *res = config_command(line, block); |
228 | switch(res->status) { | 228 | switch(res->status) { |
229 | case CMD_FAILURE: | 229 | case CMD_FAILURE: |
230 | case CMD_INVALID: | 230 | case CMD_INVALID: |