Overview
TheEditorView class provides a complete text editing UI component with viewport management, text selection, visual cursor control, and text wrapping. It works with an EditBuffer to provide the visual rendering layer for text editing.
Constructor
The render library instance.
Pointer to the native view.
The EditBuffer instance to render.
Static Methods
create
Creates a new EditorView instance.The EditBuffer to render.
The width of the viewport in characters.
The height of the viewport in lines.
A new EditorView instance.
Properties
ptr
The native pointer to the view.
extmarks
The extmarks controller for managing editor marks.
Viewport Management
setViewportSize
Sets the viewport dimensions.The viewport width in characters.
The viewport height in lines.
setViewport
Sets the complete viewport configuration.The horizontal offset.
The vertical offset (line number).
The viewport width in characters.
The viewport height in lines.
Whether to move the cursor into view.
getViewport
Gets the current viewport configuration.Object containing offsetX, offsetY, width, and height.
setScrollMargin
Sets the scroll margin for cursor visibility.The scroll margin in lines.
Text Wrapping
setWrapMode
Sets the text wrapping mode.The wrapping mode: “none” (no wrap), “char” (wrap at character), or “word” (wrap at word boundary).
Line Information
getVirtualLineCount
Gets the number of virtual lines visible in the viewport.The number of visible virtual lines.
getTotalVirtualLineCount
Gets the total number of virtual lines (including wrapping).The total number of virtual lines.
getLineInfo
Gets line information for the current viewport.Line information including offsets and positions.
getLogicalLineInfo
Gets logical line information (without wrapping).Logical line information.
Selection
setSelection
Sets the text selection by character offsets.The start character offset.
The end character offset.
Background color for the selection.
Foreground color for the selection.
updateSelection
Updates the end position of the current selection.The new end character offset.
Background color for the selection.
Foreground color for the selection.
resetSelection
Clears the current selection.getSelection
Gets the current selection range.The selection range or null if no selection.
hasSelection
Checks if there is an active selection.True if there is an active selection.
setLocalSelection
Sets selection using viewport-relative coordinates.The anchor X position in viewport.
The anchor Y position in viewport.
The focus X position in viewport.
The focus Y position in viewport.
Background color for the selection.
Foreground color for the selection.
Whether to update the cursor position.
Whether to follow the cursor.
True if the selection was set successfully.
updateLocalSelection
Updates selection using viewport-relative coordinates.The anchor X position in viewport.
The anchor Y position in viewport.
The focus X position in viewport.
The focus Y position in viewport.
Background color for the selection.
Foreground color for the selection.
Whether to update the cursor position.
Whether to follow the cursor.
True if the selection was updated successfully.
resetLocalSelection
Clears the local selection.getSelectedText
Gets the currently selected text.The selected text or empty string if no selection.
deleteSelectedText
Deletes the currently selected text.Cursor Operations
getCursor
Gets the current cursor position.The cursor position.
getVisualCursor
Gets the visual cursor position (accounting for wrapping).The visual cursor position with row, col, and offset.
setCursorByOffset
Sets the cursor by character offset.The character offset (0-based).
moveUpVisual
Moves the cursor up one visual line.moveDownVisual
Moves the cursor down one visual line.getNextWordBoundary
Finds the next word boundary from the cursor.The position of the next word boundary.
getPrevWordBoundary
Finds the previous word boundary from the cursor.The position of the previous word boundary.
getEOL
Gets the end-of-line position for the current line.The end-of-line position.
getVisualSOL
Gets the visual start-of-line position.The visual start-of-line position.
getVisualEOL
Gets the visual end-of-line position.The visual end-of-line position.
Text Retrieval
getText
Gets the text content visible in the view.The visible text content.
Placeholder Text
setPlaceholderStyledText
Sets placeholder text with styling.Array of styled text chunks for the placeholder.
Tab Indicators
setTabIndicator
Sets the character to display for tab characters.The character or Unicode code point to display for tabs.
setTabIndicatorColor
Sets the color for tab indicator characters.The color for tab indicators.
Measurement
measureForDimensions
Measures the text for given dimensions.The width to measure for.
The height to measure for.
Measurement result with line count and max width, or null on error.
Memory Management
destroy
Destroys the view and frees native resources.Types
Viewport
The vertical offset (line number).
The horizontal offset (column).
The viewport height in lines.
The viewport width in characters.
VisualCursor
The visual row position.
The visual column position.
The character offset from start of buffer.