summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-08-16 14:06:07 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-08-16 14:06:07 +0100
commit043ca9998396bf447c693b1e72078e840f582d11 (patch)
treec04dd4adbbb3906b3623961481f95aaed5b2af59 /src/input_handler.cc
parent97b871d49e76ae4e0b3f758bc1374e44b45469c7 (diff)
Cleanup mouse handling a little
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index cefe65b1..c80ca7b1 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -73,43 +73,44 @@ struct MouseHandler
return false;
Buffer& buffer = context.buffer();
- if (key.modifiers == Key::Modifiers::MousePress)
+ ByteCoord cursor;
+ switch (key.modifiers)
{
+ case Key::Modifiers::MousePress:
m_dragging = true;
m_anchor = context.window().buffer_coord(key.mouse_coord());
context.selections_write_only() = SelectionList{ buffer, m_anchor };
return true;
- }
- if (key.modifiers == Key::Modifiers::MouseRelease)
- {
+
+ case Key::Modifiers::MouseRelease:
if (not m_dragging)
return true;
m_dragging = false;
- auto cursor = context.window().buffer_coord(key.mouse_coord());
+ cursor = context.window().buffer_coord(key.mouse_coord());
context.selections_write_only() =
SelectionList{ buffer, Selection{buffer.clamp(m_anchor), cursor} };
return true;
- }
- if (key.modifiers == Key::Modifiers::MousePos)
- {
+
+ case Key::Modifiers::MousePos:
if (not m_dragging)
return true;
- auto cursor = context.window().buffer_coord(key.mouse_coord());
+ cursor = context.window().buffer_coord(key.mouse_coord());
context.selections_write_only() =
SelectionList{ buffer, Selection{buffer.clamp(m_anchor), cursor} };
return true;
- }
- if (key.modifiers == Key::Modifiers::MouseWheelDown)
- {
+
+ case Key::Modifiers::MouseWheelDown:
+ m_dragging = false;
wheel(context, 3);
return true;
- }
- if (key.modifiers == Key::Modifiers::MouseWheelUp)
- {
+
+ case Key::Modifiers::MouseWheelUp:
+ m_dragging = false;
wheel(context, -3);
return true;
+
+ default: return false;
}
- return false;
}
private: