mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibGUI: Move text search functions from GTextEditor to GTextDocument
Also add a find_all() that retuns a Vector<GTextRange> and simply does a find_next() loop, returning all the matching ranges.
This commit is contained in:
Notes:
sideshowbarker
2024-07-19 11:28:58 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b8bf998b61b
@@ -20,6 +20,11 @@ struct GTextDocumentSpan {
|
||||
|
||||
class GTextDocument : public RefCounted<GTextDocument> {
|
||||
public:
|
||||
enum class SearchShouldWrap {
|
||||
No = 0,
|
||||
Yes
|
||||
};
|
||||
|
||||
class Client {
|
||||
public:
|
||||
virtual ~Client();
|
||||
@@ -61,6 +66,16 @@ public:
|
||||
|
||||
String text_in_range(const GTextRange&) const;
|
||||
|
||||
Vector<GTextRange> find_all(const StringView& needle) const;
|
||||
|
||||
GTextRange find_next(const StringView&, const GTextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes) const;
|
||||
GTextRange find_previous(const StringView&, const GTextPosition& start = {}, SearchShouldWrap = SearchShouldWrap::Yes) const;
|
||||
|
||||
GTextPosition next_position_after(const GTextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const;
|
||||
GTextPosition previous_position_before(const GTextPosition&, SearchShouldWrap = SearchShouldWrap::Yes) const;
|
||||
|
||||
char character_at(const GTextPosition&) const;
|
||||
|
||||
private:
|
||||
explicit GTextDocument(Client* client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user