aboutsummaryrefslogtreecommitdiffhomepage
path: root/input.h
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-09-22 21:04:06 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-09-22 21:04:06 -0700
commit0a3f2205729d13897e86efe2b7d9452000117605 (patch)
treed90226dfbc496312cfa1d4de2b39c503d4ed905e /input.h
parent5eee7d17f610f58e4e797529f64751c18e237559 (diff)
Rework mode handling of `bind`
Binds with the same sequence in multiple modes was not working right. Fix up the implementation to propagate modes everywhere as necessary. This means that `bind` will properly list distinct binds with the same sequence, and `bind -e` will take mode into account properly as well. Note that `bind -e seq` now assumes the bind is in the default bind mode, whereas before it would erase the first binding with that sequence regardless of mode. `bind -e -a` still erases all binds in all modes, though `bind -M mode -e -a` still only erases all binds in the selected mode.
Diffstat (limited to 'input.h')
-rw-r--r--input.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/input.h b/input.h
index 737d2bf1..9864d730 100644
--- a/input.h
+++ b/input.h
@@ -9,6 +9,7 @@ inputrc information for key bindings.
#define FISH_INPUT_H
#include <wchar.h>
+#include <utility>
#include "input_common.h"
@@ -131,20 +132,25 @@ void input_mapping_add(const wchar_t *sequence, const wchar_t *command,
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;
+};
+
/**
- Returns all mapping names
+ Returns all mapping names and modes
*/
-wcstring_list_t input_mapping_get_names();
+std::vector<input_mapping_name_t> input_mapping_get_names();
/**
Erase binding for specified key sequence
*/
-bool input_mapping_erase(const wchar_t *sequence, const wchar_t *mode = DEFAULT_BIND_MODE);
+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_list_t *out_cmds, wcstring *out_mode, wcstring *out_new_mode);
+bool input_mapping_get(const wcstring &sequence, const wcstring &mode, wcstring_list_t *out_cmds, wcstring *out_new_mode);
/**
Return the current bind mode