Skip to content

Commit

Permalink
Fix jonas#821: Add key mappings for single and double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas authored and rolandwalker committed May 21, 2018
1 parent a75ea46 commit 08b9555
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 *<SingleQuote>* and
*<DoubleQuote>* key mappings. (GH #821)

tig-2.3.3
---------
Expand Down
3 changes: 2 additions & 1 deletion doc/tigrc.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ bind to the `<` key.
*<Hash>*, *<LessThan>* or *<LT>*, *<Home>*, *<End>*, *<PageUp>* or *<PgUp>*,
*<PageDown>* or *<PgDown>*, *<ScrollBack>* or *<SBack>*, *<ScrollFwd>* or
*<SFwd>*, *<ShiftTab>* or *<BackTab>*, *<ShiftLeft>*, *<ShiftRight>*,
*<ShiftDelete>* or *<ShiftDel>*, *<ShiftHome>*, *<ShiftEnd>*, *<F1>* ... *<F19>*
*<ShiftDelete>* or *<ShiftDel>*, *<ShiftHome>*, *<ShiftEnd>*, *<SingleQuote>*,
*<DoubleQuote>*, *<F1>* ... *<F19>*

To define key mappings with the `Ctrl` key, use `<Ctrl-key>`. In addition, key
combos consisting of an initial `Escape` key followed by a normal key value can
Expand Down
13 changes: 6 additions & 7 deletions src/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand 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 (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;
Expand Down

0 comments on commit 08b9555

Please sign in to comment.