vscode.proposed.d.ts 8.1 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 14
	export interface WorkspaceFoldersChangeEvent {
		readonly addedFolders: Uri[];
		readonly removedFolders: Uri[];
	}

15 16
	export namespace workspace {

J
Johannes Rieken 已提交
17 18 19 20
		/**
		* List of workspace folders or `undefined` when no folder is open. The *first*
		* element in the array is equal to the [`rootPath`](#workspace.rootPath)
		*/
21
		export let workspaceFolders: Uri[] | undefined;
J
Johannes Rieken 已提交
22 23 24 25 26

		/**
		 * An event that is emitted when a workspace folder is added or removed.
		 */
		export const onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>;
27 28
	}

29
	export interface WorkspaceConfiguration2 extends WorkspaceConfiguration {
30

31
		inspect<T>(section: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } | undefined;
D
Dirk Baeumer 已提交
32

33 34 35
	}

	export namespace workspace {
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
		/**
		 * Get a configuration object.
		 *
		 * When a section-identifier is provided only that part of the configuration
		 * is returned. Dots in the section-identifier are interpreted as child-access,
		 * like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
		 *
		 * When a resource is provided, only configuration scoped to that resource
		 * is returned.
		 *
		 * If editor is opened with `no folders` then returns the global configuration.
		 *
		 * If editor is opened with `folders` then returns the configuration from the folder in which the resource belongs to.
		 *
		 * If resource does not belongs to any opened folders, then returns the workspace configuration.
		 *
		 * @param section A dot-separated identifier.
		 * @param resource A resource for which configuration is asked
		 * @return The full workspace configuration or a subset.
		 */
56 57 58
		export function getConfiguration2(section?: string, resource?: Uri): WorkspaceConfiguration2;
	}

59 60 61 62 63 64 65 66 67 68 69 70
	/**
	 * Represents the workspace configuration.
	 *
	 * The workspace configuration is a merged view of
	 *
	 * - Default configuration
	 * - Global configuration
	 * - Workspace configuration (if available)
	 * - Folder configuration of the [resource](#workspace.getConfiguration2) (if requested and available)
	 *
	 * **Global configuration** comes from User Settings and shadows Defaults.
	 *
S
Sandeep Somavarapu 已提交
71
	 * **Workspace configuration** comes from the `.vscode` folder under first [workspace folders](#workspace.workspaceFolders)
72 73
	 * and shadows Globals configuration.
	 *
S
Sandeep Somavarapu 已提交
74 75
	 * **Folder configurations** comes from `.vscode` folder under [workspace folders](#workspace.workspaceFolders). Each [workspace folder](#workspace.workspaceFolders)
	 * has a configuration and the requested resource determines which folder configuration to pick. Folder configuration shodows Workspace configuration.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
	 *
	 * *Note:* Workspace and Folder configurations contains settings from `launch.json` and `tasks.json` files. Their basename will be
	 * part of the section identifier. The following snippets shows how to retrieve all configurations
	 * from `launch.json`:
	 *
	 * ```ts
	 * // launch.json configuration
	 * const config = workspace.getConfiguration('launch', workspace.workspaceFolders[1]);
	 *
	 * // retrieve values
	 * const values = config.get('configurations');
	 * ```
	 */
	export interface WorkspaceConfiguration2 extends WorkspaceConfiguration {

		/**
		 * Retrieve all information about a configuration setting. A configuration value
		 * often consists of a *default* value, a global or installation-wide value,
		 * a workspace-specific value and a folder-specific value.
		 *
		 * The *effective* value (returned by [`get`](#WorkspaceConfiguration.get))
		 * is computed like this: `defaultValue` overwritten by `globalValue`,
		 * `globalValue` overwritten by `workspaceValue`. `workspaceValue` overwritten by `folderValue`.
		 *
		 * *Note:* The configuration name must denote a leaf in the configuration tree
		 * (`editor.fontSize` vs `editor`) otherwise no result is returned.
		 *
		 * @param section Configuration name, supports _dotted_ names.
		 * @return Information about a configuration setting or `undefined`.
		 */
		inspect<T>(section: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } | undefined;

	}

110 111 112 113
	export namespace window {

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

J
Joao Moreno 已提交
115 116 117
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
118 119 120 121 122 123 124
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
	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 已提交
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191

	export interface Terminal {

		/**
		 * The name of the terminal.
		 */
		readonly name: string;

		/**
		 * The process ID of the shell process.
		 */
		readonly processId: Thenable<number>;

		/**
		 * Send text to the terminal. The text is written to the stdin of the underlying pty process
		 * (shell) of the terminal.
		 *
		 * @param text The text to send.
		 * @param addNewLine Whether to add a new line to the text being sent, this is normally
		 * required to run a command in the terminal. The character(s) added are \n or \r\n
		 * depending on the platform. This defaults to `true`.
		 */
		sendText(text: string, addNewLine?: boolean): void;

		/**
		 * Show the terminal panel and reveal this terminal in the UI.
		 *
		 * @param preserveFocus When `true` the terminal will not take focus.
		 */
		show(preserveFocus?: boolean): void;

		/**
		 * Hide the terminal panel if this terminal is currently showing.
		 */
		hide(): void;

		/**
		 * Dispose and free associated resources.
		 */
		dispose(): void;

		/**
		 * Experimental API that allows listening to the raw data stream coming from the terminal's
		 * pty process (including ANSI escape sequences).
		 *
		 * @param callback The callback that is triggered when data is sent to the terminal.
		 */
		onData(callback: (data: string) => any): void;
	}
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209

	export namespace debug {

		/**
		 * The currently active debug session or `undefined`. The active debug session is the one
		 * represented by the debug action floating window or the one currently shown in the drop down menu of the debug action floating window.
		 * If no debug session is active, the value is `undefined`.
		 */
		export const activeDebugSession: DebugSession | undefined;

		/**
		 * An [event](#Event) which fires when the [active debug session](#debug.activeDebugSession)
		 * has changed. *Note* that the event also fires when the active debug session changes
		 * to `undefined`.
		 */
		export const onDidChangeActiveDebugSession: Event<DebugSession | undefined>;
	}

210 211 212 213 214 215 216 217 218 219
	export interface DebugSession {

		/**
		 * Experimental API that allows hooking custom events from the debug session's debug adapter.
		 *
		 * @param callback The callback that is triggered when a custom event is received from the debug adapter.
		 */
		onCustomEvent(callback: (event: any) => void): void;
	}

220
}