summaryrefslogtreecommitdiff
path: root/src/selection.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-06-03 18:58:09 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-06-04 14:21:07 +0200
commit4ef1bfa4db03526f670213f29ed88212913be43f (patch)
tree19d8e34f788bea2e6f565708cf219226b176e898 /src/selection.cc
parent02b33c7d8fd0167a4cbca78be26ed32e042c7370 (diff)
Use coord instead of iterators for selections
Diffstat (limited to 'src/selection.cc')
-rw-r--r--src/selection.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/selection.cc b/src/selection.cc
index 0a4c4e32..f7360e7f 100644
--- a/src/selection.cc
+++ b/src/selection.cc
@@ -22,9 +22,9 @@ void on_buffer_change(const Buffer& buffer, SelectionList& sels,
const BufferCoord& begin, const BufferCoord& end, LineCount end_line)
{
auto update_beg = std::lower_bound(sels.begin(), sels.end(), begin,
- [](const Selection& s, const BufferCoord& c) { return std::max(s.first().coord(), s.last().coord()) < c; });
+ [](const Selection& s, const BufferCoord& c) { return std::max(s.first(), s.last()) < c; });
auto update_only_line_beg = std::upper_bound(sels.begin(), sels.end(), end_line,
- [](LineCount l, const Selection& s) { return l < std::min(s.first().coord(), s.last().coord()).line; });
+ [](LineCount l, const Selection& s) { return l < std::min(s.first(), s.last()).line; });
if (update_beg != update_only_line_beg)
{
@@ -50,10 +50,9 @@ void on_buffer_change(const Buffer& buffer, SelectionList& sels,
template<bool assume_different_line, bool assume_greater_than_begin>
struct UpdateInsert
{
- void operator()(const Buffer& buffer, BufferIterator& it,
+ void operator()(const Buffer& buffer, BufferCoord& coord,
const BufferCoord& begin, const BufferCoord& end) const
{
- auto coord = it.coord();
if (assume_different_line)
kak_assert(begin.line < coord.line);
if (not assume_greater_than_begin and coord < begin)
@@ -62,17 +61,15 @@ struct UpdateInsert
coord.column = end.column + coord.column - begin.column;
coord.line += end.line - begin.line;
- it = coord;
}
};
template<bool assume_different_line, bool assume_greater_than_begin>
struct UpdateErase
{
- void operator()(const Buffer& buffer, BufferIterator& it,
+ void operator()(const Buffer& buffer, BufferCoord& coord,
const BufferCoord& begin, const BufferCoord& end) const
{
- auto coord = it.coord();
if (not assume_greater_than_begin and coord < begin)
return;
if (assume_different_line)
@@ -89,7 +86,6 @@ struct UpdateErase
else
coord.line -= end.line - begin.line;
}
- it = coord;
}
};