A multi-line text editor. See text_area().
Super class
Widget -> TextArea
Public fields
focusableText areas can be focused.
placeholderText shown while the area is empty.
line_numbersShow a line number gutter?
wrapWrap long lines (
TRUE) or scroll horizontally?read_onlyBlock editing (cursor, selection, copy and search still work)?
languageOptional language name passed to the configured highlighter.
tab_sizeSpaces inserted by Tab (and used for tabs in loaded text).
tab_behavior"focus": Tab moves focus (default, safe in forms);"indent": Tab inserts spaces and Shift+Tab removes them.auto_indentCopy the indentation of the current line on Enter?
highlighterOptional function
(lines, state)returning a list of per-line data frames with 1-based inclusivestart,end,token.validateNULLorfunction(value)returningNULL(valid) or an error message.
Active bindings
valueThe text. Assigning replaces it (see
set_text()).textThe text (read-only alias of
value).linesThe lines as a character vector.
n_linesNumber of lines.
cursor_row, cursor_columnCursor position, 1-based (column 1 is before the first character).
selectionThe selected text (
""if none).can_undo, can_redoIs there something to undo / redo?
history_sizeCharacters held by the undo history.
match_countNumber of matches of the current search.
find_openIs the find bar open?
validDoes the value pass
validate?errorThe validation message, or
NULL.
Methods
Inherited methods
Widget$add_class()Widget$ancestors()Widget$animate()Widget$arrange_children()Widget$bind()Widget$bind_reactive()Widget$bindings()Widget$blur()Widget$capture_mouse()Widget$child_clip()Widget$clear()Widget$computed_style()Widget$focus()Widget$format()Widget$get_state()Widget$has_class()Widget$invalidate()Widget$invalidate_paint()Widget$is_displayed()Widget$is_enabled()Widget$layout_descend()Widget$layout_differs()Widget$matches()Widget$mount()Widget$on()Widget$post_message()Widget$print()Widget$query()Widget$query_one()Widget$refresh()Widget$release_mouse()Widget$remove()Widget$remove_children()Widget$remove_class()Widget$render()Widget$render_lines()Widget$run_action()Widget$run_process()Widget$run_worker()Widget$set()Widget$set_interval()Widget$set_state()Widget$set_timeout()Widget$toggle_class()Widget$walk()
TextArea$new()
Create a text area.
Usage
TextArea$new(
value = "",
placeholder = "",
id = NULL,
classes = NULL,
style = NULL,
disabled = FALSE,
line_numbers = FALSE,
wrap = TRUE,
read_only = FALSE,
language = NULL,
tab_size = 4L,
tab_behavior = "focus",
auto_indent = FALSE,
validate = NULL,
max_history = 200L,
highlighter = NULL
)Arguments
valueInitial text.
placeholderPlaceholder text.
id, classes, style, disabledSee Widget.
line_numbers, wrap, read_only, language, tab_size, tab_behavior, auto_indentSee the fields.
validateValidation function.
max_historyMaximum number of undo steps.
highlighterOptional function
(lines, state)returning a list of per-line data frames with 1-based inclusivestart,end,token.
TextArea$on_key()
Printable keys replace the selection or are inserted at the cursor; Ctrl+C / Ctrl+X copy / cut a selection. While the find bar is open, keys edit the search text.
TextArea$set_text()
Replace the whole text. Clears the undo history and moves the cursor to the start.
TextArea$select_range()
Select a range (1-based rows and columns; column 1 is before the first character).
TextArea$cursor_position()
Cursor position. Columns count grapheme clusters and terminal display cells, both 1-based.
TextArea$copy()
Copy the selection to the app clipboard (and the system
clipboard via OSC 52 when system = TRUE and supported).
TextArea$find()
Search for text and select the first match at or after the cursor.
TextArea$replace_all()
Replace all matches in one document edit. If the edit is larger than the bounded undo budget, it is applied without retaining an undo record.
TextArea$action_delete_to_line_end()
Delete from the cursor to the end of the line (or the line break when the cursor is at the end).
TextArea$paint()
Draw the visible part of the text.
Arguments
bufferA ScreenBuffer.
areaVisible part of the region.
stComputed style.