visual-carets.dhover×156all
#!/usr/bin/env dub
/+ dub.sdl:
name "editor-visual-carets"
targetPath "build"
dependency "sparkles:ui" path="../../.."
buildType "checked" {
    buildOptions "optimize" "inline" "debugInfo"
}
+/
/// A fixed RTL row demonstrates the editor context boundary without a renderer.
module 
(module) visual_carets_example

A fixed RTL row demonstrates the editor context boundary without a renderer.

visual_carets_example
;
import
(package) std
std
.
(module) std.stdio
Category Symbols
File handles _popen File isFileHandle openNetwork stderr stdin stdout
Reading chunks lines readf readfln readln
Writing toFile write writef writefln writeln
Misc KeepTerminator LockType StdioException

Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio is publically imported when importing std.stdio.

There are three layers of I/O:

  1. The lowest layer is the operating system layer. The two main schemes are Windows and Posix.

  2. C's stdio.h which unifies the two operating system schemes.

  3. std.stdio, this module, unifies the various stdio.h implementations into a high level package for D programs.

Source

std/stdio.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Alex Rønne Petersen
stdio
:
(alias template) visual_carets_example.writeln = std.stdio.writeln(T...)(T args)

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
;
import
(package) sparkles
sparkles
.
(package) sparkles.text_buffer
text_buffer
.
(module) sparkles.text_buffer.summary

The measures every node of a text's tree caches for its subtree.

A measure is additive under concatenation, so a node's summary is the sum of its children's and a position can be located by descending the tree. Malformed UTF-8 counts as the replacement characters UtfMode.replacement reads: one scalar and one UTF-16 unit per maximal subpart.

Specification

docs/specs/text-buffer/SPEC.md (TXB-TEXT4, TXB-OWN4).

summary
:
(enum) sparkles.text_buffer.summary.Affinity

Which side of an ambiguous boundary a position belongs to.

Affinity
;
import
(package) sparkles
sparkles
.
(package) sparkles.text_buffer
text_buffer
.
(module) sparkles.text_buffer.text

Text: an immutable UTF-8 text in a persistent summary tree.

Copying a text is O(1) and allocation-free; every "modifying" operation returns a new text that shares all untouched subtrees with its arguments. Positions are byte offsets. Lines end before their line feed, or before the CR of a CR LF pair.

Never in a GC-allocated array. A text counts its references, and druntime fills a GC array, from an array literal or by appending with ~=, by blitting its elements without the copy that counts one; the collector later releases them again. Keep texts, and anything holding one (Edit, ChangeSet), in a sparkles.base.buffer buffer or a static array.

Specification

docs/specs/text-buffer/SPEC.md §2–3.

text
:
(struct) sparkles.text_buffer.text.Text

An immutable byte sequence, normally UTF-8, held in a summary tree.

Text is a Regular value: copies are independent, == compares contents, and copying is one atomic increment. It is the size of one pointer.

Text
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.command

The editor's command vocabulary (EDC1–EDC11).

Commands are named by effect, not by key, so any key table can bind them (KEY11). A command is a small pointer-free value: text arrives as a TextId into the host's input text pool, so a command can sit in a key table, an event queue or a recording and be compared with ==.

Specification

docs/specs/ui/editor.md §3.

command
:
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
,
(struct) sparkles.ui.editor.command.EditCommand

One editing command.

EditCommand
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.context

What a step reads besides the state (EDT2, EDT7): the time, the viewport height, and the visual-line structure of the laid-out text.

A context is any type with the members isEditContext names, so a view can answer from its own layout and a test from plain logical lines. Every query is a pure function of the text it is given.

A layout context may additionally offer horizontalCaret(text, range, direction, extend) -> CaretTarget. It selects the next visual caret, including a nonempty selection's visual collapse edge. The step retains the returned affinity and keeps the logical anchor when extending. Without this primitive, grapheme motion retains logical order. lineBoundaryCaret(text, position, affinity, boundary) -> CaretTarget may likewise supply the visual left/right edge of the wrapped row for Home/End. For vertical motion, caretColumn(text, line, CaretTarget) -> size_t measures a caret's goal column with its affinity, and caretAt(text, line, column) -> CaretTarget returns the nearest caret together with the side of a soft wrap or bidi boundary that draws it there. Vertical motion always resolves the head's row with its affinity. LayoutContext (sparkles.ui.editor.layout) answers all of these from one cell-grid layout. The context must answer for the supplied revision, never from stale geometry.

Specification

docs/specs/ui/editor.md §2.

context
:
(struct) sparkles.ui.editor.context.CaretTarget

A source byte position and the side of an ambiguous visual boundary it belongs to.

CaretTarget
,
(struct) sparkles.ui.editor.context.LogicalContext

A context without layout (EDT7): visual lines are logical lines, ending before LF or the CR of CR LF, and columns are terminal cells. This is exactly how an editor behaves in a terminal without soft wrapping.

LogicalContext
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.field

EditorField: an editor ready to embed as a text field (EDU4).

It owns the editor state, a small pool for the text that keys and pastes carry, and the target's default key table. A host routes a focused field's keys and pastes to it and reads back whether the text changed, was submitted or was cancelled, and whether the field asked for the clipboard. The kill ring is the host session's when the host provides one (EDY1), else the field's own.

Specification

docs/specs/ui/editor.md §5–8.

field
:
(struct) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo)
FieldTextPool
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.kill_ring

Readline's kill ring (EDY1): a short, bounded history of killed text that only the editor reads, separate from the system clipboard.

An entry holds one part per range of the kill that made it, each a Text slice of the document, so a kill of any size is shared rather than copied and is never truncated. One ring serves every editor of a host session; the host owns it and passes it to the step by value.

Specification

docs/specs/ui/editor.md §5.

kill_ring
:
(struct) sparkles.ui.editor.kill_ring.KillRing

The ring: at most size entries, the oldest dropped when full.

Examples

KillRing ring;
ring.size = 3;
foreach (i, word; ["one", "two", "three", "four"])
{
    const Text[1] parts = [Text(word)];
    const dropped = ring.push(KillEntry.of(parts[]));
    assert(dropped == (i == 3));
}
assert(ring.length == 3);
assert(ring.at(0).part(0) == "four");
assert(ring.at(2).part(0) == "two");
assert(ring.at(3).part(0) == "four", "yank-pop cycles");

const Text[2] two = [Text("ab"), Text("cd")];
const Text[2] more = [Text("X"), Text("Y")];
const entry = KillEntry.of(two[]);
const forward = entry.extended(KillEntry.of(more[]), false);
assert(forward.part(0) == "abX" && forward.part(1) == "cdY");
const backward = entry.extended(KillEntry.of(more[]), true);
assert(backward.part(0) == "Xab" && backward.joinedByLine == "Xab\nYcd");
KillRing
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.selection

Selection ranges and the normalized selection set (EDT4).

A range has an anchor that stays and a head that moves; the head is where the caret is drawn, and a range whose anchor equals its head is a caret. A selection set holds at least one range, sorted, never overlapping, with exactly one primary.

Specification

docs/specs/ui/editor.md §1–2.

selection
:
(struct) sparkles.ui.editor.selection.SelectionSet

The editor's ranges: at least one, sorted by start, none overlapping, one primary. Copying is O(1) until one copy changes (SharedBuffer).

SelectionSet
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.layout

A cell-grid paragraph layout and the editor context that answers from it (EDT7; editor application EAP17–EAP18).

ParagraphLayout lays out one logical line — a bidi paragraph — as grapheme clusters on terminal cells: base resolves the paragraph's levels (UAX #9), its line opportunities (UAX #14) and each cluster's width, and the layout wraps greedily at the opportunities, resolves each visual row's levels and orders its clusters (L1, L2). It owns no Unicode algorithm of its own.

LayoutContext is an isEditContext that answers every editor query — visual rows, vertical columns, visual Left/Right, Home/End and the input method's caret area — from that one layout. A view draws the same rows with visualRowSpans (sparkles.ui.components.editor) and hit-tests through caretAtColumn, so drawing, hits and motion share one result for a revision. Layouts are a pure function of the text's bytes and the options, so a result is reused only for byte-equal text: a stale layout cannot direct an edit.

Cells are the toolkit's cell grid. Proportional shaped flow belongs to sparkles:text-layout`` and is not attempted here; within a cluster, a font still shapes, but joining across clusters on the grid is the renderer's.

Specification

docs/specs/editor/SPEC.md §5, docs/specs/ui/editor.md §2.

layout
:
(struct) sparkles.ui.editor.layout.LayoutContext

An edit context that answers from ParagraphLayout (EAP17): soft-wrapped visual rows, visual Left/Right and Home/End, and caret columns with affinity.

The few most recently used paragraphs are kept, keyed by their bytes' revision: a cached layout answers only while the text is byte-equal.

LayoutContext
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.state

The editor's state (EDT1): a Regular value advanced only by step.

Specification

docs/specs/ui/editor.md §2.

state
:
(struct) sparkles.ui.editor.state.EditorState

The editor's whole state.

EditorState
;
import
(package) sparkles
sparkles
.
(package) sparkles.ui
ui
.
(package) sparkles.ui.editor
editor
.
(module) sparkles.ui.editor.step

The editor's one transition (EDT2): ``step(state, ring, texts, command, context) → (state, ring, effects).

The step is weakly pure and deterministic: it reads no clock, clipboard or layout, only its arguments. texts resolves the TextIds a command carries (any type with withText(id, fn), such as a TextPool), and context answers the time and the visual-line queries (isEditContext).

Specification

docs/specs/ui/editor.md §2–5.

step
:
(alias template) visual_carets_example.stepInPlace = sparkles.ui.editor.step.stepInPlace(Texts, Context)(ref EditorState state, ref KillRing ring, ref scope Texts texts, in EditCommand command, ref Context context) if (isTextSource!Texts && isEditContext!Context)

step applied in place. Nonthrowing providers move state and ring in and back without copying. Potentially throwing providers use a value copy and publish only after success, preserving the caller's state on unwinding.

stepInPlace
;
/// The row is known independently: Bet at the left, Alef at the right. struct
(struct) visual_carets_example.FixedRtlRow

The row is known independently: Bet at the left, Alef at the right.

FixedRtlRow
{
(struct) sparkles.ui.editor.context.LogicalContext

A context without layout (EDT7): visual lines are logical lines, ending before LF or the CR of CR LF, and columns are terminal cells. This is exactly how an editor behaves in a terminal without soft wrapping.

LogicalContext
(field) sparkles.ui.editor.context.LogicalContext visual_carets_example.FixedRtlRow.logical
logical
;
alias logical this; /// A real layout would resolve the current wrapped row and its caret stops here.
(struct) sparkles.ui.editor.context.CaretTarget

A source byte position and the side of an ambiguous visual boundary it belongs to.

CaretTarget
sparkles.ui.editor.context.CaretTarget visual_carets_example.FixedRtlRow.lineBoundaryCaret(in sparkles.text_buffer.text.Text text, ulong position, sparkles.text_buffer.summary.Affinity affinity, sparkles.ui.editor.command.Boundary boundary) const pure nothrow @nogc @safe

A real layout would resolve the current wrapped row and its caret stops here.

lineBoundaryCaret
(in
(struct) sparkles.text_buffer.text.Text

An immutable byte sequence, normally UTF-8, held in a summary tree.

Text is a Regular value: copies are independent, == compares contents, and copying is one atomic increment. It is the size of one pointer.

Text
(parameter) const(sparkles.text_buffer.text.Text) text
text
,
(alias) object.size_t = ulong
size_t
(parameter) ulong position
position
,
(enum) sparkles.text_buffer.summary.Affinity

Which side of an ambiguous boundary a position belongs to.

Affinity
(parameter) sparkles.text_buffer.summary.Affinity affinity
affinity
,
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
(parameter) sparkles.ui.editor.command.Boundary boundary
boundary
)
const @safe pure nothrow @nogc { assert(
(parameter) const(sparkles.text_buffer.text.Text) text
text
== "אב");
return
(parameter) sparkles.ui.editor.command.Boundary boundary
boundary
==
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
.
(enum value) sparkles.ui.editor.command.Boundary.start = cast(ubyte)0u
start
?
(struct) sparkles.ui.editor.context.CaretTarget

A source byte position and the side of an ambiguous visual boundary it belongs to.

CaretTarget
(4,
(enum) sparkles.text_buffer.summary.Affinity

Which side of an ambiguous boundary a position belongs to.

Affinity
.
(enum value) sparkles.text_buffer.summary.Affinity.before = cast(ubyte)0u
before
)
:
(struct) sparkles.ui.editor.context.CaretTarget

A source byte position and the side of an ambiguous visual boundary it belongs to.

CaretTarget
(0,
(enum) sparkles.text_buffer.summary.Affinity

Which side of an ambiguous boundary a position belongs to.

Affinity
.
(enum value) sparkles.text_buffer.summary.Affinity.after = 1
after
);
} } void
void D main() @safe
main
() @safe
{ auto
(local variable) sparkles.ui.editor.state.EditorState state
state
=
(struct) sparkles.ui.editor.state.EditorState

The editor's whole state.

EditorState
.
sparkles.ui.editor.state.EditorState sparkles.ui.editor.state.EditorState.create(scope const(char)[] text, sparkles.ui.editor.state.EditorOptions options = EditorOptions(false, true, IndentOptions(true, cast(ubyte)4u, false), null, Duration(5000000L), null, 0LU), core.time.MonoTimeImpl!(ClockType.normal) time = MonoTimeImpl(0L)) pure nothrow @nogc @safe

A state holding text with a caret at its end.

create
("אב");
(local variable) sparkles.ui.editor.state.EditorState state
state
.
(field) sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.state.EditorState.selection
selection
=
sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.selection.SelectionSet.opAssign(sparkles.ui.editor.selection.SelectionSet p) pure nothrow @nogc return ref @trusted
SelectionSet
.
sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.selection.SelectionSet.caret(ulong at) pure nothrow @nogc @safe

A single caret at at.

caret
(2);
(struct) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo)
FieldTextPool
(local variable) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) input
input
;
(struct) sparkles.ui.editor.kill_ring.KillRing

The ring: at most size entries, the oldest dropped when full.

Examples

KillRing ring;
ring.size = 3;
foreach (i, word; ["one", "two", "three", "four"])
{
    const Text[1] parts = [Text(word)];
    const dropped = ring.push(KillEntry.of(parts[]));
    assert(dropped == (i == 3));
}
assert(ring.length == 3);
assert(ring.at(0).part(0) == "four");
assert(ring.at(2).part(0) == "two");
assert(ring.at(3).part(0) == "four", "yank-pop cycles");

const Text[2] two = [Text("ab"), Text("cd")];
const Text[2] more = [Text("X"), Text("Y")];
const entry = KillEntry.of(two[]);
const forward = entry.extended(KillEntry.of(more[]), false);
assert(forward.part(0) == "abX" && forward.part(1) == "cdY");
const backward = entry.extended(KillEntry.of(more[]), true);
assert(backward.part(0) == "Xab" && backward.joinedByLine == "Xab\nYcd");
KillRing
(local variable) sparkles.ui.editor.kill_ring.KillRing ring
ring
;
(struct) visual_carets_example.FixedRtlRow

The row is known independently: Bet at the left, Alef at the right.

FixedRtlRow
(local variable) visual_carets_example.FixedRtlRow context
context
;
sparkles.ui.editor.effect.EditEffects sparkles.ui.editor.step.stepInPlace!(sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo), visual_carets_example.FixedRtlRow)(ref sparkles.ui.editor.state.EditorState state, ref sparkles.ui.editor.kill_ring.KillRing ring, ref scope sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) texts, in sparkles.ui.editor.command.EditCommand command, ref visual_carets_example.FixedRtlRow context) pure @nogc @safe

step applied in place. Nonthrowing providers move state and ring in and back without copying. Potentially throwing providers use a value copy and publish only after success, preserving the caller's state on unwinding.

stepInPlace
(
(local variable) sparkles.ui.editor.state.EditorState state
state
,
(local variable) sparkles.ui.editor.kill_ring.KillRing ring
ring
,
(local variable) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) input
input
,
(struct) sparkles.ui.editor.command.EditCommand

One editing command.

EditCommand
.
sparkles.ui.editor.command.EditCommand sparkles.ui.editor.command.EditCommand.lineBoundary(sparkles.ui.editor.command.Boundary boundary, bool extend = false) pure nothrow @nogc @safe
lineBoundary
(
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
.
(enum value) sparkles.ui.editor.command.Boundary.start = cast(ubyte)0u
start
),
(local variable) visual_carets_example.FixedRtlRow context
context
);
void std.stdio.writeln!(string, ulong)(string __param_0, ulong __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("Home byte: ",
(local variable) sparkles.ui.editor.state.EditorState state
state
.
(field) sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.state.EditorState.selection
selection
.
sparkles.ui.editor.selection.EditRange sparkles.ui.editor.selection.SelectionSet.primary() const pure nothrow @nogc scope @safe

The primary range.

primary
.
(field) ulong sparkles.ui.editor.selection.EditRange.head
head
);
sparkles.ui.editor.effect.EditEffects sparkles.ui.editor.step.stepInPlace!(sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo), visual_carets_example.FixedRtlRow)(ref sparkles.ui.editor.state.EditorState state, ref sparkles.ui.editor.kill_ring.KillRing ring, ref scope sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) texts, in sparkles.ui.editor.command.EditCommand command, ref visual_carets_example.FixedRtlRow context) pure @nogc @safe

step applied in place. Nonthrowing providers move state and ring in and back without copying. Potentially throwing providers use a value copy and publish only after success, preserving the caller's state on unwinding.

stepInPlace
(
(local variable) sparkles.ui.editor.state.EditorState state
state
,
(local variable) sparkles.ui.editor.kill_ring.KillRing ring
ring
,
(local variable) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) input
input
,
(struct) sparkles.ui.editor.command.EditCommand

One editing command.

EditCommand
.
sparkles.ui.editor.command.EditCommand sparkles.ui.editor.command.EditCommand.lineBoundary(sparkles.ui.editor.command.Boundary boundary, bool extend = false) pure nothrow @nogc @safe
lineBoundary
(
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
.
(enum value) sparkles.ui.editor.command.Boundary.end = 1
end
),
(local variable) visual_carets_example.FixedRtlRow context
context
);
void std.stdio.writeln!(string, ulong)(string __param_0, ulong __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("End byte: ",
(local variable) sparkles.ui.editor.state.EditorState state
state
.
(field) sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.state.EditorState.selection
selection
.
sparkles.ui.editor.selection.EditRange sparkles.ui.editor.selection.SelectionSet.primary() const pure nothrow @nogc scope @safe

The primary range.

primary
.
(field) ulong sparkles.ui.editor.selection.EditRange.head
head
);
// The production context derives the same answers from the bidi layout. auto
(local variable) sparkles.ui.editor.state.EditorState laidOut
laidOut
=
(struct) sparkles.ui.editor.state.EditorState

The editor's whole state.

EditorState
.
sparkles.ui.editor.state.EditorState sparkles.ui.editor.state.EditorState.create(scope const(char)[] text, sparkles.ui.editor.state.EditorOptions options = EditorOptions(false, true, IndentOptions(true, cast(ubyte)4u, false), null, Duration(5000000L), null, 0LU), core.time.MonoTimeImpl!(ClockType.normal) time = MonoTimeImpl(0L)) pure nothrow @nogc @safe

A state holding text with a caret at its end.

create
("אב");
(local variable) sparkles.ui.editor.state.EditorState laidOut
laidOut
.
(field) sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.state.EditorState.selection
selection
=
sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.selection.SelectionSet.opAssign(sparkles.ui.editor.selection.SelectionSet p) pure nothrow @nogc return ref @trusted
SelectionSet
.
sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.selection.SelectionSet.caret(ulong at) pure nothrow @nogc @safe

A single caret at at.

caret
(2);
(struct) sparkles.ui.editor.layout.LayoutContext

An edit context that answers from ParagraphLayout (EAP17): soft-wrapped visual rows, visual Left/Right and Home/End, and caret columns with affinity.

The few most recently used paragraphs are kept, keyed by their bytes' revision: a cached layout answers only while the text is byte-equal.

LayoutContext
(local variable) sparkles.ui.editor.layout.LayoutContext layout
layout
;
sparkles.ui.editor.effect.EditEffects sparkles.ui.editor.step.stepInPlace!(sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo), sparkles.ui.editor.layout.LayoutContext)(ref sparkles.ui.editor.state.EditorState state, ref sparkles.ui.editor.kill_ring.KillRing ring, ref scope sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) texts, in sparkles.ui.editor.command.EditCommand command, ref sparkles.ui.editor.layout.LayoutContext context) pure @nogc @safe

step applied in place. Nonthrowing providers move state and ring in and back without copying. Potentially throwing providers use a value copy and publish only after success, preserving the caller's state on unwinding.

stepInPlace
(
(local variable) sparkles.ui.editor.state.EditorState laidOut
laidOut
,
(local variable) sparkles.ui.editor.kill_ring.KillRing ring
ring
,
(local variable) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) input
input
,
(struct) sparkles.ui.editor.command.EditCommand

One editing command.

EditCommand
.
sparkles.ui.editor.command.EditCommand sparkles.ui.editor.command.EditCommand.lineBoundary(sparkles.ui.editor.command.Boundary boundary, bool extend = false) pure nothrow @nogc @safe
lineBoundary
(
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
.
(enum value) sparkles.ui.editor.command.Boundary.start = cast(ubyte)0u
start
),
(local variable) sparkles.ui.editor.layout.LayoutContext layout
layout
);
void std.stdio.writeln!(string, ulong)(string __param_0, ulong __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("Layout Home byte: ",
(local variable) sparkles.ui.editor.state.EditorState laidOut
laidOut
.
(field) sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.state.EditorState.selection
selection
.
sparkles.ui.editor.selection.EditRange sparkles.ui.editor.selection.SelectionSet.primary() const pure nothrow @nogc scope @safe

The primary range.

primary
.
(field) ulong sparkles.ui.editor.selection.EditRange.head
head
);
sparkles.ui.editor.effect.EditEffects sparkles.ui.editor.step.stepInPlace!(sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo), sparkles.ui.editor.layout.LayoutContext)(ref sparkles.ui.editor.state.EditorState state, ref sparkles.ui.editor.kill_ring.KillRing ring, ref scope sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) texts, in sparkles.ui.editor.command.EditCommand command, ref sparkles.ui.editor.layout.LayoutContext context) pure @nogc @safe

step applied in place. Nonthrowing providers move state and ring in and back without copying. Potentially throwing providers use a value copy and publish only after success, preserving the caller's state on unwinding.

stepInPlace
(
(local variable) sparkles.ui.editor.state.EditorState laidOut
laidOut
,
(local variable) sparkles.ui.editor.kill_ring.KillRing ring
ring
,
(local variable) sparkles.base.pool.text_pool.TextPool!(InputTextTag, 4LU, 4096LU, 4096LU, Reuse.lifo) input
input
,
(struct) sparkles.ui.editor.command.EditCommand

One editing command.

EditCommand
.
sparkles.ui.editor.command.EditCommand sparkles.ui.editor.command.EditCommand.lineBoundary(sparkles.ui.editor.command.Boundary boundary, bool extend = false) pure nothrow @nogc @safe
lineBoundary
(
(enum) sparkles.ui.editor.command.Boundary

Which end of a line or the document.

Boundary
.
(enum value) sparkles.ui.editor.command.Boundary.end = 1
end
),
(local variable) sparkles.ui.editor.layout.LayoutContext layout
layout
);
void std.stdio.writeln!(string, ulong)(string __param_0, ulong __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("Layout End byte: ",
(local variable) sparkles.ui.editor.state.EditorState laidOut
laidOut
.
(field) sparkles.ui.editor.selection.SelectionSet sparkles.ui.editor.state.EditorState.selection
selection
.
sparkles.ui.editor.selection.EditRange sparkles.ui.editor.selection.SelectionSet.primary() const pure nothrow @nogc scope @safe

The primary range.

primary
.
(field) ulong sparkles.ui.editor.selection.EditRange.head
head
);
}