Skip to content

Commit

Permalink
Fix #821: Add key mappings for single and double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas committed May 18, 2018
1 parent 634155e commit 9191484
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Release notes
=============

master
------

Bug fixes:

- 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
15 changes: 7 additions & 8 deletions src/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
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 (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;
Expand Down

0 comments on commit 9191484

Please sign in to comment.