1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 04:24:48 +03:00

Buffer: add iterator_at_line_{begin,end} methods

This commit is contained in:
Maxime Coste 2011-11-28 19:31:29 +00:00
parent 51ee0b61f4
commit b24dec89a2
2 changed files with 20 additions and 0 deletions

View File

@ -96,6 +96,17 @@ BufferCoord Buffer::clamp(const BufferCoord& line_and_column) const
return result;
}
BufferIterator Buffer::iterator_at_line_begin(const BufferIterator& iterator) const
{
return BufferIterator(*this, m_lines[line_at(iterator)]);
}
BufferIterator Buffer::iterator_at_line_end(const BufferIterator& iterator) const
{
BufferPos line = line_at(iterator) + 1;
return line < m_lines.size() ? BufferIterator(*this, m_lines[line]) : end();
}
void Buffer::compute_lines()
{
m_lines.clear();

View File

@ -149,6 +149,15 @@ public:
void register_modification_listener(BufferModificationListener* listener);
void unregister_modification_listener(BufferModificationListener* listener);
// returns an iterator pointing to the first character of the line
// iterator is on
BufferIterator iterator_at_line_begin(const BufferIterator& iterator) const;
// returns an iterator pointing to the character after the last of the
// line iterator is on (which is the first of the next line if iterator is
// not on the last one)
BufferIterator iterator_at_line_end(const BufferIterator& iterator) const;
private:
BufferChar at(BufferPos position) const;