Files
vscode/src/vs/platform/editor/common/editor.ts

131 lines
3.3 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import URI from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { Event } from 'vs/base/common/event';
export interface IEditorModel {
/**
* Emitted when the model is disposed.
*/
onDispose: Event<void>;
/**
* Loads the model.
*/
load(): TPromise<IEditorModel>;
/**
* Dispose associated resources
*/
dispose(): void;
}
export interface IBaseResourceInput {
/**
* Optional options to use when opening the text input.
*/
options?: ITextEditorOptions;
/**
* Label to show for the diff editor
*/
label?: string;
/**
* Description to show for the diff editor
*/
description?: string;
}
export interface IResourceInput extends IBaseResourceInput {
/**
* The resource URL of the resource to open.
*/
resource: URI;
/**
* The encoding of the text input if known.
*/
encoding?: string;
}
export interface IEditorOptions {
/**
* Tells the editor to not receive keyboard focus when the editor is being opened. By default,
* the editor will receive keyboard focus on open.
*/
readonly preserveFocus?: boolean;
/**
* Tells the editor to reload the editor input in the editor even if it is identical to the one
* already showing. By default, the editor will not reload the input if it is identical to the
* one showing.
*/
readonly forceReload?: boolean;
/**
* Will reveal the editor if it is already opened and visible in any of the opened editor groups. Note
* that this option is just a hint that might be ignored if the user wants to open an editor explicitly
* to the side of another one or into a specific editor group.
*/
readonly revealIfVisible?: boolean;
/**
* Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups. Note
* that this option is just a hint that might be ignored if the user wants to open an editor explicitly
* to the side of another one or into a specific editor group.
*/
readonly revealIfOpened?: boolean;
/**
* An editor that is pinned remains in the editor stack even when another editor is being opened.
* An editor that is not pinned will always get replaced by another editor that is not pinned.
*/
readonly pinned?: boolean;
/**
* The index in the document stack where to insert the editor into when opening.
*/
readonly index?: number;
/**
* An active editor that is opened will show its contents directly. Set to true to open an editor
* in the background.
*/
readonly inactive?: boolean;
}
export interface ITextEditorSelection {
startLineNumber: number;
startColumn: number;
endLineNumber?: number;
endColumn?: number;
}
export interface ITextEditorOptions extends IEditorOptions {
/**
* Text editor selection.
*/
selection?: ITextEditorSelection;
/**
* Text editor view state.
*/
viewState?: object;
/**
* Option to scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.
*/
revealInCenterIfOutsideViewport?: boolean;
}