# Class EditorView

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.editor.EditorView

All Implemented Interfaces:
  `Animation, Editable, StyleListener, TextInputClient`

Direct Known Subclasses:
  `CodeView, EditField, RichView`

public class EditorView extends Component implements TextInputClient

The pure Codename One text editing surface. It renders a plain text `EditorDocument` with its own `Graphics` code, owns the caret and selection, handles pointer and keyboard interaction, and captures text through the low level `TextInputClient` contract (soft keyboard / IME) when the platform supports it, falling back to raw `keyPressed` capture on physical keyboard platforms.

This class provides the shared editing behavior. Feature layers (syntax highlighting, the gutter, styled rich text) subclass it and override `#paintContent(Graphics, int, int, int, int)` and the document/measurement hooks.

- ## Field Summary

  ### Fields inherited from class Component

  `BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR`

  ### Fields inherited from interface TextInputClient

  `KEY_BACKSPACE, KEY_COPY, KEY_CUT, KEY_DELETE, KEY_DOWN, KEY_END, KEY_ESCAPE, KEY_HOME, KEY_LEFT, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PASTE, KEY_REDO, KEY_RIGHT, KEY_SELECT_ALL, KEY_TAB, KEY_UNDO, KEY_UP, MOD_ALT, MOD_CTRL, MOD_SHIFT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `EditorView(EditorHost host, boolean codeMode)`
  Creates an editor view.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `animate()`
  Allows the animation to reduce "repaint" calls when it returns false.
  `protected int`
  `baseFontSizePixels()`
  Returns the base editor font size in pixels.
  `void`
  `blur()`
  Relinquishes focus and stops the active platform text-input session.
  `protected Dimension`
  `calcPreferredSize()`
  Calculates the preferred size based on component content.
  `protected Object`
  `captureDocumentState()`
  Captures feature-layer state associated with the document for undo/redo.
  `protected int`
  `columnAtX(int line, String text, int localX, Font f)`
  Returns the column nearest a given content-local x pixel on a line.
  `void`
  `commitText(String text)`
  Commits final text at the caret, replacing the active selection.
  `protected boolean`
  `consumesRawTextInput()`
  This view edits text, so key codes reaching it are characters rather than commands.
  `protected int`
  `contentTotalHeight()`
  Returns the total content height in pixels.
  `protected int`
  `contentWidth()`
  Returns the width available for text (component width minus padding and any gutter).
  `void`
  `copySelection()`
  Copies the selection to the clipboard.
  `void`
  `cutSelection()`
  Cuts the selection to the clipboard.
  `protected void`
  `deinitialize()`
  Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
  `void`
  `deleteBackward()`
  Deletes the selection, or the character before the caret when there is none.
  `void`
  `deleteSurroundingText(int before, int after)`
  Deletes text around the caret, the primary deletion path used by soft keyboards.
  `protected void`
  `documentEdited(int fromOffset)`
  Hook invoked when the document is mutated at `fromOffset`, used by feature layers (e.g. the code editor) to invalidate cached tokenization from the affected line onward.
  `protected void`
  `documentReplaced(int start, String removed, String inserted)`
  Hook invoked when a range is replaced, carrying the exact removed and inserted text so feature layers (e.g. the rich text editor) can keep a parallel style / block model in sync.
  `protected void`
  `documentReset()`
  Hook invoked when the whole document is reset (e.g. by `#setText(String)`), so feature layers can rebuild their parallel models.
  `void`
  `finishComposing()`
  Finalizes any active IME composition, committing the current marked text.
  `protected int`
  `firstVisibleLine()`
  Returns the first fully or partially visible line index.
  `protected void`
  `focusGained()`
  Callback allowing a developer to track when the component gains focus
  `protected void`
  `focusLost()`
  Callback allowing a developer to track wheh the component loses focus
  `int`
  `getCaretOffset()`
  Returns the current caret offset.
  `int[]`
  `getCaretRect()`
  Returns the caret rectangle in absolute screen pixels `{x, y, width, height}`, used by the platform to anchor the IME candidate window and the selection loupe near the rendered caret.
  `TextInputConfig`
  `getConfig()`
  Returns the configuration describing the desired keyboard type and input behavior.
  `protected int`
  `getContentLeftInset()`
  Returns the left inset (padding plus any gutter) at which text starts.
  `EditorDocument`
  `getDocument()`
  Returns the backing document.
  `TextInputState`
  `getEditingState()`
  Returns the current editing state (surrounding text, selection and composition) so the platform can seed autocorrect and prediction.
  `protected Font`
  `getEditorFont()`
  Returns the font used to render text.
  `protected int`
  `getHorizontalScroll()`
  Returns the current horizontal scroll offset in pixels.
  `protected int`
  `getLineHeight()`
  Returns the default height of a single visual line in pixels.
  `protected int`
  `getMaximumVerticalScroll()`
  Returns the largest valid vertical content offset.
  `int`
  `getSelectionEnd()`
  Returns the exclusive end offset of the selection (or the caret when none).
  `int`
  `getSelectionStart()`
  Returns the inclusive start offset of the selection (or the caret when none).
  `String`
  `getText()`
  Returns the whole document text.
  `protected int`
  `getTextColor()`
  Returns the default text color used by the base renderer.
  `int`
  `getTextLength()`
  Returns the total number of UTF-16 characters in the document.
  `String`
  `getTextRange(int start, int end)`
  Returns the text in `[start, end)`.
  `UndoManager`
  `getUndoManager()`
  Returns the undo manager.
  `protected int`
  `getVerticalScroll()`
  Returns the current vertical scroll offset in pixels.
  `protected void`
  `handleTab(boolean dedent)`
  Handles a tab key press (delivered as `#KEY_TAB`).
  `protected boolean`
  `handleTypedText(String text)`
  Hook giving feature layers a chance to intercept typed text before the default insertion (used by the code editor for bracket / quote auto close, tab expansion and auto indent).
  `boolean`
  `hasSelection()`
  True when a non empty selection exists.
  `protected EditorHost`
  `host()`
  Returns the host bridge, for feature layers that need to fire editor events.
  `void`
  `inputFocusGained()`
  Notifies the client that it gained the platform input focus (became first responder).
  `void`
  `inputFocusLost()`
  Notifies the client that it lost the platform input focus.
  `void`
  `insertText(String text)`
  Inserts text at the caret, replacing any active selection.
  `protected void`
  `invalidateLayout()`
  Invalidates the cached line layout (used by feature layers when line heights change).
  `boolean`
  `isEditableState()`
  True when editing is enabled.
  `protected boolean`
  `isEditAllowed(int start, int end)`
  Whether the given range may be modified.
  `void`
  `keyPressed(int keyCode)`
  If this Component is focused, the key pressed event will call this method
  `void`
  `keyReleased(int keyCode)`
  If this Component is focused, the key released event will call this method
  `void`
  `keyRepeated(int keyCode)`
  If this Component is focused, the key repeat event will call this method.
  `protected void`
  `laidOut()`
  This is a callback method to inform the Component when it's been laidout on the parent Container
  `protected int`
  `lineAtContentY(int y)`
  Returns the line index at the given content relative y pixel.
  `protected int`
  `lineContentOffsetX(int line)`
  Returns the extra left offset of a line's text within the content area (0 for plain text and code; the rich text editor overrides this for list bullets, indentation, block quotes and alignment so the caret and selection line up with the drawn text).
  `protected int`
  `lineHeightAt(int line)`
  Returns the height of the given line.
  `protected int`
  `lineTop(int line)`
  Returns the y pixel of the top of the given line in component local coordinates (scroll adjusted).
  `protected int`
  `lineTopContent(int line)`
  Returns the top y pixel of the given line relative to the content top (before scroll).
  `protected int[]`
  `lineVisualSegments(int line, String text, int from, int to, Font f)`
  Returns the visual selection segments for the logical range `[from, to)` on a line as a flat array of `{x, width, x, width, ...}` in content-local pixels.
  `void`
  `longPointerPress(int x, int y)`
  If this Component is focused this method is invoked when the user presses and holds the pointer on the Component
  `protected int`
  `measureColumnX(int line, String text, int col, Font f)`
  Returns the visual pixel x (from the start of a line) of the caret before logical column `col`.
  `void`
  `moveCaret(int newCaret, boolean extend)`
  Moves the caret to a new offset, optionally extending the selection.
  `int`
  `offsetAtPoint(int absX, int absY)`
  Returns the document offset nearest the given absolute screen point.
  `void`
  `onEditorAction(int action)`
  Delivers the keyboard return key action (done / next / search / send) configured through `TextInputConfig`.
  `void`
  `onKeyCommand(int command, int modifiers)`
  Delivers a non text key command (navigation, deletion, clipboard, undo).
  `void`
  `paint(Graphics g)`
  This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
  `protected void`
  `paintBeforeContent(Graphics g, int originX, int originY, int firstLine, int lastLine, int lineHeight, Font f)`
  Hook invoked before the visible lines are drawn, used by the code editor to paint the line number gutter.
  `protected void`
  `paintComposingUnderline(Graphics g, int line, String text, int lineStart, int lineEnd, int tx, int ly, int lineHeight, Font f)`
  Draws the IME composition (marked text) underline for the portion of the active composing range that falls on the given line.
  `protected void`
  `paintContent(Graphics g, int originX, int originY, int width, int height)`
  Paints the document content.
  `protected void`
  `paintLine(Graphics g, int line, String text, int x, int y, int lineHeight, Font f)`
  Paints a single line of text.
  `protected void`
  `paintLineDecorations(Graphics g, int line, String text, int x, int y, int lineHeight, Font f)`
  Hook invoked after a line's text is drawn, used by the code editor to paint diagnostic squiggles.
  `void`
  `pasteClipboard()`
  Inserts the clipboard contents at the caret.
  `protected void`
  `pasteClipboardData(Object data)`
  Inserts clipboard data.
  `void`
  `performRedo()`
  Redoes the last undone edit.
  `void`
  `performUndo()`
  Undoes the last edit.
  `void`
  `pointerDragged(int x, int y)`
  If this Component is focused, the pointer dragged event will call this method
  `void`
  `pointerPressed(int x, int y)`
  If this Component is focused, the pointer pressed event will call this method
  `void`
  `pointerReleased(int x, int y)`
  If this Component is focused, the pointer released event will call this method
  `int[]`
  `rectForOffset(int offset)`
  Returns the caret rectangle for an arbitrary offset in absolute screen pixels `{x, y, w, h}`.
  `protected final void`
  `refreshUndoAfterState()`
  Refreshes the most recent undo unit after a feature layer finishes decorating an inserted range.
  `void`
  `replaceRange(int start, int end, String text)`
  Replaces the range `[start, end)` with `text` (a direct, range based edit from the platform).
  `protected void`
  `replaceRange(int start, int end, String text, boolean record)`
  Replaces the range `[start, end)` with `text`, updating the caret, history and platform input state.
  `protected void`
  `restoreDocumentState(Object state)`
  Restores a feature-layer snapshot captured by `#captureDocumentState()`.
  `protected void`
  `scrollByPixels(int deltaX, int deltaY)`
  Scrolls the content by the given pixel deltas (as delivered by the mouse wheel gesture).
  `void`
  `selectAll()`
  Selects the entire document.
  `int[]`
  `selectionRects(int start, int end)`
  Returns the selection rectangles covering `[start, end)` as a flat array of absolute-pixel rectangles `{x, y, w, h, x, y, w, h, ...}` (one entry per visual line the range spans).
  `void`
  `setBackgroundColor(int color)`
  Sets the surface background color.
  `void`
  `setComposingText(String text, int relativeCaret)`
  Updates the in progress IME composition (marked text) at the caret.
  `void`
  `setEditableState(boolean editable)`
  Enables or disables editing.
  `protected final void`
  `setEditorHost(EditorHost h)`
  Binds the editor host after construction.
  `void`
  `setFontSizeDips(int dips)`
  Optionally overrides the editor font size in device independent pixels.
  `void`
  `setSelectionColor(int color)`
  Sets the selection highlight color.
  `void`
  `setSelectionRange(int start, int end)`
  Sets the selection to `[start, end)` (a caret when equal).
  `void`
  `setText(String text)`
  Replaces the whole document text and resets the caret and history.
  `void`
  `setTextColor(int color)`
  Sets the default text color.
  `protected boolean`
  `uniformLineHeight()`
  True when every line has the same height (the common case, and the fast path).

  ### Methods inherited from class Component

  `accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, fireClicked, getAbsoluteX, getAbsoluteY, getAccessibilityNode, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSemantics, getSideGap, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initLaf, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, longKeyPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, paramString, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, removeStylusListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setPullToRefresh, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### EditorView

    public EditorView(EditorHost host, boolean codeMode)

    Creates an editor view.

    ###### Parameters

    - `host`: the bridge to the owning editor component / platform input source

    - `codeMode`: true for a code editor (autocorrect and autocapitalize disabled)

- ## Method Details

  - ### scrollByPixels

    protected void scrollByPixels(int deltaX, int deltaY)
    Scrolls the content by the given pixel deltas (as delivered by the mouse wheel gesture).

  - ### setEditorHost

    protected final void setEditorHost(EditorHost h)
    Binds the editor host after construction. Used by a subclass that is its own host (see `com.codename1.ui.EditField`), which cannot pass `this` to the constructor.

  - ### getDocument

    public EditorDocument getDocument()
    Returns the backing document.

  - ### getUndoManager

    public UndoManager getUndoManager()
    Returns the undo manager.

  - ### getCaretOffset

    public int getCaretOffset()
    Returns the current caret offset.

  - ### setBackgroundColor

    public void setBackgroundColor(int color)
    Sets the surface background color.

  - ### setTextColor

    public void setTextColor(int color)
    Sets the default text color.

  - ### setSelectionColor

    public void setSelectionColor(int color)
    Sets the selection highlight color.

  - ### getTextColor

    protected int getTextColor()
    Returns the default text color used by the base renderer.

  - ### setText

    public void setText(String text)
    Replaces the whole document text and resets the caret and history.

  - ### getText

    public String getText()
    Returns the whole document text.

  - ### setEditableState

    public void setEditableState(boolean editable)
    Enables or disables editing.

  - ### isEditableState

    public boolean isEditableState()
    True when editing is enabled.

  - ### blur

    public void blur()
    Relinquishes focus and stops the active platform text-input session.

  - ### baseFontSizePixels

    protected int baseFontSizePixels()
    Returns the base editor font size in pixels.

  - ### setFontSizeDips

    public void setFontSizeDips(int dips)
    Optionally overrides the editor font size in device independent pixels. Pass 0 to use the font supplied by the component's style (the default, which is correctly sized for the current skin).

  - ### getEditorFont

    protected Font getEditorFont()
    Returns the font used to render text. By default this is the component's style font (managed and correctly sized by Codename One, and refreshed when the skin / theme reloads, which avoids stale native font handles rendering as squares). Subclasses may override to supply styled variants.

  - ### getLineHeight

    protected int getLineHeight()
    Returns the default height of a single visual line in pixels.

  - ### lineHeightAt

    protected int lineHeightAt(int line)
    Returns the height of the given line. The default is uniform (`#getLineHeight()`); the rich text editor overrides this for headings and font size runs.

  - ### uniformLineHeight

    protected boolean uniformLineHeight()
    True when every line has the same height (the common case, and the fast path). Feature layers with variable line heights override this to return false.

  - ### invalidateLayout

    protected void invalidateLayout()
    Invalidates the cached line layout (used by feature layers when line heights change).

  - ### lineTopContent

    protected int lineTopContent(int line)
    Returns the top y pixel of the given line relative to the content top (before scroll).

  - ### contentTotalHeight

    protected int contentTotalHeight()
    Returns the total content height in pixels.

  - ### lineAtContentY

    protected int lineAtContentY(int y)
    Returns the line index at the given content relative y pixel.

  - ### getContentLeftInset

    protected int getContentLeftInset()
    Returns the left inset (padding plus any gutter) at which text starts.

  - ### contentWidth

    protected int contentWidth()
    Returns the width available for text (component width minus padding and any gutter).

  - ### hasSelection

    public boolean hasSelection()
    True when a non empty selection exists.

  - ### getSelectionStart

    public int getSelectionStart()
    Returns the inclusive start offset of the selection (or the caret when none).

  - ### getSelectionEnd

    public int getSelectionEnd()
    Returns the exclusive end offset of the selection (or the caret when none).

  - ### paint

    public void paint(Graphics g)
    Description copied from class: `Component`

    This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

    ###### Parameters

    - `g`: the component graphics
    Specified by:
      `paint` in interface `Animation`
    Overrides:
      `paint` in class `Component`

  - ### longPointerPress

    public void longPointerPress(int x, int y)
    Description copied from class: `Component`
    If this Component is focused this method is invoked when the user presses and holds the pointer on the Component
    Overrides:
      `longPointerPress` in class `Component`

  - ### paintContent

    protected void paintContent(Graphics g, int originX, int originY, int width, int height)

    Paints the document content. `originY` is already offset by the scroll position, so line `n` is at `originY + n * getLineHeight()`. Subclasses override to add highlighting, a gutter or styled runs but should call through for the shared caret / selection rendering, or reimplement it.

    ###### Parameters

    - `g`: the graphics context

    - `originX`: the x pixel at which line text starts

    - `originY`: the y pixel of the first line (scroll adjusted)

    - `width`: the content width

    - `height`: the content height

  - ### paintComposingUnderline

    protected void paintComposingUnderline(Graphics g, int line, String text, int lineStart, int lineEnd, int tx, int ly, int lineHeight, Font f)
    Draws the IME composition (marked text) underline for the portion of the active composing range that falls on the given line. The composing range is set by `#setComposingText(String, int)` while an input method is composing (e.g. CJK) and cleared by `#finishComposing()`.

  - ### paintBeforeContent

    protected void paintBeforeContent(Graphics g, int originX, int originY, int firstLine, int lastLine, int lineHeight, Font f)
    Hook invoked before the visible lines are drawn, used by the code editor to paint the line number gutter. `originY` is scroll adjusted so line `n` sits at `originY + n * lineHeight`.

  - ### paintLineDecorations

    protected void paintLineDecorations(Graphics g, int line, String text, int x, int y, int lineHeight, Font f)
    Hook invoked after a line's text is drawn, used by the code editor to paint diagnostic squiggles.

  - ### lineTop

    protected int lineTop(int line)
    Returns the y pixel of the top of the given line in component local coordinates (scroll adjusted).

  - ### firstVisibleLine

    protected int firstVisibleLine()
    Returns the first fully or partially visible line index.

  - ### getHorizontalScroll

    protected int getHorizontalScroll()
    Returns the current horizontal scroll offset in pixels.

  - ### getVerticalScroll

    protected int getVerticalScroll()
    Returns the current vertical scroll offset in pixels.

  - ### getMaximumVerticalScroll

    protected int getMaximumVerticalScroll()
    Returns the largest valid vertical content offset.

  - ### paintLine

    protected void paintLine(Graphics g, int line, String text, int x, int y, int lineHeight, Font f)

    Paints a single line of text. Subclasses override to add syntax coloring; the base implementation draws the whole line in the default text color.

    ###### Parameters

    - `g`: the graphics context

    - `line`: the zero based line index

    - `text`: the line text

    - `x`: the x pixel at which the line text starts

    - `y`: the top y pixel of the line

    - `lineHeight`: the line height

    - `f`: the font

  - ### offsetAtPoint

    public int offsetAtPoint(int absX, int absY)

    Returns the document offset nearest the given absolute screen point.

    ###### Parameters

    - `absX`: absolute x

    - `absY`: absolute y

    Specified by:
      `offsetAtPoint` in interface `TextInputClient`

  - ### consumesRawTextInput

    protected boolean consumesRawTextInput()

    This view edits text, so key codes reaching it are characters rather than commands.

    Only while it is editable. A read only view declines the insert in `keyReleased`, so claiming the code anyway took a colliding soft key away from the menu bar and then did nothing with it -- the command was silently lost.

    Overrides:
      `consumesRawTextInput` in class `Component`

  - ### isEditAllowed

    protected boolean isEditAllowed(int start, int end)

    Whether the given range may be modified. Subclasses that make part of the document read only override this so every mutation path is covered, including input method composition, which writes to the document without going through `#replaceRange(int, int, String, boolean)`.

    ###### Parameters

    - `start`: inclusive start offset of the edit

    - `end`: exclusive end offset of the edit

    Returns: true when the edit may proceed

  - ### replaceRange

    protected void replaceRange(int start, int end, String text, boolean record)

    Replaces the range `[start, end)` with `text`, updating the caret, history and platform input state.

    ###### Parameters

    - `start`: inclusive start offset

    - `end`: exclusive end offset

    - `text`: the replacement text (may be empty)

    - `record`: true to record the mutation for undo

  - ### documentEdited

    protected void documentEdited(int fromOffset)
    Hook invoked when the document is mutated at `fromOffset`, used by feature layers (e.g. the code editor) to invalidate cached tokenization from the affected line onward.

  - ### documentReplaced

    protected void documentReplaced(int start, String removed, String inserted)

    Hook invoked when a range is replaced, carrying the exact removed and inserted text so feature layers (e.g. the rich text editor) can keep a parallel style / block model in sync. The default is a no-op.

    ###### Parameters

    - `start`: the offset at which the replacement happened

    - `removed`: the removed text

    - `inserted`: the inserted text

  - ### documentReset

    protected void documentReset()
    Hook invoked when the whole document is reset (e.g. by `#setText(String)`), so feature layers can rebuild their parallel models. The default is a no-op.

  - ### captureDocumentState

    protected Object captureDocumentState()
    Captures feature-layer state associated with the document for undo/redo. Plain and code editors return null; rich editors override this to snapshot formatting, blocks, links and images.

  - ### restoreDocumentState

    protected void restoreDocumentState(Object state)
    Restores a feature-layer snapshot captured by `#captureDocumentState()`.

  - ### refreshUndoAfterState

    protected final void refreshUndoAfterState()
    Refreshes the most recent undo unit after a feature layer finishes decorating an inserted range.

  - ### insertText

    public void insertText(String text)
    Inserts text at the caret, replacing any active selection.

  - ### handleTypedText

    protected boolean handleTypedText(String text)

    Hook giving feature layers a chance to intercept typed text before the default insertion (used by the code editor for bracket / quote auto close, tab expansion and auto indent). Return true when the text was consumed. The default returns false.

    ###### Parameters

    - `text`: the text being typed / committed

  - ### handleTab

    protected void handleTab(boolean dedent)

    Handles a tab key press (delivered as `#KEY_TAB`). Feature layers override this for indent / dedent behavior. The default inserts a tab character on a plain tab and does nothing on a dedent (a plain editor has no indentation to remove).

    ###### Parameters

    - `dedent`: true when shift was held (shift-tab)

  - ### host

    protected EditorHost host()
    Returns the host bridge, for feature layers that need to fire editor events.

  - ### deleteBackward

    public void deleteBackward()
    Deletes the selection, or the character before the caret when there is none. This is what Backspace does, including its handling of a surrogate pair, and it is public so a host that has swallowed the keystroke -- a desktop menu accelerator, for instance -- can hand it back rather than approximating it with the IME oriented `#deleteSurroundingText(int, int)`.

  - ### moveCaret

    public void moveCaret(int newCaret, boolean extend)

    Moves the caret to a new offset, optionally extending the selection.

    ###### Parameters

    - `newCaret`: the target offset (clamped to the document)

    - `extend`: true to extend the selection from the current anchor

  - ### selectAll

    public void selectAll()
    Selects the entire document.

  - ### copySelection

    public void copySelection()
    Copies the selection to the clipboard. Public so a host that owns the platform menu bar can route its Copy item here: a menu accelerator consumes the keystroke before the editor sees it, so the host has to perform the operation on the editor's behalf.

  - ### cutSelection

    public void cutSelection()
    Cuts the selection to the clipboard. See `#copySelection()` for why this is public.

  - ### pasteClipboard

    public void pasteClipboard()
    Inserts the clipboard contents at the caret. See `#copySelection()` for why this is public.

  - ### pasteClipboardData

    protected void pasteClipboardData(Object data)
    Inserts clipboard data. Rich editor subclasses may override this to preserve formatting.

  - ### lineContentOffsetX

    protected int lineContentOffsetX(int line)
    Returns the extra left offset of a line's text within the content area (0 for plain text and code; the rich text editor overrides this for list bullets, indentation, block quotes and alignment so the caret and selection line up with the drawn text).

  - ### measureColumnX

    protected int measureColumnX(int line, String text, int col, Font f)
    Returns the visual pixel x (from the start of a line) of the caret before logical column `col`. For plain left-to-right text this is simply the substring width; for lines containing right-to-left or mixed (bidirectional) text it maps the logical column through the resolved visual order so the caret lines up with the reordered glyphs. The rich text editor overrides this to measure per styled run.

  - ### columnAtX

    protected int columnAtX(int line, String text, int localX, Font f)
    Returns the column nearest a given content-local x pixel on a line. Bidi aware: it locates the visual run containing the pixel and maps back to a logical column. The rich text editor overrides it to be styled-run aware.

  - ### lineVisualSegments

    protected int[] lineVisualSegments(int line, String text, int from, int to, Font f)
    Returns the visual selection segments for the logical range `[from, to)` on a line as a flat array of `{x, width, x, width, ...}` in content-local pixels. A bidi line can yield several disjoint segments; a plain line yields a single segment.

  - ### laidOut

    protected void laidOut()
    Description copied from class: `Component`
    This is a callback method to inform the Component when it's been laidout on the parent Container
    Overrides:
      `laidOut` in class `Component`

  - ### focusGained

    protected void focusGained()
    Description copied from class: `Component`
    Callback allowing a developer to track when the component gains focus
    Overrides:
      `focusGained` in class `Component`

  - ### focusLost

    protected void focusLost()
    Description copied from class: `Component`
    Callback allowing a developer to track wheh the component loses focus
    Overrides:
      `focusLost` in class `Component`

  - ### deinitialize

    protected void deinitialize()
    Description copied from class: `Component`
    Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.
    Overrides:
      `deinitialize` in class `Component`

  - ### animate

    public boolean animate()
    Description copied from class: `Component`

    Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the `com.codename1.ui.Display` class.

    ###### Returns

    true if a repaint is desired or false if no repaint is necessary

    Specified by:
      `animate` in interface `Animation`
    Overrides:
      `animate` in class `Component`

  - ### pointerPressed

    public void pointerPressed(int x, int y)
    Description copied from class: `Component`

    If this Component is focused, the pointer pressed event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerPressed` in class `Component`

  - ### pointerDragged

    public void pointerDragged(int x, int y)
    Description copied from class: `Component`

    If this Component is focused, the pointer dragged event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerDragged` in class `Component`

  - ### pointerReleased

    public void pointerReleased(int x, int y)
    Description copied from class: `Component`

    If this Component is focused, the pointer released event will call this method

    ###### Parameters

    - `x`: the pointer x coordinate

    - `y`: the pointer y coordinate

    Overrides:
      `pointerReleased` in class `Component`

  - ### keyPressed

    public void keyPressed(int keyCode)
    Description copied from class: `Component`

    If this Component is focused, the key pressed event will call this method

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.
    Overrides:
      `keyPressed` in class `Component`

  - ### keyRepeated

    public void keyRepeated(int keyCode)
    Description copied from class: `Component`

    If this Component is focused, the key repeat event will call this method.

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.
    Overrides:
      `keyRepeated` in class `Component`

  - ### keyReleased

    public void keyReleased(int keyCode)
    Description copied from class: `Component`

    If this Component is focused, the key released event will call this method

    ###### Parameters

    - `keyCode`: the key code value to indicate a physical key.
    Overrides:
      `keyReleased` in class `Component`

  - ### commitText

    public void commitText(String text)
    Description copied from interface: `TextInputClient`

    Commits final text at the caret, replacing the active selection. This is the normal path for a typed character, an accepted autocorrect suggestion, dictation and paste.

    ###### Parameters

    - `text`: the committed text
    Specified by:
      `commitText` in interface `TextInputClient`

  - ### setComposingText

    public void setComposingText(String text, int relativeCaret)
    Description copied from interface: `TextInputClient`

    Updates the in progress IME composition (marked text) at the caret. The composing text is not yet final and is typically rendered underlined; it is replaced on the next `#setComposingText` and finalized by `#finishComposing`.

    ###### Parameters

    - `text`: the current marked text

    - `relativeCaret`: caret position relative to the marked text (platform convention)

    Specified by:
      `setComposingText` in interface `TextInputClient`

  - ### finishComposing

    public void finishComposing()
    Description copied from interface: `TextInputClient`
    Finalizes any active IME composition, committing the current marked text.
    Specified by:
      `finishComposing` in interface `TextInputClient`

  - ### deleteSurroundingText

    public void deleteSurroundingText(int before, int after)
    Description copied from interface: `TextInputClient`

    Deletes text around the caret, the primary deletion path used by soft keyboards.

    ###### Parameters

    - `before`: number of UTF-16 units to delete before the caret

    - `after`: number of UTF-16 units to delete after the caret

    Specified by:
      `deleteSurroundingText` in interface `TextInputClient`

  - ### onKeyCommand

    public void onKeyCommand(int command, int modifiers)
    Description copied from interface: `TextInputClient`

    Delivers a non text key command (navigation, deletion, clipboard, undo). Text producing keys are delivered through `#commitText` instead.

    ###### Parameters

    - `command`: one of the `KEY_*` constants

    - `modifiers`: a bit mask of the `MOD_*` constants

    Specified by:
      `onKeyCommand` in interface `TextInputClient`

  - ### performUndo

    public void performUndo()
    Undoes the last edit.

  - ### performRedo

    public void performRedo()
    Redoes the last undone edit.

  - ### onEditorAction

    public void onEditorAction(int action)
    Description copied from interface: `TextInputClient`

    Delivers the keyboard return key action (done / next / search / send) configured through `TextInputConfig`.

    ###### Parameters

    - `action`: one of the `TextInputConfig` `ACTION_*` constants
    Specified by:
      `onEditorAction` in interface `TextInputClient`

  - ### getEditingState

    public TextInputState getEditingState()
    Description copied from interface: `TextInputClient`
    Returns the current editing state (surrounding text, selection and composition) so the platform can seed autocorrect and prediction. May return a window around the caret for very large documents.
    Specified by:
      `getEditingState` in interface `TextInputClient`

  - ### getCaretRect

    public int[] getCaretRect()
    Description copied from interface: `TextInputClient`
    Returns the caret rectangle in absolute screen pixels `{x, y, width, height}`, used by the platform to anchor the IME candidate window and the selection loupe near the rendered caret.
    Specified by:
      `getCaretRect` in interface `TextInputClient`

  - ### rectForOffset

    public int[] rectForOffset(int offset)
    Description copied from interface: `TextInputClient`
    Returns the caret rectangle for an arbitrary offset in absolute screen pixels `{x, y, w, h}`.
    Specified by:
      `rectForOffset` in interface `TextInputClient`

  - ### getTextLength

    public int getTextLength()
    Description copied from interface: `TextInputClient`
    Returns the total number of UTF-16 characters in the document.
    Specified by:
      `getTextLength` in interface `TextInputClient`

  - ### getTextRange

    public String getTextRange(int start, int end)
    Description copied from interface: `TextInputClient`
    Returns the text in `[start, end)`.
    Specified by:
      `getTextRange` in interface `TextInputClient`

  - ### selectionRects

    public int[] selectionRects(int start, int end)
    Description copied from interface: `TextInputClient`
    Returns the selection rectangles covering `[start, end)` as a flat array of absolute-pixel rectangles `{x, y, w, h, x, y, w, h, ...}` (one entry per visual line the range spans).
    Specified by:
      `selectionRects` in interface `TextInputClient`

  - ### replaceRange

    public void replaceRange(int start, int end, String text)
    Description copied from interface: `TextInputClient`
    Replaces the range `[start, end)` with `text` (a direct, range based edit from the platform).
    Specified by:
      `replaceRange` in interface `TextInputClient`

  - ### setSelectionRange

    public void setSelectionRange(int start, int end)
    Description copied from interface: `TextInputClient`
    Sets the selection to `[start, end)` (a caret when equal).
    Specified by:
      `setSelectionRange` in interface `TextInputClient`

  - ### getConfig

    public TextInputConfig getConfig()
    Description copied from interface: `TextInputClient`
    Returns the configuration describing the desired keyboard type and input behavior.
    Specified by:
      `getConfig` in interface `TextInputClient`

  - ### inputFocusGained

    public void inputFocusGained()
    Description copied from interface: `TextInputClient`
    Notifies the client that it gained the platform input focus (became first responder).
    Specified by:
      `inputFocusGained` in interface `TextInputClient`

  - ### inputFocusLost

    public void inputFocusLost()
    Description copied from interface: `TextInputClient`
    Notifies the client that it lost the platform input focus.
    Specified by:
      `inputFocusLost` in interface `TextInputClient`

  - ### calcPreferredSize

    protected Dimension calcPreferredSize()
    Description copied from class: `Component`

    Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

    ###### Returns

    the calculated preferred size based on component content

    Overrides:
      `calcPreferredSize` in class `Component`