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