2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
7 * commands.c: all command functions (see commands_parser.c)
12 #include <yajl/yajl_gen.h>
15 * Holds an intermediate represenation of the result of a call to any command.
16 * When calling parse_command("floating enable, border none"), the parser will
17 * internally use this struct when calling cmd_floating and cmd_border.
19 struct CommandResultIR {
20 /* The JSON generator to append a reply to (may be NULL). */
23 /* The next state to transition to. Passed to the function so that we can
24 * determine the next state as a result of a function call, like
25 * cfg_criteria_pop_state() does. */
28 /* Whether the command requires calling tree_render. */
29 bool needs_tree_render;
32 typedef struct CommandResult CommandResult;
35 * A struct that contains useful information about the result of a command as a
36 * whole (e.g. a compound command like "floating enable, border none").
37 * needs_tree_render is true if needs_tree_render of any individual command was
40 struct CommandResult {
42 /* the error_message is currently only set for parse errors */
44 bool needs_tree_render;
48 * Parses a string (or word, if as_word is true). Extracted out of
49 * parse_command so that it can be used in src/workspace.c for interpreting
53 char *parse_string(const char **walk, bool as_word);
56 * Parses and executes the given command. If a caller-allocated yajl_gen is
57 * passed, a json reply will be generated in the format specified by the ipc
58 * protocol. Pass NULL if no json reply is required.
60 * Free the returned CommandResult with command_result_free().
62 CommandResult *parse_command(const char *input, yajl_gen gen);
65 * Frees a CommandResult
67 void command_result_free(CommandResult *result);