Rename button_to_str() to the more idiomatic to_string()

Analogous to the parent commit.

This returns StringView, but it's immortal so it's even better
than String.
This commit is contained in:
Johannes Altmanninger 2022-08-04 10:54:55 +02:00
parent 01f3d7cbda
commit 0eb4e68c40
2 changed files with 4 additions and 4 deletions

View File

@ -162,7 +162,7 @@ KeyList parse_keys(StringView str)
return result; return result;
} }
StringView button_to_str(Key::MouseButton button) StringView to_string(Key::MouseButton button)
{ {
switch (button) switch (button)
{ {
@ -189,9 +189,9 @@ String to_string(Key key)
case Key::Modifiers::MousePos: case Key::Modifiers::MousePos:
return format("<mouse:move:{}.{}>", coord.line, coord.column); return format("<mouse:move:{}.{}>", coord.line, coord.column);
case Key::Modifiers::MousePress: case Key::Modifiers::MousePress:
return format("<mouse:press:{}:{}.{}>", button_to_str(key.mouse_button()), coord.line, coord.column); return format("<mouse:press:{}:{}.{}>", key.mouse_button(), coord.line, coord.column);
case Key::Modifiers::MouseRelease: case Key::Modifiers::MouseRelease:
return format("<mouse:release:{}:{}.{}>", button_to_str(key.mouse_button()), coord.line, coord.column); return format("<mouse:release:{}:{}.{}>", key.mouse_button(), coord.line, coord.column);
case Key::Modifiers::Scroll: case Key::Modifiers::Scroll:
return format("<scroll:{}>", static_cast<int>(key.key)); return format("<scroll:{}>", static_cast<int>(key.key));
case Key::Modifiers::Resize: case Key::Modifiers::Resize:

View File

@ -103,7 +103,7 @@ class StringView;
KeyList parse_keys(StringView str); KeyList parse_keys(StringView str);
String to_string(Key key); String to_string(Key key);
StringView button_to_str(Key::MouseButton button); StringView to_string(Key::MouseButton button);
Key::MouseButton str_to_button(StringView str); Key::MouseButton str_to_button(StringView str);
constexpr Key shift(Key key) constexpr Key shift(Key key)