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 | |
| parent | 6cd5d807574c44cf2230b9e9d370b660817390c7 (diff) | |
Add a Window::display_position(const BufferIterator&) method
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.cc | 24 | ||||
| -rw-r--r-- | src/window.hh | 2 |
2 files changed, 26 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()); diff --git a/src/window.hh b/src/window.hh index f8e2ef3c..6e2d59d6 100644 --- a/src/window.hh +++ b/src/window.hh @@ -35,6 +35,8 @@ public: void center_selection(); void update_display_buffer(); + DisplayCoord display_position(const BufferIterator& it); + String status_line() const; HighlighterGroup& highlighters() { return m_highlighters; } |
