Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IEditor

A widget that provides a code editor.

Hierarchy

Index

Properties

charWidth

charWidth: number

The widget of a character in the editor in pixels.

edgeRequested

edgeRequested: ISignal<IEditor, EdgeLocation>

A signal emitted when either the top or bottom edge is requested.

host

host: HTMLElement

The DOM node that hosts the editor.

isDisposed

isDisposed: boolean

Test whether the object has been disposed.

Notes

This property is always safe to access.

lineCount

lineCount: number

Get the number of lines in the eidtor.

lineHeight

lineHeight: number

The height of a line in the editor in pixels.

model

model: IModel

The model used by the editor.

selectionStyle

selectionStyle: ISelectionStyle

The default selection style for the editor.

uuid

uuid: string

The uuid of this selection owner.

Methods

addKeydownHandler

  • Add a keydown handler to the editor.

    Parameters

    Returns IDisposable

    A disposable that can be used to remove the handler.

blur

  • blur(): void
  • Explicitly blur the editor.

    Returns void

clearHistory

  • clearHistory(): void

dispose

  • dispose(): void
  • Dispose of the resources held by the object.

    Notes

    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    Undefined Behavior

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    Returns void

focus

  • focus(): void
  • Brings browser focus to this editor text.

    Returns void

getCoordinateForPosition

  • Get the window coordinates given a cursor position.

    Parameters

    Returns ICoordinate

    The coordinates of the position.

getCursorPosition

getLine

  • getLine(line: number): string | undefined
  • Returns the content for the given line number.

    Parameters

    • line: number

      The line of interest.

    Returns string | undefined

    The value of the line.

    Notes

    Lines are 0-based, and accessing a line out of range returns undefined.

getOffsetAt

  • Find an offset for the given position.

    Parameters

    • position: IPosition

      The position of interest.

    Returns number

    The offset at the position, clamped to the extent of the editor contents.

getOption

  • getOption<K>(option: K): IConfig[K]
  • Get a config option for the editor.

    Type parameters

    • K: keyof IConfig

    Parameters

    • option: K

    Returns IConfig[K]

getPositionAt

  • getPositionAt(offset: number): IPosition | undefined
  • Find a position for the given offset.

    Parameters

    • offset: number

      The offset of interest.

    Returns IPosition | undefined

    The position at the offset, clamped to the extent of the editor contents.

getPositionForCoordinate

  • Get the cursor position given window coordinates.

    Parameters

    Returns IPosition | null

    The position of the coordinates, or null if not contained in the editor.

getSelection

getSelections

getTokenForPosition

getTokens

hasFocus

  • hasFocus(): boolean
  • Test whether the editor has keyboard focus.

    Returns boolean

newIndentedLine

  • newIndentedLine(): void
  • Inserts a new line at the cursor position and indents it.

    Returns void

redo

  • redo(): void

refresh

  • refresh(): void
  • Repaint the editor.

    Notes

    A repainted editor should fit to its host node.

    Returns void

resizeToFit

  • resizeToFit(): void
  • Resize the editor to fit its host node.

    Returns void

revealPosition

  • Reveals the given position in the editor.

    Parameters

    • position: IPosition

      The desired position to reveal.

    Returns void

revealSelection

  • revealSelection(selection: IRange): void
  • Reveals the given selection in the editor.

    Parameters

    Returns void

setCursorPosition

  • setCursorPosition(position: IPosition): void

setOption

  • setOption<K>(option: K, value: IConfig[K]): void
  • Set a config option for the editor.

    Type parameters

    • K: keyof IConfig

    Parameters

    • option: K
    • value: IConfig[K]

    Returns void

setSelection

  • setSelection(selection: IRange): void

setSelections

  • setSelections(selections: IRange[]): void
  • Sets the selections for all the cursors.

    Parameters

    • selections: IRange[]

      The new selections.

      Notes

      Cursors will be removed or added, as necessary. Passing an empty array resets a cursor position to the start of a document.

    Returns void

setSize

  • Set the size of the editor.

    Parameters

    • size: IDimension | null

      The desired size.

      Notes

      Use null if the size is unknown.

    Returns void

undo

  • undo(): void
  • Undo one edit (if any undo events are stored).

    Returns void

Generated using TypeDoc