Merge remote-tracking branch 'Screwtapello/map-ctrl-symbol-keys-ncurses' into master

This commit is contained in:
Maxime Coste 2020-11-01 10:11:12 +11:00
commit f25442fbad
2 changed files with 15 additions and 0 deletions

View File

@ -229,6 +229,10 @@ UnitTest test_keys{[]()
alt('j'), alt('j'),
ctrl('r'), ctrl('r'),
shift(Key::Up), shift(Key::Up),
ctrl('['),
ctrl('\\'),
ctrl(']'),
ctrl('_'),
}; };
String keys_as_str; String keys_as_str;
for (auto& key : keys) for (auto& key : keys)

View File

@ -623,8 +623,19 @@ Optional<Key> NCursesUI::get_next_key()
kill(0, SIGTSTP); // We suspend at this line kill(0, SIGTSTP); // We suspend at this line
return {}; return {};
} }
// Special case: you can type NUL with Ctrl-2 or Ctrl-Shift-2 or
// Ctrl-Backtick, but the most straightforward way is Ctrl-Space.
if (c == 0)
return ctrl(' ');
// Represent Ctrl-letter combinations in lower-case, to be clear
// that Shift is not involved.
if (c < 27) if (c < 27)
return ctrl(c - 1 + 'a'); return ctrl(c - 1 + 'a');
// Represent Ctrl-symbol combinations in "upper-case", as they are
// traditionally-rendered.
// Note that Escape is handled elsewhere.
if (c < 32)
return ctrl(c - 1 + 'A');
struct Sentinel{}; struct Sentinel{};
struct CharIterator struct CharIterator