diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-03-18 23:40:26 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-03-18 23:40:26 +0000 |
| commit | 3e28539b81518f9f4f388a2ba32ca128b15a477c (patch) | |
| tree | 3652db5aadf34589a6a5ef37d24caa49393c5c87 /src/window.cc | |
| parent | d3738b858b9ae90e8eacce3a2e366a9f61c68b35 (diff) | |
Add a display coord to buffer coord method to Window
Diffstat (limited to 'src/window.cc')
| -rw-r--r-- | src/window.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/window.cc b/src/window.cc index 0e999162..aa9f2824 100644 --- a/src/window.cc +++ b/src/window.cc @@ -234,7 +234,7 @@ ByteCoord find_buffer_coord(const DisplayLine& line, const Buffer& buffer, } } -CharCoord Window::display_position(ByteCoord coord) +CharCoord Window::display_position(ByteCoord coord) const { LineCount l = 0; for (auto& line : m_display_buffer.lines()) @@ -247,6 +247,13 @@ CharCoord Window::display_position(ByteCoord coord) return { 0, 0 }; } +ByteCoord Window::buffer_coord(CharCoord coord) const +{ + if (0_line <= coord.line and coord.line < m_display_buffer.lines().size()) + return find_buffer_coord(m_display_buffer.lines()[(int)coord.line], buffer(), coord.column); + return { 0, 0 }; +} + ByteCoord Window::offset_coord(ByteCoord coord, CharCount offset) { return buffer().offset_coord(coord, offset); |
