1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-26 04:52:53 +03:00

Merge remote-tracking branch 'jeapostrophe/master'

This commit is contained in:
Maxime Coste 2018-12-09 10:33:44 +11:00
commit e90e77e5fc
2 changed files with 51 additions and 3 deletions

View File

@ -109,6 +109,10 @@ constexpr Key ctrl(Key key)
{ {
return { key.modifiers | Key::Modifiers::Control, key.key }; return { key.modifiers | Key::Modifiers::Control, key.key };
} }
constexpr Key shift_alt(Key k) { return shift(alt(k)); }
constexpr Key shift_ctrl(Key k) { return shift(ctrl(k)); }
constexpr Key alt_ctrl(Key k) { return alt(ctrl(k)); }
constexpr Key shift_alt_ctrl(Key k) { return shift(alt(ctrl(k))); }
constexpr Codepoint encode_coord(DisplayCoord coord) { return (Codepoint)(((int)coord.line << 16) | ((int)coord.column & 0x0000FFFF)); } constexpr Codepoint encode_coord(DisplayCoord coord) { return (Codepoint)(((int)coord.line << 16) | ((int)coord.column & 0x0000FFFF)); }

View File

@ -26,6 +26,7 @@ namespace Kakoune
using std::min; using std::min;
using std::max; using std::max;
using std::function;
struct NCursesWin : WINDOW {}; struct NCursesWin : WINDOW {};
@ -661,12 +662,55 @@ Optional<Key> NCursesUI::get_next_key()
const int new_c = wgetch(m_window); const int new_c = wgetch(m_window);
if (new_c == '[') // potential CSI if (new_c == '[') // potential CSI
{ {
const Codepoint csi_val = wgetch(m_window); const Codepoint c1 = wgetch(m_window);
switch (csi_val) switch (c1)
{ {
case 'I': return {Key::FocusIn}; case 'I': return {Key::FocusIn};
case 'O': return {Key::FocusOut}; case 'O': return {Key::FocusOut};
default: break; // nothing case '1':
{
const Codepoint c2 = wgetch(m_window);
if (c2 != ';')
{
ungetch(c2); ungetch(c1);
break;
}
const Codepoint c3 = wgetch(m_window);
function<Key(Key)> f;
switch (c3)
{
case '2': f = shift; break;
case '3': f = alt; break;
case '4': f = shift_alt; break;
case '5': f = ctrl; break;
case '6': f = shift_ctrl; break;
case '7': f = alt_ctrl; break;
case '8': f = shift_alt_ctrl; break;
}
if (!f)
{
ungetch(c3); ungetch(c2); ungetch(c1);
break;
}
const Codepoint c4 = wgetch(m_window);
switch (c4)
{
case 'A': return f(Key::Up);
case 'B': return f(Key::Down);
case 'C': return f(Key::Right);
case 'D': return f(Key::Left);
case 'H': return f(Key::Home);
case 'F': return f(Key::End);
}
ungetch(c4); ungetch(c3); ungetch(c2); ungetch(c1);
break;
}
default:
ungetch(c1);
break;
} }
} }
wtimeout(m_window, -1); wtimeout(m_window, -1);