You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
10 years ago
|
#ifndef _SWAY_COMMANDS_H
|
||
|
#define _SWAY_COMMANDS_H
|
||
|
#include <stdbool.h>
|
||
9 years ago
|
#include <json-c/json.h>
|
||
9 years ago
|
#include <wlc/wlc.h>
|
||
10 years ago
|
#include "config.h"
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Indicates the result of a command's execution.
|
||
|
*/
|
||
|
enum cmd_status {
|
||
|
CMD_SUCCESS, /**< The command was successful */
|
||
|
CMD_FAILURE, /**< The command resulted in an error */
|
||
|
CMD_INVALID, /**< Unknown command or parser error */
|
||
|
CMD_DEFER, /**< Command execution deferred */
|
||
9 years ago
|
// Config Blocks
|
||
|
CMD_BLOCK_END,
|
||
|
CMD_BLOCK_MODE,
|
||
9 years ago
|
CMD_BLOCK_BAR,
|
||
9 years ago
|
CMD_BLOCK_BAR_COLORS,
|
||
|
CMD_BLOCK_INPUT
|
||
10 years ago
|
};
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Stores the result of executing a command.
|
||
|
*/
|
||
9 years ago
|
struct cmd_results {
|
||
|
enum cmd_status status;
|
||
9 years ago
|
char *input;
|
||
9 years ago
|
/**
|
||
|
* Human friendly error message, or NULL on success
|
||
|
*/
|
||
9 years ago
|
char *error;
|
||
|
};
|
||
|
|
||
9 years ago
|
/**
|
||
|
* Parse and handles a command.
|
||
|
*/
|
||
9 years ago
|
struct cmd_results *handle_command(char *command);
|
||
9 years ago
|
/**
|
||
|
* Parse and handles a command during config file loading.
|
||
|
*
|
||
|
* Do not use this under normal conditions.
|
||
|
*/
|
||
9 years ago
|
struct cmd_results *config_command(char *command, enum cmd_status block);
|
||
9 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Allocates a cmd_results object.
|
||
|
*/
|
||
9 years ago
|
struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
|
||
9 years ago
|
/**
|
||
|
* Frees a cmd_results object.
|
||
|
*/
|
||
9 years ago
|
void free_cmd_results(struct cmd_results *results);
|
||
9 years ago
|
/**
|
||
|
* Serializes cmd_results to a JSON string.
|
||
|
*
|
||
|
* Free the JSON string later on.
|
||
|
*/
|
||
9 years ago
|
const char *cmd_results_to_json(struct cmd_results *results);
|
||
10 years ago
|
|
||
9 years ago
|
void remove_view_from_scratchpad(swayc_t *);
|
||
9 years ago
|
|
||
10 years ago
|
#endif
|