# Package com.codename1.ui.editor

package com.codename1.ui.editor

The pure Codename One text editing engine that backs `com.codename1.ui.RichTextArea` and `com.codename1.ui.CodeEditor`.

Overview

This package renders and edits text entirely with the Codename One graphics pipeline - it owns the document model, caret, selection, undo stack, layout and painting, and binds directly to the platform text input source (soft keyboard, autocorrect and IME composition) rather than embedding a native web view. Because the engine draws every glyph itself it behaves consistently across platforms and supports mixed left-to-right and right-to-left text via the Unicode Bidirectional Algorithm.

Key types

- `EditorDocument` - the mutable character buffer with a line index that caret, selection, undo and the platform input source all operate on.

- `EditorView` - the base `com.codename1.ui.Component` that measures, paints, scrolls and hit-tests the document and implements the text input client contract; `CodeView` and `RichView` extend it for the code and rich text feature layers.

- `BidiUtil` - the Unicode Bidirectional Algorithm used to resolve embedding levels and reorder mixed-direction runs for measurement and paint.

- `HtmlImporter` - parses the HTML fragment accepted by `RichTextArea` into the styled block/run model the engine renders.

These classes are the implementation of the two public editor components; applications interact with `RichTextArea` and `CodeEditor` rather than with the types here.

- Related Packages
  Package
  Description
  com.codename1.ui
  Main widget package containing the component/container "composite" similar both in terminology and design to Swing/AWT.
- Class
  Description
  CodePureEditor
  The pure code editor backend.
  CodeView
  The pure code editor surface.
  EditorDocument
  The plain text backing store shared by the pure Codename One editors.
  EditorHost
  The bridge a pure editor view uses to reach the owning editor component and, through it, the platform text input source.
  EditorView
  The pure Codename One text editing surface.
  HtmlImporter
  Parses an HTML string into the pure rich text editor model (plain text plus per character `TextStyle` and per paragraph `RichBlocks.BlockAttr`).
  HtmlImporter.Result
  The imported content.
  HtmlSerializer
  Serializes the pure rich text editor model (text + `InlineStyles` + `RichBlocks`) back into an HTML string for `RichTextArea#getHtml`.
  InlineStyles
  The per character inline style model for the pure rich text editor.
  InlineStyles.StylePredicate
  A predicate over a style, used by `#allInRange`.
  InlineStyles.StyleTransform
  A transform applied to a character's style, used to toggle bold, set a color, etc.
  LanguageDef
  Describes the lexical rules of a programming language for the pure code editor's tokenizer: its keyword set, comment styles, string delimiters and number syntax.
  PureEditor
  The pure Codename One editor backend.
  RichBlocks
  The per paragraph block attribute model for the pure rich text editor.
  RichBlocks.BlockAttr
  A single paragraph's block attributes.
  RichPureEditor
  The pure rich text editor backend.
  RichTextImporter
  Converts supported rich-text interchange formats into the HTML fragment consumed by the shared `HtmlImporter`.
  RichView
  The pure rich text editor surface.
  TextStyle
  An immutable inline text style (bold / italic / underline / strike, foreground color, highlight color and relative font size) used by the pure rich text editor.
  ThemePalette
  The color palette for the pure code editor, mirroring the light (GitHub style) and dark (VS Code style) themes used by the previous `BrowserComponent` backend so switching backends is visually consistent.
  Tokenizer
  A small, allocation light, stateful lexer for the pure code editor.
  Tokenizer.Token
  A colored span within a line: `[start, start + length)` has the given kind.
  Tokenizer.TokenLine
  The result of tokenizing one line: the colored spans and the lexer state to carry to the next line.
  UndoManager
  A compact undo / redo stack for the pure editors.