mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
LibGUI: Add TextDocument::span_at(TextPosition)
This commit is contained in:
parent
4e0ab1dd22
commit
23c4f10027
2 changed files with 11 additions and 0 deletions
|
@ -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() } };
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,8 @@ public:
|
||||||
const Vector<TextDocumentSpan>& spans() const { return m_spans; }
|
const Vector<TextDocumentSpan>& spans() const { return m_spans; }
|
||||||
void set_span_at_index(size_t index, TextDocumentSpan span) { m_spans[index] = move(span); }
|
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 append_line(NonnullOwnPtr<TextDocumentLine>);
|
||||||
void remove_line(size_t line_index);
|
void remove_line(size_t line_index);
|
||||||
void remove_all_lines();
|
void remove_all_lines();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue