summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/sway/commands.c b/sway/commands.c
index cf3d5b3f..fe480f0c 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -860,31 +860,31 @@ static bool cmd_ws_auto_back_and_forth(struct sway_config *config, int argc, cha
860 860
861/* Keep alphabetized */ 861/* Keep alphabetized */
862static struct cmd_handler handlers[] = { 862static struct cmd_handler handlers[] = {
863 { "bindsym", cmd_bindsym }, 863 { "bindsym", cmd_bindsym, 0 },
864 { "default_orientation", cmd_orientation }, 864 { "default_orientation", cmd_orientation, 0},
865 { "exec", cmd_exec }, 865 { "exec", cmd_exec, -1 },
866 { "exec_always", cmd_exec_always }, 866 { "exec_always", cmd_exec_always, -1 },
867 { "exit", cmd_exit }, 867 { "exit", cmd_exit, 1 },
868 { "floating", cmd_floating }, 868 { "floating", cmd_floating, 1 },
869 { "floating_modifier", cmd_floating_mod }, 869 { "floating_modifier", cmd_floating_mod, 0 },
870 { "focus", cmd_focus }, 870 { "focus", cmd_focus, 1 },
871 { "focus_follows_mouse", cmd_focus_follows_mouse }, 871 { "focus_follows_mouse", cmd_focus_follows_mouse, 0 },
872 { "fullscreen", cmd_fullscreen }, 872 { "fullscreen", cmd_fullscreen, 1 },
873 { "gaps", cmd_gaps }, 873 { "gaps", cmd_gaps, 0 },
874 { "kill", cmd_kill }, 874 { "kill", cmd_kill, 1 },
875 { "layout", cmd_layout }, 875 { "layout", cmd_layout, 1 },
876 { "log_colors", cmd_log_colors }, 876 { "log_colors", cmd_log_colors, 0 },
877 { "move", cmd_move}, 877 { "move", cmd_move, 1 },
878 { "output", cmd_output}, 878 { "output", cmd_output, 0 },
879 { "reload", cmd_reload }, 879 { "reload", cmd_reload, 1 },
880 { "resize", cmd_resize }, 880 { "resize", cmd_resize, 1 },
881 { "scratchpad", cmd_scratchpad }, 881 { "scratchpad", cmd_scratchpad, 1 },
882 { "set", cmd_set }, 882 { "set", cmd_set, 0 },
883 { "split", cmd_split }, 883 { "split", cmd_split, 1 },
884 { "splith", cmd_splith }, 884 { "splith", cmd_splith, 1 },
885 { "splitv", cmd_splitv }, 885 { "splitv", cmd_splitv, 1 },
886 { "workspace", cmd_workspace }, 886 { "workspace", cmd_workspace, -1 },
887 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth } 887 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth, 0 }
888}; 888};
889 889
890static char **split_directive(char *line, int *argc) { 890static char **split_directive(char *line, int *argc) {
@@ -945,9 +945,11 @@ static int handler_compare(const void *_a, const void *_b) {
945 return strcasecmp(a->command, b->command); 945 return strcasecmp(a->command, b->command);
946} 946}
947 947
948static struct cmd_handler *find_handler(struct cmd_handler handlers[], int l, char *line) { 948struct cmd_handler *find_handler(char *line) {
949 struct cmd_handler d = { .command=line }; 949 struct cmd_handler d = { .command=line };
950 struct cmd_handler *res = bsearch(&d, handlers, l, sizeof(struct cmd_handler), handler_compare); 950 struct cmd_handler *res = bsearch(&d, handlers,
951 sizeof(handlers) / sizeof(struct cmd_handler),
952 sizeof(struct cmd_handler), handler_compare);
951 return res; 953 return res;
952} 954}
953 955
@@ -964,7 +966,7 @@ bool handle_command(struct sway_config *config, char *exec) {
964 strncpy(cmd, exec, index); 966 strncpy(cmd, exec, index);
965 cmd[index] = '\0'; 967 cmd[index] = '\0';
966 } 968 }
967 struct cmd_handler *handler = find_handler(handlers, sizeof(handlers) / sizeof(struct cmd_handler), cmd); 969 struct cmd_handler *handler = find_handler(cmd);
968 if (handler == NULL) { 970 if (handler == NULL) {
969 sway_log(L_ERROR, "Unknown command '%s'", cmd); 971 sway_log(L_ERROR, "Unknown command '%s'", cmd);
970 exec_success = false; // TODO: return error, probably 972 exec_success = false; // TODO: return error, probably