aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/commands.h
diff options
context:
space:
mode:
authorLibravatar Zandr Martin <zandrmartin@gmail.com>2016-09-02 13:46:19 -0500
committerLibravatar Zandr Martin <zandrmartin@gmail.com>2016-09-02 13:46:19 -0500
commit79ffea328c992c5109406771a59a9f016d85970d (patch)
tree5d965e72127f227ea0a38dc5c6e4fc14e08d9498 /include/sway/commands.h
parentrefactor commands.c (diff)
parentMerge pull request #878 from lukaslihotzki/master (diff)
downloadsway-79ffea328c992c5109406771a59a9f016d85970d.tar.gz
sway-79ffea328c992c5109406771a59a9f016d85970d.tar.zst
sway-79ffea328c992c5109406771a59a9f016d85970d.zip
Merge branch 'master' of git://github.com/SirCmpwn/sway into commands-refactor
Diffstat (limited to 'include/sway/commands.h')
-rw-r--r--include/sway/commands.h181
1 files changed, 181 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
new file mode 100644
index 00000000..f646c412
--- /dev/null
+++ b/include/sway/commands.h
@@ -0,0 +1,181 @@
1#ifndef _SWAY_COMMANDS_H
2#define _SWAY_COMMANDS_H
3#include <stdbool.h>
4#include <json-c/json.h>
5#include <wlc/wlc.h>
6#include "config.h"
7
8/**
9 * Indicates the result of a command's execution.
10 */
11enum cmd_status {
12 CMD_SUCCESS, /**< The command was successful */
13 CMD_FAILURE, /**< The command resulted in an error */
14 CMD_INVALID, /**< Unknown command or parser error */
15 CMD_DEFER, /**< Command execution deferred */
16 // Config Blocks
17 CMD_BLOCK_END,
18 CMD_BLOCK_MODE,
19 CMD_BLOCK_BAR,
20 CMD_BLOCK_BAR_COLORS,
21 CMD_BLOCK_INPUT
22};
23
24/**
25 * Stores the result of executing a command.
26 */
27struct cmd_results {
28 enum cmd_status status;
29 char *input;
30 /**
31 * Human friendly error message, or NULL on success
32 */
33 char *error;
34};
35
36enum expected_args {
37 EXPECTED_MORE_THAN,
38 EXPECTED_AT_LEAST,
39 EXPECTED_LESS_THAN,
40 EXPECTED_EQUAL_TO
41};
42
43struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val);
44struct cmd_results *add_color(const char*, char*, const char*);
45void input_cmd_apply(struct input_config *input);
46void hide_view_in_scratchpad(swayc_t *sp_view);
47
48swayc_t *sp_view;
49int sp_index;
50
51/**
52 * Parse and handles a command.
53 */
54struct cmd_results *handle_command(char *command);
55/**
56 * Parse and handles a command during config file loading.
57 *
58 * Do not use this under normal conditions.
59 */
60struct cmd_results *config_command(char *command, enum cmd_status block);
61
62/**
63 * Allocates a cmd_results object.
64 */
65struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
66/**
67 * Frees a cmd_results object.
68 */
69void free_cmd_results(struct cmd_results *results);
70/**
71 * Serializes cmd_results to a JSON string.
72 *
73 * Free the JSON string later on.
74 */
75const char *cmd_results_to_json(struct cmd_results *results);
76
77void remove_view_from_scratchpad(swayc_t *);
78
79/**
80 * Actual command function signatures for individual .c files in commands/ directory.
81 */
82
83typedef struct cmd_results *sway_cmd(int argc, char **argv);
84
85sway_cmd cmd_assign;
86sway_cmd cmd_bar;
87sway_cmd cmd_bindcode;
88sway_cmd cmd_bindsym;
89sway_cmd cmd_border;
90sway_cmd cmd_client_focused;
91sway_cmd cmd_client_focused_inactive;
92sway_cmd cmd_client_unfocused;
93sway_cmd cmd_client_urgent;
94sway_cmd cmd_client_placeholder;
95sway_cmd cmd_client_background;
96sway_cmd cmd_debuglog;
97sway_cmd cmd_exec;
98sway_cmd cmd_exec_always;
99sway_cmd cmd_exit;
100sway_cmd cmd_floating;
101sway_cmd cmd_floating_maximum_size;
102sway_cmd cmd_floating_minimum_size;
103sway_cmd cmd_floating_mod;
104sway_cmd cmd_floating_scroll;
105sway_cmd cmd_focus;
106sway_cmd cmd_focus_follows_mouse;
107sway_cmd cmd_font;
108sway_cmd cmd_for_window;
109sway_cmd cmd_fullscreen;
110sway_cmd cmd_gaps;
111sway_cmd cmd_hide_edge_borders;
112sway_cmd cmd_include;
113sway_cmd cmd_input;
114sway_cmd cmd_kill;
115sway_cmd cmd_layout;
116sway_cmd cmd_log_colors;
117sway_cmd cmd_mode;
118sway_cmd cmd_mouse_warping;
119sway_cmd cmd_move;
120sway_cmd cmd_new_float;
121sway_cmd cmd_new_window;
122sway_cmd cmd_orientation;
123sway_cmd cmd_output;
124sway_cmd cmd_reload;
125sway_cmd cmd_resize;
126sway_cmd cmd_scratchpad;
127sway_cmd cmd_seamless_mouse;
128sway_cmd cmd_set;
129sway_cmd cmd_smart_gaps;
130sway_cmd cmd_split;
131sway_cmd cmd_splith;
132sway_cmd cmd_splitt;
133sway_cmd cmd_splitv;
134sway_cmd cmd_sticky;
135sway_cmd cmd_workspace;
136sway_cmd cmd_ws_auto_back_and_forth;
137sway_cmd cmd_workspace_layout;
138
139sway_cmd bar_cmd_binding_mode_indicator;
140sway_cmd bar_cmd_bindsym;
141sway_cmd bar_cmd_colors;
142sway_cmd bar_cmd_font;
143sway_cmd bar_cmd_mode;
144sway_cmd bar_cmd_modifier;
145sway_cmd bar_cmd_output;
146sway_cmd bar_cmd_height;
147sway_cmd bar_cmd_hidden_state;
148sway_cmd bar_cmd_id;
149sway_cmd bar_cmd_position;
150sway_cmd bar_cmd_separator_symbol;
151sway_cmd bar_cmd_status_command;
152sway_cmd bar_cmd_pango_markup;
153sway_cmd bar_cmd_strip_workspace_numbers;
154sway_cmd bar_cmd_swaybar_command;
155sway_cmd bar_cmd_tray_output;
156sway_cmd bar_cmd_tray_padding;
157sway_cmd bar_cmd_wrap_scroll;
158sway_cmd bar_cmd_workspace_buttons;
159
160sway_cmd bar_colors_cmd_active_workspace;
161sway_cmd bar_colors_cmd_background;
162sway_cmd bar_colors_cmd_background;
163sway_cmd bar_colors_cmd_binding_mode;
164sway_cmd bar_colors_cmd_focused_workspace;
165sway_cmd bar_colors_cmd_inactive_workspace;
166sway_cmd bar_colors_cmd_separator;
167sway_cmd bar_colors_cmd_statusline;
168sway_cmd bar_colors_cmd_urgent_workspace;
169
170sway_cmd input_cmd_accel_profile;
171sway_cmd input_cmd_click_method;
172sway_cmd input_cmd_drag_lock;
173sway_cmd input_cmd_dwt;
174sway_cmd input_cmd_events;
175sway_cmd input_cmd_middle_emulation;
176sway_cmd input_cmd_natural_scroll;
177sway_cmd input_cmd_pointer_accel;
178sway_cmd input_cmd_scroll_method;
179sway_cmd input_cmd_tap;
180
181#endif