2021-02-07 16:56:02 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-07 16:56:02 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2021-09-30 23:19:58 +02:00
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
#include <LibGUI/TextDocument.h>
|
|
|
|
|
#include <LibGUI/TextPosition.h>
|
2021-02-07 16:56:02 +01:00
|
|
|
|
|
|
|
|
namespace Syntax {
|
|
|
|
|
|
|
|
|
|
class HighlighterClient {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~HighlighterClient() = default;
|
|
|
|
|
|
|
|
|
|
virtual Vector<GUI::TextDocumentSpan>& spans() = 0;
|
2022-04-01 20:58:27 +03:00
|
|
|
virtual Vector<GUI::TextDocumentSpan> const& spans() const = 0;
|
2021-02-07 16:56:02 +01:00
|
|
|
virtual void set_span_at_index(size_t index, GUI::TextDocumentSpan span) = 0;
|
|
|
|
|
|
2023-02-23 15:33:48 +00:00
|
|
|
virtual Vector<GUI::TextDocumentFoldingRegion>& folding_regions() = 0;
|
|
|
|
|
virtual Vector<GUI::TextDocumentFoldingRegion> const& folding_regions() const = 0;
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
virtual DeprecatedString highlighter_did_request_text() const = 0;
|
2021-02-07 16:56:02 +01:00
|
|
|
virtual void highlighter_did_request_update() = 0;
|
|
|
|
|
virtual GUI::TextDocument& highlighter_did_request_document() = 0;
|
|
|
|
|
virtual GUI::TextPosition highlighter_did_request_cursor() const = 0;
|
|
|
|
|
virtual void highlighter_did_set_spans(Vector<GUI::TextDocumentSpan>) = 0;
|
2023-02-23 15:33:48 +00:00
|
|
|
virtual void highlighter_did_set_folding_regions(Vector<GUI::TextDocumentFoldingRegion>) = 0;
|
2021-02-07 16:56:02 +01:00
|
|
|
|
|
|
|
|
void do_set_spans(Vector<GUI::TextDocumentSpan> spans) { highlighter_did_set_spans(move(spans)); }
|
2023-02-23 15:33:48 +00:00
|
|
|
void do_set_folding_regions(Vector<GUI::TextDocumentFoldingRegion> folding_regions) { highlighter_did_set_folding_regions(move(folding_regions)); }
|
2021-02-07 16:56:02 +01:00
|
|
|
void do_update() { highlighter_did_request_update(); }
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString get_text() const { return highlighter_did_request_text(); }
|
2021-02-07 16:56:02 +01:00
|
|
|
GUI::TextDocument& get_document() { return highlighter_did_request_document(); }
|
|
|
|
|
GUI::TextPosition get_cursor() const { return highlighter_did_request_cursor(); }
|
2022-03-29 16:31:26 +03:00
|
|
|
|
|
|
|
|
static constexpr auto span_collection_index = 0;
|
2021-02-07 16:56:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|