Add support for Home/End key in prompts
This commit is contained in:
parent
b08749285e
commit
a453ddaf37
|
@ -95,6 +95,10 @@ public:
|
|||
if (m_cursor_pos < m_line.char_length())
|
||||
++m_cursor_pos;
|
||||
}
|
||||
else if (key == Key::Home)
|
||||
m_cursor_pos = 0;
|
||||
else if (key == Key::End)
|
||||
m_cursor_pos = m_line.char_length();
|
||||
else if (key == Key::Backspace)
|
||||
{
|
||||
if (m_cursor_pos != 0)
|
||||
|
|
12
src/keys.cc
12
src/keys.cc
|
@ -19,12 +19,18 @@ using KeyAndName = std::pair<String, Codepoint>;
|
|||
static std::vector<KeyAndName> keynamemap = {
|
||||
{ "ret", '\r' },
|
||||
{ "space", ' ' },
|
||||
{ "tab", '\t' },
|
||||
{ "backspace", Key::Backspace},
|
||||
{ "esc", Key::Escape },
|
||||
{ "left", Key::Left },
|
||||
{ "right", Key::Right },
|
||||
{ "up", Key::Up },
|
||||
{ "down", Key::Down},
|
||||
{ "backspace", Key::Backspace}
|
||||
{ "left", Key::Left },
|
||||
{ "right", Key::Right },
|
||||
{ "pageup", Key::PageUp },
|
||||
{ "pagedown", Key::PageDown },
|
||||
{ "home", Key::Home },
|
||||
{ "end", Key::End },
|
||||
{ "backtab", Key::BackTab },
|
||||
};
|
||||
|
||||
KeyList parse_keys(const String& str)
|
||||
|
|
|
@ -28,6 +28,8 @@ struct Key
|
|||
Right,
|
||||
PageUp,
|
||||
PageDown,
|
||||
Home,
|
||||
End,
|
||||
BackTab,
|
||||
Invalid,
|
||||
};
|
||||
|
|
|
@ -273,6 +273,8 @@ Key NCursesUI::get_key()
|
|||
case KEY_RIGHT: return Key::Right;
|
||||
case KEY_PPAGE: return Key::PageUp;
|
||||
case KEY_NPAGE: return Key::PageDown;
|
||||
case KEY_HOME: return Key::Home;
|
||||
case KEY_END: return Key::End;
|
||||
case KEY_BTAB: return Key::BackTab;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user