pxt-core-own
Version:
Microsoft MakeCode, also known as Programming Experience Toolkit (PXT), provides Blocks / JavaScript tools and editors
1,502 lines (1,409 loc) • 176 kB
TypeScript
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Type definitions for monaco-editor v0.9.0
* Released under the MIT license
*-----------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module monaco {
interface Thenable<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}
export interface IDisposable {
dispose(): void;
}
export interface IEvent<T> {
(listener: (e: T) => any, thisArg?: any): IDisposable;
}
/**
* A helper that allows to emit and listen to typed events
*/
export class Emitter<T> {
constructor();
event: IEvent<T>;
fire(event?: T): void;
dispose(): void;
}
export enum Severity {
Ignore = 0,
Info = 1,
Warning = 2,
Error = 3,
}
/**
* The value callback to complete a promise
*/
export interface TValueCallback<T> {
(value: T): void;
}
export interface ProgressCallback {
(progress: any): any;
}
/**
* A Promise implementation that supports progress and cancelation.
*/
export class Promise<V> {
constructor(init: (complete: TValueCallback<V>, error: (err: any) => void, progress: ProgressCallback) => void, oncancel?: any);
public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => Promise<U>, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => Promise<U> | U, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => U, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U>, error?: (err: any) => void, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => Promise<U>, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => Promise<U> | U, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => U, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => Promise<U> | U, error?: (err: any) => void, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => U, error?: (err: any) => Promise<U>, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => U, error?: (err: any) => Promise<U> | U, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => U, error?: (err: any) => U, progress?: ProgressCallback): Promise<U>;
public then<U>(success?: (value: V) => U, error?: (err: any) => void, progress?: ProgressCallback): Promise<U>;
public done(success?: (value: V) => void, error?: (err: any) => any, progress?: ProgressCallback): void;
public cancel(): void;
public static as<ValueType>(value: Promise<ValueType>): Promise<ValueType>;
public static as<ValueType>(value: Thenable<ValueType>): Thenable<ValueType>;
public static as<ValueType>(value: ValueType): Promise<ValueType>;
public static is(value: any): value is Thenable<any>;
public static timeout(delay: number): Promise<void>;
public static join<ValueType>(promises: Promise<ValueType>[]): Promise<ValueType[]>;
public static join<ValueType>(promises: Thenable<ValueType>[]): Thenable<ValueType[]>;
public static join<ValueType>(promises: { [n: string]: Promise<ValueType> }): Promise<{ [n: string]: ValueType }>;
public static any<ValueType>(promises: Promise<ValueType>[]): Promise<{ key: string; value: Promise<ValueType>; }>;
public static wrap<ValueType>(value: Thenable<ValueType>): Promise<ValueType>;
public static wrap<ValueType>(value: ValueType): Promise<ValueType>;
public static wrapError<ValueType>(error: Error): Promise<ValueType>;
}
export class CancellationTokenSource {
token: CancellationToken;
cancel(): void;
dispose(): void;
}
export interface CancellationToken {
isCancellationRequested: boolean;
/**
* An event emitted when cancellation is requested
* @event
*/
onCancellationRequested: IEvent<any>;
}
/**
* Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986.
* This class is a simple parser which creates the basic component paths
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
* and encoding.
*
* foo://example.com:8042/over/there?name=ferret#nose
* \_/ \______________/\_________/ \_________/ \__/
* | | | | |
* scheme authority path query fragment
* | _____________________|__
* / \ / \
* urn:example:animal:ferret:nose
*
*
*/
export class Uri {
static isUri(thing: any): thing is Uri;
constructor();
/**
* scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'.
* The part before the first colon.
*/
scheme: string;
/**
* authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'.
* The part between the first double slashes and the next slash.
*/
authority: string;
/**
* path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'.
*/
path: string;
/**
* query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'.
*/
query: string;
/**
* fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'.
*/
fragment: string;
/**
* Returns a string representing the corresponding file system path of this Uri.
* Will handle UNC paths and normalize windows drive letters to lower-case. Also
* uses the platform specific path separator. Will *not* validate the path for
* invalid characters and semantics. Will *not* look at the scheme of this Uri.
*/
fsPath: string;
with(change: {
scheme?: string;
authority?: string;
path?: string;
query?: string;
fragment?: string;
}): Uri;
static parse(value: string): Uri;
static file(path: string): Uri;
static from(components: {
scheme?: string;
authority?: string;
path?: string;
query?: string;
fragment?: string;
}): Uri;
/**
*
* @param skipEncoding Do not encode the result, default is `false`
*/
toString(skipEncoding?: boolean): string;
toJSON(): any;
static revive(data: any): Uri;
}
/**
* Virtual Key Codes, the value does not hold any inherent meaning.
* Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
* But these are "more general", as they should work across browsers & OS`s.
*/
export enum KeyCode {
/**
* Placed first to cover the 0 value of the enum.
*/
Unknown = 0,
Backspace = 1,
Tab = 2,
Enter = 3,
Shift = 4,
Ctrl = 5,
Alt = 6,
PauseBreak = 7,
CapsLock = 8,
Escape = 9,
Space = 10,
PageUp = 11,
PageDown = 12,
End = 13,
Home = 14,
LeftArrow = 15,
UpArrow = 16,
RightArrow = 17,
DownArrow = 18,
Insert = 19,
Delete = 20,
KEY_0 = 21,
KEY_1 = 22,
KEY_2 = 23,
KEY_3 = 24,
KEY_4 = 25,
KEY_5 = 26,
KEY_6 = 27,
KEY_7 = 28,
KEY_8 = 29,
KEY_9 = 30,
KEY_A = 31,
KEY_B = 32,
KEY_C = 33,
KEY_D = 34,
KEY_E = 35,
KEY_F = 36,
KEY_G = 37,
KEY_H = 38,
KEY_I = 39,
KEY_J = 40,
KEY_K = 41,
KEY_L = 42,
KEY_M = 43,
KEY_N = 44,
KEY_O = 45,
KEY_P = 46,
KEY_Q = 47,
KEY_R = 48,
KEY_S = 49,
KEY_T = 50,
KEY_U = 51,
KEY_V = 52,
KEY_W = 53,
KEY_X = 54,
KEY_Y = 55,
KEY_Z = 56,
Meta = 57,
ContextMenu = 58,
F1 = 59,
F2 = 60,
F3 = 61,
F4 = 62,
F5 = 63,
F6 = 64,
F7 = 65,
F8 = 66,
F9 = 67,
F10 = 68,
F11 = 69,
F12 = 70,
F13 = 71,
F14 = 72,
F15 = 73,
F16 = 74,
F17 = 75,
F18 = 76,
F19 = 77,
NumLock = 78,
ScrollLock = 79,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the ';:' key
*/
US_SEMICOLON = 80,
/**
* For any country/region, the '+' key
* For the US standard keyboard, the '=+' key
*/
US_EQUAL = 81,
/**
* For any country/region, the ',' key
* For the US standard keyboard, the ',<' key
*/
US_COMMA = 82,
/**
* For any country/region, the '-' key
* For the US standard keyboard, the '-_' key
*/
US_MINUS = 83,
/**
* For any country/region, the '.' key
* For the US standard keyboard, the '.>' key
*/
US_DOT = 84,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the '/?' key
*/
US_SLASH = 85,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the '`~' key
*/
US_BACKTICK = 86,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the '[{' key
*/
US_OPEN_SQUARE_BRACKET = 87,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the '\|' key
*/
US_BACKSLASH = 88,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the ']}' key
*/
US_CLOSE_SQUARE_BRACKET = 89,
/**
* Used for miscellaneous characters; it can vary by keyboard.
* For the US standard keyboard, the ''"' key
*/
US_QUOTE = 90,
/**
* Used for miscellaneous characters; it can vary by keyboard.
*/
OEM_8 = 91,
/**
* Either the angle bracket key or the backslash key on the RT 102-key keyboard.
*/
OEM_102 = 92,
NUMPAD_0 = 93,
NUMPAD_1 = 94,
NUMPAD_2 = 95,
NUMPAD_3 = 96,
NUMPAD_4 = 97,
NUMPAD_5 = 98,
NUMPAD_6 = 99,
NUMPAD_7 = 100,
NUMPAD_8 = 101,
NUMPAD_9 = 102,
NUMPAD_MULTIPLY = 103,
NUMPAD_ADD = 104,
NUMPAD_SEPARATOR = 105,
NUMPAD_SUBTRACT = 106,
NUMPAD_DECIMAL = 107,
NUMPAD_DIVIDE = 108,
/**
* Cover all key codes when IME is processing input.
*/
KEY_IN_COMPOSITION = 109,
ABNT_C1 = 110,
ABNT_C2 = 111,
/**
* Placed last to cover the length of the enum.
* Please do not depend on this value!
*/
MAX_VALUE = 112,
}
export class KeyMod {
static CtrlCmd: number;
static Shift: number;
static Alt: number;
static WinCtrl: number;
static chord(firstPart: number, secondPart: number): number;
}
/**
* MarkedString can be used to render human readable text. It is either a markdown string
* or a code-block that provides a language and a code snippet. Note that
* markdown strings will be sanitized - that means html will be escaped.
*/
export type MarkedString = string | {
language: string;
value: string;
};
export interface IKeyboardEvent {
browserEvent: KeyboardEvent;
target: HTMLElement;
ctrlKey: boolean;
shiftKey: boolean;
altKey: boolean;
metaKey: boolean;
keyCode: KeyCode;
code: string;
equals(keybinding: number): boolean;
preventDefault(): void;
stopPropagation(): void;
}
export interface IMouseEvent {
browserEvent: MouseEvent;
leftButton: boolean;
middleButton: boolean;
rightButton: boolean;
target: HTMLElement;
detail: number;
posx: number;
posy: number;
ctrlKey: boolean;
shiftKey: boolean;
altKey: boolean;
metaKey: boolean;
timestamp: number;
preventDefault(): void;
stopPropagation(): void;
}
export interface IScrollEvent {
scrollTop: number;
scrollLeft: number;
scrollWidth: number;
scrollHeight: number;
scrollTopChanged: boolean;
scrollLeftChanged: boolean;
scrollWidthChanged: boolean;
scrollHeightChanged: boolean;
}
/**
* A position in the editor. This interface is suitable for serialization.
*/
export interface IPosition {
/**
* line number (starts at 1)
*/
lineNumber: number;
/**
* column (the first character in a line is between column 1 and column 2)
*/
column: number;
}
/**
* A position in the editor.
*/
export class Position {
/**
* line number (starts at 1)
*/
lineNumber: number;
/**
* column (the first character in a line is between column 1 and column 2)
*/
column: number;
constructor(lineNumber: number, column: number);
/**
* Test if this position equals other position
*/
equals(other: IPosition): boolean;
/**
* Test if position `a` equals position `b`
*/
static equals(a: IPosition, b: IPosition): boolean;
/**
* Test if this position is before other position.
* If the two positions are equal, the result will be false.
*/
isBefore(other: IPosition): boolean;
/**
* Test if position `a` is before position `b`.
* If the two positions are equal, the result will be false.
*/
static isBefore(a: IPosition, b: IPosition): boolean;
/**
* Test if this position is before other position.
* If the two positions are equal, the result will be true.
*/
isBeforeOrEqual(other: IPosition): boolean;
/**
* Test if position `a` is before position `b`.
* If the two positions are equal, the result will be true.
*/
static isBeforeOrEqual(a: IPosition, b: IPosition): boolean;
/**
* A function that compares positions, useful for sorting
*/
static compare(a: IPosition, b: IPosition): number;
/**
* Clone this position.
*/
clone(): Position;
/**
* Convert to a human-readable representation.
*/
toString(): string;
/**
* Create a `Position` from an `IPosition`.
*/
static lift(pos: IPosition): Position;
/**
* Test if `obj` is an `IPosition`.
*/
static isIPosition(obj: any): obj is IPosition;
}
/**
* A range in the editor. This interface is suitable for serialization.
*/
export interface IRange {
/**
* Line number on which the range starts (starts at 1).
*/
startLineNumber: number;
/**
* Column on which the range starts in line `startLineNumber` (starts at 1).
*/
startColumn: number;
/**
* Line number on which the range ends.
*/
endLineNumber: number;
/**
* Column on which the range ends in line `endLineNumber`.
*/
endColumn: number;
}
/**
* A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
*/
export class Range {
/**
* Line number on which the range starts (starts at 1).
*/
startLineNumber: number;
/**
* Column on which the range starts in line `startLineNumber` (starts at 1).
*/
startColumn: number;
/**
* Line number on which the range ends.
*/
endLineNumber: number;
/**
* Column on which the range ends in line `endLineNumber`.
*/
endColumn: number;
constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number);
/**
* Test if this range is empty.
*/
isEmpty(): boolean;
/**
* Test if `range` is empty.
*/
static isEmpty(range: IRange): boolean;
/**
* Test if position is in this range. If the position is at the edges, will return true.
*/
containsPosition(position: IPosition): boolean;
/**
* Test if `position` is in `range`. If the position is at the edges, will return true.
*/
static containsPosition(range: IRange, position: IPosition): boolean;
/**
* Test if range is in this range. If the range is equal to this range, will return true.
*/
containsRange(range: IRange): boolean;
/**
* Test if `otherRange` is in `range`. If the ranges are equal, will return true.
*/
static containsRange(range: IRange, otherRange: IRange): boolean;
/**
* A reunion of the two ranges.
* The smallest position will be used as the start point, and the largest one as the end point.
*/
plusRange(range: IRange): Range;
/**
* A reunion of the two ranges.
* The smallest position will be used as the start point, and the largest one as the end point.
*/
static plusRange(a: IRange, b: IRange): Range;
/**
* A intersection of the two ranges.
*/
intersectRanges(range: IRange): Range;
/**
* A intersection of the two ranges.
*/
static intersectRanges(a: IRange, b: IRange): Range;
/**
* Test if this range equals other.
*/
equalsRange(other: IRange): boolean;
/**
* Test if range `a` equals `b`.
*/
static equalsRange(a: IRange, b: IRange): boolean;
/**
* Return the end position (which will be after or equal to the start position)
*/
getEndPosition(): Position;
/**
* Return the start position (which will be before or equal to the end position)
*/
getStartPosition(): Position;
/**
* Clone this range.
*/
cloneRange(): Range;
/**
* Transform to a user presentable string representation.
*/
toString(): string;
/**
* Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
*/
setEndPosition(endLineNumber: number, endColumn: number): Range;
/**
* Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
*/
setStartPosition(startLineNumber: number, startColumn: number): Range;
/**
* Create a new empty range using this range's start position.
*/
collapseToStart(): Range;
/**
* Create a new empty range using this range's start position.
*/
static collapseToStart(range: IRange): Range;
static fromPositions(start: IPosition, end?: IPosition): Range;
/**
* Create a `Range` from an `IRange`.
*/
static lift(range: IRange): Range;
/**
* Test if `obj` is an `IRange`.
*/
static isIRange(obj: any): obj is IRange;
/**
* Test if the two ranges are touching in any way.
*/
static areIntersectingOrTouching(a: IRange, b: IRange): boolean;
/**
* A function that compares ranges, useful for sorting ranges
* It will first compare ranges on the startPosition and then on the endPosition
*/
static compareRangesUsingStarts(a: IRange, b: IRange): number;
/**
* A function that compares ranges, useful for sorting ranges
* It will first compare ranges on the endPosition and then on the startPosition
*/
static compareRangesUsingEnds(a: IRange, b: IRange): number;
/**
* Test if the range spans multiple lines.
*/
static spansMultipleLines(range: IRange): boolean;
}
/**
* A selection in the editor.
* The selection is a range that has an orientation.
*/
export interface ISelection {
/**
* The line number on which the selection has started.
*/
selectionStartLineNumber: number;
/**
* The column on `selectionStartLineNumber` where the selection has started.
*/
selectionStartColumn: number;
/**
* The line number on which the selection has ended.
*/
positionLineNumber: number;
/**
* The column on `positionLineNumber` where the selection has ended.
*/
positionColumn: number;
}
/**
* A selection in the editor.
* The selection is a range that has an orientation.
*/
export class Selection extends Range {
/**
* The line number on which the selection has started.
*/
selectionStartLineNumber: number;
/**
* The column on `selectionStartLineNumber` where the selection has started.
*/
selectionStartColumn: number;
/**
* The line number on which the selection has ended.
*/
positionLineNumber: number;
/**
* The column on `positionLineNumber` where the selection has ended.
*/
positionColumn: number;
constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number);
/**
* Clone this selection.
*/
clone(): Selection;
/**
* Transform to a human-readable representation.
*/
toString(): string;
/**
* Test if equals other selection.
*/
equalsSelection(other: ISelection): boolean;
/**
* Test if the two selections are equal.
*/
static selectionsEqual(a: ISelection, b: ISelection): boolean;
/**
* Get directions (LTR or RTL).
*/
getDirection(): SelectionDirection;
/**
* Create a new selection with a different `positionLineNumber` and `positionColumn`.
*/
setEndPosition(endLineNumber: number, endColumn: number): Selection;
/**
* Get the position at `positionLineNumber` and `positionColumn`.
*/
getPosition(): Position;
/**
* Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
*/
setStartPosition(startLineNumber: number, startColumn: number): Selection;
/**
* Create a `Selection` from one or two positions
*/
static fromPositions(start: IPosition, end?: IPosition): Selection;
/**
* Create a `Selection` from an `ISelection`.
*/
static liftSelection(sel: ISelection): Selection;
/**
* `a` equals `b`.
*/
static selectionsArrEqual(a: ISelection[], b: ISelection[]): boolean;
/**
* Test if `obj` is an `ISelection`.
*/
static isISelection(obj: any): obj is ISelection;
/**
* Create with a direction.
*/
static createWithDirection(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, direction: SelectionDirection): Selection;
}
/**
* The direction of a selection.
*/
export enum SelectionDirection {
/**
* The selection starts above where it ends.
*/
LTR = 0,
/**
* The selection starts below where it ends.
*/
RTL = 1,
}
export class Token {
_tokenBrand: void;
offset: number;
type: string;
language: string;
constructor(offset: number, type: string, language: string);
toString(): string;
}
}
declare module monaco.editor {
/**
* Create a new editor under `domElement`.
* `domElement` should be empty (not contain other dom nodes).
* The editor will read the size of `domElement`.
*/
export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor;
/**
* Emitted when an editor is created.
* Creating a diff editor might cause this listener to be invoked with the two editors.
* @event
*/
export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable;
/**
* Create a new diff editor under `domElement`.
* `domElement` should be empty (not contain other dom nodes).
* The editor will read the size of `domElement`.
*/
export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor;
export interface IDiffNavigator {
revealFirst: boolean;
canNavigate(): boolean;
next(): void;
previous(): void;
dispose(): void;
}
export interface IDiffNavigatorOptions {
followsCaret?: boolean;
ignoreCharChanges?: boolean;
alwaysRevealFirst?: boolean;
}
export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator;
/**
* Create a new editor model.
* You can specify the language that should be set for this model or let the language be inferred from the `uri`.
*/
export function createModel(value: string, language?: string, uri?: Uri): IModel;
/**
* Change the language for a model.
*/
export function setModelLanguage(model: IModel, language: string): void;
/**
* Set the markers for a model.
*/
export function setModelMarkers(model: IModel, owner: string, markers: IMarkerData[]): void;
/**
* Get the model that has `uri` if it exists.
*/
export function getModel(uri: Uri): IModel;
/**
* Get all the created models.
*/
export function getModels(): IModel[];
/**
* Emitted when a model is created.
* @event
*/
export function onDidCreateModel(listener: (model: IModel) => void): IDisposable;
/**
* Emitted right before a model is disposed.
* @event
*/
export function onWillDisposeModel(listener: (model: IModel) => void): IDisposable;
/**
* Emitted when a different language is set to a model.
* @event
*/
export function onDidChangeModelLanguage(listener: (e: {
model: IModel;
oldLanguage: string;
}) => void): IDisposable;
/**
* Create a new web worker that has model syncing capabilities built in.
* Specify an AMD module to load that will `create` an object that will be proxied.
*/
export function createWebWorker<T>(opts: IWebWorkerOptions): MonacoWebWorker<T>;
/**
* Colorize the contents of `domNode` using attribute `data-lang`.
*/
export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void>;
/**
* Colorize `text` using language `languageId`.
*/
export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string>;
/**
* Colorize a line in a model.
*/
export function colorizeModelLine(model: IModel, lineNumber: number, tabSize?: number): string;
/**
* Tokenize `text` using language `languageId`
*/
export function tokenize(text: string, languageId: string): Token[][];
/**
* Define a new theme.
*/
export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void;
/**
* Switches to a theme.
*/
export function setTheme(themeName: string): void;
export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black';
export interface IStandaloneThemeData {
base: BuiltinTheme;
inherit: boolean;
rules: ITokenThemeRule[];
colors: IColors;
}
export type IColors = {
[colorId: string]: string;
};
export interface ITokenThemeRule {
token: string;
foreground?: string;
background?: string;
fontStyle?: string;
}
/**
* A web worker that can provide a proxy to an arbitrary file.
*/
export interface MonacoWebWorker<T> {
/**
* Terminate the web worker, thus invalidating the returned proxy.
*/
dispose(): void;
/**
* Get a proxy to the arbitrary loaded code.
*/
getProxy(): Promise<T>;
/**
* Synchronize (send) the models at `resources` to the web worker,
* making them available in the monaco.worker.getMirrorModels().
*/
withSyncedResources(resources: Uri[]): Promise<T>;
}
export interface IWebWorkerOptions {
/**
* The AMD moduleId to load.
* It should export a function `create` that should return the exported proxy.
*/
moduleId: string;
/**
* The data to send over when calling create on the module.
*/
createData?: any;
/**
* A label to be used to identify the web worker for debugging purposes.
*/
label?: string;
}
/**
* The options to create an editor.
*/
export interface IEditorConstructionOptions extends IEditorOptions {
/**
* The initial model associated with this code editor.
*/
model?: IModel;
/**
* The initial value of the auto created model in the editor.
* To not create automatically a model, use `model: null`.
*/
value?: string;
/**
* The initial language of the auto created model in the editor.
* To not create automatically a model, use `model: null`.
*/
language?: string;
/**
* Initial theme to be used for rendering.
* The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
* You can create custom themes via `monaco.editor.defineTheme`.
* To switch a theme, use `monaco.editor.setTheme`
*/
theme?: string;
/**
* An URL to open when Ctrl+H (Windows and Linux) or Cmd+H (OSX) is pressed in
* the accessibility help dialog in the editor.
*
* Defaults to "https://go.microsoft.com/fwlink/?linkid=852450"
*/
accessibilityHelpUrl?: string;
}
/**
* The options to create a diff editor.
*/
export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
/**
* Initial theme to be used for rendering.
* The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
* You can create custom themes via `monaco.editor.defineTheme`.
* To switch a theme, use `monaco.editor.setTheme`
*/
theme?: string;
}
export interface IStandaloneCodeEditor extends ICodeEditor {
addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
addAction(descriptor: IActionDescriptor): IDisposable;
}
export interface IStandaloneDiffEditor extends IDiffEditor {
addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
addAction(descriptor: IActionDescriptor): IDisposable;
getOriginalEditor(): IStandaloneCodeEditor;
getModifiedEditor(): IStandaloneCodeEditor;
}
export interface ICommandHandler {
(...args: any[]): void;
}
export interface IContextKey<T> {
set(value: T): void;
reset(): void;
get(): T;
}
export interface IEditorOverrideServices {
[index: string]: any;
}
/**
* A structure defining a problem/warning/etc.
*/
export interface IMarkerData {
code?: string;
severity: Severity;
message: string;
source?: string;
startLineNumber: number;
startColumn: number;
endLineNumber: number;
endColumn: number;
}
export interface IColorizerOptions {
tabSize?: number;
}
export interface IColorizerElementOptions extends IColorizerOptions {
theme?: string;
mimeType?: string;
}
export enum ScrollbarVisibility {
Auto = 1,
Hidden = 2,
Visible = 3,
}
export interface ThemeColor {
id: string;
}
/**
* Vertical Lane in the overview ruler of the editor.
*/
export enum OverviewRulerLane {
Left = 1,
Center = 2,
Right = 4,
Full = 7,
}
/**
* Options for rendering a model decoration in the overview ruler.
*/
export interface IModelDecorationOverviewRulerOptions {
/**
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
color: string | ThemeColor;
/**
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
darkColor: string | ThemeColor;
/**
* CSS color to render in the overview ruler.
* e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
*/
hcColor?: string | ThemeColor;
/**
* The position in the overview ruler.
*/
position: OverviewRulerLane;
}
/**
* Options for a model decoration.
*/
export interface IModelDecorationOptions {
/**
* Customize the growing behavior of the decoration when typing at the edges of the decoration.
* Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
*/
stickiness?: TrackedRangeStickiness;
/**
* CSS class name describing the decoration.
*/
className?: string;
/**
* Message to be rendered when hovering over the glyph margin decoration.
*/
glyphMarginHoverMessage?: MarkedString | MarkedString[];
/**
* Array of MarkedString to render as the decoration message.
*/
hoverMessage?: MarkedString | MarkedString[];
/**
* Should the decoration expand to encompass a whole line.
*/
isWholeLine?: boolean;
/**
* If set, render this decoration in the overview ruler.
*/
overviewRuler?: IModelDecorationOverviewRulerOptions;
/**
* If set, the decoration will be rendered in the glyph margin with this CSS class name.
*/
glyphMarginClassName?: string;
/**
* If set, the decoration will be rendered in the lines decorations with this CSS class name.
*/
linesDecorationsClassName?: string;
/**
* If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name.
*/
marginClassName?: string;
/**
* If set, the decoration will be rendered inline with the text with this CSS class name.
* Please use this only for CSS rules that must impact the text. For example, use `className`
* to have a background color decoration.
*/
inlineClassName?: string;
/**
* If set, the decoration will be rendered before the text with this CSS class name.
*/
beforeContentClassName?: string;
/**
* If set, the decoration will be rendered after the text with this CSS class name.
*/
afterContentClassName?: string;
}
/**
* New model decorations.
*/
export interface IModelDeltaDecoration {
/**
* Range that this decoration covers.
*/
range: IRange;
/**
* Options associated with this decoration.
*/
options: IModelDecorationOptions;
}
/**
* A decoration in the model.
*/
export interface IModelDecoration {
/**
* Identifier for a decoration.
*/
id: string;
/**
* Identifier for a decoration's owener.
*/
ownerId: number;
/**
* Range that this decoration covers.
*/
range: Range;
/**
* Options associated with this decoration.
*/
options: IModelDecorationOptions;
/**
* A flag describing if this is a problem decoration (e.g. warning/error).
*/
isForValidation: boolean;
}
/**
* Word inside a model.
*/
export interface IWordAtPosition {
/**
* The word.
*/
word: string;
/**
* The column where the word starts.
*/
startColumn: number;
/**
* The column where the word ends.
*/
endColumn: number;
}
/**
* End of line character preference.
*/
export enum EndOfLinePreference {
/**
* Use the end of line character identified in the text buffer.
*/
TextDefined = 0,
/**
* Use line feed (\n) as the end of line character.
*/
LF = 1,
/**
* Use carriage return and line feed (\r\n) as the end of line character.
*/
CRLF = 2,
}
/**
* The default end of line to use when instantiating models.
*/
export enum DefaultEndOfLine {
/**
* Use line feed (\n) as the end of line character.
*/
LF = 1,
/**
* Use carriage return and line feed (\r\n) as the end of line character.
*/
CRLF = 2,
}
/**
* End of line character preference.
*/
export enum EndOfLineSequence {
/**
* Use line feed (\n) as the end of line character.
*/
LF = 0,
/**
* Use carriage return and line feed (\r\n) as the end of line character.
*/
CRLF = 1,
}
/**
* An identifier for a single edit operation.
*/
export interface ISingleEditOperationIdentifier {
/**
* Identifier major
*/
major: number;
/**
* Identifier minor
*/
minor: number;
}
/**
* A builder and helper for edit operations for a command.
*/
export interface IEditOperationBuilder {
/**
* Add a new edit operation (a replace operation).
* @param range The range to replace (delete). May be empty to represent a simple insert.
* @param text The text to replace with. May be null to represent a simple delete.
*/
addEditOperation(range: Range, text: string): void;
/**
* Add a new edit operation (a replace operation).
* The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()`
* @param range The range to replace (delete). May be empty to represent a simple insert.
* @param text The text to replace with. May be null to represent a simple delete.
*/
addTrackedEditOperation(range: Range, text: string): void;
/**
* Track `selection` when applying edit operations.
* A best effort will be made to not grow/expand the selection.
* An empty selection will clamp to a nearby character.
* @param selection The selection to track.
* @param trackPreviousOnEmpty If set, and the selection is empty, indicates whether the selection
* should clamp to the previous or the next character.
* @return A unique identifer.
*/
trackSelection(selection: Selection, trackPreviousOnEmpty?: boolean): string;
}
/**
* A helper for computing cursor state after a command.
*/
export interface ICursorStateComputerData {
/**
* Get the inverse edit operations of the added edit operations.
*/
getInverseEditOperations(): IIdentifiedSingleEditOperation[];
/**
* Get a previously tracked selection.
* @param id The unique identifier returned by `trackSelection`.
* @return The selection.
*/
getTrackedSelection(id: string): Selection;
}
/**
* A command that modifies text / cursor state on a model.
*/
export interface ICommand {
/**
* Get the edit operations needed to execute this command.
* @param model The model the command will execute on.
* @param builder A helper to collect the needed edit operations and to track selections.
*/
getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void;
/**
* Compute the cursor state after the edit operations were applied.
* @param model The model the commad has executed on.
* @param helper A helper to get inverse edit operations and to get previously tracked selections.
* @return The cursor state after the command executed.
*/
computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection;
}
/**
* A single edit operation, that acts as a simple replace.
* i.e. Replace text at `range` with `text` in model.
*/
export interface ISingleEditOperation {
/**
* The range to replace. This can be empty to emulate a simple insert.
*/
range: IRange;
/**
* The text to replace with. This can be null to emulate a simple delete.
*/
text: string;
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
*/
forceMoveMarkers?: boolean;
}
/**
* A single edit operation, that has an identifier.
*/
export interface IIdentifiedSingleEditOperation {
/**
* An identifier associated with this single edit operation.
*/
identifier: ISingleEditOperationIdentifier;
/**
* The range to replace. This can be empty to emulate a simple insert.
*/
range: Range;
/**
* The text to replace with. This can be null to emulate a simple delete.
*/
text: string;
/**
* This indicates that this operation has "insert" semantics.
* i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
*/
forceMoveMarkers: boolean;
/**
* This indicates that this operation is inserting automatic whitespace
* that can be removed on next model edit operation if `config.trimAutoWhitespace` is true.
*/
isAutoWhitespaceEdit?: boolean;
}
/**
* A callback that can compute the cursor state after applying a series of edit operations.
*/
export interface ICursorStateComputer {
/**
* A callback that can compute the resulting cursors state after some edit operations have been executed.
*/
(inverseEditOperations: IIdentifiedSingleEditOperation[]): Selection[];
}
export class TextModelResolvedOptions {
_textModelResolvedOptionsBrand: void;
tabSize: number;
insertSpaces: boolean;
defaultEOL: DefaultEndOfLine;
trimAutoWhitespace: boolean;
}
export interface ITextModelUpdateOptions {
tabSize?: number;
insertSpaces?: boolean;
trimAutoWhitespace?: boolean;
}
/**
* A textual read-only model.
*/
export interface ITextModel {
/**
* Get the resolved options for this model.
*/
getOptions(): TextModelResolvedOptions;
/**
* Get the current version id of the model.
* Anytime a change happens to the model (even undo/redo),
* the version id is incremented.
*/
getVersionId(): number;
/**
* Get the alternative version id of the model.
* This alternative version id is not always incremented,
* it will return the same values in the case of undo-redo.
*/
getAlternativeVersionId(): number;
/**
* Replace the entire text buffer value contained in this model.
*/
setValue(newValue: string): void;
/**
* Get the text stored in this model.
* @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`.
* @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.
* @return The text.
*/
getValue(eol?: EndOfLinePreference, preserveBOM?: boolean): string;
/**
* Get the length of the text stored in this model.
*/
getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number;
/**
* Get the text in a certain range.
* @param range The range describing what text to get.
* @param eol The end of line character preference. This will only be used for multiline ranges. Defaults to `EndOfLinePreference.TextDefined`.
* @return The text.
*/
getValueInRange(range: IRange, eol?: EndOfLinePreference): string;
/**
* Get the length of text in a certain range.
* @param range The range describing what text length to get.
* @return The text length.
*/
getValueLengthInRange(range: IRange): number;
/**
* Get the number of lines in the model.
*/
getLineCount(): number;
/**
* Get the text for a certain line.
*/
getLineContent(lineNumber: number): string;
/**
* Get the text for all lines.
*/
getLinesContent(): string[];
/**
* Get the end of line sequence predominantly used in the text buffer.
* @return EOL char sequence (e.g.: '\n' or '\r\n').
*/
getEOL(): string;
/**
* Change the end of line sequence used in the text buffer.
*/
setEOL(eol: EndOfLineSequence): void;
/**
* Get the minimum legal column for line at `lineNumber`
*/
getLineMinColumn(lineNumber: number): number;
/**
* Get the maximum legal column for line at `lineNumber`
*/
getLineMaxColumn(lineNumber: number): number;
/**
* Returns the column before the first non whitespace character for line at `lineNumber`.
* Returns 0 if line is empty or contains only whitespace.
*/
getLineFirstNonWhitespaceColumn(lineNumber: number): number;
/**
* Returns the column after the last non whitespace character for line at `lineNumber`.
* Returns 0 if line is empty or contains only whitespace.
*/
getLineLastNonWhitespaceColumn(lineNumber: number): number;