]> git.sur5r.net Git - i3/i3/blob - parser-specs/commands.spec
Merge pull request #1752 from Airblader/feature-test-cleanups-1
[i3/i3] / parser-specs / commands.spec
1 # vim:ts=2:sw=2:expandtab
2 #
3 # i3 - an improved dynamic tiling window manager
4 # © 2009 Michael Stapelberg and contributors (see also: LICENSE)
5 #
6 # parser-specs/commands.spec: Specification file for generate-command-parser.pl
7 # which will generate the appropriate header files for our C parser.
8 #
9 # Use :source highlighting.vim in vim to get syntax highlighting
10 # for this file.
11
12 state INITIAL:
13   # We have an end token here for all the commands which just call some
14   # function without using an explicit 'end' token.
15   end ->
16   '[' -> call cmd_criteria_init(); CRITERIA
17   'move' -> MOVE
18   'exec' -> EXEC
19   'exit' -> call cmd_exit()
20   'restart' -> call cmd_restart()
21   'reload' -> call cmd_reload()
22   'shmlog' -> SHMLOG
23   'debuglog' -> DEBUGLOG
24   'border' -> BORDER
25   'layout' -> LAYOUT
26   'append_layout' -> APPEND_LAYOUT
27   'workspace' -> WORKSPACE
28   'focus' -> FOCUS
29   'kill' -> KILL
30   'open' -> call cmd_open()
31   'fullscreen' -> FULLSCREEN
32   'split' -> SPLIT
33   'floating' -> FLOATING
34   'mark' -> MARK
35   'unmark' -> UNMARK
36   'resize' -> RESIZE
37   'rename' -> RENAME
38   'nop' -> NOP
39   'scratchpad' -> SCRATCHPAD
40   'mode' -> MODE
41   'bar' -> BAR
42
43 state CRITERIA:
44   ctype = 'class'       -> CRITERION
45   ctype = 'instance'    -> CRITERION
46   ctype = 'window_role' -> CRITERION
47   ctype = 'con_id'      -> CRITERION
48   ctype = 'id'          -> CRITERION
49   ctype = 'window_type' -> CRITERION
50   ctype = 'con_mark'    -> CRITERION
51   ctype = 'title'       -> CRITERION
52   ctype = 'urgent'      -> CRITERION
53   ']' -> call cmd_criteria_match_windows(); INITIAL
54
55 state CRITERION:
56   '=' -> CRITERION_STR
57
58 state CRITERION_STR:
59   cvalue = word
60       -> call cmd_criteria_add($ctype, $cvalue); CRITERIA
61
62 # exec [--no-startup-id] <command>
63 state EXEC:
64   nosn = '--no-startup-id'
65       ->
66   command = string
67       -> call cmd_exec($nosn, $command)
68
69 # shmlog <size>|toggle|on|off
70 state SHMLOG:
71   # argument may be a number
72   argument = string
73     -> call cmd_shmlog($argument)
74
75 # debuglog toggle|on|off
76 state DEBUGLOG:
77   argument = 'toggle', 'on', 'off'
78     -> call cmd_debuglog($argument)
79
80 # border normal|pixel [<n>]
81 # border none|1pixel|toggle
82 state BORDER:
83   border_style = 'normal', 'pixel'
84     -> BORDER_WIDTH
85   border_style = 'none', 'toggle'
86     -> call cmd_border($border_style, "0")
87   border_style = '1pixel'
88     -> call cmd_border($border_style, "1")
89
90 state BORDER_WIDTH:
91   end
92     -> call cmd_border($border_style, "2")
93   border_width = word
94     -> call cmd_border($border_style, $border_width)
95
96 # layout default|stacked|stacking|tabbed|splitv|splith
97 # layout toggle [split|all]
98 state LAYOUT:
99   layout_mode = 'default', 'stacked', 'stacking', 'tabbed', 'splitv', 'splith'
100       -> call cmd_layout($layout_mode)
101   'toggle'
102       -> LAYOUT_TOGGLE
103
104 # layout toggle [split|all]
105 state LAYOUT_TOGGLE:
106   end
107       -> call cmd_layout_toggle($toggle_mode)
108   toggle_mode = 'split', 'all'
109       -> call cmd_layout_toggle($toggle_mode)
110
111 # append_layout <path>
112 state APPEND_LAYOUT:
113   path = string -> call cmd_append_layout($path)
114
115 # workspace next|prev|next_on_output|prev_on_output
116 # workspace back_and_forth
117 # workspace <name>
118 # workspace number <number>
119 state WORKSPACE:
120   direction = 'next_on_output', 'prev_on_output', 'next', 'prev'
121       -> call cmd_workspace($direction)
122   'back_and_forth'
123       -> call cmd_workspace_back_and_forth()
124   'number'
125       -> WORKSPACE_NUMBER
126   workspace = string 
127       -> call cmd_workspace_name($workspace)
128
129 state WORKSPACE_NUMBER:
130   workspace = string
131       -> call cmd_workspace_number($workspace)
132
133 # focus left|right|up|down
134 # focus output <output>
135 # focus tiling|floating|mode_toggle
136 # focus parent|child
137 # focus
138 state FOCUS:
139   direction = 'left', 'right', 'up', 'down'
140       -> call cmd_focus_direction($direction)
141   'output'
142       -> FOCUS_OUTPUT
143   window_mode = 'tiling', 'floating', 'mode_toggle'
144       -> call cmd_focus_window_mode($window_mode)
145   level = 'parent', 'child'
146       -> call cmd_focus_level($level)
147   end
148       -> call cmd_focus()
149
150 state FOCUS_OUTPUT:
151   output = string
152       -> call cmd_focus_output($output)
153
154 # kill [window|client]
155 state KILL:
156   kill_mode = 'window', 'client'
157       -> call cmd_kill($kill_mode)
158   end
159       -> call cmd_kill($kill_mode)
160
161 # fullscreen enable|toggle [global]
162 # fullscreen disable
163 # fullscreen [global]
164 state FULLSCREEN:
165   action = 'disable'
166       -> call cmd_fullscreen($action, "output")
167   action = 'enable', 'toggle'
168       -> FULLSCREEN_MODE
169   action = ''
170       -> FULLSCREEN_COMPAT
171
172 state FULLSCREEN_MODE:
173   mode = 'global'
174       -> call cmd_fullscreen($action, $mode)
175   end
176       -> call cmd_fullscreen($action, "output")
177
178 state FULLSCREEN_COMPAT:
179   mode = 'global'
180       -> call cmd_fullscreen("toggle", $mode)
181   end
182       -> call cmd_fullscreen("toggle", "output")
183
184 # split v|h|vertical|horizontal
185 state SPLIT:
186   direction = 'horizontal', 'vertical', 'v', 'h'
187       -> call cmd_split($direction)
188
189 # floating enable|disable|toggle
190 state FLOATING:
191   floating = 'enable', 'disable', 'toggle'
192       -> call cmd_floating($floating)
193
194 # mark [--toggle] <mark>
195 state MARK:
196   toggle = '--toggle'
197       ->
198   mark = string
199       -> call cmd_mark($mark, $toggle)
200
201 # unmark [mark]
202 state UNMARK:
203   end
204       -> call cmd_unmark($mark)
205   mark = string
206       -> call cmd_unmark($mark)
207
208 # resize
209 state RESIZE:
210   way = 'grow', 'shrink'
211       -> RESIZE_DIRECTION
212
213 state RESIZE_DIRECTION:
214   direction = 'up', 'down', 'left', 'right', 'width', 'height'
215       -> RESIZE_PX
216
217 state RESIZE_PX:
218   resize_px = word
219       -> RESIZE_TILING
220   end
221       -> call cmd_resize($way, $direction, "10", "10")
222
223 state RESIZE_TILING:
224   'px'
225       ->
226   'or'
227       -> RESIZE_TILING_OR
228   end
229       -> call cmd_resize($way, $direction, $resize_px, "10")
230
231 state RESIZE_TILING_OR:
232   resize_ppt = word
233       -> RESIZE_TILING_FINAL
234
235 state RESIZE_TILING_FINAL:
236   'ppt', end
237       -> call cmd_resize($way, $direction, $resize_px, $resize_ppt)
238
239 # rename workspace <name> to <name>
240 # rename workspace to <name>
241 state RENAME:
242   'workspace'
243       -> RENAME_WORKSPACE
244
245 state RENAME_WORKSPACE:
246   old_name = 'to'
247       -> RENAME_WORKSPACE_LIKELY_TO
248   old_name = word
249       -> RENAME_WORKSPACE_TO
250
251 state RENAME_WORKSPACE_LIKELY_TO:
252   'to'
253       -> RENAME_WORKSPACE_NEW_NAME
254   new_name = word
255       -> call cmd_rename_workspace(NULL, $new_name)
256
257 state RENAME_WORKSPACE_TO:
258   'to'
259       -> RENAME_WORKSPACE_NEW_NAME
260
261 state RENAME_WORKSPACE_NEW_NAME:
262   end
263       -> call cmd_rename_workspace(NULL, "to")
264   new_name = string
265       -> call cmd_rename_workspace($old_name, $new_name)
266
267 # move <direction> [<pixels> [px]]
268 # move [window|container] [to] workspace [<str>|next|prev|next_on_output|prev_on_output|current]
269 # move [window|container] [to] output <str>
270 # move [window|container] [to] mark <str>
271 # move [window|container] [to] scratchpad
272 # move workspace to [output] <str>
273 # move scratchpad
274 # move [window|container] [to] [absolute] position [ [<pixels> [px] <pixels> [px]] | center ]
275 # move [window|container] [to] position mouse|cursor|pointer
276 state MOVE:
277   'window'
278       ->
279   'container'
280       ->
281   'to'
282       ->
283   'workspace'
284       -> MOVE_WORKSPACE
285   'output'
286       -> MOVE_TO_OUTPUT
287   'mark'
288       -> MOVE_TO_MARK
289   'scratchpad'
290       -> call cmd_move_scratchpad()
291   direction = 'left', 'right', 'up', 'down'
292       -> MOVE_DIRECTION
293   method = 'position'
294       -> MOVE_TO_POSITION
295   method = 'absolute'
296       -> MOVE_TO_ABSOLUTE_POSITION
297
298 state MOVE_DIRECTION:
299   pixels = word
300       -> MOVE_DIRECTION_PX
301   end
302       -> call cmd_move_direction($direction, "10")
303
304 state MOVE_DIRECTION_PX:
305   'px'
306       -> call cmd_move_direction($direction, $pixels)
307   end
308       -> call cmd_move_direction($direction, $pixels)
309
310 state MOVE_WORKSPACE:
311   'to '
312       -> MOVE_WORKSPACE_TO_OUTPUT
313   workspace = 'next_on_output', 'prev_on_output', 'next', 'prev', 'current'
314       -> call cmd_move_con_to_workspace($workspace)
315   'back_and_forth'
316       -> call cmd_move_con_to_workspace_back_and_forth()
317   'number'
318       -> MOVE_WORKSPACE_NUMBER
319   workspace = string
320       -> call cmd_move_con_to_workspace_name($workspace)
321
322 state MOVE_WORKSPACE_NUMBER:
323   number = string
324       -> call cmd_move_con_to_workspace_number($number)
325
326 state MOVE_TO_OUTPUT:
327   output = string
328       -> call cmd_move_con_to_output($output)
329
330 state MOVE_TO_MARK:
331   mark = string
332       -> call cmd_move_con_to_mark($mark)
333
334 state MOVE_WORKSPACE_TO_OUTPUT:
335   'output'
336       ->
337   output = string
338       -> call cmd_move_workspace_to_output($output)
339
340 state MOVE_TO_ABSOLUTE_POSITION:
341   'position'
342       -> MOVE_TO_POSITION
343
344 state MOVE_TO_POSITION:
345   'center'
346       -> call cmd_move_window_to_center($method)
347   'mouse', 'cursor', 'pointer'
348       -> call cmd_move_window_to_mouse()
349   coord_x = word
350       -> MOVE_TO_POSITION_X
351
352 state MOVE_TO_POSITION_X:
353   'px'
354       ->
355   coord_y = word
356       -> MOVE_TO_POSITION_Y
357
358 state MOVE_TO_POSITION_Y:
359   'px', end
360       -> call cmd_move_window_to_position($method, $coord_x, $coord_y)
361
362 # mode <string>
363 state MODE:
364   mode = string
365       -> call cmd_mode($mode)
366
367 state NOP:
368   comment = string
369       -> call cmd_nop($comment)
370   end
371       -> call cmd_nop(NULL)
372
373 state SCRATCHPAD:
374   'show'
375       -> call cmd_scratchpad_show()
376
377 # bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) [<bar_id>]
378 state BAR:
379   bar_type = 'hidden_state'
380       -> BAR_HIDDEN_STATE
381   bar_type = 'mode'
382       -> BAR_MODE
383
384 state BAR_HIDDEN_STATE:
385   bar_value = 'hide', 'show', 'toggle'
386       -> BAR_W_ID
387
388 state BAR_MODE:
389   bar_value = 'dock', 'hide', 'invisible', 'toggle'
390       -> BAR_W_ID
391
392 state BAR_W_ID:
393   bar_id = word
394       ->
395   end
396       -> call cmd_bar($bar_type, $bar_value, $bar_id)