|
RADLib
RADical C++ application framework
|
Multi-line text editor model with derived display text and scrolling helpers. More...
#include <RADWidgets.h>
Inheritance diagram for RADUi::TextEditorModel:
Collaboration diagram for RADUi::TextEditorModel:Public Member Functions | |
| const std::string & | text () const |
| Returns raw editor text. More... | |
| void | setText (std::string text) |
| Replaces raw editor text. More... | |
| void | setEditorText (std::string text) |
| Replaces editor text after decoding visible whitespace when needed. More... | |
| size_t | insertText (size_t byteOffset, std::string_view text) |
| Inserts text at a byte offset and returns the new offset. More... | |
| const std::string & | displayText () const |
| Returns text transformed for display settings. More... | |
| const std::string & | lineNumberText () const |
| Returns newline-separated line-number text. More... | |
| size_t | lineCount () const |
| Returns current line count. More... | |
| bool | showLineNumbers () const |
| Returns true when line numbers should be displayed. More... | |
| void | setShowLineNumbers (bool show) |
| Enables or disables line-number display. More... | |
| bool | showWhitespace () const |
| Returns true when whitespace markers should be shown. More... | |
| void | setShowWhitespace (bool show) |
| Enables or disables visible whitespace display. More... | |
| double | scrollY () const |
| Returns model scroll offset in logical pixels. More... | |
| void | setScrollY (double scrollY) |
| Sets model scroll offset in logical pixels. More... | |
| double | slintViewportY () const |
| Returns Slint-compatible viewport offset. More... | |
| void | setSlintViewportY (double viewportY) |
| Sets scroll offset from a Slint viewport position. More... | |
| void | setViewportHeight (double viewportHeight) |
| Sets the visible viewport height used by ensureLineVisible(). More... | |
| double | viewportHeight () const |
| Returns the configured viewport height. More... | |
| void | ensureLineVisible (size_t line, double lineHeight=19.0, double padding=12.0) |
| Scrolls as needed so zero-based line is visible. More... | |
| void | scrollToLastLine (double lineHeight=19.0, double padding=12.0) |
| Scrolls so the last line is visible. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Static Public Member Functions | |
| static std::string | makeWhitespaceVisible (std::string_view text) |
| Converts tabs/spaces/newlines into visible display symbols. More... | |
| static std::string | decodeVisibleWhitespace (std::string_view text) |
| Converts visible whitespace display symbols back to raw text. More... | |
| static size_t | countLines (std::string_view text) |
| Counts text lines, treating empty text as one line. More... | |
| static std::string | makeLineNumberText (size_t lineCount) |
| Builds newline-separated line-number text for lineCount lines. More... | |
Public Attributes | |
| RADCore::Event< void() > | changed |
| Raised when editor text, display settings, or scroll state changes. More... | |
Multi-line text editor model with derived display text and scrolling helpers.
|
static |
Counts text lines, treating empty text as one line.
|
static |
Converts visible whitespace display symbols back to raw text.
| const std::string& RADUi::TextEditorModel::displayText | ( | ) | const |
Returns text transformed for display settings.
| void RADUi::TextEditorModel::ensureLineVisible | ( | size_t | line, |
| double | lineHeight = 19.0, |
||
| double | padding = 12.0 |
||
| ) |
Scrolls as needed so zero-based line is visible.
| size_t RADUi::TextEditorModel::insertText | ( | size_t | byteOffset, |
| std::string_view | text | ||
| ) |
Inserts text at a byte offset and returns the new offset.
| size_t RADUi::TextEditorModel::lineCount | ( | ) | const |
Returns current line count.
| const std::string& RADUi::TextEditorModel::lineNumberText | ( | ) | const |
Returns newline-separated line-number text.
|
static |
Builds newline-separated line-number text for lineCount lines.
|
static |
Converts tabs/spaces/newlines into visible display symbols.
| void RADUi::TextEditorModel::scrollToLastLine | ( | double | lineHeight = 19.0, |
| double | padding = 12.0 |
||
| ) |
Scrolls so the last line is visible.
| double RADUi::TextEditorModel::scrollY | ( | ) | const |
Returns model scroll offset in logical pixels.
| void RADUi::TextEditorModel::setEditorText | ( | std::string | text | ) |
Replaces editor text after decoding visible whitespace when needed.
| void RADUi::TextEditorModel::setScrollY | ( | double | scrollY | ) |
Sets model scroll offset in logical pixels.
| void RADUi::TextEditorModel::setShowLineNumbers | ( | bool | show | ) |
Enables or disables line-number display.
| void RADUi::TextEditorModel::setShowWhitespace | ( | bool | show | ) |
Enables or disables visible whitespace display.
| void RADUi::TextEditorModel::setSlintViewportY | ( | double | viewportY | ) |
Sets scroll offset from a Slint viewport position.
| void RADUi::TextEditorModel::setText | ( | std::string | text | ) |
Replaces raw editor text.
| void RADUi::TextEditorModel::setViewportHeight | ( | double | viewportHeight | ) |
Sets the visible viewport height used by ensureLineVisible().
| bool RADUi::TextEditorModel::showLineNumbers | ( | ) | const |
Returns true when line numbers should be displayed.
| bool RADUi::TextEditorModel::showWhitespace | ( | ) | const |
Returns true when whitespace markers should be shown.
| double RADUi::TextEditorModel::slintViewportY | ( | ) | const |
Returns Slint-compatible viewport offset.
| const std::string& RADUi::TextEditorModel::text | ( | ) | const |
Returns raw editor text.
| double RADUi::TextEditorModel::viewportHeight | ( | ) | const |
Returns the configured viewport height.
| RADCore::Event<void () > RADUi::TextEditorModel::changed |
Raised when editor text, display settings, or scroll state changes.