vscode.proposed.d.ts 4.8 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

// This is the place for API experiments and proposal.

declare module 'vscode' {

10
	export interface OpenDialogOptions {
11 12
		defaultResource?: Uri;
		openLabel?: string;
13 14 15 16
		openFiles?: boolean;
		openFolders?: boolean;
		openMany?: boolean;
	}
17

18 19 20 21
	export interface SaveDialogOptions {
		defaultResource?: Uri;
		saveLabel?: string;
	}
D
Dirk Baeumer 已提交
22

23
	export namespace window {
24
		export function showOpenDialog(options: OpenDialogOptions): Thenable<Uri[]>;
25
		export function showSaveDialog(options: SaveDialogOptions): Thenable<Uri>;
26 27
	}

J
Johannes Rieken 已提交
28 29 30 31
	// todo@joh discover files etc
	export interface FileSystemProvider {
		// todo@joh -> added, deleted, renamed, changed
		onDidChange: Event<Uri>;
D
Dirk Baeumer 已提交
32

J
Johannes Rieken 已提交
33 34
		resolveContents(resource: Uri): string | Thenable<string>;
		writeContents(resource: Uri, contents: string): void | Thenable<void>;
35

36 37 38
		// -- search
		// todo@joh - extract into its own provider?
		findFiles(query: string, progress: Progress<Uri>, token?: CancellationToken): Thenable<void>;
39 40
	}

41
	export namespace workspace {
J
Johannes Rieken 已提交
42
		export function registerFileSystemProvider(authority: string, provider: FileSystemProvider): Disposable;
43 44
	}

45 46 47 48
	export namespace window {

		export function sampleFunction(): Thenable<any>;
	}
P
Pine Wu 已提交
49

J
Joao Moreno 已提交
50 51 52
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
53 54 55 56 57 58 59
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
		 * Diff information commands are different from ordinary [commands](#commands.registerCommand) as
		 * they only execute when there is an active diff editor when the command is called, and the diff
		 * information has been computed. Also, the command handler of an editor command has access to
		 * the diff information.
		 *
		 * @param command A unique identifier for the command.
		 * @param callback A command handler function with access to the [diff information](#LineChange).
		 * @param thisArg The `this` context used when invoking the handler function.
		 * @return Disposable which unregisters this command on disposal.
		 */
		export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable;
	}
D
Daniel Imms 已提交
78

J
Joao Moreno 已提交
79 80 81
	/**
	 * Represents a color in RGBA space.
	 */
82
	export class Color {
J
Joao Moreno 已提交
83 84 85 86

		/**
		 * The red component of this color in the range [0-1].
		 */
87
		readonly red: number;
J
Joao Moreno 已提交
88 89 90 91

		/**
		 * The green component of this color in the range [0-1].
		 */
92
		readonly green: number;
J
Joao Moreno 已提交
93 94 95 96

		/**
		 * The blue component of this color in the range [0-1].
		 */
97 98
		readonly blue: number;

J
Joao Moreno 已提交
99 100 101 102 103 104
		/**
		 * The alpha component of this color in the range [0-1].
		 */
		readonly alpha: number;

		constructor(red: number, green: number, blue: number, alpha: number);
105 106
	}

J
Joao Moreno 已提交
107
	/**
108
	 * Represents a color format
J
Joao Moreno 已提交
109
	 */
110 111 112 113 114
	export enum ColorFormat {
		RGB = 0,
		HEX = 1,
		HSL = 2
	}
J
Joao Moreno 已提交
115

J
Joao Moreno 已提交
116 117 118 119 120 121 122 123
	/**
	 * Represents a color range from a document.
	 */
	export class ColorRange {

		/**
		 * The range in the document where this color appers.
		 */
124 125
		range: Range;

J
Joao Moreno 已提交
126 127 128
		/**
		 * The actual color value for this color range.
		 */
129 130
		color: Color;

J
Joao Moreno 已提交
131 132 133 134 135 136 137
		/**
		 * Creates a new color range.
		 *
		 * @param range The range the color appears in. Must not be empty.
		 * @param color The value of the color.
		 * @param format The format in which this color is currently formatted.
		 */
138
		constructor(range: Range, color: Color);
M
Michel Kaporin 已提交
139
	}
140

J
Joao Moreno 已提交
141 142 143 144
	/**
	 * The document color provider defines the contract between extensions and feature of
	 * picking and modifying colors in the editor.
	 */
145
	export interface DocumentColorProvider {
J
Joao Moreno 已提交
146 147 148 149 150 151 152 153 154
		/**
		 * Provide colors for the given document.
		 *
		 * @param document The document in which the command was invoked.
		 * @param token A cancellation token.
		 * @return An array of [color ranges](#ColorRange) or a thenable that resolves to such. The lack of a result
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
		provideDocumentColors(document: TextDocument, token: CancellationToken): ProviderResult<ColorRange[]>;
155 156 157
		/**
		 * Provide the string representation for a color.
		 */
158
		resolveDocumentColor(color: Color, colorFormat: ColorFormat): ProviderResult<string>;
159 160 161 162 163
	}

	export namespace languages {
		export function registerColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable;
	}
164
}