diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-09-30 16:22:03 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-09-30 16:22:03 +0200 |
| commit | 801e3eaae25964dd297c3ffeb00fc28475e3da86 (patch) | |
| tree | 6668e9a1abe897735627c9634cce8a3349262654 /src/window.cc | |
| parent | 6cd5d807574c44cf2230b9e9d370b660817390c7 (diff) | |
Add a Window::display_position(const BufferIterator&) method
Diffstat (limited to 'src/window.cc')
| -rw-r--r-- | src/window.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/window.cc b/src/window.cc index 310268b6..7e62264a 100644 --- a/src/window.cc +++ b/src/window.cc @@ -129,6 +129,30 @@ void Window::scroll_to_keep_cursor_visible_ifn() } } +DisplayCoord Window::display_position(const BufferIterator& iterator) +{ + DisplayCoord res{0,0}; + for (auto& line : m_display_buffer.lines()) + { + if (line.buffer_line() == iterator.line()) + { + for (auto& atom : line) + { + auto& content = atom.content; + if (content.has_buffer_range() and + iterator >= content.begin() and iterator < content.end()) + { + res.column += iterator - content.begin(); + return res; + } + res.column += content.length(); + } + } + ++res.line; + } + return { 0, 0 }; +} + String Window::status_line() const { BufferCoord cursor = buffer().line_and_column_at(selections().back().last()); |
