fltk.text
FLTK Text Widgets
This module provides text editing and display widgets:
- TextBuffer: Text content storage for text widgets
- TextDisplay: Read-only text display widget
- TextEditor: Full-featured editable text widget
License
BSD-3-ClauseCopyright
Copyright © 2025 DDN (D Developer Network) Members
Types 3
classTextBuffer
Text buffer for storing and manipulating text content.
TextBuffer holds the text content displayed by TextDisplay widgets. Multiple displays can share the same buffer.
Example:
auto buffer = new TextBuffer();
buffer.text = "Hello, World!";
buffer.append("\nMore text");
auto display = new TextDisplay(10, 10, 300, 200);
display.buffer = buffer;Methods
void text(string content)Sets the buffer's text content.void append(string content)Appends text to the buffer.void insert(int pos, string content)Inserts text at a position.void remove(int start, int end)Removes text from a range.Constructors
this()Creates a new text buffer.this(TextBufferPtr handle, bool owned = false)Creates a wrapper around an existing buffer handle.Destructors
classTextDisplay : Widget
Text display widget for showing text content.
TextDisplay shows the content of a TextBuffer. It supports scrolling and text selection but is read-only.
Example:
auto buffer = new TextBuffer();
buffer.text = "Some text content...";
auto display = new TextDisplay(10, 10, 300, 200, "Output:");
display.buffer = buffer;Methods
TextBuffer buffer()Gets the text buffer.void buffer(TextBuffer buf)Sets the text buffer.void scrollTo(int line)Scrolls to a specific line.void textFont(int font)Sets the text font.void textSize(int size)Sets the text size.void textColor(uint color)Sets the text color.void cursorColor(uint color)Sets the cursor color.void showCursor(bool visible)Shows or hides the cursor.void wrapMode(WrapMode mode, int margin = 0)Sets the wrap mode.void lineNumberWidth(int width)Sets the line number display width.Constructors
this(int x, int y, int width, int height, string label = null)Creates a new text display widget.Destructors
Nested Templates
WrapModeWrap mode options.classTextEditor : Widget
Editable text widget.
TextEditor provides a full-featured text editing widget with support for copy, cut, paste, and text insertion.
Example:
auto buffer = new TextBuffer();
auto editor = new TextEditor(10, 10, 400, 300, "Editor:");
editor.buffer = buffer;
buffer.text = "Hello, World!";Methods
TextBuffer buffer()Gets the text buffer.void buffer(TextBuffer buf)Sets the text buffer.void copy()Copies selected text to clipboard.void cut()Cuts selected text to clipboard.void paste()Pastes text from clipboard.void insert(string text)Inserts text at the current cursor position.Constructors
this(int x, int y, int width, int height, string label = null)Destructors