class documentation

class TextEditor(textbox.TextBox):

Constructor: TextEditor(view_manager, callback)

View In Hierarchy

A simple text editor built for Picoware.

The callback is useful for saving to a file or updating a preview in real-time.

Method __init__ Initialize the TextEditor with a view manager and an optional callback.
Method __setattr__ Set an attribute, routing text and cursor changes to setters.
Method callback.setter Set the callback function for text changes.
Method current_text.setter Set the current text content.
Method jump_to_bottom Moves the cursor and viewport to the end of the text and redraws.
Method jump_to_top Moves the cursor and viewport to the beginning of the text and redraws.
Method refresh Refresh the text editor display.
Method run Runs the text editor - call this every frame/tick.
Method set_text Set the text content of the text box.
Constant TYPE_ADD Undocumented
Constant TYPE_DELETE Undocumented
Property callback Gets the current callback function.
Property current_text Returns the current text content of the text box.
Method __process_text_input Process text input and update the textbox.
Instance Variable _callback Undocumented
Instance Variable _vm Undocumented
def __init__(self, view_manager, callback: callable = None):

Initialize the TextEditor with a view manager and an optional callback.

Parameters
view_manager:ViewManagerThe view manager to handle drawing and input.
callback:callableCallable taking (action_type, char, cursor_pos). Defaults to None.
def __setattr__(self, name, value):

Set an attribute, routing text and cursor changes to setters.

Parameters
name:strThe attribute name.
valueThe attribute value.
def callback(self, func: callable):

Set the callback function for text changes.

Parameters
func:callableThe new callback function.
def current_text(self, value: str):

Set the current text content.

Parameters
value:strThe new text content.
def jump_to_bottom(self):

Moves the cursor and viewport to the end of the text and redraws.

def jump_to_top(self):

Moves the cursor and viewport to the beginning of the text and redraws.

def refresh(self):

Refresh the text editor display.

def run(self) -> bool:

Runs the text editor - call this every frame/tick.

def set_text(self, text: str):

Set the text content of the text box.

Parameters
text:strThe new text content.
TYPE_ADD: int =

Undocumented

Value
0
TYPE_DELETE: int =

Undocumented

Value
1
@property
callback: callable =

Gets the current callback function.

@property
current_text: str =

Returns the current text content of the text box.

def __process_text_input(self, button: int):

Process text input and update the textbox.

Parameters
button:intThe button code pressed.
_callback =

Undocumented

_vm =

Undocumented