Interface IEditor
Expand description
interface IEditor {
createDecorationsCollection(
decorations?: IModelDeltaDecoration[],
): IEditorDecorationsCollection;
dispose(): void;
focus(): void;
getEditorType(): string;
getId(): string;
getModel(): IEditorModel;
getPosition(): Position;
getSelection(): Selection;
getSelections(): Selection[];
getSupportedActions(): IEditorAction[];
getVisibleColumnFromPosition(
position: IPosition,
): number;
hasTextFocus(): boolean;
layout(
dimension?: IDimension,
postponeRendering?: boolean,
): void;
onDidDispose(listener: () => void): IDisposable;
restoreViewState(state: IEditorViewState): void;
revealLine(
lineNumber: number,
scrollType?: ScrollType,
): void;
revealLineInCenter(
lineNumber: number,
scrollType?: ScrollType,
): void;
revealLineInCenterIfOutsideViewport(
lineNumber: number,
scrollType?: ScrollType,
): void;
revealLineNearTop(
lineNumber: number,
scrollType?: ScrollType,
): void;
revealLines(
startLineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void;
revealLinesInCenter(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void;
revealLinesInCenterIfOutsideViewport(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void;
revealLinesNearTop(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void;
revealPosition(
position: IPosition,
scrollType?: ScrollType,
): void;
revealPositionInCenter(
position: IPosition,
scrollType?: ScrollType,
): void;
revealPositionInCenterIfOutsideViewport(
position: IPosition,
scrollType?: ScrollType,
): void;
revealPositionNearTop(
position: IPosition,
scrollType?: ScrollType,
): void;
revealRange(
range: IRange,
scrollType?: ScrollType,
): void;
revealRangeAtTop(
range: IRange,
scrollType?: ScrollType,
): void;
revealRangeInCenter(
range: IRange,
scrollType?: ScrollType,
): void;
revealRangeInCenterIfOutsideViewport(
range: IRange,
scrollType?: ScrollType,
): void;
revealRangeNearTop(
range: IRange,
scrollType?: ScrollType,
): void;
revealRangeNearTopIfOutsideViewport(
range: IRange,
scrollType?: ScrollType,
): void;
saveViewState(): IEditorViewState;
setModel(model: IEditorModel): void;
setPosition(position: IPosition, source?: string): void;
setSelection(selection: IRange, source?: string): void;
setSelection(selection: Range, source?: string): void;
setSelection(
selection: ISelection,
source?: string,
): void;
setSelection(
selection: Selection,
source?: string,
): void;
setSelections(
selections: readonly ISelection[],
source?: string,
): void;
trigger(
source: string,
handlerId: string,
payload: unknown,
): void;
updateOptions(newOptions: IEditorOptions): void;
}Methods§
§createDecorationsCollection(
decorations?: IModelDeltaDecoration[],
): IEditorDecorationsCollection
createDecorationsCollection(
decorations?: IModelDeltaDecoration[],
): IEditorDecorationsCollection
Create a collection of decorations. All decorations added through this collection will get the ownerId of the editor (meaning they will not show up in other editors). These decorations will be automatically cleared when the editor's model changes.
§dispose(): void
dispose(): void
Dispose the editor.
§focus(): void
focus(): void
Brings browser focus to the editor text
§getEditorType(): string
getEditorType(): string
Get the editor type. Please see EditorType.
This is to avoid an instanceof check
§getId(): string
getId(): string
Get a unique id for this editor instance.
§getModel(): IEditorModel
getModel(): IEditorModel
Gets the current model attached to this editor.
§getSupportedActions(): IEditorAction[]
getSupportedActions(): IEditorAction[]
Returns all actions associated with this editor.
§getVisibleColumnFromPosition(position: IPosition): number
getVisibleColumnFromPosition(position: IPosition): number
Given a position, returns a column number that takes tab-widths into account.
§hasTextFocus(): boolean
hasTextFocus(): boolean
Returns true if the text inside this editor is focused (i.e. cursor is blinking).
§layout(
dimension?: IDimension,
postponeRendering?: boolean,
): void
layout(
dimension?: IDimension,
postponeRendering?: boolean,
): void
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.
By default, this will also render the editor immediately. If you prefer to delay rendering to the next animation frame, use postponeRendering == true.
§restoreViewState(state: IEditorViewState): void
restoreViewState(state: IEditorViewState): void
Restores the view state of the editor from a serializable object generated by saveViewState.
§revealLine(
lineNumber: number,
scrollType?: ScrollType,
): void
revealLine(
lineNumber: number,
scrollType?: ScrollType,
): void
Scroll vertically as necessary and reveal a line.
§revealLineInCenter(
lineNumber: number,
scrollType?: ScrollType,
): void
revealLineInCenter(
lineNumber: number,
scrollType?: ScrollType,
): void
Scroll vertically as necessary and reveal a line centered vertically.
§revealLineInCenterIfOutsideViewport(
lineNumber: number,
scrollType?: ScrollType,
): void
revealLineInCenterIfOutsideViewport(
lineNumber: number,
scrollType?: ScrollType,
): void
Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport.
§revealLineNearTop(
lineNumber: number,
scrollType?: ScrollType,
): void
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.
§revealLines(
startLineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
revealLines(
startLineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
Scroll vertically as necessary and reveal lines.
§revealLinesInCenter(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
revealLinesInCenter(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
Scroll vertically as necessary and reveal lines centered vertically.
§revealLinesInCenterIfOutsideViewport(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
revealLinesInCenterIfOutsideViewport(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
Scroll vertically as necessary and reveal lines centered vertically only if it lies outside the viewport.
§revealLinesNearTop(
lineNumber: number,
endLineNumber: number,
scrollType?: ScrollType,
): void
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.
§revealPosition(
position: IPosition,
scrollType?: ScrollType,
): void
revealPosition(
position: IPosition,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a position.
§revealPositionInCenter(
position: IPosition,
scrollType?: ScrollType,
): void
revealPositionInCenter(
position: IPosition,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a position centered vertically.
§revealPositionInCenterIfOutsideViewport(
position: IPosition,
scrollType?: ScrollType,
): void
revealPositionInCenterIfOutsideViewport(
position: IPosition,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a position centered vertically only if it lies outside the viewport.
§revealPositionNearTop(
position: IPosition,
scrollType?: ScrollType,
): void
revealPositionNearTop(
position: IPosition,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport, optimized for viewing a code definition.
§revealRange(range: IRange, scrollType?: ScrollType): void
revealRange(range: IRange, scrollType?: ScrollType): void
Scroll vertically or horizontally as necessary and reveal a range.
§revealRangeAtTop(
range: IRange,
scrollType?: ScrollType,
): void
revealRangeAtTop(
range: IRange,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a range at the top of the viewport.
§revealRangeInCenter(
range: IRange,
scrollType?: ScrollType,
): void
revealRangeInCenter(
range: IRange,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a range centered vertically.
§revealRangeInCenterIfOutsideViewport(
range: IRange,
scrollType?: ScrollType,
): void
revealRangeInCenterIfOutsideViewport(
range: IRange,
scrollType?: ScrollType,
): void
Scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.
§revealRangeNearTop(
range: IRange,
scrollType?: ScrollType,
): void
revealRangeNearTop(
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.
§revealRangeNearTopIfOutsideViewport(
range: IRange,
scrollType?: ScrollType,
): void
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.
§saveViewState(): IEditorViewState
saveViewState(): IEditorViewState
Saves current view state of the editor in a serializable object.
§setModel(model: IEditorModel): void
setModel(model: IEditorModel): void
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.
§setPosition(position: IPosition, source?: string): void
setPosition(position: IPosition, source?: string): void
Set the primary position of the cursor. This will remove any secondary cursors.
§setSelection(selection: IRange, source?: string): void
setSelection(selection: IRange, source?: string): void
Set the primary selection of the editor. This will remove any secondary cursors.
§setSelection(selection: Range, source?: string): void
setSelection(selection: Range, source?: string): void
Set the primary selection of the editor. This will remove any secondary cursors.
§setSelection(selection: ISelection, source?: string): void
setSelection(selection: ISelection, source?: string): void
Set the primary selection of the editor. This will remove any secondary cursors.
§setSelection(selection: Selection, source?: string): void
setSelection(selection: Selection, source?: string): void
Set the primary selection of the editor. This will remove any secondary cursors.
§setSelections(
selections: readonly ISelection[],
source?: string,
): void
setSelections(
selections: readonly ISelection[],
source?: string,
): void
Set the selections for all the cursors of the editor. Cursors will be removed or added, as necessary.
§trigger(
source: string,
handlerId: string,
payload: unknown,
): void
trigger(
source: string,
handlerId: string,
payload: unknown,
): void
Directly trigger a handler or an editor action.
§updateOptions(newOptions: IEditorOptions): void
updateOptions(newOptions: IEditorOptions): void
Update the editor's options after the editor has been created.
Events§
§onDidDispose(listener: () => void): IDisposable
onDidDispose(listener: () => void): IDisposable
An event emitted when the editor has been disposed.
An editor.