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