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