Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
StructuredCssEdit.h File Reference
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include "donner/editor/FlashDecorations.h"
Include dependency graph for StructuredCssEdit.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::StructuredCssTarget
 Exact selection and edit boundaries for a source-backed CSS rule or declaration. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::editor::StructuredCssSourceEncoding : std::uint8_t {
  Text ,
  CData ,
  Attribute ,
  Unmapped
}
 XML source representation of the authored CSS item.
enum class  donner::editor::StructuredCssOperation {
  ReplaceSelector ,
  ReplaceName ,
  ReplaceValue ,
  AddImportant ,
  RemoveImportant ,
  InsertDeclaration ,
  InsertRule ,
  RemoveDeclaration ,
  RemoveRule
}
 Structured edit to a CSS rule or declaration.

Functions

std::optional< StructuredCssTarget > donner::editor::FindStructuredCssTarget (EditorApp &app, std::string_view source, std::size_t offset)
 Locate parsed CSS covering a source offset in the current editor snapshot.
bool donner::editor::CanInsertStructuredCssDeclaration (EditorApp &app, std::string_view source, const StructuredCssTarget &target)
 Check whether a declaration can be inserted at the current parsed source boundary.
bool donner::editor::ApplyStructuredCssEdit (EditorApp &app, DocumentSyncController &sync, TextEditor &editor, const StructuredCssTarget &target, StructuredCssOperation operation, std::string_view replacement={})
 Apply one CSS operation as one document command and one document undo step.
bool donner::editor::CanMoveStructuredCss (EditorApp &app, std::string_view source, const StructuredCssTarget &from, const StructuredCssTarget &destination, bool after)
 Check whether two revision-bound CSS targets can be reordered.
bool donner::editor::MoveStructuredCss (EditorApp &app, DocumentSyncController &sync, TextEditor &editor, const StructuredCssTarget &from, const StructuredCssTarget &destination, bool after)
 Move a CSS item relative to another compatible item.

Function Documentation

◆ ApplyStructuredCssEdit()

bool donner::editor::ApplyStructuredCssEdit ( EditorApp & app,
DocumentSyncController & sync,
TextEditor & editor,
const StructuredCssTarget & target,
StructuredCssOperation operation,
std::string_view replacement = {} )

Apply one CSS operation as one document command and one document undo step.

Parameters
appActive editor document.
syncSource owner that mirrors the committed document delta.
editorSource editor receiving the edit.
targetPreviously resolved, revision-bound CSS target.
operationRequested typed operation.
replacementAuthored CSS replacement for replace or insert operations.
Returns
True if the operation changed the source buffer.

◆ CanInsertStructuredCssDeclaration()

bool donner::editor::CanInsertStructuredCssDeclaration ( EditorApp & app,
std::string_view source,
const StructuredCssTarget & target )

Check whether a declaration can be inserted at the current parsed source boundary.

Parameters
appActive editor document.
sourceCurrent source pane contents.
targetPreviously resolved, revision-bound CSS target.

◆ CanMoveStructuredCss()

bool donner::editor::CanMoveStructuredCss ( EditorApp & app,
std::string_view source,
const StructuredCssTarget & from,
const StructuredCssTarget & destination,
bool after )

Check whether two revision-bound CSS targets can be reordered.

Parameters
appActive editor document.
sourceCurrent source pane contents.
fromDragged CSS item.
destinationCompatible destination of the same item kind.
afterInsert after rather than before the destination.

◆ FindStructuredCssTarget()

std::optional< StructuredCssTarget > donner::editor::FindStructuredCssTarget ( EditorApp & app,
std::string_view source,
std::size_t offset )

Locate parsed CSS covering a source offset in the current editor snapshot.

Parameters
appActive editor document.
sourceCurrent source pane contents.
offsetByte position that identifies the target.

◆ MoveStructuredCss()

bool donner::editor::MoveStructuredCss ( EditorApp & app,
DocumentSyncController & sync,
TextEditor & editor,
const StructuredCssTarget & from,
const StructuredCssTarget & destination,
bool after )

Move a CSS item relative to another compatible item.

Parameters
appActive editor document.
syncSource owner that mirrors the committed document delta.
editorSource editor receiving the committed source delta.
fromDragged CSS item.
destinationCompatible destination of the same item kind.
afterInsert after rather than before the destination.
Returns
True when the source changed.