Skip to content

Commit

Permalink
fix(key_event): KeySequence::repr() prefer unescaped punctuation char…
Browse files Browse the repository at this point in the history
…acters
  • Loading branch information
lotem committed Dec 25, 2016
1 parent bad8ab1 commit aa43e5e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/key_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ KeySequence::KeySequence(const string& repr) {
clear();
}

static bool is_unescaped_character(const KeyEvent& key_event) {
int ch = key_event.keycode();
return key_event.modifier() == 0 &&
ch >= 0x20 && ch <= 0x7e &&
ch != '{' && ch != '}';
}

string KeySequence::repr() const {
std::ostringstream result;
string k;
Expand All @@ -97,6 +104,9 @@ string KeySequence::repr() const {
if (k.size() == 1) {
result << k;
}
else if (is_unescaped_character(*it)) {
result << char(it->keycode());
}
else {
result << '{' << k << '}';
}
Expand Down

0 comments on commit aa43e5e

Please sign in to comment.