]> git.sur5r.net Git - i3/i3/blob - parser-specs/commands.spec
475dc4bd33c2b99dec75d6f8814553db721e4a7f
[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 = word
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 <name>
121 # workspace number <number>
122 state WORKSPACE:
123   direction = 'next_on_output', 'prev_on_output', 'next', 'prev'
124       -> call cmd_workspace($direction)
125   'back_and_forth'
126       -> call cmd_workspace_back_and_forth()
127   'number'
128       -> WORKSPACE_NUMBER
129   workspace = string 
130       -> call cmd_workspace_name($workspace)
131
132 state WORKSPACE_NUMBER:
133   workspace = string
134       -> call cmd_workspace_number($workspace)
135
136 # focus left|right|up|down
137 # focus output <output>
138 # focus tiling|floating|mode_toggle
139 # focus parent|child
140 # focus
141 state FOCUS:
142   direction = 'left', 'right', 'up', 'down'
143       -> call cmd_focus_direction($direction)
144   'output'
145       -> FOCUS_OUTPUT
146   window_mode = 'tiling', 'floating', 'mode_toggle'
147       -> call cmd_focus_window_mode($window_mode)
148   level = 'parent', 'child'
149       -> call cmd_focus_level($level)
150   end
151       -> call cmd_focus()
152
153 state FOCUS_OUTPUT:
154   output = string
155       -> call cmd_focus_output($output)
156
157 # kill [window|client]
158 state KILL:
159   kill_mode = 'window', 'client'
160       -> call cmd_kill($kill_mode)
161   end
162       -> call cmd_kill($kill_mode)
163
164 # fullscreen enable|toggle [global]
165 # fullscreen disable
166 # fullscreen [global]
167 state FULLSCREEN:
168   action = 'disable'
169       -> call cmd_fullscreen($action, "output")
170   action = 'enable', 'toggle'
171       -> FULLSCREEN_MODE
172   action = ''
173       -> FULLSCREEN_COMPAT
174
175 state FULLSCREEN_MODE:
176   mode = 'global'
177       -> call cmd_fullscreen($action, $mode)
178   end
179       -> call cmd_fullscreen($action, "output")
180
181 state FULLSCREEN_COMPAT:
182   mode = 'global'
183       -> call cmd_fullscreen("toggle", $mode)
184   end
185       -> call cmd_fullscreen("toggle", "output")
186
187 # sticky enable|disable|toggle
188 state STICKY:
189   action = 'enable', 'disable', 'toggle'
190       -> call cmd_sticky($action)
191
192 # split v|h|vertical|horizontal
193 state SPLIT:
194   direction = 'horizontal', 'vertical', 'v', 'h'
195       -> call cmd_split($direction)
196
197 # floating enable|disable|toggle
198 state FLOATING:
199   floating = 'enable', 'disable', 'toggle'
200       -> call cmd_floating($floating)
201
202 # mark [--add|--replace] [--toggle] <mark>
203 state MARK:
204   mode = '--add', '--replace'
205       ->
206   toggle = '--toggle'
207       ->
208   mark = string
209       -> call cmd_mark($mark, $mode, $toggle)
210
211 # unmark [mark]
212 state UNMARK:
213   end
214       -> call cmd_unmark($mark)
215   mark = string
216       -> call cmd_unmark($mark)
217
218 # resize
219 state RESIZE:
220   way = 'grow', 'shrink'
221       -> RESIZE_DIRECTION
222   set = 'set'
223       -> RESIZE_SET
224
225 state RESIZE_DIRECTION:
226   direction = 'up', 'down', 'left', 'right', 'width', 'height'
227       -> RESIZE_PX
228
229 state RESIZE_PX:
230   resize_px = number
231       -> RESIZE_TILING
232   end
233       -> call cmd_resize($way, $direction, 10, 10)
234
235 state RESIZE_TILING:
236   'px'
237       ->
238   'or'
239       -> RESIZE_TILING_OR
240   end
241       -> call cmd_resize($way, $direction, &resize_px, 10)
242
243 state RESIZE_TILING_OR:
244   resize_ppt = number
245       -> RESIZE_TILING_FINAL
246
247 state RESIZE_TILING_FINAL:
248   'ppt', end
249       -> call cmd_resize($way, $direction, &resize_px, &resize_ppt)
250
251 state RESIZE_SET:
252   width = number
253       -> RESIZE_WIDTH
254
255 state RESIZE_WIDTH:
256   'px'
257       ->
258   height = number
259       -> RESIZE_HEIGHT
260
261 state RESIZE_HEIGHT:
262   'px', end
263       -> call cmd_resize_set(&width, &height)
264
265 # rename workspace <name> to <name>
266 # rename workspace to <name>
267 state RENAME:
268   'workspace'
269       -> RENAME_WORKSPACE
270
271 state RENAME_WORKSPACE:
272   old_name = 'to'
273       -> RENAME_WORKSPACE_LIKELY_TO
274   old_name = word
275       -> RENAME_WORKSPACE_TO
276
277 state RENAME_WORKSPACE_LIKELY_TO:
278   'to'
279       -> RENAME_WORKSPACE_NEW_NAME
280   new_name = word
281       -> call cmd_rename_workspace(NULL, $new_name)
282
283 state RENAME_WORKSPACE_TO:
284   'to'
285       -> RENAME_WORKSPACE_NEW_NAME
286
287 state RENAME_WORKSPACE_NEW_NAME:
288   end
289       -> call cmd_rename_workspace(NULL, "to")
290   new_name = string
291       -> call cmd_rename_workspace($old_name, $new_name)
292
293 # move <direction> [<pixels> [px]]
294 # move [window|container] [to] workspace [<str>|next|prev|next_on_output|prev_on_output|current]
295 # move [window|container] [to] output <str>
296 # move [window|container] [to] mark <str>
297 # move [window|container] [to] scratchpad
298 # move workspace to [output] <str>
299 # move scratchpad
300 # move [window|container] [to] [absolute] position [ [<pixels> [px] <pixels> [px]] | center ]
301 # move [window|container] [to] position mouse|cursor|pointer
302 state MOVE:
303   'window'
304       ->
305   'container'
306       ->
307   'to'
308       ->
309   'workspace'
310       -> MOVE_WORKSPACE
311   'output'
312       -> MOVE_TO_OUTPUT
313   'mark'
314       -> MOVE_TO_MARK
315   'scratchpad'
316       -> call cmd_move_scratchpad()
317   direction = 'left', 'right', 'up', 'down'
318       -> MOVE_DIRECTION
319   method = 'position'
320       -> MOVE_TO_POSITION
321   method = 'absolute'
322       -> MOVE_TO_ABSOLUTE_POSITION
323
324 state MOVE_DIRECTION:
325   pixels = number
326       -> MOVE_DIRECTION_PX
327   end
328       -> call cmd_move_direction($direction, 10)
329
330 state MOVE_DIRECTION_PX:
331   'px'
332       -> call cmd_move_direction($direction, &pixels)
333   end
334       -> call cmd_move_direction($direction, &pixels)
335
336 state MOVE_WORKSPACE:
337   'to '
338       -> MOVE_WORKSPACE_TO_OUTPUT
339   workspace = 'next_on_output', 'prev_on_output', 'next', 'prev', 'current'
340       -> call cmd_move_con_to_workspace($workspace)
341   'back_and_forth'
342       -> call cmd_move_con_to_workspace_back_and_forth()
343   'number'
344       -> MOVE_WORKSPACE_NUMBER
345   workspace = string
346       -> call cmd_move_con_to_workspace_name($workspace)
347
348 state MOVE_WORKSPACE_NUMBER:
349   number = string
350       -> call cmd_move_con_to_workspace_number($number)
351
352 state MOVE_TO_OUTPUT:
353   output = string
354       -> call cmd_move_con_to_output($output)
355
356 state MOVE_TO_MARK:
357   mark = string
358       -> call cmd_move_con_to_mark($mark)
359
360 state MOVE_WORKSPACE_TO_OUTPUT:
361   'output'
362       ->
363   output = string
364       -> call cmd_move_workspace_to_output($output)
365
366 state MOVE_TO_ABSOLUTE_POSITION:
367   'position'
368       -> MOVE_TO_POSITION
369
370 state MOVE_TO_POSITION:
371   'center'
372       -> call cmd_move_window_to_center($method)
373   'mouse', 'cursor', 'pointer'
374       -> call cmd_move_window_to_mouse()
375   coord_x = number
376       -> MOVE_TO_POSITION_X
377
378 state MOVE_TO_POSITION_X:
379   'px'
380       ->
381   coord_y = number
382       -> MOVE_TO_POSITION_Y
383
384 state MOVE_TO_POSITION_Y:
385   'px', end
386       -> call cmd_move_window_to_position($method, &coord_x, &coord_y)
387
388 # mode <string>
389 state MODE:
390   mode = string
391       -> call cmd_mode($mode)
392
393 state NOP:
394   comment = string
395       -> call cmd_nop($comment)
396   end
397       -> call cmd_nop(NULL)
398
399 state SCRATCHPAD:
400   'show'
401       -> call cmd_scratchpad_show()
402
403 state TITLE_FORMAT:
404   format = string
405       -> call cmd_title_format($format)
406
407 # bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) [<bar_id>]
408 state BAR:
409   bar_type = 'hidden_state'
410       -> BAR_HIDDEN_STATE
411   bar_type = 'mode'
412       -> BAR_MODE
413
414 state BAR_HIDDEN_STATE:
415   bar_value = 'hide', 'show', 'toggle'
416       -> BAR_W_ID
417
418 state BAR_MODE:
419   bar_value = 'dock', 'hide', 'invisible', 'toggle'
420       -> BAR_W_ID
421
422 state BAR_W_ID:
423   bar_id = word
424       ->
425   end
426       -> call cmd_bar($bar_type, $bar_value, $bar_id)