Buffer: add iterator_at_line_{begin,end} methods
This commit is contained in:
parent
51ee0b61f4
commit
b24dec89a2
|
@ -96,6 +96,17 @@ BufferCoord Buffer::clamp(const BufferCoord& line_and_column) const
|
||||||
return result;
|
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()
|
void Buffer::compute_lines()
|
||||||
{
|
{
|
||||||
m_lines.clear();
|
m_lines.clear();
|
||||||
|
|
|
@ -149,6 +149,15 @@ public:
|
||||||
void register_modification_listener(BufferModificationListener* listener);
|
void register_modification_listener(BufferModificationListener* listener);
|
||||||
void unregister_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:
|
private:
|
||||||
BufferChar at(BufferPos position) const;
|
BufferChar at(BufferPos position) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user