i3 - improved tiling WM


add command to remove marks

Patch status: needinfo

Patch by koebi

To apply this patch, use:
curl http://cr.i3wm.org/patch/190/raw.patch | git am

b/docs/userguide

17
@@ -1679,9 +1679,10 @@ bindsym $mod+a [class="urxvt" title="VIM"] focus
18
 This feature is like the jump feature: It allows you to directly jump to a
19
 specific window (this means switching to the appropriate workspace and setting
20
 focus to the windows). However, you can directly mark a specific window with
21
-an arbitrary label and use it afterwards.  You do not need to ensure that your
22
-windows have unique classes or titles, and you do not need to change your
23
-configuration file.
24
+an arbitrary label and use it afterwards. You can unmark the label in the same
25
+way, using the unmark command. If you don't specify a label, unmark removes all
26
+marks. You do not need to ensure that your windows have unique classes or 
27
+titles, and you do not need to change your configuration file.
28
 
29
 As the command needs to include the label with which you want to mark the
30
 window, you cannot simply bind it to a key.  +i3-input+ is a tool created

b/include/commands.h

35
@@ -116,6 +116,12 @@ void cmd_workspace_name(I3_CMD, char *name);
36
 void cmd_mark(I3_CMD, char *mark);
37
 
38
 /**
39
+ * Implementation of 'unmark [mark]'
40
+ *
41
+ */
42
+void cmd_unmark(I3_CMD, char *mark);
43
+
44
+/**
45
  * Implementation of 'mode <string>'.
46
  *
47
  */

b/parser-specs/commands.spec

52
@@ -32,6 +32,7 @@ state INITIAL:
53
   'split' -> SPLIT
54
   'floating' -> FLOATING
55
   'mark' -> MARK
56
+  'unmark' -> UNMARK
57
   'resize' -> RESIZE
58
   'rename' -> RENAME
59
   'nop' -> NOP
60
@@ -177,6 +178,13 @@ state MARK:
61
   mark = string
62
       -> call cmd_mark($mark)
63
 
64
+# unmark [mark]
65
+state UNMARK:
66
+  end
67
+      -> call cmd_unmark($mark)
68
+  mark = string
69
+      -> call cmd_unmark($mark)
70
+
71
 # resize
72
 state RESIZE:
73
   way = 'grow', 'shrink'

b/src/commands.c

78
@@ -1007,6 +1007,7 @@ void cmd_workspace_name(I3_CMD, char *name) {
79
  * Implementation of 'mark <mark>'
80
  *
81
  */
82
+
83
 void cmd_mark(I3_CMD, char *mark) {
84
     DLOG("Clearing all windows which have that mark first\n");
85
 
86
@@ -1032,6 +1033,32 @@ void cmd_mark(I3_CMD, char *mark) {
87
 }
88
 
89
 /*
90
+ * Implementation of 'unmark [mark]'
91
+ *
92
+ */ 
93
+
94
+void cmd_unmark(I3_CMD, char *mark) {
95
+   if ( mark == NULL ){
96
+       Con *con;
97
+       TAILQ_FOREACH(con, &all_cons, all_cons) {
98
+           FREE(con->mark);
99
+       }
100
+       DLOG("removed all window marks");
101
+   } else {
102
+       Con *con;
103
+       TAILQ_FOREACH(con, &all_cons, all_cons) {
104
+           if (con->mark && strcmp(con->mark, mark) == 0)
105
+               FREE(con->mark);
106
+           }
107
+       DLOG("removed window mark %s\n", mark);
108
+    }
109
+    
110
+    cmd_output->needs_tree_render = true;
111
+    // XXX: default reply for now, make this a better reply
112
+    ysuccess(true);
113
+}
114
+
115
+/*
116
  * Implementation of 'mode <string>'.
117
  *
118
  */

b/testcases/t/187-commands-parser.t

123
@@ -144,7 +144,7 @@ is(parser_calls("\nworkspace test"),
124
 ################################################################################
125
 
126
 is(parser_calls('unknown_literal'),
127
-   "ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'debuglog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'resize', 'rename', 'nop', 'scratchpad', 'mode', 'bar'\n" .
128
+   "ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'unmark', 'resize', 'rename', 'nop', 'scratchpad', 'mode', 'bar'\n" .
129
    "ERROR: Your command: unknown_literal\n" .
130
    "ERROR:               ^^^^^^^^^^^^^^^",
131
    'error for unknown literal ok');