vscode.proposed.d.ts 5.3 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 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
	// export enum FileErrorCodes {
	// 	/**
	// 	 * Not owner.
	// 	 */
	// 	EPERM = 1,
	// 	/**
	// 	 * No such file or directory.
	// 	 */
	// 	ENOENT = 2,
	// 	/**
	// 	 * I/O error.
	// 	 */
	// 	EIO = 5,
	// 	/**
	// 	 * Permission denied.
	// 	 */
	// 	EACCES = 13,
	// 	/**
	// 	 * File exists.
	// 	 */
	// 	EEXIST = 17,
	// 	/**
	// 	 * Not a directory.
	// 	 */
	// 	ENOTDIR = 20,
	// 	/**
	// 	 * Is a directory.
	// 	 */
	// 	EISDIR = 21,
	// 	/**
	// 	 *  File too large.
	// 	 */
	// 	EFBIG = 27,
	// 	/**
	// 	 * No space left on device.
	// 	 */
	// 	ENOSPC = 28,
	// 	/**
	// 	 * Directory is not empty.
	// 	 */
	// 	ENOTEMPTY = 66,
	// 	/**
	// 	 * Invalid file handle.
	// 	 */
	// 	ESTALE = 70,
	// 	/**
	// 	 * Illegal NFS file handle.
	// 	 */
	// 	EBADHANDLE = 10001,
	// }

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
	export enum FileChangeType {
		Updated = 0,
		Added = 1,
		Deleted = 2
	}

	export interface FileChange {
		type: FileChangeType;
		resource: Uri;
	}

	export enum FileType {
		File = 0,
		Dir = 1,
		Symlink = 2
	}

	export interface FileStat {
79
		id: number | string;
80
		mtime: number;
J
Johannes Rieken 已提交
81
		// atime: number;
82 83 84 85
		size: number;
		type: FileType;
	}

J
Johannes Rieken 已提交
86 87
	// todo@joh discover files etc
	export interface FileSystemProvider {
D
Dirk Baeumer 已提交
88

89 90 91
		onDidChange?: Event<FileChange[]>;

		root: Uri;
92

93 94
		// more...
		//
J
Johannes Rieken 已提交
95
		utimes(resource: Uri, mtime: number, atime: number): Thenable<FileStat>;
96

97
		stat(resource: Uri): Thenable<FileStat>;
98

99
		read(resource: Uri, offset: number, length: number, progress: Progress<Uint8Array>): Thenable<number>;
100 101 102 103 104

		// todo@remote
		// offset - byte offset to start
		// count - number of bytes to write
		// Thenable<number> - number of bytes actually written
105
		write(resource: Uri, content: Uint8Array): Thenable<void>;
106 107 108

		// todo@remote
		// Thenable<FileStat>
109 110 111 112 113
		move(resource: Uri, target: Uri): Thenable<FileStat>;

		// todo@remote
		// helps with performance bigly
		// copy?(from: Uri, to: Uri): Thenable<void>;
114 115 116

		// todo@remote
		// Thenable<FileStat>
117
		mkdir(resource: Uri): Thenable<FileStat>;
118

119 120 121 122 123
		readdir(resource: Uri): Thenable<[Uri, FileStat][]>;

		// todo@remote
		// ? merge both
		// ? recursive del
124
		rmdir(resource: Uri): Thenable<void>;
125 126 127 128
		unlink(resource: Uri): Thenable<void>;

		// todo@remote
		// create(resource: Uri): Thenable<FileStat>;
J
Johannes Rieken 已提交
129 130 131

		// find files by names
		findFiles?(query: string, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
132 133
	}

134
	export namespace workspace {
J
Johannes Rieken 已提交
135
		export function registerFileSystemProvider(authority: string, provider: FileSystemProvider): Disposable;
136 137
	}

138 139 140 141
	export namespace window {

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

J
Joao Moreno 已提交
143 144 145
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
146 147 148 149 150 151 152
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
	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;
	}
171 172 173 174 175 176 177

	//#region decorations

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
178
		bubble?: boolean;
179 180
		abbreviation?: string;
		color?: ThemeColor;
181
		source?: string;
182 183 184
	}

	export interface DecorationProvider {
185
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
186 187 188 189
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
190
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
191 192 193
	}

	//#endregion
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220

	/**
	 * Represents the debug console.
	 */
	export interface DebugConsole {
		/**
		 * Append the given value to the debug console.
		 *
		 * @param value A string, falsy values will not be printed.
		 */
		append(value: string): void;

		/**
		 * Append the given value and a line feed character
		 * to the debug console.
		 *
		 * @param value A string, falsy values will be printed.
		 */
		appendLine(value: string): void;
	}

	export namespace debug {
		/**
		 * The [debug console](#DebugConsole) singleton.
		 */
		export let console: DebugConsole;
	}
J
Johannes Rieken 已提交
221
}