]> git.sur5r.net Git - i3/i3/blob - parser-specs/commands.spec
5e2bfd8f0b0296373c6be9bba040e1f3a469669a
[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 [--toggle] <mark>
203 state MARK:
204   toggle = '--toggle'
205       ->
206   mark = string
207       -> call cmd_mark($mark, $toggle)
208
209 # unmark [mark]
210 state UNMARK:
211   end
212       -> call cmd_unmark($mark)
213   mark = string
214       -> call cmd_unmark($mark)
215
216 # resize
217 state RESIZE:
218   way = 'grow', 'shrink'
219       -> RESIZE_DIRECTION
220   set = 'set'
221       -> RESIZE_SET
222
223 state RESIZE_DIRECTION:
224   direction = 'up', 'down', 'left', 'right', 'width', 'height'
225       -> RESIZE_PX
226
227 state RESIZE_PX:
228   resize_px = word
229       -> RESIZE_TILING
230   end
231       -> call cmd_resize($way, $direction, "10", "10")
232
233 state RESIZE_TILING:
234   'px'
235       ->
236   'or'
237       -> RESIZE_TILING_OR
238   end
239       -> call cmd_resize($way, $direction, $resize_px, "10")
240
241 state RESIZE_TILING_OR:
242   resize_ppt = word
243       -> RESIZE_TILING_FINAL
244
245 state RESIZE_TILING_FINAL:
246   'ppt', end
247       -> call cmd_resize($way, $direction, $resize_px, $resize_ppt)
248
249 state RESIZE_SET:
250   width = word
251       -> RESIZE_WIDTH
252
253 state RESIZE_WIDTH:
254   'px'
255       ->
256   height = word
257       -> RESIZE_HEIGHT
258
259 state RESIZE_HEIGHT:
260   'px', end
261       -> call cmd_size($width, $height)
262
263 # rename workspace <name> to <name>
264 # rename workspace to <name>
265 state RENAME:
266   'workspace'
267       -> RENAME_WORKSPACE
268
269 state RENAME_WORKSPACE:
270   old_name = 'to'
271       -> RENAME_WORKSPACE_LIKELY_TO
272   old_name = word
273       -> RENAME_WORKSPACE_TO
274
275 state RENAME_WORKSPACE_LIKELY_TO:
276   'to'
277       -> RENAME_WORKSPACE_NEW_NAME
278   new_name = word
279       -> call cmd_rename_workspace(NULL, $new_name)
280
281 state RENAME_WORKSPACE_TO:
282   'to'
283       -> RENAME_WORKSPACE_NEW_NAME
284
285 state RENAME_WORKSPACE_NEW_NAME:
286   end
287       -> call cmd_rename_workspace(NULL, "to")
288   new_name = string
289       -> call cmd_rename_workspace($old_name, $new_name)
290
291 # move <direction> [<pixels> [px]]
292 # move [window|container] [to] workspace [<str>|next|prev|next_on_output|prev_on_output|current]
293 # move [window|container] [to] output <str>
294 # move [window|container] [to] mark <str>
295 # move [window|container] [to] scratchpad
296 # move workspace to [output] <str>
297 # move scratchpad
298 # move [window|container] [to] [absolute] position [ [<pixels> [px] <pixels> [px]] | center ]
299 # move [window|container] [to] position mouse|cursor|pointer
300 state MOVE:
301   'window'
302       ->
303   'container'
304       ->
305   'to'
306       ->
307   'workspace'
308       -> MOVE_WORKSPACE
309   'output'
310       -> MOVE_TO_OUTPUT
311   'mark'
312       -> MOVE_TO_MARK
313   'scratchpad'
314       -> call cmd_move_scratchpad()
315   direction = 'left', 'right', 'up', 'down'
316       -> MOVE_DIRECTION
317   method = 'position'
318       -> MOVE_TO_POSITION
319   method = 'absolute'
320       -> MOVE_TO_ABSOLUTE_POSITION
321
322 state MOVE_DIRECTION:
323   pixels = word
324       -> MOVE_DIRECTION_PX
325   end
326       -> call cmd_move_direction($direction, "10")
327
328 state MOVE_DIRECTION_PX:
329   'px'
330       -> call cmd_move_direction($direction, $pixels)
331   end
332       -> call cmd_move_direction($direction, $pixels)
333
334 state MOVE_WORKSPACE:
335   'to '
336       -> MOVE_WORKSPACE_TO_OUTPUT
337   workspace = 'next_on_output', 'prev_on_output', 'next', 'prev', 'current'
338       -> call cmd_move_con_to_workspace($workspace)
339   'back_and_forth'
340       -> call cmd_move_con_to_workspace_back_and_forth()
341   'number'
342       -> MOVE_WORKSPACE_NUMBER
343   workspace = string
344       -> call cmd_move_con_to_workspace_name($workspace)
345
346 state MOVE_WORKSPACE_NUMBER:
347   number = string
348       -> call cmd_move_con_to_workspace_number($number)
349
350 state MOVE_TO_OUTPUT:
351   output = string
352       -> call cmd_move_con_to_output($output)
353
354 state MOVE_TO_MARK:
355   mark = string
356       -> call cmd_move_con_to_mark($mark)
357
358 state MOVE_WORKSPACE_TO_OUTPUT:
359   'output'
360       ->
361   output = string
362       -> call cmd_move_workspace_to_output($output)
363
364 state MOVE_TO_ABSOLUTE_POSITION:
365   'position'
366       -> MOVE_TO_POSITION
367
368 state MOVE_TO_POSITION:
369   'center'
370       -> call cmd_move_window_to_center($method)
371   'mouse', 'cursor', 'pointer'
372       -> call cmd_move_window_to_mouse()
373   coord_x = word
374       -> MOVE_TO_POSITION_X
375
376 state MOVE_TO_POSITION_X:
377   'px'
378       ->
379   coord_y = word
380       -> MOVE_TO_POSITION_Y
381
382 state MOVE_TO_POSITION_Y:
383   'px', end
384       -> call cmd_move_window_to_position($method, $coord_x, $coord_y)
385
386 # mode <string>
387 state MODE:
388   mode = string
389       -> call cmd_mode($mode)
390
391 state NOP:
392   comment = string
393       -> call cmd_nop($comment)
394   end
395       -> call cmd_nop(NULL)
396
397 state SCRATCHPAD:
398   'show'
399       -> call cmd_scratchpad_show()
400
401 state TITLE_FORMAT:
402   format = string
403       -> call cmd_title_format($format)
404
405 # bar (hidden_state hide|show|toggle)|(mode dock|hide|invisible|toggle) [<bar_id>]
406 state BAR:
407   bar_type = 'hidden_state'
408       -> BAR_HIDDEN_STATE
409   bar_type = 'mode'
410       -> BAR_MODE
411
412 state BAR_HIDDEN_STATE:
413   bar_value = 'hide', 'show', 'toggle'
414       -> BAR_W_ID
415
416 state BAR_MODE:
417   bar_value = 'dock', 'hide', 'invisible', 'toggle'
418       -> BAR_W_ID
419
420 state BAR_W_ID:
421   bar_id = word
422       ->
423   end
424       -> call cmd_bar($bar_type, $bar_value, $bar_id)