mirror of
https://github.com/swaywm/sway.git
synced 2025-11-15 06:59:50 -05:00
Make command block implementation generic
This commit is contained in:
parent
2d480e754e
commit
7c810dc344
12 changed files with 293 additions and 410 deletions
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
typedef struct cmd_results *sway_cmd(int argc, char **argv);
|
||||
|
||||
struct cmd_handler {
|
||||
char *command;
|
||||
sway_cmd *handle;
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates the result of a command's execution.
|
||||
*/
|
||||
|
|
@ -11,16 +18,9 @@ enum cmd_status {
|
|||
CMD_FAILURE, /**< The command resulted in an error */
|
||||
CMD_INVALID, /**< Unknown command or parser error */
|
||||
CMD_DEFER, /**< Command execution deferred */
|
||||
// Config Blocks
|
||||
CMD_BLOCK_END,
|
||||
CMD_BLOCK_MODE,
|
||||
CMD_BLOCK_BAR,
|
||||
CMD_BLOCK_BAR_COLORS,
|
||||
CMD_BLOCK_INPUT,
|
||||
CMD_BLOCK_SEAT,
|
||||
CMD_BLOCK,
|
||||
CMD_BLOCK_COMMANDS,
|
||||
CMD_BLOCK_IPC,
|
||||
CMD_BLOCK_IPC_EVENTS,
|
||||
CMD_BLOCK_END
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -45,6 +45,8 @@ enum expected_args {
|
|||
struct cmd_results *checkarg(int argc, const char *name,
|
||||
enum expected_args type, int val);
|
||||
|
||||
struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
|
||||
int handlers_size);
|
||||
/**
|
||||
* Parse and executes a command.
|
||||
*/
|
||||
|
|
@ -54,7 +56,12 @@ struct cmd_results *execute_command(char *command, struct sway_seat *seat);
|
|||
*
|
||||
* Do not use this under normal conditions.
|
||||
*/
|
||||
struct cmd_results *config_command(char *command, enum cmd_status block);
|
||||
struct cmd_results *config_command(char *command);
|
||||
/**
|
||||
* Parse and handle a sub command
|
||||
*/
|
||||
struct cmd_results *subcommand(char **argv, int argc,
|
||||
struct cmd_handler *handlers, int handlers_size);
|
||||
/*
|
||||
* Parses a command policy rule.
|
||||
*/
|
||||
|
|
@ -77,8 +84,6 @@ const char *cmd_results_to_json(struct cmd_results *results);
|
|||
struct cmd_results *add_color(const char *name,
|
||||
char *buffer, const char *color);
|
||||
|
||||
typedef struct cmd_results *sway_cmd(int argc, char **argv);
|
||||
|
||||
sway_cmd cmd_assign;
|
||||
sway_cmd cmd_bar;
|
||||
sway_cmd cmd_bindcode;
|
||||
|
|
|
|||
|
|
@ -403,8 +403,6 @@ bool read_config(FILE *file, struct sway_config *config);
|
|||
*/
|
||||
void free_config(struct sway_config *config);
|
||||
|
||||
void config_clear_handler_context(struct sway_config *config);
|
||||
|
||||
void free_sway_variable(struct sway_variable *var);
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue