windows.ts 3.2 KB
Newer Older
B
Benjamin Pasero 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import { TPromise } from 'vs/base/common/winjs.base';
B
Benjamin Pasero 已提交
9
import { OpenContext, IWindowConfiguration, ReadyState, INativeOpenDialogOptions } from 'vs/platform/windows/common/windows';
B
Benjamin Pasero 已提交
10 11
import { ParsedArgs } from 'vs/platform/environment/common/environment';
import Event from 'vs/base/common/event';
B
Benjamin Pasero 已提交
12 13
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IProcessEnvironment } from 'vs/base/common/platform';
14
import { IWorkspaceIdentifier } from "vs/platform/workspaces/common/workspaces";
B
Benjamin Pasero 已提交
15 16 17 18 19

export interface ICodeWindow {
	id: number;
	win: Electron.BrowserWindow;
	config: IWindowConfiguration;
20

21
	openedFolderPath: string;
22
	openedWorkspace: IWorkspaceIdentifier;
23

24
	lastFocusTime: number;
B
Benjamin Pasero 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

	readyState: ReadyState;

	close(): void;

	send(channel: string, ...args: any[]): void;
	sendWhenReady(channel: string, ...args: any[]): void;

	toggleFullScreen(): void;
	hasHiddenTitleBarStyle(): boolean;
	setRepresentedFilename(name: string): void;
	getRepresentedFilename(): string;
	onWindowTitleDoubleClick(): void;
}

export const IWindowsMainService = createDecorator<IWindowsMainService>('windowsMainService');

B
Benjamin Pasero 已提交
42 43 44 45 46
export interface IWindowsCountChangedEvent {
	oldCount: number;
	newCount: number;
}

B
Benjamin Pasero 已提交
47 48 49 50 51
export interface IWindowsMainService {
	_serviceBrand: any;

	// events
	onWindowReady: Event<ICodeWindow>;
52
	onActiveWindowChanged: Event<ICodeWindow>;
B
Benjamin Pasero 已提交
53
	onWindowsCountChanged: Event<IWindowsCountChangedEvent>;
B
Benjamin Pasero 已提交
54 55 56 57 58 59
	onWindowClose: Event<number>;
	onWindowReload: Event<number>;

	// methods
	ready(initialUserEnv: IProcessEnvironment): void;
	reload(win: ICodeWindow, cli?: ParsedArgs): void;
60
	openWorkspace(win?: ICodeWindow): void;
61
	closeWorkspace(win: ICodeWindow): void;
B
Benjamin Pasero 已提交
62 63
	open(openConfig: IOpenConfiguration): ICodeWindow[];
	openExtensionDevelopmentHostWindow(openConfig: IOpenConfiguration): void;
B
Benjamin Pasero 已提交
64 65 66
	pickFileFolderAndOpen(options: INativeOpenDialogOptions): void;
	pickFolderAndOpen(options: INativeOpenDialogOptions): void;
	pickFileAndOpen(options: INativeOpenDialogOptions): void;
B
Benjamin Pasero 已提交
67 68
	focusLastActive(cli: ParsedArgs, context: OpenContext): ICodeWindow;
	getLastActiveWindow(): ICodeWindow;
69
	waitForWindowClose(windowId: number): TPromise<void>;
B
Benjamin Pasero 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
	openNewWindow(context: OpenContext): void;
	sendToFocused(channel: string, ...args: any[]): void;
	sendToAll(channel: string, payload: any, windowIdsToIgnore?: number[]): void;
	getFocusedWindow(): ICodeWindow;
	getWindowById(windowId: number): ICodeWindow;
	getWindows(): ICodeWindow[];
	getWindowCount(): number;
	quit(): void;
}

export interface IOpenConfiguration {
	context: OpenContext;
	cli: ParsedArgs;
	userEnv?: IProcessEnvironment;
	pathsToOpen?: string[];
	preferNewWindow?: boolean;
	forceNewWindow?: boolean;
	forceReuseWindow?: boolean;
	forceEmpty?: boolean;
	diffMode?: boolean;
90
	forceOpenWorkspaceAsFile?: boolean;
B
Benjamin Pasero 已提交
91 92 93 94 95 96 97
	initialStartup?: boolean;
}

export interface ISharedProcess {
	whenReady(): TPromise<void>;
	toggle(): void;
}