vscode.proposed.d.ts 4.2 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' {

J
Johannes Rieken 已提交
10 11 12 13
	// todo@joh discover files etc
	export interface FileSystemProvider {
		// todo@joh -> added, deleted, renamed, changed
		onDidChange: Event<Uri>;
D
Dirk Baeumer 已提交
14

J
Johannes Rieken 已提交
15 16
		resolveContents(resource: Uri): string | Thenable<string>;
		writeContents(resource: Uri, contents: string): void | Thenable<void>;
17 18 19
	}

	export namespace workspace {
J
Johannes Rieken 已提交
20 21

		export function registerFileSystemProvider(authority: string, provider: FileSystemProvider): Disposable;
22 23
	}

24 25 26 27
	export namespace window {

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

J
Joao Moreno 已提交
29 30 31
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
32 33 34 35 36 37 38
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
	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 已提交
57

58
	/**
C
Christof Marti 已提交
59
	 * Namespace for handling credentials.
60
	 */
C
Christof Marti 已提交
61
	export namespace credentials {
62 63

		/**
C
Christof Marti 已提交
64
		 * Read a previously stored secret from the credential store.
D
Daniel Imms 已提交
65
		 *
C
Christof Marti 已提交
66 67 68
		 * @param service The service of the credential.
		 * @param account The account of the credential.
		 * @return A promise for the secret of the credential.
69
		 */
C
Christof Marti 已提交
70
		export function readSecret(service: string, account: string): Thenable<string | undefined>;
71 72

		/**
C
Christof Marti 已提交
73
		 * Write a secret to the credential store.
D
Daniel Imms 已提交
74
		 *
C
Christof Marti 已提交
75 76 77 78
		 * @param service The service of the credential.
		 * @param account The account of the credential.
		 * @param secret The secret of the credential to write to the credential store.
		 * @return A promise indicating completion of the operation.
79
		 */
C
Christof Marti 已提交
80
		export function writeSecret(service: string, account: string, secret: string): Thenable<void>;
81 82

		/**
C
Christof Marti 已提交
83
		 * Delete a previously stored secret from the credential store.
D
Daniel Imms 已提交
84
		 *
C
Christof Marti 已提交
85 86 87
		 * @param service The service of the credential.
		 * @param account The account of the credential.
		 * @return A promise resolving to true if there was a secret for that service and account.
88
		 */
C
Christof Marti 已提交
89
		export function deleteSecret(service: string, account: string): Thenable<boolean>;
90
	}
91 92

	export class Color {
93 94 95 96 97 98 99
		readonly red: number;
		readonly green: number;
		readonly blue: number;
		readonly alpha?: number;

		constructor(red: number, green: number, blue: number, alpha?: number);

100 101
		static fromHSLA(hue: number, saturation: number, luminosity: number, alpha?: number): Color;
		static fromHex(hex: string): Color;
102 103
	}

J
Joao Moreno 已提交
104 105
	export type ColorFormat = string | { opaque: string, transparent: string };

106 107 108 109 110 111
	// TODO@Michel
	export class ColorInfo {
		range: Range;

		color: Color;

J
Joao Moreno 已提交
112
		format: ColorFormat;
113

J
Joao Moreno 已提交
114
		availableFormats: ColorFormat[];
115

J
Joao Moreno 已提交
116
		constructor(range: Range, color: Color, format: ColorFormat, availableFormats: ColorFormat[]);
M
Michel Kaporin 已提交
117
	}
118 119 120 121 122 123 124 125

	export interface DocumentColorProvider {
		provideDocumentColors(document: TextDocument, token: CancellationToken): ProviderResult<ColorInfo[]>;
	}

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