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