LibGUI: Add TextDocument::span_at(TextPosition)

This commit is contained in:
Andreas Kling 2020-10-29 23:52:07 +01:00
parent 4e0ab1dd22
commit 23c4f10027
Notes: sideshowbarker 2024-07-19 01:38:51 +09:00
2 changed files with 11 additions and 0 deletions

View file

@ -699,4 +699,13 @@ TextRange TextDocument::range_for_entire_line(size_t line_index) const
return { { line_index, 0 }, { line_index, line(line_index).length() } };
}
const TextDocumentSpan* TextDocument::span_at(const TextPosition& position) const
{
for (auto& span : m_spans) {
if (span.range.contains(position))
return &span;
}
return nullptr;
}
}

View file

@ -93,6 +93,8 @@ public:
const Vector<TextDocumentSpan>& spans() const { return m_spans; }
void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[index] = move(span); }
const TextDocumentSpan* span_at(const TextPosition&) const;
void append_line(NonnullOwnPtr<TextDocumentLine>);
void remove_line(size_t line_index);
void remove_all_lines();