TextLayouter

Constructors

this
this(TextStyle defaultStyle)

Members

Enums

FindResult
enum FindResult

Finds the given text, setting the given selection to it, if found.

Functions

appendText
void appendText(const(char)[] text, StyleHandle style)

Appends text at the end, without disturbing user selection.

clearWasMutatedFlag
void clearWasMutatedFlag()

The layouter maintains a flag to tell if the content has been changed.

find
FindResult find(int selectionId, const(char)[] text, bool direction, bool wraparound)

Finds the given text, setting the given selection to it, if found.

getDrawableText
void getDrawableText(bool delegate(scope const(char)[] segment, TextStyle style, DrawingInformation information, CaretInformation[] carets...) dg, Rectangle box)

Gets the text that you need to draw, guaranteeing each call to your delegate will:

getText
void getText(void delegate(scope const(char)[] segment, TextStyle style) handler)

Calls your delegate for each segment of the text, guaranteeing you will be called exactly once for each non-nil char in the string and each slice will have exactly one style. A segment may be as small as a single char.

getTextString
string getTextString()

Gets the current text value as a plain-text string.

height
int height()

The rendered size of the text.

invalidateLayout
void invalidateLayout(size_t start, size_t end, int changeInTextLength)

This should be called (internally, end users don't need to see it) any time the text or style has changed.

isWordwrapPoint
bool isWordwrapPoint(dchar c)

Can override this to define if a char is a word splitter for word wrapping.

justificationWidth
void justificationWidth(int width)

Not implemented.

offsetOfClick
int offsetOfClick(Point p)

Selections have two parts: an anchor (typically set to where the user clicked the mouse down) and a focus (typically where the user released the mouse button). As you click and drag, you want to change the focus while keeping the anchor the same.

registerStyle
StyleHandle registerStyle(TextStyle style)

Registers a text style you can use in text segments.

relayoutIfNecessary
void relayoutIfNecessary()

This should be called (internally, end users don't need to see it) any time you're going to return something to the user that is dependent on the layout.

relayoutImplementation
void relayoutImplementation()
restoreState
void restoreState(const(State)* state)

The editor's internal state can be saved and restored as an opaque blob. You might use this to make undo checkpoints and similar.

saveState
const(State)* saveState()

The editor's internal state can be saved and restored as an opaque blob. You might use this to make undo checkpoints and similar.

selection
Selection selection(int id)

Gets the object representing the given selection.

selectionsAt
ulong selectionsAt(int offset)

Returns a bitmask of the selections active at any given offset.

styleAtPoint
const(TextStyle) styleAtPoint(Point p)
wasMutated
bool wasMutated()

The layouter maintains a flag to tell if the content has been changed.

width
int width()

The rendered size of the text.

wordWrapWidth
void wordWrapWidth(int width)

Set to 0 to disable word wrapping.

Structs

StyleHandle
struct StyleHandle

Represents a possible registered style for a segment of text.

Bugs

Only tested on Latin scripts at this time. Other things should be possible but might need work. Let me know if you need it and I'll see what I can do.

Meta