aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/unmark.c
diff options
context:
space:
mode:
authorLibravatar Calvin Lee <cyrus296@gmail.com>2017-04-02 14:38:33 -0600
committerLibravatar Calvin Lee <cyrus296@gmail.com>2017-04-03 11:48:37 -0600
commit2445d279604d7be38c00db60ffde4279a3c75459 (patch)
tree030844d9fb13be7814dd760a6ffedbec8f5264cd /sway/commands/unmark.c
parentUpdate man page (diff)
downloadsway-2445d279604d7be38c00db60ffde4279a3c75459.tar.gz
sway-2445d279604d7be38c00db60ffde4279a3c75459.tar.zst
sway-2445d279604d7be38c00db60ffde4279a3c75459.zip
Impliment i3-style marks
This commit adds three commands to sway: `show_marks`, `mark` and `unmark`. Marks are displayed right-aligned in the window border as i3 does. Marks may be found using criteria. Fixes #1007
Diffstat (limited to 'sway/commands/unmark.c')
-rw-r--r--sway/commands/unmark.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c
new file mode 100644
index 00000000..34a2ae44
--- /dev/null
+++ b/sway/commands/unmark.c
@@ -0,0 +1,31 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/commands.h"
4#include "list.h"
5#include "stringop.h"
6
7struct cmd_results *cmd_unmark(int argc, char **argv) {
8 swayc_t *view = get_focused_container(&root_container);
9
10 if (view->marks) {
11 if (argc) {
12 char *mark = join_args(argv, argc);
13 int index;
14 if ((index = list_seq_find(view->marks, (int (*)(const void *, const void *))strcmp, mark)) != -1) {
15 free(view->marks->items[index]);
16 list_del(view->marks, index);
17
18 if (view->marks->length == 0) {
19 list_free(view->marks);
20 view->marks = NULL;
21 }
22 }
23 free(mark);
24 } else {
25 list_foreach(view->marks, free);
26 list_free(view->marks);
27 view->marks = NULL;
28 }
29 }
30 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
31}