diff --git a/NEWS.adoc b/NEWS.adoc index c10e2427d..9487f3193 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -19,6 +19,8 @@ Bug fixes: - Fix resource leak. (GH #780) - Fix various compiler warnings and pointer arithmetic. (GH #799, #803) - Workaround potential null pointer dereferences. (GH #824) + - 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 ef3c0ec93..b0b9d3744 100644 --- a/src/keys.c +++ b/src/keys.c @@ -243,6 +243,8 @@ static const struct key_mapping key_mappings[] = { { "ShiftDel", KEY_SDC }, { "ShiftHome", KEY_SHOME }, { "ShiftEnd", KEY_SEND }, + { "SingleQuote", '\'' }, + { "DoubleQuote", '"' }, }; static const struct key_mapping * @@ -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 (strchr(" #<'\"", mapping->value)) { + 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;