Buffer: add is_valid(BufferCoord) method
This commit is contained in:
parent
dd3a7f739d
commit
72ef210e1b
|
@ -446,4 +446,11 @@ void Buffer::notify_saved()
|
|||
}
|
||||
}
|
||||
|
||||
bool Buffer::is_valid(const BufferCoord& c) const
|
||||
{
|
||||
return (c.line < line_count() and c.column < m_lines[c.line].length()) or
|
||||
(c.line == line_count() - 1 and c.column == m_lines.back().length()) or
|
||||
(c.line == line_count() and c.column == 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -123,6 +123,8 @@ public:
|
|||
String string(const BufferIterator& begin,
|
||||
const BufferIterator& end) const;
|
||||
|
||||
bool is_valid(const BufferCoord& c) const;
|
||||
|
||||
BufferIterator begin() const;
|
||||
BufferIterator end() const;
|
||||
ByteCount character_count() const;
|
||||
|
|
|
@ -20,12 +20,7 @@ inline const Buffer& BufferIterator::buffer() const
|
|||
|
||||
inline bool BufferIterator::is_valid() const
|
||||
{
|
||||
return m_buffer and
|
||||
((line() < m_buffer->line_count() and
|
||||
column() < m_buffer->m_lines[line()].length()) or
|
||||
((line() == m_buffer->line_count() and column() == 0)) or
|
||||
(line() == m_buffer->line_count() - 1 and
|
||||
column() == m_buffer->m_lines.back().length()));
|
||||
return m_buffer and m_buffer->is_valid(m_coord);
|
||||
}
|
||||
|
||||
inline void BufferIterator::clamp(bool avoid_eol)
|
||||
|
|
Loading…
Reference in New Issue
Block a user