Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ICodeEditor

A rich code editor.

Hierarchy

Index

Events

Methods

Events

onContextMenu

onDidAttemptReadOnlyEdit

  • onDidAttemptReadOnlyEdit(listener: () => void): IDisposable
  • An event emitted when editing failed because the editor is read-only.

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidBlurEditorText

  • onDidBlurEditorText(listener: () => void): IDisposable
  • An event emitted when the text inside this editor lost focus (i.e. cursor stops blinking).

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidBlurEditorWidget

  • onDidBlurEditorWidget(listener: () => void): IDisposable
  • An event emitted when the text inside this editor or an editor widget lost focus.

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidChangeConfiguration

onDidChangeCursorPosition

onDidChangeCursorSelection

onDidChangeModel

onDidChangeModelContent

onDidChangeModelDecorations

onDidChangeModelLanguage

onDidChangeModelLanguageConfiguration

onDidChangeModelOptions

onDidContentSizeChange

onDidDispose

  • An event emitted when the editor has been disposed.

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidFocusEditorText

  • onDidFocusEditorText(listener: () => void): IDisposable
  • An event emitted when the text inside this editor gained focus (i.e. cursor starts blinking).

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidFocusEditorWidget

  • onDidFocusEditorWidget(listener: () => void): IDisposable
  • An event emitted when the text inside this editor or an editor widget gained focus.

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidLayoutChange

onDidPaste

  • An event emitted when users paste text in the editor.

    Parameters

    Returns IDisposable

onDidScrollChange

  • An event emitted when the scroll in the editor has changed.

    Parameters

    Returns IDisposable

onKeyDown

onKeyUp

onMouseDown

onMouseLeave

onMouseMove

onMouseUp

Methods

addContentWidget

  • Add a content widget. Widgets must have unique ids, otherwise they will be overwritten.

    Parameters

    Returns void

addOverlayWidget

  • Add an overlay widget. Widgets must have unique ids, otherwise they will be overwritten.

    Parameters

    Returns void

applyFontInfo

  • applyFontInfo(target: HTMLElement): void
  • Apply the same font settings as the editor to target.

    Parameters

    • target: HTMLElement

    Returns void

changeViewZones

deltaDecorations

  • All decorations added through this call will get the ownerId of this editor.

    see

    ITextModel.deltaDecorations

    Parameters

    Returns string[]

dispose

  • dispose(): void

executeCommand

  • executeCommand(source: string | null | undefined, command: ICommand): void
  • Execute a command on the editor. The edits will land on the undo-redo stack, but no "undo stop" will be pushed.

    Parameters

    • source: string | null | undefined

      The source of the call.

    • command: ICommand

      The command to execute

    Returns void

executeCommands

  • executeCommands(source: string | null | undefined, commands: (ICommand | null)[]): void
  • Execute multiple (concomitant) commands on the editor.

    Parameters

    • source: string | null | undefined

      The source of the call.

    • commands: (ICommand | null)[]

    Returns void

executeEdits

  • Execute edits on the editor. The edits will land on the undo-redo stack, but no "undo stop" will be pushed.

    Parameters

    Returns boolean

focus

  • focus(): void
  • Brings browser focus to the editor text

    Returns void

getAction

  • Get an action that is a contribution to this editor.

    id

    Unique identifier of the contribution.

    Parameters

    • id: string

    Returns IEditorAction

    The action or null if action not found.

getContainerDomNode

  • getContainerDomNode(): HTMLElement
  • Returns the editor's container dom node

    Returns HTMLElement

getContentHeight

  • getContentHeight(): number
  • Get the height of the editor's content. This is information that is "erased" when computing scrollHeight = Math.max(contentHeight, height)

    Returns number

getContentWidth

  • getContentWidth(): number
  • Get the width of the editor's content. This is information that is "erased" when computing scrollWidth = Math.max(contentWidth, width)

    Returns number

getContribution

  • getContribution<T>(id: string): T
  • Get a contribution of this editor.

    id

    Unique identifier of the contribution.

    Type parameters

    Parameters

    • id: string

    Returns T

    The contribution or null if contribution not found.

getDomNode

  • getDomNode(): HTMLElement | null
  • Returns the editor's dom node

    Returns HTMLElement | null

getEditorType

  • getEditorType(): string
  • Get the editor type. Please see EditorType. This is to avoid an instanceof check

    Returns string

getId

  • getId(): string
  • Get a unique id for this editor instance.

    Returns string

getLayoutInfo

  • Get the layout info for the editor.

    Returns EditorLayoutInfo

getLineDecorations

  • Get all the decorations on a line (filtering out decorations from other editors).

    Parameters

    • lineNumber: number

    Returns IModelDecoration[] | null

getModel

  • Type the getModel() of IEditor.

    Returns ITextModel | null

getOffsetForColumn

  • getOffsetForColumn(lineNumber: number, column: number): number
  • Get the horizontal position (left offset) for the column w.r.t to the beginning of the line. This method works only if the line lineNumber is currently rendered (in the editor's viewport). Use this method with caution.

    Parameters

    • lineNumber: number
    • column: number

    Returns number

getOption

getOptions

  • Gets all the editor computed options.

    Returns IComputedEditorOptions

getPosition

getRawOptions

  • Returns the editor's configuration (without any validation or defaults).

    Returns IEditorOptions

getScrollHeight

  • getScrollHeight(): number
  • Get the scrollHeight of the editor's viewport.

    Returns number

getScrollLeft

  • getScrollLeft(): number
  • Get the scrollLeft of the editor's viewport.

    Returns number

getScrollTop

  • getScrollTop(): number
  • Get the scrollTop of the editor's viewport.

    Returns number

getScrollWidth

  • getScrollWidth(): number
  • Get the scrollWidth of the editor's viewport.

    Returns number

getScrolledVisiblePosition

  • getScrolledVisiblePosition(position: IPosition): { height: number; left: number; top: number } | null
  • Get the visible position for position. The result position takes scrolling into account and is relative to the top left corner of the editor. Explanation 1: the results of this method will change for the same position if the user scrolls the editor. Explanation 2: the results of this method will not change if the container of the editor gets repositioned. Warning: the results of this method are inaccurate for positions that are outside the current editor viewport.

    Parameters

    Returns { height: number; left: number; top: number } | null

getSelection

getSelections

getSupportedActions

getTargetAtClientPoint

  • getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget | null
  • Get the hit test target at coordinates clientX and clientY. The coordinates are relative to the top-left of the viewport.

    Parameters

    • clientX: number
    • clientY: number

    Returns IMouseTarget | null

    Hit test target or null if the coordinates fall outside the editor or the editor has no model.

getTopForLineNumber

  • getTopForLineNumber(lineNumber: number): number
  • Get the vertical position (top offset) for the line w.r.t. to the first line.

    Parameters

    • lineNumber: number

    Returns number

getTopForPosition

  • getTopForPosition(lineNumber: number, column: number): number
  • Get the vertical position (top offset) for the position w.r.t. to the first line.

    Parameters

    • lineNumber: number
    • column: number

    Returns number

getValue

  • getValue(options?: { lineEnding: string; preserveBOM: boolean }): string
  • Get value of the current model attached to this editor.

    see

    ITextModel.getValue

    Parameters

    • Optional options: { lineEnding: string; preserveBOM: boolean }
      • lineEnding: string
      • preserveBOM: boolean

    Returns string

getVisibleColumnFromPosition

  • getVisibleColumnFromPosition(position: IPosition): number

getVisibleRanges

  • getVisibleRanges(): Range[]
  • Returns the ranges that are currently visible. Does not account for horizontal scrolling.

    Returns Range[]

hasTextFocus

  • hasTextFocus(): boolean
  • Returns true if the text inside this editor is focused (i.e. cursor is blinking).

    Returns boolean

hasWidgetFocus

  • hasWidgetFocus(): boolean
  • Returns true if the text inside this editor or an editor widget has focus.

    Returns boolean

layout

  • Instructs the editor to remeasure its container. This method should be called when the container of the editor gets resized.

    If a dimension is passed in, the passed in value will be used.

    Parameters

    Returns void

layoutContentWidget

  • Layout/Reposition a content widget. This is a ping to the editor to call widget.getPosition() and update appropriately.

    Parameters

    Returns void

layoutOverlayWidget

  • Layout/Reposition an overlay widget. This is a ping to the editor to call widget.getPosition() and update appropriately.

    Parameters

    Returns void

onDidCompositionEnd

  • onDidCompositionEnd(listener: () => void): IDisposable
  • An event emitted after composition has ended.

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

onDidCompositionStart

  • onDidCompositionStart(listener: () => void): IDisposable
  • An event emitted after composition has started.

    Parameters

    • listener: () => void
        • (): void
        • Returns void

    Returns IDisposable

popUndoStop

  • popUndoStop(): boolean
  • Remove the "undo stop" in the undo-redo stack.

    Returns boolean

pushUndoStop

  • pushUndoStop(): boolean
  • Create an "undo stop" in the undo-redo stack.

    Returns boolean

removeContentWidget

  • Remove a content widget.

    Parameters

    Returns void

removeOverlayWidget

  • Remove an overlay widget.

    Parameters

    Returns void

render

  • render(forceRedraw?: boolean): void
  • Force an editor render now.

    Parameters

    • Optional forceRedraw: boolean

    Returns void

restoreViewState

  • Restores the view state of the editor from a serializable object generated by saveViewState.

    Parameters

    Returns void

revealLine

  • revealLine(lineNumber: number, scrollType?: ScrollType): void
  • Scroll vertically as necessary and reveal a line.

    Parameters

    • lineNumber: number
    • Optional scrollType: ScrollType

    Returns void

revealLineInCenter

  • revealLineInCenter(lineNumber: number, scrollType?: ScrollType): void
  • Scroll vertically as necessary and reveal a line centered vertically.

    Parameters

    • lineNumber: number
    • Optional scrollType: ScrollType

    Returns void

revealLineInCenterIfOutsideViewport

  • revealLineInCenterIfOutsideViewport(lineNumber: number, scrollType?: ScrollType): void

revealLineNearTop

  • revealLineNearTop(lineNumber: number, scrollType?: ScrollType): void
  • Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition.

    Parameters

    • lineNumber: number
    • Optional scrollType: ScrollType

    Returns void

revealLines

  • revealLines(startLineNumber: number, endLineNumber: number, scrollType?: ScrollType): void
  • Scroll vertically as necessary and reveal lines.

    Parameters

    • startLineNumber: number
    • endLineNumber: number
    • Optional scrollType: ScrollType

    Returns void

revealLinesInCenter

  • revealLinesInCenter(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void
  • Scroll vertically as necessary and reveal lines centered vertically.

    Parameters

    • lineNumber: number
    • endLineNumber: number
    • Optional scrollType: ScrollType

    Returns void

revealLinesInCenterIfOutsideViewport

  • revealLinesInCenterIfOutsideViewport(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void

revealLinesNearTop

  • revealLinesNearTop(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void
  • Scroll vertically as necessary and reveal lines close to the top of the viewport, optimized for viewing a code definition.

    Parameters

    • lineNumber: number
    • endLineNumber: number
    • Optional scrollType: ScrollType

    Returns void

revealPosition

revealPositionInCenter

revealPositionInCenterIfOutsideViewport

revealPositionNearTop

  • Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport, optimized for viewing a code definition.

    Parameters

    Returns void

revealRange

  • Scroll vertically or horizontally as necessary and reveal a range.

    Parameters

    Returns void

revealRangeAtTop

  • Scroll vertically or horizontally as necessary and reveal a range at the top of the viewport.

    Parameters

    Returns void

revealRangeInCenter

revealRangeInCenterIfOutsideViewport

  • revealRangeInCenterIfOutsideViewport(range: IRange, scrollType?: ScrollType): void

revealRangeNearTop

  • Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, optimized for viewing a code definition.

    Parameters

    Returns void

revealRangeNearTopIfOutsideViewport

  • revealRangeNearTopIfOutsideViewport(range: IRange, scrollType?: ScrollType): void
  • Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, optimized for viewing a code definition. Only if it lies outside the viewport.

    Parameters

    Returns void

saveViewState

setModel

  • Sets the current model attached to this editor. If the previous model was created by the editor via the value key in the options literal object, it will be destroyed. Otherwise, if the previous model was set via setModel, or the model key in the options literal object, the previous model will not be destroyed. It is safe to call setModel(null) to simply detach the current model from the editor.

    Parameters

    Returns void

setPosition

  • Set the primary position of the cursor. This will remove any secondary cursors.

    Parameters

    • position: IPosition

      New primary cursor's position

    Returns void

setScrollLeft

  • setScrollLeft(newScrollLeft: number, scrollType?: ScrollType): void
  • Change the scrollLeft of the editor's viewport.

    Parameters

    • newScrollLeft: number
    • Optional scrollType: ScrollType

    Returns void

setScrollPosition

  • Change the scroll position of the editor's viewport.

    Parameters

    Returns void

setScrollTop

  • setScrollTop(newScrollTop: number, scrollType?: ScrollType): void
  • Change the scrollTop of the editor's viewport.

    Parameters

    • newScrollTop: number
    • Optional scrollType: ScrollType

    Returns void

setSelection

  • setSelection(selection: IRange): void
  • setSelection(selection: Range): void
  • setSelection(selection: ISelection): void
  • setSelection(selection: Selection): void
  • Set the primary selection of the editor. This will remove any secondary cursors.

    Parameters

    • selection: IRange

      The new selection

    Returns void

  • Set the primary selection of the editor. This will remove any secondary cursors.

    Parameters

    • selection: Range

      The new selection

    Returns void

  • Set the primary selection of the editor. This will remove any secondary cursors.

    Parameters

    Returns void

  • Set the primary selection of the editor. This will remove any secondary cursors.

    Parameters

    Returns void

setSelections

  • setSelections(selections: readonly ISelection[]): void
  • Set the selections for all the cursors of the editor. Cursors will be removed or added, as necessary.

    Parameters

    Returns void

setValue

  • setValue(newValue: string): void
  • Set the value of the current model attached to this editor.

    see

    ITextModel.setValue

    Parameters

    • newValue: string

    Returns void

trigger

  • trigger(source: string | null | undefined, handlerId: string, payload: any): void
  • Directly trigger a handler or an editor action.

    Parameters

    • source: string | null | undefined

      The source of the call.

    • handlerId: string

      The id of the handler or the id of a contribution.

    • payload: any

      Extra data to be sent to the handler.

    Returns void

updateOptions

  • Update the editor's options after the editor has been created.

    Parameters

    Returns void

Generated using TypeDoc