diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 33 |
1 files changed, 28 insertions, 5 deletions
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"); |