diff --git a/NEWS.adoc b/NEWS.adoc index aa60cbc36..582a60fb5 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -1,6 +1,14 @@ Release notes ============= +master +------ + +Bug fixes: + + - Bind to single and double quotes by using the ** and + ** key mappings. (GH #821) + tig-2.3.3 --------- diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index 859595d89..f75cff997 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -599,7 +599,8 @@ bind to the `<` key. **, ** or **, **, **, ** or **, ** or **, ** or **, ** or **, ** or **, **, **, -** or **, **, **, ** ... ** +** or **, **, **, **, +**, ** ... ** To define key mappings with the `Ctrl` key, use ``. In addition, key combos consisting of an initial `Escape` key followed by a normal key value can diff --git a/src/keys.c b/src/keys.c index 6a15eb3cb..8572f7d4f 100644 --- a/src/keys.c +++ b/src/keys.c @@ -193,6 +193,7 @@ static const struct key_mapping key_mappings[] = { { "Backspace", KEY_BACKSPACE }, { "Del", KEY_DC }, { "Delete", KEY_DC }, + { "DoubleQuote", '"' }, { "Down", KEY_DOWN }, { "End", KEY_END }, { "Enter", KEY_RETURN }, @@ -234,12 +235,13 @@ static const struct key_mapping key_mappings[] = { { "ScrollBack", KEY_SR }, { "ScrollFwd", KEY_SF }, { "ShiftDel", KEY_SDC }, - { "ShiftDelete", KEY_SDC }, + { "ShiftDelete", KEY_SDC }, { "ShiftEnd", KEY_SEND }, { "ShiftHome", KEY_SHOME }, { "ShiftLeft", KEY_SLEFT }, { "ShiftRight", KEY_SRIGHT }, { "ShiftTab", KEY_BTAB }, + { "SingleQuote", '\'' }, { "Space", ' ' }, { "Tab", KEY_TAB }, { "Up", KEY_UP }, @@ -314,14 +316,11 @@ get_key_value(const char **name_ptr, struct key *key) if (!mapping) return error("Unknown key mapping: %.*s", len, start); - if (mapping->value == ' ') - return parse_key_value(key, name_ptr, 0, " ", end); + if (mapping->value < KEY_MIN) { + const char replacement[] = { mapping->value, 0 }; - if (mapping->value == '#') - return parse_key_value(key, name_ptr, 0, "#", end); - - if (mapping->value == '<') - return parse_key_value(key, name_ptr, 0, "<", end); + return parse_key_value(key, name_ptr, 0, replacement, end); + } *name_ptr = end + 1; key->data.value = mapping->value;