Parse meta as 8 bit in Normal mode to fix the terminals using that

The solution is a bit hackish, as we only consider the 8th bit to
mean alt in normal mode, because its unlikely accentuated characters
are going to be mapped there. It fixes using Alt on xterm, and
probably on iterm2 as well (not requiring the meta-sends-esc config
change anymore)
This commit is contained in:
Maxime Coste 2017-05-27 06:18:39 +01:00
parent b9080d8b2c
commit 72acb0177d
2 changed files with 10 additions and 0 deletions

View File

@ -202,6 +202,15 @@ public:
{
ScopedSetBool set_in_on_key{m_in_on_key};
// Hack to parse keys sent by terminals using the 8th bit to mark the
// meta key. In normal mode, give priority to a potential alt-key than
// the accentuated character.
if (key.key >= 127 and key.key < 256)
{
key.modifiers |= Key::Modifiers::Alt;
key.key &= 0x7f;
}
bool do_restore_hooks = false;
auto restore_hooks = on_scope_end([&, this]{
if (m_hooks_disabled and enabled() and do_restore_hooks)

View File

@ -485,6 +485,7 @@ void NCursesUI::check_resize(bool force)
m_window = (NCursesWin*)newpad(ws.ws_row, ws.ws_col);
intrflush(m_window, false);
keypad(m_window, true);
meta(m_window, true);
m_dimensions = DisplayCoord{ws.ws_row-1, ws.ws_col};