Support mosue event in key_to_str

This commit is contained in:
Maxime Coste 2016-03-23 13:39:52 +00:00
parent 5bf9243006
commit abd5afe012

View File

@ -114,7 +114,23 @@ KeyList parse_keys(StringView str)
String key_to_str(Key key) String key_to_str(Key key)
{ {
if (key.modifiers & Key::Modifiers::MouseEvent) if (key.modifiers & Key::Modifiers::MouseEvent)
return "<mouse event>"; {
const auto coord = key.coord() + CharCoord{1,1};
switch (key.modifiers)
{
case Key::Modifiers::MousePos:
return format("<mouse:move:{}.{}>", coord.line, coord.column);
case Key::Modifiers::MousePress:
return format("<mouse:press:{}.{}>", coord.line, coord.column);
case Key::Modifiers::MouseRelease:
return format("<mouse:release:{}.{}>", coord.line, coord.column);
case Key::Modifiers::MouseWheelDown:
return "<mouse:wheel_down>";
case Key::Modifiers::MouseWheelUp:
return "<mouse:wheel_up>";
default: kak_assert(false);
}
}
bool named = false; bool named = false;
String res; String res;