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