aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/unmark.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-14 22:47:10 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-15 11:18:27 +1000
commit22d38600d0edbb35029b3076c14e0e119dbf3dd2 (patch)
treead548731ca215e2ec0f56cde86a6ff16df8cb323 /sway/commands/unmark.c
parentMerge pull request #1978 from RedSoxFan/fix-1975 (diff)
downloadsway-22d38600d0edbb35029b3076c14e0e119dbf3dd2.tar.gz
sway-22d38600d0edbb35029b3076c14e0e119dbf3dd2.tar.zst
sway-22d38600d0edbb35029b3076c14e0e119dbf3dd2.zip
Implement marks
Diffstat (limited to 'sway/commands/unmark.c')
-rw-r--r--sway/commands/unmark.c32
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
10struct 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}