summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-11-26 19:38:07 +0100
committerMaxime Coste <frrrwww@gmail.com>2012-11-26 19:38:07 +0100
commit557128b641e7704715b72ebeabd4fc85b4f08d58 (patch)
treee74f383c52da99ca34e511efdf32cc45853c1dbb /src
parentcad4d3c01edd47bdb9dccd6b9998e0d9eaa4c65c (diff)
IncrementalInsert::move_cursors: use overloaded for LineCount/CharCount editor implementation
Diffstat (limited to 'src')
-rw-r--r--src/editor.cc14
-rw-r--r--src/editor.hh3
-rw-r--r--src/input_handler.cc8
3 files changed, 13 insertions, 12 deletions
diff --git a/src/editor.cc b/src/editor.cc
index 1d0d7d0e..4334e946 100644
--- a/src/editor.cc
+++ b/src/editor.cc
@@ -461,14 +461,14 @@ void IncrementalInserter::erase()
}
}
-void IncrementalInserter::move_cursors(const BufferCoord& offset)
+void IncrementalInserter::move_cursors(CharCount move)
{
- for (auto& sel : m_editor.m_selections)
- {
- BufferCoord pos = sel.last().coord();
- BufferIterator it = m_editor.m_buffer->iterator_at(pos + offset);
- sel = Selection(it, it);
- }
+ m_editor.move_selections(move, SelectMode::Replace);
+}
+
+void IncrementalInserter::move_cursors(LineCount move)
+{
+ m_editor.move_selections(move, SelectMode::Replace);
}
}
diff --git a/src/editor.hh b/src/editor.hh
index 06b9378a..df2d0ffb 100644
--- a/src/editor.hh
+++ b/src/editor.hh
@@ -121,7 +121,8 @@ public:
void insert(String content);
void insert(const memoryview<String>& strings);
void erase();
- void move_cursors(const BufferCoord& offset);
+ void move_cursors(CharCount move);
+ void move_cursors(LineCount move);
Buffer& buffer() const { return m_editor.buffer(); }
Editor& editor() const { return m_editor; }
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 00365d90..fc0d6649 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -502,13 +502,13 @@ public:
else if (key == Key::Backspace)
m_inserter.erase();
else if (key == Key::Left)
- m_inserter.move_cursors({0, -1});
+ m_inserter.move_cursors(-1_char);
else if (key == Key::Right)
- m_inserter.move_cursors({0, 1});
+ m_inserter.move_cursors(1_char);
else if (key == Key::Up)
- m_inserter.move_cursors({-1, 0});
+ m_inserter.move_cursors(-1_line);
else if (key == Key::Down)
- m_inserter.move_cursors({ 1, 0});
+ m_inserter.move_cursors(1_line);
else if (key.modifiers == Key::Modifiers::None)
{
m_inserter.insert(codepoint_to_str(key.key));