|
|
Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
|
#include <cstddef>#include <optional>#include <span>#include <string_view>#include <vector>#include "donner/base/EcsRegistry.h"#include "donner/editor/TextEditor.h"#include "donner/svg/SVGDocument.h"#include "donner/svg/SVGElement.h"Namespaces | |
| namespace | donner |
| Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css. | |
Functions | |
| bool | donner::editor::HighlightElementSource (TextEditor &textEditor, const svg::SVGElement &element) |
| Selects the source range for an SVG element in the text editor. | |
| bool | donner::editor::HighlightSourceByteRange (TextEditor &textEditor, SourceByteRange byteRange) |
| Selects a raw source byte range in the text editor. | |
| std::optional< SourceByteRange > | donner::editor::EntitySourceByteRange (EntityHandle handle, std::string_view source) |
| Return the serialized XML node byte range for an ECS entity. | |
| std::optional< SourceByteRange > | donner::editor::ElementSourceByteRange (const svg::SVGElement &element, std::string_view source) |
| Return the serialized XML node byte range for an SVG element. | |
| std::vector< svg::SVGElement > | donner::editor::ExcludeSelectedSourceHoverElements (std::vector< svg::SVGElement > hoverElements, std::span< const svg::SVGElement > selectedElements) |
| Removes elements already represented by the active editor selection from source-hover candidates. | |
| std::vector< svg::SVGElement > | donner::editor::ExcludeDocumentRootSourceHoverElement (std::vector< svg::SVGElement > hoverElements, const svg::SVGDocument &document) |
| Removes the document root from automatic source-hover candidates. | |
| std::optional< svg::SVGElement > | donner::editor::FindElementAtSourceOffset (const svg::SVGDocument &document, std::string_view source, std::size_t offset) |
Finds the deepest SVG element whose source range contains offset. | |
| std::optional< svg::SVGElement > | donner::editor::FindElementNearSourceOffset (const svg::SVGDocument &document, std::string_view source, std::size_t offset) |
| Finds the SVG element nearest a source caret-like offset. | |
| std::optional< svg::SVGElement > | donner::editor::FindElementAtSourceCursor (const svg::SVGDocument &document, const TextEditor &textEditor) |
| Finds the deepest SVG element at the text editor cursor. | |
| std::optional< SourceByteRange > donner::editor::ElementSourceByteRange | ( | const svg::SVGElement & | element, |
| std::string_view | source ) |
Return the serialized XML node byte range for an SVG element.
| element | SVG element whose source node should be resolved. |
| source | Source text corresponding to the element's document. |
std::nullopt if no source range exists. | std::optional< SourceByteRange > donner::editor::EntitySourceByteRange | ( | EntityHandle | handle, |
| std::string_view | source ) |
Return the serialized XML node byte range for an ECS entity.
This is useful for resolved references where the caller has an EntityHandle but not a public svg::SVGElement wrapper.
| handle | Entity whose XML node source should be resolved. |
| source | Source text corresponding to the entity's document. |
std::nullopt if no source range exists. | std::vector< svg::SVGElement > donner::editor::ExcludeDocumentRootSourceHoverElement | ( | std::vector< svg::SVGElement > | hoverElements, |
| const svg::SVGDocument & | document ) |
Removes the document root from automatic source-hover candidates.
The root <svg> source range covers the entire document, so automatic source hover should not turn that into a whole-canvas overlay preview.
| hoverElements | Candidate elements resolved from the source hover position. |
| document | Document whose root should be excluded. |
| std::vector< svg::SVGElement > donner::editor::ExcludeSelectedSourceHoverElements | ( | std::vector< svg::SVGElement > | hoverElements, |
| std::span< const svg::SVGElement > | selectedElements ) |
Removes elements already represented by the active editor selection from source-hover candidates.
| hoverElements | Candidate elements resolved from the source hover position. |
| selectedElements | Active editor selection. |
| std::optional< svg::SVGElement > donner::editor::FindElementAtSourceCursor | ( | const svg::SVGDocument & | document, |
| const TextEditor & | textEditor ) |
Finds the deepest SVG element at the text editor cursor.
| document | Source-backed SVG document to inspect. |
| textEditor | Source editor containing the cursor and source text. |
std::nullopt if none is found. | std::optional< svg::SVGElement > donner::editor::FindElementAtSourceOffset | ( | const svg::SVGDocument & | document, |
| std::string_view | source, | ||
| std::size_t | offset ) |
Finds the deepest SVG element whose source range contains offset.
| document | Source-backed SVG document to inspect. |
| source | Source text corresponding to document. |
| offset | Byte offset in source. |
offset, or std::nullopt if none is found. | std::optional< svg::SVGElement > donner::editor::FindElementNearSourceOffset | ( | const svg::SVGDocument & | document, |
| std::string_view | source, | ||
| std::size_t | offset ) |
Finds the SVG element nearest a source caret-like offset.
Unlike FindElementAtSourceOffset, this treats positions immediately after an opening or closing tag as still referring to that tag's element. This is useful for cursor and hover interactions where the UI position can land on the character cell after the source token.
| document | Source-backed SVG document to inspect. |
| source | Source text corresponding to document. |
| offset | Byte offset in source. |
offset, or std::nullopt. | bool donner::editor::HighlightElementSource | ( | TextEditor & | textEditor, |
| const svg::SVGElement & | element ) |
Selects the source range for an SVG element in the text editor.
| textEditor | Source editor to update. |
| element | Element whose serialized XML node should be selected. |
| bool donner::editor::HighlightSourceByteRange | ( | TextEditor & | textEditor, |
| SourceByteRange | byteRange ) |
Selects a raw source byte range in the text editor.
| textEditor | Source editor to update. |
| byteRange | Half-open byte range to select. |