From 2587649ca28ac9a161c51430c630a34fc09f8dc5 Mon Sep 17 00:00:00 2001 From: Julian Aron Prenner Date: Tue, 31 Dec 2013 14:53:29 +0100 Subject: [PATCH] Allow restricting earsing and listing of bindings to specific mode; implement force repaint and multi-char bindings; --- builtin.cpp | 29 ++++++++++++++++++----- input.cpp | 24 +++++++++++++++---- input.h | 1 + reader.cpp | 1 + share/functions/fish_vi_key_bindings.fish | 29 +++++++++++++++++++---- 5 files changed, 69 insertions(+), 15 deletions(-) diff --git a/builtin.cpp b/builtin.cpp index dfee2c0a3..335b81ce5 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -403,7 +403,7 @@ int builtin_test(parser_t &parser, wchar_t **argv); /** List all current key bindings */ -static void builtin_bind_list() +static void builtin_bind_list(const wchar_t *bind_mode) { size_t i; wcstring_list_t lst; @@ -417,6 +417,12 @@ static void builtin_bind_list() wcstring mode; input_mapping_get(seq, ecmd, mode); + + if(bind_mode != NULL && wcscmp(mode.c_str(), bind_mode)) + { + continue; + } + ecmd = escape_string(ecmd, 1); wcstring tname; @@ -522,7 +528,7 @@ static int builtin_bind_add(const wchar_t *seq, const wchar_t *cmd, const wchar_ \param seq an array of all key bindings to erase \param all if specified, _all_ key bindings will be erased */ -static void builtin_bind_erase(wchar_t **seq, int all) +static void builtin_bind_erase(wchar_t **seq, int all, const wchar_t *mode) { if (all) { @@ -532,7 +538,7 @@ static void builtin_bind_erase(wchar_t **seq, int all) for (i=0; i 0); + bool timed; + if(iswalnum(str[j])) + { + timed = false; + } + else + { + timed = (j > 0); + } + c = input_common_readch(timed); if (str[j] != c) + { break; + } } if (str[j] == L'\0') @@ -548,7 +561,6 @@ void input_unreadch(wint_t ch) wint_t input_readch() { - size_t i; CHECK_BLOCK(R_NULL); @@ -569,8 +581,12 @@ wint_t input_readch() { const input_mapping_t &m = mapping_list.at(i); + // debug(0, L"trying mapping (%ls,%ls,%ls,%ls)\n", escape(m.seq.c_str(), 1), + // m.command.c_str(), m.mode.c_str(), m.new_mode.c_str()); + if(wcscmp(m.mode.c_str(), input_get_bind_mode())) { + // debug(0, L"skipping mapping because mode %ls != %ls\n", m.mode.c_str(), input_get_bind_mode()); continue; } @@ -641,7 +657,7 @@ bool input_mapping_erase(const wchar_t *sequence, const wchar_t *mode) for (i=0; i