diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sway/commands.c b/sway/commands.c index 5a1fd32e..8d003dfa 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _POSIX_C_SOURCE 200809 | ||
2 | #include <ctype.h> | 1 | #include <ctype.h> |
3 | #include <stdarg.h> | 2 | #include <stdarg.h> |
4 | #include <stdlib.h> | 3 | #include <stdlib.h> |
@@ -46,6 +45,7 @@ static const struct cmd_handler handlers[] = { | |||
46 | { "assign", cmd_assign }, | 45 | { "assign", cmd_assign }, |
47 | { "bar", cmd_bar }, | 46 | { "bar", cmd_bar }, |
48 | { "bindcode", cmd_bindcode }, | 47 | { "bindcode", cmd_bindcode }, |
48 | { "bindgesture", cmd_bindgesture }, | ||
49 | { "bindswitch", cmd_bindswitch }, | 49 | { "bindswitch", cmd_bindswitch }, |
50 | { "bindsym", cmd_bindsym }, | 50 | { "bindsym", cmd_bindsym }, |
51 | { "client.background", cmd_client_noop }, | 51 | { "client.background", cmd_client_noop }, |
@@ -92,6 +92,7 @@ static const struct cmd_handler handlers[] = { | |||
92 | { "titlebar_border_thickness", cmd_titlebar_border_thickness }, | 92 | { "titlebar_border_thickness", cmd_titlebar_border_thickness }, |
93 | { "titlebar_padding", cmd_titlebar_padding }, | 93 | { "titlebar_padding", cmd_titlebar_padding }, |
94 | { "unbindcode", cmd_unbindcode }, | 94 | { "unbindcode", cmd_unbindcode }, |
95 | { "unbindgesture", cmd_unbindgesture }, | ||
95 | { "unbindswitch", cmd_unbindswitch }, | 96 | { "unbindswitch", cmd_unbindswitch }, |
96 | { "unbindsym", cmd_unbindsym }, | 97 | { "unbindsym", cmd_unbindsym }, |
97 | { "workspace", cmd_workspace }, | 98 | { "workspace", cmd_workspace }, |
@@ -102,6 +103,7 @@ static const struct cmd_handler handlers[] = { | |||
102 | static const struct cmd_handler config_handlers[] = { | 103 | static const struct cmd_handler config_handlers[] = { |
103 | { "default_orientation", cmd_default_orientation }, | 104 | { "default_orientation", cmd_default_orientation }, |
104 | { "include", cmd_include }, | 105 | { "include", cmd_include }, |
106 | { "primary_selection", cmd_primary_selection }, | ||
105 | { "swaybg_command", cmd_swaybg_command }, | 107 | { "swaybg_command", cmd_swaybg_command }, |
106 | { "swaynag_command", cmd_swaynag_command }, | 108 | { "swaynag_command", cmd_swaynag_command }, |
107 | { "workspace_layout", cmd_workspace_layout }, | 109 | { "workspace_layout", cmd_workspace_layout }, |
@@ -145,7 +147,7 @@ static int handler_compare(const void *_a, const void *_b) { | |||
145 | return strcasecmp(a->command, b->command); | 147 | return strcasecmp(a->command, b->command); |
146 | } | 148 | } |
147 | 149 | ||
148 | const struct cmd_handler *find_handler(char *line, | 150 | const struct cmd_handler *find_handler(const char *line, |
149 | const struct cmd_handler *handlers, size_t handlers_size) { | 151 | const struct cmd_handler *handlers, size_t handlers_size) { |
150 | if (!handlers || !handlers_size) { | 152 | if (!handlers || !handlers_size) { |
151 | return NULL; | 153 | return NULL; |
@@ -378,10 +380,13 @@ struct cmd_results *config_command(char *exec, char **new_block) { | |||
378 | sway_log(SWAY_INFO, "Config command: %s", exec); | 380 | sway_log(SWAY_INFO, "Config command: %s", exec); |
379 | const struct cmd_handler *handler = find_core_handler(argv[0]); | 381 | const struct cmd_handler *handler = find_core_handler(argv[0]); |
380 | if (!handler || !handler->handle) { | 382 | if (!handler || !handler->handle) { |
381 | const char *error = handler | 383 | if (handler) { |
382 | ? "Command '%s' is shimmed, but unimplemented" | 384 | results = cmd_results_new(CMD_INVALID, |
383 | : "Unknown/invalid command '%s'"; | 385 | "Command '%s' is shimmed, but unimplemented", argv[0]); |
384 | results = cmd_results_new(CMD_INVALID, error, argv[0]); | 386 | } else { |
387 | results = cmd_results_new(CMD_INVALID, | ||
388 | "Unknown/invalid command '%s'", argv[0]); | ||
389 | } | ||
385 | goto cleanup; | 390 | goto cleanup; |
386 | } | 391 | } |
387 | 392 | ||
@@ -407,6 +412,7 @@ struct cmd_results *config_command(char *exec, char **new_block) { | |||
407 | && handler->handle != cmd_bindsym | 412 | && handler->handle != cmd_bindsym |
408 | && handler->handle != cmd_bindcode | 413 | && handler->handle != cmd_bindcode |
409 | && handler->handle != cmd_bindswitch | 414 | && handler->handle != cmd_bindswitch |
415 | && handler->handle != cmd_bindgesture | ||
410 | && handler->handle != cmd_set | 416 | && handler->handle != cmd_set |
411 | && handler->handle != cmd_for_window | 417 | && handler->handle != cmd_for_window |
412 | && (*argv[i] == '\"' || *argv[i] == '\'')) { | 418 | && (*argv[i] == '\"' || *argv[i] == '\'')) { |
@@ -482,14 +488,10 @@ struct cmd_results *cmd_results_new(enum cmd_status status, | |||
482 | } | 488 | } |
483 | results->status = status; | 489 | results->status = status; |
484 | if (format) { | 490 | if (format) { |
485 | char *error = malloc(256); | ||
486 | va_list args; | 491 | va_list args; |
487 | va_start(args, format); | 492 | va_start(args, format); |
488 | if (error) { | 493 | results->error = vformat_str(format, args); |
489 | vsnprintf(error, 256, format, args); | ||
490 | } | ||
491 | va_end(args); | 494 | va_end(args); |
492 | results->error = error; | ||
493 | } else { | 495 | } else { |
494 | results->error = NULL; | 496 | results->error = NULL; |
495 | } | 497 | } |