diff options
Diffstat (limited to 'input.h')
-rw-r--r-- | input.h | 82 |
1 files changed, 67 insertions, 15 deletions
@@ -9,11 +9,18 @@ inputrc information for key bindings. #define FISH_INPUT_H #include <wchar.h> +#include <utility> #include "input_common.h" + +#define DEFAULT_BIND_MODE L"default" +#define FISH_BIND_MODE_VAR L"fish_bind_mode" + /** Key codes for inputrc-style keyboard functions that are passed on to the caller of input_read() + + NOTE: IF YOU MODIFY THIS YOU MUST UPDATE THE name_arr AND code_arr VARIABLES TO MATCH! */ enum { @@ -31,6 +38,7 @@ enum R_YANK, R_YANK_POP, R_COMPLETE, + R_COMPLETE_AND_SEARCH, R_BEGINNING_OF_HISTORY, R_END_OF_HISTORY, R_BACKWARD_KILL_LINE, @@ -38,7 +46,6 @@ enum R_KILL_WORD, R_BACKWARD_KILL_WORD, R_BACKWARD_KILL_PATH_COMPONENT, - R_DUMP_FUNCTIONS, R_HISTORY_TOKEN_SEARCH_BACKWARD, R_HISTORY_TOKEN_SEARCH_FORWARD, R_SELF_INSERT, @@ -53,12 +60,24 @@ enum R_BEGINNING_OF_BUFFER, R_END_OF_BUFFER, R_REPAINT, + R_FORCE_REPAINT, R_UP_LINE, R_DOWN_LINE, R_SUPPRESS_AUTOSUGGESTION, - R_ACCEPT_AUTOSUGGESTION -} -; + R_ACCEPT_AUTOSUGGESTION, + R_BEGIN_SELECTION, + R_END_SELECTION, + R_KILL_SELECTION, + R_FORWARD_JUMP, + R_BACKWARD_JUMP, + R_AND, + R_CANCEL +}; + +wcstring describe_char(wint_t c); + +#define R_MIN R_NULL +#define R_MAX R_CANCEL /** Initialize the terminal by calling setupterm, and set up arrays @@ -85,8 +104,12 @@ void input_destroy(); readch attempts to parse it. If no more input follows after the escape key, it is assumed to be an actual escape key press, and is returned as such. + + The argument determines whether fish commands are allowed to be run + as bindings. If false, when a character is encountered that would + invoke a fish command, it is unread and R_NULL is returned. */ -wint_t input_readch(); +wint_t input_readch(bool allow_commands = true); /** Push a character or a readline function onto the stack of unread @@ -102,22 +125,51 @@ void input_unreadch(wint_t ch); \param sequence the sequence to bind \param command an input function that will be run whenever the key sequence occurs */ -void input_mapping_add(const wchar_t *sequence, const wchar_t *command); +void input_mapping_add(const wchar_t *sequence, const wchar_t *command, + const wchar_t *mode = DEFAULT_BIND_MODE, + const wchar_t *new_mode = DEFAULT_BIND_MODE); + +void input_mapping_add(const wchar_t *sequence, const wchar_t **commands, size_t commands_len, + const wchar_t *mode = DEFAULT_BIND_MODE, const wchar_t *new_mode = DEFAULT_BIND_MODE); + +struct input_mapping_name_t { + wcstring seq; + wcstring mode; +}; /** - Insert all mapping names into the specified wcstring_list_t + Returns all mapping names and modes */ -void input_mapping_get_names(wcstring_list_t &lst); +std::vector<input_mapping_name_t> input_mapping_get_names(); /** Erase binding for specified key sequence */ -bool input_mapping_erase(const wchar_t *sequence); +bool input_mapping_erase(const wcstring &sequence, const wcstring &mode = DEFAULT_BIND_MODE); /** - Gets the command bound to the specified key sequence. Returns true if it exists, false if not. + Gets the command bound to the specified key sequence in the specified mode. Returns true if it exists, false if not. */ -bool input_mapping_get(const wcstring &sequence, wcstring &cmd); +bool input_mapping_get(const wcstring &sequence, const wcstring &mode, wcstring_list_t *out_cmds, wcstring *out_new_mode); + +/** + Return the current bind mode +*/ +wcstring input_get_bind_mode(); + +/** + Set the current bind mode +*/ +void input_set_bind_mode(const wcstring &bind_mode); + + +wchar_t input_function_pop_arg(); + + +/** + Sets the return status of the most recently executed input function +*/ +void input_function_set_status(bool status); /** Return the sequence for the terminfo variable of the specified name. @@ -127,8 +179,8 @@ bool input_mapping_get(const wcstring &sequence, wcstring &cmd); */ bool input_terminfo_get_sequence(const wchar_t *name, wcstring *out_seq); -/** Return the name of the terminfo variable with the specified sequence */ -bool input_terminfo_get_name(const wcstring &seq, wcstring &name); +/** Return the name of the terminfo variable with the specified sequence, in out_name. Returns true if found, false if not found. */ +bool input_terminfo_get_name(const wcstring &seq, wcstring *out_name); /** Return a list of all known terminfo names */ wcstring_list_t input_terminfo_get_names(bool skip_null); @@ -139,8 +191,8 @@ wchar_t input_function_get_code(const wcstring &name); /** Returns a list of all existing input function names */ wcstring_list_t input_function_get_names(void); -/** Updates our idea of whether we support term256 */ -void update_fish_term256(); +/** Updates our idea of whether we support term256 and term24bit */ +void update_fish_color_support(); #endif |