diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-05-30 14:17:19 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-05-30 14:23:25 +0200 |
| commit | 28e127a48ad1c1fff4e34a68be887a56a888d309 (patch) | |
| tree | 5054b99bbbe8b092931342082b09a3a6dbc62586 /src/buffer.cc | |
| parent | 07c837931333b9ea9e227fb5eaf5f60111cb2545 (diff) | |
remove avoid_eol parameter from Buffer::{iterator_at,clamp}
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index cefc8f9f..49ef596a 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -86,10 +86,9 @@ bool Buffer::set_name(String name) return false; } -BufferIterator Buffer::iterator_at(const BufferCoord& line_and_column, - bool avoid_eol) const +BufferIterator Buffer::iterator_at(const BufferCoord& coord) const { - return BufferIterator(*this, clamp(line_and_column, avoid_eol)); + return BufferIterator(*this, clamp(coord)); } ByteCount Buffer::line_length(LineCount line) const @@ -98,17 +97,15 @@ ByteCount Buffer::line_length(LineCount line) const return m_lines[line].length(); } -BufferCoord Buffer::clamp(const BufferCoord& line_and_column, - bool avoid_eol) const +BufferCoord Buffer::clamp(BufferCoord coord) const { if (m_lines.empty()) - return BufferCoord(); + return BufferCoord{}; - BufferCoord result(line_and_column.line, line_and_column.column); - result.line = Kakoune::clamp(result.line, 0_line, line_count() - 1); - ByteCount max_col = std::max(0_byte, line_length(result.line) - (avoid_eol ? 2 : 1)); - result.column = Kakoune::clamp(result.column, 0_byte, max_col); - return result; + coord.line = Kakoune::clamp(coord.line, 0_line, line_count() - 1); + ByteCount max_col = std::max(0_byte, line_length(coord.line) - 1); + coord.column = Kakoune::clamp(coord.column, 0_byte, max_col); + return coord; } BufferIterator Buffer::iterator_at_line_begin(LineCount line) const |
