diff options
Diffstat (limited to 'sway/commands/unmark.c')
-rw-r--r-- | sway/commands/unmark.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c new file mode 100644 index 00000000..a7d39432 --- /dev/null +++ b/sway/commands/unmark.c | |||
@@ -0,0 +1,32 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/config.h" | ||
5 | #include "sway/tree/view.h" | ||
6 | #include "list.h" | ||
7 | #include "log.h" | ||
8 | #include "stringop.h" | ||
9 | |||
10 | struct cmd_results *cmd_unmark(int argc, char **argv) { | ||
11 | if (argc == 0) { | ||
12 | // Remove all marks from the current container | ||
13 | struct sway_container *container = | ||
14 | config->handler_context.current_container; | ||
15 | if (container->type != C_VIEW) { | ||
16 | return cmd_results_new(CMD_INVALID, "unmark", | ||
17 | "Only views can have marks"); | ||
18 | } | ||
19 | view_clear_marks(container->sway_view); | ||
20 | } else { | ||
21 | // Remove a single mark from whichever container has it | ||
22 | char *mark = join_args(argv, argc); | ||
23 | if (!view_find_and_unmark(mark)) { | ||
24 | free(mark); | ||
25 | return cmd_results_new(CMD_INVALID, "unmark", | ||
26 | "No view exists with that mark"); | ||
27 | } | ||
28 | free(mark); | ||
29 | } | ||
30 | |||
31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
32 | } | ||