mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGUI: Add TextDocument::span_at(TextPosition)
This commit is contained in:
parent
4e0ab1dd22
commit
23c4f10027
Notes:
sideshowbarker
2024-07-19 01:38:51 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/23c4f100274
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() } };
|
||||
}
|
||||
|
||||
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; }
|
||||
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();
|
||||
|
|
Loading…
Reference in a new issue