merge with master
This commit is contained in:
commit
92fb16ab11
74 changed files with 2953 additions and 1108 deletions
|
@ -57,7 +57,7 @@
|
|||
},
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "0.34.5",
|
||||
"version": "0.35.5",
|
||||
"license": "MIT",
|
||||
"repositoryURL": "https://github.com/atom/electron",
|
||||
"isProd": true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
environment:
|
||||
ATOM_SHELL_INTERNAL_RUN_AS_NODE: 1
|
||||
ELECTRON_RUN_AS_NODE: 1
|
||||
|
||||
install:
|
||||
- ps: Install-Product node 4.1.1 x64
|
||||
|
|
|
@ -7,7 +7,7 @@ var path = require('path');
|
|||
var gulp = require('gulp');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var filter = require('gulp-filter');
|
||||
var minifyCSS = require('gulp-minify-css');
|
||||
var minifyCSS = require('gulp-cssnano');
|
||||
var uglify = require('gulp-uglify');
|
||||
var es = require('event-stream');
|
||||
var concat = require('gulp-concat');
|
||||
|
|
|
@ -63,6 +63,7 @@ var copyrightFilterList = [
|
|||
'!**/*.md',
|
||||
'!**/*.bat',
|
||||
'!**/*.cmd',
|
||||
'!resources/win32/bin/code.js',
|
||||
'!**/*.sh',
|
||||
'!**/*.txt',
|
||||
'!src/vs/editor/standalone-languages/swift.ts',
|
||||
|
|
|
@ -29,13 +29,11 @@ var build = path.join(root, '.build');
|
|||
var commit = util.getVersion(root);
|
||||
|
||||
var baseModules = [
|
||||
'app', 'applicationinsights', 'assert', 'auto-updater', 'browser-window',
|
||||
'child_process', 'chokidar', 'crash-reporter', 'crypto', 'dialog', 'emmet',
|
||||
'applicationinsights', 'assert', 'child_process', 'chokidar', 'crypto', 'emmet',
|
||||
'events', 'fs', 'getmac', 'glob', 'graceful-fs', 'http', 'http-proxy-agent',
|
||||
'https', 'https-proxy-agent', 'iconv-lite', 'ipc', 'menu', 'menu-item', 'net',
|
||||
'original-fs', 'os', 'path', 'readline', 'remote', 'sax', 'screen', 'semver',
|
||||
'shell', 'stream', 'string_decoder', 'url', 'vscode-textmate', 'web-frame', 'winreg',
|
||||
'yauzl', 'native-keymap'
|
||||
'https', 'https-proxy-agent', 'iconv-lite', 'electron', 'net',
|
||||
'os', 'path', 'readline', 'sax', 'semver', 'stream', 'string_decoder', 'url',
|
||||
'vscode-textmate', 'winreg', 'yauzl', 'native-keymap'
|
||||
];
|
||||
|
||||
// Build
|
||||
|
|
|
@ -125,7 +125,8 @@ function registerSupports(modeID: string, host: TypeScriptServiceClientHost, cli
|
|||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '`', close: '`', notIn: ['string', 'comment'] }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -47,7 +47,7 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
|
|||
|
||||
newEnv['STDIN_PIPE_NAME'] = stdInPipeName;
|
||||
newEnv['STDOUT_PIPE_NAME'] = stdOutPipeName;
|
||||
newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
|
||||
newEnv['ELECTRON_RUN_AS_NODE'] = '1';
|
||||
|
||||
return newEnv;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ var stdOutPipeName = process.env['STDOUT_PIPE_NAME'];
|
|||
|
||||
log('STDIN_PIPE_NAME: ' + stdInPipeName);
|
||||
log('STDOUT_PIPE_NAME: ' + stdOutPipeName);
|
||||
log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE']);
|
||||
log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
|
||||
// stdout redirection to named pipe
|
||||
(function() {
|
||||
|
@ -136,7 +136,7 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
|
|||
// Unset the custom environmental variables that should not get inherited
|
||||
delete process.env['STDIN_PIPE_NAME'];
|
||||
delete process.env['STDOUT_PIPE_NAME'];
|
||||
delete process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
|
||||
delete process.env['ELECTRON_RUN_AS_NODE'];
|
||||
|
||||
require(program);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "Code",
|
||||
"version": "0.10.6",
|
||||
"electronVersion": "0.34.5",
|
||||
"electronVersion": "0.35.5",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
|
@ -47,10 +47,10 @@
|
|||
"gulp-azure-storage": "^0.3.0",
|
||||
"gulp-bom": "^1.0.0",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"gulp-cssnano": "^2.1.0",
|
||||
"gulp-filter": "^3.0.0",
|
||||
"gulp-insert": "^0.5.0",
|
||||
"gulp-json-editor": "^2.2.1",
|
||||
"gulp-minify-css": "^1.2.1",
|
||||
"gulp-mocha": "^2.1.3",
|
||||
"gulp-remote-src": "^0.4.0",
|
||||
"gulp-rename": "^1.2.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@echo off
|
||||
setlocal
|
||||
set VSCODE_DEV=
|
||||
set ATOM_SHELL_INTERNAL_RUN_AS_NODE=1
|
||||
set ELECTRON_RUN_AS_NODE=1
|
||||
"%~dp0..\\Code.exe" "%~dp0code.js" %*
|
||||
endlocal
|
|
@ -1,3 +1,3 @@
|
|||
delete process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
|
||||
delete process.env['ELECTRON_RUN_AS_NODE'];
|
||||
require('child_process').spawn(require('path').resolve(__dirname, '..', 'Code.exe'), process.argv.slice(2), { detached: true, stdio: 'ignore' });
|
||||
process.exit(0);
|
|
@ -1,6 +1,6 @@
|
|||
@echo off
|
||||
|
||||
set ATOM_SHELL_INTERNAL_RUN_AS_NODE=1
|
||||
set ELECTRON_RUN_AS_NODE=1
|
||||
|
||||
pushd %~dp0\..
|
||||
.\.build\electron\Code.exe .\node_modules\mocha\bin\_mocha %*
|
||||
|
|
|
@ -9,11 +9,11 @@ fi
|
|||
|
||||
# Unit Tests
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
cd $ROOT ; ulimit -n 4096 ; ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 \
|
||||
cd $ROOT ; ulimit -n 4096 ; ELECTRON_RUN_AS_NODE=1 \
|
||||
./.build/electron/Electron.app/Contents/MacOS/Electron \
|
||||
node_modules/mocha/bin/_mocha $*
|
||||
else
|
||||
cd $ROOT ; ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 \
|
||||
cd $ROOT ; ELECTRON_RUN_AS_NODE=1 \
|
||||
./.build/electron/electron \
|
||||
node_modules/mocha/bin/_mocha $*
|
||||
fi
|
||||
|
|
5
src/bootstrap.js
vendored
5
src/bootstrap.js
vendored
|
@ -3,6 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// disable electron's asar support early on because bootstrap.js is used in forked processes
|
||||
// where the environment is purely node based. this will instruct electron to not treat files
|
||||
// with *.asar ending any special from normal files.
|
||||
process.noAsar = true;
|
||||
|
||||
// Will be defined if we got forked from another node process
|
||||
// In that case we override console.log/warn/error to be able
|
||||
// to send loading issues to the main side for logging.
|
||||
|
|
369
src/typings/atom-browser.d.ts
vendored
369
src/typings/atom-browser.d.ts
vendored
|
@ -1,369 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path="./node.d.ts" />
|
||||
|
||||
declare module 'ipc' {
|
||||
|
||||
export interface IIPCEvent {
|
||||
sender: BrowserWindow;
|
||||
}
|
||||
|
||||
export function on(what: string, callback: (event: IIPCEvent, something: any) => void): void;
|
||||
export function removeAllListeners(what: string): void;
|
||||
export function send(channel: string, data: any): void;
|
||||
}
|
||||
|
||||
declare module 'app' {
|
||||
interface IApp extends IEventEmitter {
|
||||
quit(): void;
|
||||
getVersion(): string;
|
||||
getPath(name:string): string;
|
||||
getName(): string;
|
||||
addRecentDocument(path:string): void;
|
||||
clearRecentDocuments(): void;
|
||||
getPath(name: string): string;
|
||||
setPath(name: string, path: string): void;
|
||||
setUserTasks(tasks:ITask[]): void;
|
||||
setAppUserModelId(id:string): void;
|
||||
dock: IDock;
|
||||
}
|
||||
|
||||
var app:IApp;
|
||||
export = app;
|
||||
}
|
||||
|
||||
declare module 'ipc' {
|
||||
export function on(what: string, callback: Function): void;
|
||||
export function once(what: string, callback: Function): void;
|
||||
export function removeAllListeners(what: string): void;
|
||||
}
|
||||
|
||||
declare module 'shell' {
|
||||
interface IShell {
|
||||
showItemInFolder(path: string): void;
|
||||
openItem(path: string): void;
|
||||
openExternal(url: string): boolean;
|
||||
moveItemToTrash(path: string): boolean;
|
||||
beep(): void;
|
||||
}
|
||||
|
||||
var shell:IShell;
|
||||
export = shell;
|
||||
}
|
||||
|
||||
declare module 'screen' {
|
||||
var screen:IScreen;
|
||||
export = screen;
|
||||
}
|
||||
|
||||
declare module 'browser-window' {
|
||||
var IBrowserWindow:{
|
||||
new (options: IBrowserWindowOptions): BrowserWindow;
|
||||
getFocusedWindow(): BrowserWindow;
|
||||
getAllWindows(): BrowserWindow[];
|
||||
fromId(id: number): BrowserWindow;
|
||||
};
|
||||
|
||||
export = IBrowserWindow;
|
||||
}
|
||||
|
||||
declare module 'dialog' {
|
||||
interface IOpenDialogOptions {
|
||||
title?: string;
|
||||
defaultPath?: string;
|
||||
filters?: string[];
|
||||
properties?: string[];
|
||||
}
|
||||
|
||||
interface ISaveDialogOptions {
|
||||
}
|
||||
|
||||
interface IMessageBoxOptions {
|
||||
|
||||
/**
|
||||
* Can be "none", "info" or "warning"
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
/**
|
||||
* Array of texts for buttons
|
||||
*/
|
||||
buttons?: string[];
|
||||
|
||||
title?: string;
|
||||
message?: string;
|
||||
detail?: string;
|
||||
|
||||
cancelId?: number;
|
||||
noLink?: boolean;
|
||||
}
|
||||
|
||||
interface IDialog {
|
||||
showOpenDialog(options: IOpenDialogOptions, callback?:(paths:string[]) => void): string[];
|
||||
showOpenDialog(win: BrowserWindow, options: IOpenDialogOptions, callback?:(paths:string[]) => void): string[];
|
||||
|
||||
showSaveDialog(options: ISaveDialogOptions, callback?:(path:string) => void): string;
|
||||
showSaveDialog(win: BrowserWindow, options: ISaveDialogOptions, callback?:(path:string) => void): string;
|
||||
|
||||
showMessageBox(options: IMessageBoxOptions, callback?:(index:number) => void): number;
|
||||
showMessageBox(win: BrowserWindow, options: IMessageBoxOptions, callback?:(index:number) => void): number;
|
||||
}
|
||||
|
||||
var dialog:IDialog;
|
||||
export = dialog;
|
||||
}
|
||||
|
||||
declare module 'menu' {
|
||||
|
||||
interface IMenu {
|
||||
new (): Menu;
|
||||
setApplicationMenu(menu: Menu): void;
|
||||
buildFromTemplate(template: string): void;
|
||||
}
|
||||
|
||||
var menu:IMenu;
|
||||
export = menu;
|
||||
}
|
||||
|
||||
declare module 'menu-item' {
|
||||
|
||||
interface IMenuItem {
|
||||
new (options: IMenuItemConfig): MenuItem;
|
||||
}
|
||||
|
||||
var menuItem:IMenuItem;
|
||||
export = menuItem;
|
||||
}
|
||||
|
||||
interface IEventEmitter {
|
||||
addListener(event: string, listener: Function): EventEmitter;
|
||||
on(event: string, listener: Function): EventEmitter;
|
||||
once(event: string, listener: Function): EventEmitter;
|
||||
removeListener(event: string, listener: Function): EventEmitter;
|
||||
removeAllListeners(event?: string): EventEmitter;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
declare class EventEmitter implements IEventEmitter {
|
||||
addListener(event: string, listener: Function): EventEmitter;
|
||||
on(event: string, listener: Function): EventEmitter;
|
||||
once(event: string, listener: Function): EventEmitter;
|
||||
removeListener(event: string, listener: Function): EventEmitter;
|
||||
removeAllListeners(event?: string): EventEmitter;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
declare class WebContents extends EventEmitter {
|
||||
send(channel: string, ...args: any[]): void;
|
||||
executeJavaScript(code: string): void;
|
||||
selectAll(): void;
|
||||
undo(): void;
|
||||
redo(): void;
|
||||
}
|
||||
|
||||
declare class BrowserWindow extends EventEmitter {
|
||||
id: number;
|
||||
webContents: WebContents;
|
||||
|
||||
show(): void;
|
||||
hide(): void;
|
||||
focus(): void;
|
||||
loadUrl(url: string): void;
|
||||
getUrl(): string;
|
||||
close(): void;
|
||||
destroy(): void;
|
||||
setFullScreen(fullscreen: boolean): void;
|
||||
isFullScreen(): boolean;
|
||||
isMaximized(): boolean;
|
||||
minimize(): void;
|
||||
isFocused(): boolean;
|
||||
isMinimized(): boolean;
|
||||
isVisible(): boolean;
|
||||
restore(): boolean;
|
||||
getSize(): number[];
|
||||
setSize(width: number, height: number): void;
|
||||
getPosition(): number[];
|
||||
setPosition(x: number, y: number): void;
|
||||
setMenuBarVisibility(visible: boolean): void;
|
||||
setAutoHideMenuBar(autoHide: boolean): void;
|
||||
maximize(): void;
|
||||
setRepresentedFilename(path: string): void;
|
||||
setTitle(title: string): void;
|
||||
getTitle():string;
|
||||
|
||||
toggleDevTools(): void;
|
||||
openDevTools(): void;
|
||||
closeDevTools(): void;
|
||||
isDevToolsFocused(): boolean;
|
||||
devToolsWebContents: WebContents;
|
||||
|
||||
send(channel: string, msg: any): void;
|
||||
}
|
||||
|
||||
interface IMenuItemConfig {
|
||||
label?: string;
|
||||
role?: string;
|
||||
click?: () => void;
|
||||
type?: string;
|
||||
selector?: string;
|
||||
accelerator?: string;
|
||||
enabled?: boolean;
|
||||
visible?: boolean;
|
||||
checked?: boolean;
|
||||
submenu?: Menu;
|
||||
}
|
||||
|
||||
declare class MenuItem implements IMenuItemConfig {
|
||||
label: string;
|
||||
click: () => void;
|
||||
type: string;
|
||||
selector: string;
|
||||
accelerator: string;
|
||||
enabled: boolean;
|
||||
visible: boolean;
|
||||
checked: boolean;
|
||||
submenu: Menu;
|
||||
}
|
||||
|
||||
declare class Menu {
|
||||
items: MenuItem[];
|
||||
|
||||
append(menuItem: MenuItem): void;
|
||||
insert(pos: number, menuItem: MenuItem): void;
|
||||
popup(win: BrowserWindow, x?: number, y?: number): void;
|
||||
}
|
||||
|
||||
interface IScreen extends IEventEmitter {
|
||||
getCursorScreenPoint():IPoint;
|
||||
getPrimaryDisplay():IDisplay;
|
||||
getAllDisplays():IDisplay[];
|
||||
getDisplayNearestPoint(point:IPoint):IDisplay;
|
||||
getDisplayMatching(rect:IBounds):IDisplay;
|
||||
}
|
||||
|
||||
interface IDisplay {
|
||||
id:number;
|
||||
bounds:IBounds;
|
||||
workArea:IBounds;
|
||||
size:IDimension;
|
||||
workAreaSize:IDimension;
|
||||
scaleFactor:number;
|
||||
rotation:number;
|
||||
touchSupport:string;
|
||||
}
|
||||
|
||||
interface IBounds {
|
||||
x:number;
|
||||
y:number;
|
||||
width:number;
|
||||
height:number;
|
||||
}
|
||||
|
||||
interface IDimension {
|
||||
width:number;
|
||||
height:number;
|
||||
}
|
||||
|
||||
interface IPoint {
|
||||
x:number;
|
||||
y:number;
|
||||
}
|
||||
|
||||
interface IBrowserWindowOptions {
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
show?: boolean;
|
||||
frame?: boolean;
|
||||
kiosk?: boolean;
|
||||
'web-preferences'?: IWebPreferences;
|
||||
icon?: string;
|
||||
'min-width'?: number;
|
||||
'min-height'?: number;
|
||||
'always-on-top'?: boolean;
|
||||
'skip-taskbar'?: boolean;
|
||||
'background-color'?: string;
|
||||
resizable?: boolean;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
interface IWebPreferences {
|
||||
javascript?: boolean;
|
||||
'web-security'?: boolean;
|
||||
images?: boolean;
|
||||
java?: boolean;
|
||||
'text-areas-are-resizable'?: boolean;
|
||||
webgl?: boolean;
|
||||
webaudio?: boolean;
|
||||
plugins?: boolean;
|
||||
'extra-plugin-dirs'?: string[];
|
||||
'experimental-features'?: boolean;
|
||||
'experimental-canvas-features'?: boolean;
|
||||
'subpixel-font-scaling'?: boolean;
|
||||
'overlay-scrollbars'?: boolean;
|
||||
'overlay-fullscreen-video'?: boolean;
|
||||
'shared-worker'?: boolean;
|
||||
'direct-write'?: boolean;
|
||||
}
|
||||
|
||||
interface ITask {
|
||||
program: string;
|
||||
arguments?: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
iconPath?: string;
|
||||
iconIndex?: number;
|
||||
}
|
||||
|
||||
interface IDock {
|
||||
setMenu(menu:Menu): void;
|
||||
show(): void;
|
||||
hide(): void;
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/auto-updater.md
|
||||
declare module 'auto-updater' {
|
||||
export interface IAutoUpdater extends IEventEmitter {
|
||||
setFeedUrl(url: string): void;
|
||||
checkForUpdates(): void;
|
||||
}
|
||||
|
||||
export interface IUpdate {
|
||||
url: string;
|
||||
name: string;
|
||||
releaseNotes?: string;
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export function setFeedUrl(url: string): void;
|
||||
export function checkForUpdates(): void;
|
||||
export function addListener(event: string, listener: Function): EventEmitter;
|
||||
export function on(event: string, listener: Function): EventEmitter;
|
||||
export function once(event: string, listener: Function): EventEmitter;
|
||||
export function removeListener(event: string, listener: Function): EventEmitter;
|
||||
export function removeAllListeners(event?: string): EventEmitter;
|
||||
export function setMaxListeners(n: number): void;
|
||||
export function listeners(event: string): Function[];
|
||||
export function emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
declare module 'crash-reporter' {
|
||||
export function start(config?: ICrashReporterConfigBrowser): void;
|
||||
}
|
||||
|
||||
interface ICrashReporterConfigBrowser {
|
||||
productName?: string,
|
||||
companyName: string,
|
||||
submitUrl?: string,
|
||||
autoSubmit?: boolean,
|
||||
ignoreSystemCrashHandler?: boolean,
|
||||
extra?: any
|
||||
}
|
320
src/typings/atom-renderer.d.ts
vendored
320
src/typings/atom-renderer.d.ts
vendored
|
@ -1,320 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path="./node.d.ts" />
|
||||
|
||||
declare module 'web-frame' {
|
||||
export function getZoomLevel(): number;
|
||||
export function setZoomLevel(zoomLevel: number): void;
|
||||
}
|
||||
|
||||
declare module 'clipboard' {
|
||||
export function readText(type?:string): string;
|
||||
export function writeText(text:string, type?:string): void;
|
||||
export function clear(type?:string): void;
|
||||
}
|
||||
|
||||
declare module 'ipc' {
|
||||
export function on(what: string, callback: Function): void;
|
||||
export function once(what: string, callback: Function): void;
|
||||
export function removeListener(what: string, callback: (something: any) => void): void;
|
||||
export function removeAllListeners(what: string): void;
|
||||
export function send(channel: string, ...args:any[]): void;
|
||||
export function sendSync(channel: string, ...args:any[]): void;
|
||||
}
|
||||
|
||||
declare module 'remote' {
|
||||
|
||||
interface IProcess extends IEventEmitter {
|
||||
argv:string[];
|
||||
platform:string;
|
||||
execPath:string;
|
||||
}
|
||||
|
||||
export var process:IProcess;
|
||||
|
||||
export interface IEventEmitter {
|
||||
addListener(event: string, listener: Function): EventEmitter;
|
||||
on(event: string, listener: Function): EventEmitter;
|
||||
once(event: string, listener: Function): EventEmitter;
|
||||
removeListener(event: string, listener: Function): EventEmitter;
|
||||
removeAllListeners(event?: string): EventEmitter;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
export class EventEmitter implements IEventEmitter {
|
||||
addListener(event: string, listener: Function): EventEmitter;
|
||||
on(event: string, listener: Function): EventEmitter;
|
||||
once(event: string, listener: Function): EventEmitter;
|
||||
removeListener(event: string, listener: Function): EventEmitter;
|
||||
removeAllListeners(event?: string): EventEmitter;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
}
|
||||
|
||||
export interface HTMLIWebView extends HTMLObjectElement {
|
||||
|
||||
/**
|
||||
* Sets or retrieves a URL to be loaded by the object.
|
||||
*/
|
||||
src: string;
|
||||
|
||||
send(channel: string, ...args: any[]): void;
|
||||
executeJavaScript(code: string): void;
|
||||
|
||||
stop(): void;
|
||||
|
||||
openDevTools(): void;
|
||||
closeDevTools(): void;
|
||||
isDevToolsOpened(): boolean;
|
||||
}
|
||||
|
||||
export class Event {
|
||||
returnValue: any;
|
||||
sender: WebContents;
|
||||
}
|
||||
|
||||
export interface IIPC extends IEventEmitter {
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/app.md
|
||||
export interface IApp extends IEventEmitter {
|
||||
quit(): void;
|
||||
getVersion(): string;
|
||||
getPath(name:string): string;
|
||||
getName(): string;
|
||||
addRecentDocument(path:string): void;
|
||||
clearRecentDocuments(): void;
|
||||
}
|
||||
|
||||
export interface IOpenDialogOptions {
|
||||
title?: string;
|
||||
defaultPath?: string;
|
||||
filters?: { name:string; extensions:string[] }[];
|
||||
properties?: string[];
|
||||
}
|
||||
|
||||
export interface ISaveDialogOptions extends IOpenDialogOptions {
|
||||
}
|
||||
|
||||
export interface IMessageBoxOptions {
|
||||
|
||||
/**
|
||||
* Can be "none", "info" or "warning"
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
/**
|
||||
* Array of texts for buttons
|
||||
*/
|
||||
buttons?: string[];
|
||||
|
||||
title?: string;
|
||||
message?: string;
|
||||
detail?: string;
|
||||
|
||||
cancelId?: number;
|
||||
noLink?: boolean;
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/dialog.md
|
||||
export interface IDialog {
|
||||
showOpenDialog(options: IOpenDialogOptions, callback?:(paths:string[]) => void): string[];
|
||||
showOpenDialog(win: BrowserWindow, options: IOpenDialogOptions, callback?:(paths:string[]) => void): string[];
|
||||
|
||||
showSaveDialog(options: ISaveDialogOptions, callback?:(path:string) => void): string;
|
||||
showSaveDialog(win: BrowserWindow, options: ISaveDialogOptions, callback?:(path:string) => void): string;
|
||||
|
||||
showMessageBox(options: ISaveDialogOptions, callback?:(index:number) => void): number;
|
||||
showMessageBox(win: BrowserWindow, options: IMessageBoxOptions, callback?:(index:number) => void): number;
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/shell.md
|
||||
export interface IShell {
|
||||
showItemInFolder(path: string): void;
|
||||
openItem(path: string): void;
|
||||
openExternal(url: string): boolean;
|
||||
moveItemToTrash(path: string): boolean;
|
||||
beep(): void;
|
||||
}
|
||||
|
||||
export interface IWebContents {
|
||||
new (): WebContents;
|
||||
}
|
||||
|
||||
export class WebContents extends EventEmitter {
|
||||
selectAll(): void;
|
||||
undo(): void;
|
||||
redo(): void;
|
||||
send(channel: string, ...args: any[]): void;
|
||||
}
|
||||
|
||||
export interface IBrowserWindow {
|
||||
new (options: IBrowserWindowOptions): BrowserWindow;
|
||||
getFocusedWindow(): BrowserWindow;
|
||||
}
|
||||
|
||||
export interface IBrowserWindowOptions {
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
show?: boolean;
|
||||
frame?: boolean;
|
||||
kiosk?: boolean;
|
||||
'web-preferences'?: IWebPreferences;
|
||||
'min-width'?: number;
|
||||
'min-height'?: number;
|
||||
'always-on-top'?: boolean;
|
||||
'skip-taskbar'?: boolean;
|
||||
'background-color'?: string;
|
||||
resizable?: boolean;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export interface IWebPreferences {
|
||||
javascript?: boolean;
|
||||
'web-security'?: boolean;
|
||||
images?: boolean;
|
||||
java?: boolean;
|
||||
'text-areas-are-resizable'?: boolean;
|
||||
webgl?: boolean;
|
||||
webaudio?: boolean;
|
||||
plugins?: boolean;
|
||||
'extra-plugin-dirs'?: string[];
|
||||
'experimental-features'?: boolean;
|
||||
'experimental-canvas-features'?: boolean;
|
||||
'subpixel-font-scaling'?: boolean;
|
||||
'overlay-scrollbars'?: boolean;
|
||||
'overlay-fullscreen-video'?: boolean;
|
||||
'shared-worker'?: boolean;
|
||||
'direct-write'?: boolean;
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/browser-window.md
|
||||
export class BrowserWindow extends EventEmitter {
|
||||
id: number;
|
||||
webContents: WebContents;
|
||||
|
||||
show(): void;
|
||||
hide() : void;
|
||||
focus(): void;
|
||||
isFocused(): boolean;
|
||||
reload(): void;
|
||||
loadUrl(url: string): void;
|
||||
close(): void;
|
||||
destroy(): void;
|
||||
setFullScreen(fullscreen: boolean): void;
|
||||
isFullScreen(): boolean;
|
||||
isMaximized(): boolean;
|
||||
isMinimized(): boolean;
|
||||
isVisible(): boolean;
|
||||
getSize(): number[];
|
||||
setSize(width: number, height: number): void;
|
||||
getPosition(): number[];
|
||||
setPosition(x: number, y: number): void;
|
||||
setMenuBarVisibility(visible: boolean): void;
|
||||
setAutoHideMenuBar(autoHide: boolean): void;
|
||||
maximize(): void;
|
||||
setRepresentedFilename(path: string): void;
|
||||
setDocumentEdited(edited: boolean): void;
|
||||
isDocumentEdited(): boolean;
|
||||
setTitle(title: string): void;
|
||||
getTitle(): string;
|
||||
flashFrame(flag: boolean): void;
|
||||
|
||||
openDevTools(): void;
|
||||
closeDevTools(): void;
|
||||
toggleDevTools(): void;
|
||||
isDevToolsOpened(): boolean;
|
||||
isDevToolsFocused(): boolean;
|
||||
devToolsWebContents: WebContents;
|
||||
}
|
||||
|
||||
export interface IMenu {
|
||||
new (): Menu;
|
||||
setApplicationMenu(menu: Menu): void;
|
||||
buildFromTemplate(template: string): void;
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/menu.md
|
||||
export class Menu {
|
||||
items: MenuItem[];
|
||||
|
||||
append(menuItem: MenuItem): void;
|
||||
insert(pos: number, menuItem: MenuItem): void;
|
||||
popup(win: BrowserWindow, x?: number, y?: number): void;
|
||||
}
|
||||
|
||||
export interface IMenuItem {
|
||||
new (options: IMenuItemConfig): MenuItem;
|
||||
}
|
||||
|
||||
// https://github.com/atom/electron/blob/master/docs/api/menu-item.md
|
||||
export class MenuItem implements IMenuItemConfig {
|
||||
label: string;
|
||||
role: string;
|
||||
click: () => void;
|
||||
type: string;
|
||||
selector: string;
|
||||
accelerator: string;
|
||||
enabled: boolean;
|
||||
visible: boolean;
|
||||
checked: boolean;
|
||||
submenu: Menu;
|
||||
}
|
||||
|
||||
export interface IMenuItemConfig {
|
||||
label?: string;
|
||||
click?: () => void;
|
||||
type?: string;
|
||||
selector?: string;
|
||||
accelerator?: string;
|
||||
enabled?: boolean;
|
||||
visible?: boolean;
|
||||
checked?: boolean;
|
||||
submenu?: Menu;
|
||||
}
|
||||
|
||||
export interface IClipboard {
|
||||
readText(type?:string): string;
|
||||
writeText(text:string, type?:string): void;
|
||||
clear(type?:string): void;
|
||||
}
|
||||
|
||||
export interface IUnknown {
|
||||
|
||||
}
|
||||
|
||||
export function require(moduleName: 'shell'): IShell;
|
||||
export function require(moduleName: 'menu'): IMenu;
|
||||
export function require(moduleName: 'menu-item'): IMenuItem;
|
||||
export function require(moduleName: 'app'): IApp;
|
||||
export function require(moduleName: 'dialog'): IDialog;
|
||||
export function require(moduleName: 'ipc'): IIPC;
|
||||
export function require(moduleName: 'clipboard'): IClipboard;
|
||||
export function require(moduleName: 'browser-window'): IBrowserWindow;
|
||||
export function require(moduleName: string): IUnknown;
|
||||
|
||||
export function getCurrentWindow(): BrowserWindow;
|
||||
export function getGlobal(name: string): any;
|
||||
|
||||
}
|
||||
|
||||
declare module 'crash-reporter' {
|
||||
export function start(config?: ICrashReporterConfigRenderer): void;
|
||||
}
|
||||
|
||||
interface ICrashReporterConfigRenderer {
|
||||
productName?: string,
|
||||
companyName: string,
|
||||
submitUrl?: string,
|
||||
autoSubmit?: boolean,
|
||||
ignoreSystemCrashHandler?: boolean,
|
||||
extra?: any
|
||||
}
|
1884
src/typings/electron.d.ts
vendored
Normal file
1884
src/typings/electron.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -123,6 +123,9 @@ let KEY_CODE_MAP: {[keyCode:number]:KeyCode} = {};
|
|||
KEY_CODE_MAP[220] = KeyCode.US_BACKSLASH;
|
||||
KEY_CODE_MAP[221] = KeyCode.US_CLOSE_SQUARE_BRACKET;
|
||||
KEY_CODE_MAP[222] = KeyCode.US_QUOTE;
|
||||
KEY_CODE_MAP[223] = KeyCode.OEM_8;
|
||||
|
||||
KEY_CODE_MAP[226] = KeyCode.OEM_102;
|
||||
|
||||
if (Browser.isIE11orEarlier) {
|
||||
KEY_CODE_MAP[91] = KeyCode.Meta;
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import Platform = require('vs/base/common/platform');
|
||||
import * as nls from 'vs/nls';
|
||||
import * as defaultPlatform from 'vs/base/common/platform';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
|
||||
export interface ISimplifiedPlatform {
|
||||
isMacintosh: boolean;
|
||||
isWindows: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual Key Codes, the value does not hold any inherent meaning.
|
||||
* Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
|
||||
|
@ -106,49 +111,68 @@ export enum KeyCode {
|
|||
ScrollLock,
|
||||
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the ';:' key
|
||||
*/
|
||||
US_SEMICOLON,
|
||||
/**
|
||||
* For any country/region, the '+' key
|
||||
* For the US standard keyboard, the '=+' key
|
||||
*/
|
||||
US_EQUAL,
|
||||
/**
|
||||
* For any country/region, the ',' key
|
||||
* For the US standard keyboard, the ',<' key
|
||||
*/
|
||||
US_COMMA,
|
||||
/**
|
||||
* For any country/region, the '-' key
|
||||
* For the US standard keyboard, the '-_' key
|
||||
*/
|
||||
US_MINUS,
|
||||
/**
|
||||
* For any country/region, the '.' key
|
||||
* For the US standard keyboard, the '.>' key
|
||||
*/
|
||||
US_DOT,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '/?' key
|
||||
*/
|
||||
US_SLASH,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '`~' key
|
||||
*/
|
||||
US_BACKTICK,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '[{' key
|
||||
*/
|
||||
US_OPEN_SQUARE_BRACKET,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the '\|' key
|
||||
*/
|
||||
US_BACKSLASH,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the ']}' key
|
||||
*/
|
||||
US_CLOSE_SQUARE_BRACKET,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
* For the US standard keyboard, the ''"' key
|
||||
*/
|
||||
US_QUOTE,
|
||||
/**
|
||||
* Used for miscellaneous characters; it can vary by keyboard.
|
||||
*/
|
||||
OEM_8,
|
||||
/**
|
||||
* Either the angle bracket key or the backslash key on the RT 102-key keyboard.
|
||||
*/
|
||||
OEM_102,
|
||||
|
||||
NUMPAD_0, // VK_NUMPAD0, 0x60, Numeric keypad 0 key
|
||||
NUMPAD_1, // VK_NUMPAD1, 0x61, Numeric keypad 1 key
|
||||
|
@ -174,8 +198,58 @@ export enum KeyCode {
|
|||
MAX_VALUE
|
||||
}
|
||||
|
||||
let TO_STRING_MAP: string[] = [];
|
||||
(function() {
|
||||
interface IReverseMap {
|
||||
[str:string]:KeyCode;
|
||||
}
|
||||
|
||||
class Mapping {
|
||||
|
||||
_fromKeyCode: string[];
|
||||
_toKeyCode: IReverseMap;
|
||||
|
||||
constructor(fromKeyCode: string[], toKeyCode: IReverseMap) {
|
||||
this._fromKeyCode = fromKeyCode;
|
||||
this._toKeyCode = toKeyCode;
|
||||
}
|
||||
|
||||
fromKeyCode(keyCode:KeyCode): string {
|
||||
return this._fromKeyCode[keyCode];
|
||||
}
|
||||
|
||||
toKeyCode(str:string): KeyCode {
|
||||
if (this._toKeyCode.hasOwnProperty(str)) {
|
||||
return this._toKeyCode[str];
|
||||
}
|
||||
return KeyCode.Unknown;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function createMapping(fill1:(map:string[])=>void, fill2:(reverseMap:IReverseMap)=>void): Mapping {
|
||||
let MAP: string[] = [];
|
||||
fill1(MAP);
|
||||
|
||||
let REVERSE_MAP: IReverseMap = {};
|
||||
for (let i = 0, len = MAP.length; i < len; i++) {
|
||||
if (!MAP[i]) {
|
||||
continue;
|
||||
}
|
||||
REVERSE_MAP[MAP[i]] = i;
|
||||
}
|
||||
fill2(REVERSE_MAP);
|
||||
|
||||
let FINAL_REVERSE_MAP: IReverseMap = {};
|
||||
for (let entry in REVERSE_MAP) {
|
||||
if (REVERSE_MAP.hasOwnProperty(entry)) {
|
||||
FINAL_REVERSE_MAP[entry] = REVERSE_MAP[entry];
|
||||
FINAL_REVERSE_MAP[entry.toLowerCase()] = REVERSE_MAP[entry];
|
||||
}
|
||||
}
|
||||
|
||||
return new Mapping(MAP, FINAL_REVERSE_MAP);
|
||||
}
|
||||
|
||||
let STRING = createMapping((TO_STRING_MAP) => {
|
||||
TO_STRING_MAP[KeyCode.Unknown] = 'unknown';
|
||||
|
||||
TO_STRING_MAP[KeyCode.Backspace] = 'Backspace';
|
||||
|
@ -274,6 +348,8 @@ let TO_STRING_MAP: string[] = [];
|
|||
TO_STRING_MAP[KeyCode.US_BACKSLASH] = '\\';
|
||||
TO_STRING_MAP[KeyCode.US_CLOSE_SQUARE_BRACKET] = ']';
|
||||
TO_STRING_MAP[KeyCode.US_QUOTE] = '\'';
|
||||
TO_STRING_MAP[KeyCode.OEM_8] = 'OEM_8';
|
||||
TO_STRING_MAP[KeyCode.OEM_102] = 'OEM_102';
|
||||
|
||||
TO_STRING_MAP[KeyCode.NUMPAD_0] = 'NumPad0';
|
||||
TO_STRING_MAP[KeyCode.NUMPAD_1] = 'NumPad1';
|
||||
|
@ -298,29 +374,41 @@ let TO_STRING_MAP: string[] = [];
|
|||
// console.warn('Missing string representation for ' + KeyCode[i]);
|
||||
// }
|
||||
// }
|
||||
})();
|
||||
}, (FROM_STRING_MAP) => {
|
||||
FROM_STRING_MAP['\r'] = KeyCode.Enter;
|
||||
});
|
||||
|
||||
let FROM_STRING_MAP: {[str:string]:KeyCode;} = {};
|
||||
FROM_STRING_MAP['\r'] = KeyCode.Enter;
|
||||
(function() {
|
||||
for (let i = 0, len = TO_STRING_MAP.length; i < len; i++) {
|
||||
if (!TO_STRING_MAP[i]) {
|
||||
continue;
|
||||
|
||||
let USER_SETTINGS = createMapping((TO_USER_SETTINGS_MAP) => {
|
||||
for (let i = 0, len = STRING._fromKeyCode.length; i < len; i++) {
|
||||
TO_USER_SETTINGS_MAP[i] = STRING._fromKeyCode[i];
|
||||
}
|
||||
FROM_STRING_MAP[TO_STRING_MAP[i]] = i;
|
||||
FROM_STRING_MAP[TO_STRING_MAP[i].toLowerCase()] = i;
|
||||
}
|
||||
})();
|
||||
TO_USER_SETTINGS_MAP[KeyCode.LeftArrow] = 'Left';
|
||||
TO_USER_SETTINGS_MAP[KeyCode.UpArrow] = 'Up';
|
||||
TO_USER_SETTINGS_MAP[KeyCode.RightArrow] = 'Right';
|
||||
TO_USER_SETTINGS_MAP[KeyCode.DownArrow] = 'Down';
|
||||
}, (FROM_USER_SETTINGS_MAP) => {
|
||||
FROM_USER_SETTINGS_MAP['OEM_1'] = KeyCode.US_SEMICOLON;
|
||||
FROM_USER_SETTINGS_MAP['OEM_PLUS'] = KeyCode.US_EQUAL;
|
||||
FROM_USER_SETTINGS_MAP['OEM_COMMA'] = KeyCode.US_COMMA;
|
||||
FROM_USER_SETTINGS_MAP['OEM_MINUS'] = KeyCode.US_MINUS;
|
||||
FROM_USER_SETTINGS_MAP['OEM_PERIOD'] = KeyCode.US_DOT;
|
||||
FROM_USER_SETTINGS_MAP['OEM_2'] = KeyCode.US_SLASH;
|
||||
FROM_USER_SETTINGS_MAP['OEM_3'] = KeyCode.US_BACKTICK;
|
||||
FROM_USER_SETTINGS_MAP['OEM_4'] = KeyCode.US_OPEN_SQUARE_BRACKET;
|
||||
FROM_USER_SETTINGS_MAP['OEM_5'] = KeyCode.US_BACKSLASH;
|
||||
FROM_USER_SETTINGS_MAP['OEM_6'] = KeyCode.US_CLOSE_SQUARE_BRACKET;
|
||||
FROM_USER_SETTINGS_MAP['OEM_7'] = KeyCode.US_QUOTE;
|
||||
FROM_USER_SETTINGS_MAP['OEM_8'] = KeyCode.OEM_8;
|
||||
FROM_USER_SETTINGS_MAP['OEM_102'] = KeyCode.OEM_102;
|
||||
});
|
||||
|
||||
export namespace KeyCode {
|
||||
export function toString(key:KeyCode): string {
|
||||
return TO_STRING_MAP[key];
|
||||
return STRING.fromKeyCode(key);
|
||||
}
|
||||
export function fromString(key:string): KeyCode {
|
||||
if (FROM_STRING_MAP.hasOwnProperty(key)) {
|
||||
return FROM_STRING_MAP[key];
|
||||
}
|
||||
return KeyCode.Unknown;
|
||||
return STRING.toKeyCode(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,49 +520,65 @@ export class Keybinding {
|
|||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toUSLabel(value:number): string {
|
||||
return _asString(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE));
|
||||
private static _toUSLabel(value:number, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toUSHTMLLabel(value:number): IHTMLContentElement[] {
|
||||
return _asHTML(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE));
|
||||
private static _toUSHTMLLabel(value:number, Platform:ISimplifiedPlatform): IHTMLContentElement[] {
|
||||
return _asHTML(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toCustomLabel(value:number, labelProvider:IKeyBindingLabelProvider): string {
|
||||
return _asString(value, labelProvider);
|
||||
private static _toCustomLabel(value:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toCustomHTMLLabel(value:number, labelProvider:IKeyBindingLabelProvider): IHTMLContentElement[] {
|
||||
return _asHTML(value, labelProvider);
|
||||
private static _toCustomHTMLLabel(value:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): IHTMLContentElement[] {
|
||||
return _asHTML(value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prints the binding in a format suitable for electron's accelerators.
|
||||
* See https://github.com/atom/electron/blob/master/docs/api/accelerator.md
|
||||
*/
|
||||
private static _toElectronAccelerator(value:number): string {
|
||||
private static _toElectronAccelerator(value:number, Platform:ISimplifiedPlatform): string {
|
||||
if (BinaryKeybindings.hasChord(value)) {
|
||||
// Electron cannot handle chords
|
||||
return null;
|
||||
}
|
||||
return _asString(value, ElectronAcceleratorLabelProvider.INSTANCE);
|
||||
return _asString(value, ElectronAcceleratorLabelProvider.INSTANCE, Platform);
|
||||
}
|
||||
|
||||
private static _cachedKeybindingRegex: string = null;
|
||||
public static getUserSettingsKeybindingRegex(): string {
|
||||
if (!this._cachedKeybindingRegex) {
|
||||
let numpadKey = "numpad(0|1|2|3|4|5|6|7|8|9|_multiply|_add|_subtract|_decimal|_divide|_separator)";
|
||||
let oemKey = "`|\\-|=|\\[|\\]|\\\\\\\\|;|'|,|\\.|\\/|oem_8|oem_102";
|
||||
let specialKey = "left|up|right|down|pageup|pagedown|end|home|tab|enter|escape|space|backspace|delete|pausebreak|capslock|insert|contextmenu|numlock|scrolllock";
|
||||
let casualKey = "[a-z]|[0-9]|f(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19)";
|
||||
let key = '((' + [numpadKey, oemKey, specialKey, casualKey].join(')|(') + '))';
|
||||
let mod = '((ctrl|shift|alt|cmd|win|meta)\\+)*';
|
||||
let keybinding = '(' + mod + key + ')';
|
||||
|
||||
this._cachedKeybindingRegex = '"\\s*(' + keybinding + '(\\s+' + keybinding +')?' + ')\\s*"';
|
||||
}
|
||||
return this._cachedKeybindingRegex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for the user settings file.
|
||||
*/
|
||||
public static toUserSettingsLabel(value:number): string {
|
||||
let result = _asString(value, UserSettingsKeyLabelProvider.INSTANCE);
|
||||
result = result.toLowerCase().replace(/arrow/g, '');
|
||||
public static toUserSettingsLabel(value:number, Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
let result = _asString(value, UserSettingsKeyLabelProvider.INSTANCE, Platform);
|
||||
result = result.toLowerCase();
|
||||
|
||||
if (Platform.isMacintosh) {
|
||||
result = result.replace(/meta/g, 'cmd');
|
||||
|
@ -485,6 +589,90 @@ export class Keybinding {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static fromUserSettingsLabel(input: string, Platform: ISimplifiedPlatform = defaultPlatform): number {
|
||||
if (!input) {
|
||||
return null;
|
||||
}
|
||||
input = input.toLowerCase().trim();
|
||||
|
||||
let ctrlCmd = false,
|
||||
shift = false,
|
||||
alt = false,
|
||||
winCtrl = false,
|
||||
key:string = '';
|
||||
|
||||
while (/^(ctrl|shift|alt|meta|win|cmd)(\+|\-)/.test(input)) {
|
||||
if (/^ctrl(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
winCtrl = true;
|
||||
} else {
|
||||
ctrlCmd = true;
|
||||
}
|
||||
input = input.substr('ctrl-'.length);
|
||||
}
|
||||
if (/^shift(\+|\-)/.test(input)) {
|
||||
shift = true;
|
||||
input = input.substr('shift-'.length);
|
||||
}
|
||||
if (/^alt(\+|\-)/.test(input)) {
|
||||
alt = true;
|
||||
input = input.substr('alt-'.length);
|
||||
}
|
||||
if (/^meta(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('meta-'.length);
|
||||
}
|
||||
if (/^win(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('win-'.length);
|
||||
}
|
||||
if (/^cmd(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('cmd-'.length);
|
||||
}
|
||||
}
|
||||
|
||||
let chord: number = 0;
|
||||
|
||||
let firstSpaceIdx = input.indexOf(' ');
|
||||
if (firstSpaceIdx > 0) {
|
||||
key = input.substring(0, firstSpaceIdx);
|
||||
chord = Keybinding.fromUserSettingsLabel(input.substring(firstSpaceIdx), Platform);
|
||||
} else {
|
||||
key = input;
|
||||
}
|
||||
|
||||
let keyCode = USER_SETTINGS.toKeyCode(key);
|
||||
|
||||
let result = 0;
|
||||
if (ctrlCmd) {
|
||||
result |= KeyMod.CtrlCmd;
|
||||
}
|
||||
if (shift) {
|
||||
result |= KeyMod.Shift;
|
||||
}
|
||||
if (alt) {
|
||||
result |= KeyMod.Alt;
|
||||
}
|
||||
if (winCtrl) {
|
||||
result |= KeyMod.WinCtrl;
|
||||
}
|
||||
result |= keyCode;
|
||||
return KeyMod.chord(result, chord);
|
||||
}
|
||||
|
||||
public value:number;
|
||||
|
||||
constructor(keybinding:number) {
|
||||
|
@ -514,44 +702,44 @@ export class Keybinding {
|
|||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public _toUSLabel(): string {
|
||||
return Keybinding._toUSLabel(this.value);
|
||||
public _toUSLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toUSLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public _toUSHTMLLabel(): IHTMLContentElement[] {
|
||||
return Keybinding._toUSHTMLLabel(this.value);
|
||||
public _toUSHTMLLabel(Platform:ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
|
||||
return Keybinding._toUSHTMLLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public toCustomLabel(labelProvider:IKeyBindingLabelProvider): string {
|
||||
return Keybinding._toCustomLabel(this.value, labelProvider);
|
||||
public toCustomLabel(labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toCustomLabel(this.value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public toCustomHTMLLabel(labelProvider:IKeyBindingLabelProvider): IHTMLContentElement[] {
|
||||
return Keybinding._toCustomHTMLLabel(this.value, labelProvider);
|
||||
public toCustomHTMLLabel(labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
|
||||
return Keybinding._toCustomHTMLLabel(this.value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prints the binding in a format suitable for electron's accelerators.
|
||||
* See https://github.com/atom/electron/blob/master/docs/api/accelerator.md
|
||||
*/
|
||||
public _toElectronAccelerator(): string {
|
||||
return Keybinding._toElectronAccelerator(this.value);
|
||||
public _toElectronAccelerator(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toElectronAccelerator(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for the user settings file.
|
||||
*/
|
||||
public toUserSettingsLabel(): string {
|
||||
return Keybinding.toUserSettingsLabel(this.value);
|
||||
public toUserSettingsLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding.toUserSettingsLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -662,11 +850,11 @@ class UserSettingsKeyLabelProvider implements IKeyBindingLabelProvider {
|
|||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return KeyCode.toString(keyCode);
|
||||
return USER_SETTINGS.fromKeyCode(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
function _asString(keybinding:number, labelProvider:IKeyBindingLabelProvider): string {
|
||||
function _asString(keybinding:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): string {
|
||||
let result:string[] = [],
|
||||
ctrlCmd = BinaryKeybindings.hasCtrlCmd(keybinding),
|
||||
shift = BinaryKeybindings.hasShift(keybinding),
|
||||
|
@ -707,7 +895,7 @@ function _asString(keybinding:number, labelProvider:IKeyBindingLabelProvider): s
|
|||
var actualResult = result.join(labelProvider.modifierSeparator);
|
||||
|
||||
if (BinaryKeybindings.hasChord(keybinding)) {
|
||||
return actualResult + ' ' + _asString(BinaryKeybindings.extractChordPart(keybinding), labelProvider);
|
||||
return actualResult + ' ' + _asString(BinaryKeybindings.extractChordPart(keybinding), labelProvider, Platform);
|
||||
}
|
||||
|
||||
return actualResult;
|
||||
|
@ -727,7 +915,7 @@ function _pushKey(result:IHTMLContentElement[], str:string): void {
|
|||
});
|
||||
}
|
||||
|
||||
function _asHTML(keybinding:number, labelProvider:IKeyBindingLabelProvider, isChord:boolean = false): IHTMLContentElement[] {
|
||||
function _asHTML(keybinding:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform, isChord:boolean = false): IHTMLContentElement[] {
|
||||
let result:IHTMLContentElement[] = [],
|
||||
ctrlCmd = BinaryKeybindings.hasCtrlCmd(keybinding),
|
||||
shift = BinaryKeybindings.hasShift(keybinding),
|
||||
|
@ -768,7 +956,7 @@ function _asHTML(keybinding:number, labelProvider:IKeyBindingLabelProvider, isCh
|
|||
let chordTo: IHTMLContentElement[] = null;
|
||||
|
||||
if (BinaryKeybindings.hasChord(keybinding)) {
|
||||
chordTo = _asHTML(BinaryKeybindings.extractChordPart(keybinding), labelProvider, true);
|
||||
chordTo = _asHTML(BinaryKeybindings.extractChordPart(keybinding), labelProvider, Platform, true);
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
text: ' '
|
||||
|
|
|
@ -48,7 +48,7 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
|
|||
|
||||
newEnv['STDIN_PIPE_NAME'] = stdInPipeName;
|
||||
newEnv['STDOUT_PIPE_NAME'] = stdOutPipeName;
|
||||
newEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
|
||||
newEnv['ELECTRON_RUN_AS_NODE'] = '1';
|
||||
|
||||
return newEnv;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ var stdOutPipeName = process.env['STDOUT_PIPE_NAME'];
|
|||
|
||||
log('STDIN_PIPE_NAME: ' + stdInPipeName);
|
||||
log('STDOUT_PIPE_NAME: ' + stdOutPipeName);
|
||||
log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE']);
|
||||
log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||
|
||||
// stdout redirection to named pipe
|
||||
(function() {
|
||||
|
@ -136,7 +136,7 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
|
|||
// Unset the custom environmental variables that should not get inherited
|
||||
delete process.env['STDIN_PIPE_NAME'];
|
||||
delete process.env['STDOUT_PIPE_NAME'];
|
||||
delete process.env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
|
||||
delete process.env['ELECTRON_RUN_AS_NODE'];
|
||||
|
||||
require(program);
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import {KeyCode, KeyMod, BinaryKeybindings} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode, KeyMod, BinaryKeybindings, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import * as Strings from 'vs/base/common/strings';
|
||||
|
||||
interface ITestKeybinding {
|
||||
ctrlCmd?: boolean;
|
||||
|
@ -65,4 +66,44 @@ suite('keyCodes', () => {
|
|||
assert.equal(encodedFirstPart, KeyMod.CtrlCmd | KeyCode.KEY_Y, 'first part');
|
||||
assert.equal(encodedSecondPart, encodedSecondPart, 'chord part');
|
||||
});
|
||||
|
||||
test('getUserSettingsKeybindingRegex', () => {
|
||||
let regex = new RegExp(Keybinding.getUserSettingsKeybindingRegex());
|
||||
|
||||
function testIsGood(userSettingsLabel:string, message:string = userSettingsLabel): void {
|
||||
let userSettings = '"' + userSettingsLabel.replace(/\\/g, '\\\\') + '"';
|
||||
let isGood = regex.test(userSettings);
|
||||
assert.ok(isGood, message);
|
||||
}
|
||||
|
||||
// check that all key codes are covered by the regex
|
||||
let ignore: boolean[] = [];
|
||||
ignore[KeyCode.Shift] = true;
|
||||
ignore[KeyCode.Ctrl] = true;
|
||||
ignore[KeyCode.Alt] = true;
|
||||
ignore[KeyCode.Meta] = true;
|
||||
for (let keyCode = KeyCode.Unknown + 1; keyCode < KeyCode.MAX_VALUE; keyCode++) {
|
||||
if (ignore[keyCode]) {
|
||||
continue;
|
||||
}
|
||||
let userSettings = Keybinding.toUserSettingsLabel(keyCode);
|
||||
testIsGood(userSettings, keyCode + ' - ' + KeyCode[keyCode] + ' - ' + userSettings);
|
||||
}
|
||||
|
||||
// one modifier
|
||||
testIsGood('ctrl+a');
|
||||
testIsGood('shift+a');
|
||||
testIsGood('alt+a');
|
||||
testIsGood('cmd+a');
|
||||
testIsGood('meta+a');
|
||||
testIsGood('win+a');
|
||||
|
||||
// more modifiers
|
||||
testIsGood('ctrl+shift+a');
|
||||
testIsGood('shift+alt+a');
|
||||
testIsGood('ctrl+shift+alt+a');
|
||||
|
||||
// chords
|
||||
testIsGood('ctrl+a ctrl+a');
|
||||
})
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
|||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {IKeybindingContextKey, IKeybindingItem, ICommandHandler, ICommandsMap} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {AbstractPluginService} from 'vs/platform/plugins/common/abstractPluginService';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/commonKeybindingResolver';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {PluginsRegistry, PluginsMessageCollector} from 'vs/platform/plugins/common/pluginsRegistry';
|
||||
|
||||
export class SimpleEditor implements IEditor {
|
||||
|
|
|
@ -16,7 +16,6 @@ import Actions = require('vs/base/common/actions');
|
|||
import ActionBar = require('vs/base/browser/ui/actionbar/actionbar');
|
||||
import Lifecycle = require('vs/base/common/lifecycle');
|
||||
import SortedList = require('vs/base/common/sortedList');
|
||||
import {KeybindingsUtils} from 'vs/platform/keybinding/common/keybindingsUtils';
|
||||
import {IContextViewService, IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {INullService} from 'vs/platform/instantiation/common/instantiation';
|
||||
|
|
|
@ -21,7 +21,7 @@ import {CommonEditorRegistry, ContextKey, EditorActionDescriptor} from 'vs/edito
|
|||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {RunOnceScheduler} from 'vs/base/common/async';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/commonKeybindingResolver';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
@ -137,26 +137,10 @@ export class DefineKeybindingController implements EditorCommon.IEditorContribut
|
|||
this._updateDecorations.schedule();
|
||||
}
|
||||
|
||||
private static _cachedKeybindingRegex: string = null;
|
||||
private static _getKeybindingRegex(): string {
|
||||
if (!this._cachedKeybindingRegex) {
|
||||
let numpadKey = "numpad(0|1|2|3|4|5|6|7|8|9|_multiply|_add|_subtract|_decimal|_divide)";
|
||||
let punctKey = "`|\\-|=|\\[|\\]|\\\\\\\\|;|'|,|\\.|\\/";
|
||||
let specialKey = "left|up|right|down|pageup|pagedown|end|home|tab|enter|escape|space|backspace|delete|pausebreak|capslock|insert";
|
||||
let casualKey = "[a-z]|[0-9]|f(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)";
|
||||
let key = '((' + [numpadKey, punctKey, specialKey, casualKey].join(')|(') + '))';
|
||||
let mod = '((ctrl|shift|alt|cmd|win|meta)\\+)*';
|
||||
let keybinding = '(' + mod + key + ')';
|
||||
|
||||
this._cachedKeybindingRegex = '"\\s*(' + keybinding + '(\\s+' + keybinding +')?' + ')\\s*"';
|
||||
}
|
||||
return this._cachedKeybindingRegex;
|
||||
}
|
||||
|
||||
private _dec:string[] = [];
|
||||
private _updateDecorationsNow(): void {
|
||||
let model = this._editor.getModel();
|
||||
let regex = DefineKeybindingController._getKeybindingRegex();
|
||||
let regex = Keybinding.getUserSettingsKeybindingRegex();
|
||||
|
||||
var m = model.findMatches(regex, false, true, false, false);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import Filters = require('vs/base/common/filters');
|
|||
import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions';
|
||||
import {EditorAction, Behaviour} from 'vs/editor/common/editorAction';
|
||||
import EditorQuickOpen = require('./editorQuickOpen');
|
||||
import {KeybindingsUtils} from 'vs/platform/keybinding/common/keybindingsUtils';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
|
||||
export class EditorActionCommandEntry extends QuickOpenModel.QuickOpenEntryGroup {
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
|
||||
import 'vs/css!./keybindings';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import nls = require('vs/nls');
|
||||
import lifecycle = require('vs/base/common/lifecycle');
|
||||
import DOM = require('vs/base/browser/dom');
|
||||
import Keyboard = require('vs/base/browser/keyboardEvent');
|
||||
import {IDisposable} from 'vs/base/common/lifecycle';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {IKeybindingService, IKeybindingScopeLocation, ICommandHandler, IKeybindingItem, IKeybindings, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {IKeybindingService, IKeybindingScopeLocation, ICommandHandler, IKeybindingItem, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IResolveResult, CommonKeybindingResolver} from 'vs/platform/keybinding/common/commonKeybindingResolver';
|
||||
import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {Keybinding, KeyCode} from 'vs/base/common/keyCodes';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
|
||||
var KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
|
||||
let KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
|
||||
|
||||
export class KeybindingContext {
|
||||
private _parent: KeybindingContext;
|
||||
|
@ -45,8 +45,8 @@ export class KeybindingContext {
|
|||
}
|
||||
|
||||
public getValue(): any {
|
||||
var r = this._parent ? this._parent.getValue() : Object.create(null);
|
||||
for (var key in this._value) {
|
||||
let r = this._parent ? this._parent.getValue() : Object.create(null);
|
||||
for (let key in this._value) {
|
||||
r[key] = this._value[key];
|
||||
}
|
||||
return r;
|
||||
|
@ -138,10 +138,10 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
};
|
||||
|
||||
protected _domNode: HTMLElement;
|
||||
private _toDispose: lifecycle.IDisposable;
|
||||
private _toDispose: IDisposable;
|
||||
private _resolver: KeybindingResolver;
|
||||
private _currentChord: number;
|
||||
private _currentChordStatusMessage: lifecycle.IDisposable;
|
||||
private _currentChordStatusMessage: IDisposable;
|
||||
|
||||
constructor(domNode: HTMLElement) {
|
||||
this._lastContextId = -1;
|
||||
|
@ -150,7 +150,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
this._contexts = Object.create(null);
|
||||
this._contexts[String(this._myContextId)] = new KeybindingContext(this._myContextId, null);
|
||||
this._toDispose = DOM.addDisposableListener(this._domNode, DOM.EventType.KEY_DOWN, (e:KeyboardEvent) => {
|
||||
var keyEvent = new Keyboard.StandardKeyboardEvent(e);
|
||||
let keyEvent = new StandardKeyboardEvent(e);
|
||||
this._dispatch(keyEvent);
|
||||
});
|
||||
|
||||
|
@ -201,9 +201,10 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
}
|
||||
|
||||
private _getAllCommandsAsComment(): string {
|
||||
var boundCommands = this._resolver.getDefaultBoundCommands();
|
||||
var unboundCommands = Object.keys(KeybindingsRegistry.getCommands()).filter(commandId => commandId[0] !== '_' && !boundCommands[commandId]);
|
||||
var pretty = unboundCommands.join('\n// - ');
|
||||
let boundCommands = this._resolver.getDefaultBoundCommands();
|
||||
let unboundCommands = Object.keys(KeybindingsRegistry.getCommands()).filter(commandId => commandId[0] !== '_' && !boundCommands[commandId]);
|
||||
unboundCommands.sort();
|
||||
let pretty = unboundCommands.join('\n// - ');
|
||||
|
||||
return '// ' + nls.localize('unboundCommands', "Here are other available commands: ") + '\n// - ' + pretty;
|
||||
}
|
||||
|
@ -213,17 +214,17 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
}
|
||||
|
||||
private _dispatch(e: DOM.IKeyboardEvent): void {
|
||||
var isModifierKey = (e.keyCode === KeyCode.Ctrl || e.keyCode === KeyCode.Shift || e.keyCode === KeyCode.Alt || e.keyCode === KeyCode.Meta);
|
||||
let isModifierKey = (e.keyCode === KeyCode.Ctrl || e.keyCode === KeyCode.Shift || e.keyCode === KeyCode.Alt || e.keyCode === KeyCode.Meta);
|
||||
if (isModifierKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var contextId = this._findContextAttr(e.target);
|
||||
var context = this.getContext(contextId);
|
||||
var contextValue = context.getValue();
|
||||
let contextId = this._findContextAttr(e.target);
|
||||
let context = this.getContext(contextId);
|
||||
let contextValue = context.getValue();
|
||||
// console.log(JSON.stringify(contextValue, null, '\t'));
|
||||
|
||||
var resolveResult = this._resolver.resolveKeyboardEvent(contextValue, this._currentChord, e);
|
||||
let resolveResult = this._resolver.resolve(contextValue, this._currentChord, e.asKeybinding());
|
||||
|
||||
if (resolveResult && resolveResult.enterChord) {
|
||||
e.preventDefault();
|
||||
|
@ -253,7 +254,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
if (!/^\^/.test(resolveResult.commandId)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
var commandId = resolveResult.commandId.replace(/^\^/, '');
|
||||
let commandId = resolveResult.commandId.replace(/^\^/, '');
|
||||
this._invokeHandler(commandId, { context: contextValue }).done(undefined, err => {
|
||||
this._messageService.show(Severity.Warning, err);
|
||||
});
|
||||
|
@ -289,7 +290,7 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
}
|
||||
|
||||
public createChildContext(parentContextId: number = this._myContextId): number {
|
||||
var id = (++this._lastContextId);
|
||||
let id = (++this._lastContextId);
|
||||
this._contexts[String(id)] = new KeybindingContext(id, this.getContext(parentContextId));
|
||||
return id;
|
||||
}
|
||||
|
@ -300,9 +301,9 @@ export class KeybindingService extends AbstractKeybindingService implements IKey
|
|||
|
||||
public executeCommand(commandId: string, args:any = {}): TPromise<any> {
|
||||
if (!args.context) {
|
||||
var contextId = this._findContextAttr(<HTMLElement>document.activeElement);
|
||||
var context = this.getContext(contextId);
|
||||
var contextValue = context.getValue();
|
||||
let contextId = this._findContextAttr(<HTMLElement>document.activeElement);
|
||||
let context = this.getContext(contextId);
|
||||
let contextValue = context.getValue();
|
||||
|
||||
args.context = contextValue;
|
||||
}
|
||||
|
@ -368,9 +369,3 @@ class ScopedKeybindingService extends AbstractKeybindingService {
|
|||
return this._parent.executeCommand(commandId, args);
|
||||
}
|
||||
}
|
||||
|
||||
export class KeybindingResolver extends CommonKeybindingResolver {
|
||||
public resolveKeyboardEvent(context: any, currentChord: number, key: DOM.IKeyboardEvent): IResolveResult {
|
||||
return this.resolve(context, currentChord, key.asKeybinding());
|
||||
}
|
||||
}
|
368
src/vs/platform/keybinding/common/keybindingResolver.ts
Normal file
368
src/vs/platform/keybinding/common/keybindingResolver.ts
Normal file
|
@ -0,0 +1,368 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as defaultPlatform from 'vs/base/common/platform';
|
||||
import {IKeybindingItem, KbExpr, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {KeyMod, KeyCode, BinaryKeybindings, Keybinding, ISimplifiedPlatform} from 'vs/base/common/keyCodes';
|
||||
|
||||
export interface IResolveResult {
|
||||
enterChord: number;
|
||||
commandId: string;
|
||||
}
|
||||
|
||||
export interface IBoundCommands {
|
||||
[commandId: string]: boolean;
|
||||
}
|
||||
|
||||
interface ICommandMap {
|
||||
[partialKeybinding: number]: ICommandEntry[];
|
||||
}
|
||||
|
||||
interface IChordsMap {
|
||||
[partialKeybinding: number]: ICommandMap;
|
||||
}
|
||||
|
||||
interface ICommandEntry {
|
||||
context: KbExpr;
|
||||
keybinding: number;
|
||||
commandId: string;
|
||||
}
|
||||
|
||||
export class KeybindingResolver {
|
||||
private _defaultKeybindings: IKeybindingItem[];
|
||||
private _defaultBoundCommands: IBoundCommands;
|
||||
private _map: ICommandMap;
|
||||
private _chords: IChordsMap;
|
||||
private _lookupMap: {
|
||||
[commandId: string]: IKeybindingItem[];
|
||||
};
|
||||
private _lookupMapUnreachable: {
|
||||
// The value contains the keybinding or first part of a chord
|
||||
[commandId: string]: number[];
|
||||
};
|
||||
private _shouldWarnOnConflict: boolean;
|
||||
|
||||
constructor(defaultKeybindings: IKeybindingItem[], overrides: IKeybindingItem[], shouldWarnOnConflict:boolean = true) {
|
||||
defaultKeybindings = defaultKeybindings.slice(0).sort(sorter);
|
||||
|
||||
this._defaultKeybindings = defaultKeybindings;
|
||||
this._shouldWarnOnConflict = shouldWarnOnConflict;
|
||||
|
||||
this._defaultBoundCommands = Object.create(null);
|
||||
for (let i = 0, len = defaultKeybindings.length; i < len; i++) {
|
||||
this._defaultBoundCommands[defaultKeybindings[i].command] = true;
|
||||
}
|
||||
|
||||
this._map = Object.create(null);
|
||||
this._lookupMap = Object.create(null);
|
||||
this._lookupMapUnreachable = Object.create(null);
|
||||
this._chords = Object.create(null);
|
||||
|
||||
let defaultKeybindingsCount = defaultKeybindings.length;
|
||||
let allKeybindings = defaultKeybindings.concat(overrides);
|
||||
for (let i = 0, len = allKeybindings.length; i < len; i++) {
|
||||
let k = allKeybindings[i];
|
||||
if (k.keybinding === 0) {
|
||||
continue;
|
||||
}
|
||||
if (k.context) {
|
||||
k.context = k.context.normalize();
|
||||
}
|
||||
|
||||
let entry:ICommandEntry = {
|
||||
context: k.context,
|
||||
keybinding: k.keybinding,
|
||||
commandId: k.command
|
||||
};
|
||||
|
||||
if (BinaryKeybindings.hasChord(k.keybinding)) {
|
||||
// This is a chord
|
||||
let keybindingFirstPart = BinaryKeybindings.extractFirstPart(k.keybinding);
|
||||
let keybindingChordPart = BinaryKeybindings.extractChordPart(k.keybinding);
|
||||
|
||||
this._chords[keybindingFirstPart] = this._chords[keybindingFirstPart] || Object.create(null);
|
||||
this._chords[keybindingFirstPart][keybindingChordPart] = this._chords[keybindingFirstPart][keybindingChordPart] || [];
|
||||
this._chords[keybindingFirstPart][keybindingChordPart].push(entry);
|
||||
|
||||
this._addKeyPress(keybindingFirstPart, entry, k, i < defaultKeybindingsCount);
|
||||
|
||||
} else {
|
||||
this._addKeyPress(k.keybinding, entry, k, i < defaultKeybindingsCount);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _addKeyPress(keypress: number, entry: ICommandEntry, item:IKeybindingItem, isDefault:boolean): void {
|
||||
|
||||
if (!this._map[keypress]) {
|
||||
// There is no conflict so far
|
||||
this._map[keypress] = [entry];
|
||||
this._addToLookupMap(item);
|
||||
return;
|
||||
}
|
||||
|
||||
let conflicts = this._map[keypress];
|
||||
|
||||
for (let i = conflicts.length - 1; i >= 0; i--) {
|
||||
let conflict = conflicts[i];
|
||||
|
||||
if (conflict.commandId === item.command) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (BinaryKeybindings.hasChord(conflict.keybinding) && BinaryKeybindings.hasChord(entry.keybinding) && conflict.keybinding !== entry.keybinding) {
|
||||
// The conflict only shares the chord start with this command
|
||||
continue;
|
||||
}
|
||||
|
||||
if (KeybindingResolver.contextIsEntirelyIncluded(true, conflict.context, item.context)) {
|
||||
// `item` completely overwrites `conflict`
|
||||
if (this._shouldWarnOnConflict && isDefault) {
|
||||
console.warn('Conflict detected, command `' + conflict.commandId + '` cannot be triggered by ' + Keybinding.toUserSettingsLabel(keypress));
|
||||
}
|
||||
this._lookupMapUnreachable[conflict.commandId] = this._lookupMapUnreachable[conflict.commandId] || [];
|
||||
this._lookupMapUnreachable[conflict.commandId].push(conflict.keybinding);
|
||||
}
|
||||
}
|
||||
|
||||
conflicts.push(entry);
|
||||
this._addToLookupMap(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if `a` is completely covered by `b`.
|
||||
* Returns true if `b` is a more relaxed `a`.
|
||||
* Return true if (`a` === true implies `b` === true).
|
||||
*/
|
||||
public static contextIsEntirelyIncluded(inNormalizedForm: boolean, a: KbExpr, b: KbExpr): boolean {
|
||||
if (!inNormalizedForm) {
|
||||
a = a ? a.normalize() : null;
|
||||
b = b ? b.normalize() : null;
|
||||
}
|
||||
if (!b) {
|
||||
return true;
|
||||
}
|
||||
if (!a) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let aRulesArr = a.serialize().split(' && ');
|
||||
let bRulesArr = b.serialize().split(' && ');
|
||||
|
||||
let aRules: { [rule:string]: boolean; } = Object.create(null);
|
||||
for (let i = 0, len = aRulesArr.length; i < len; i++) {
|
||||
aRules[aRulesArr[i]] = true;
|
||||
}
|
||||
|
||||
for (let i = 0, len = bRulesArr.length; i < len; i++) {
|
||||
if (!aRules[bRulesArr[i]]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private _addToLookupMap(item: IKeybindingItem): void {
|
||||
if (!item.command) {
|
||||
return;
|
||||
}
|
||||
this._lookupMap[item.command] = this._lookupMap[item.command] || [];
|
||||
this._lookupMap[item.command].push(item);
|
||||
}
|
||||
|
||||
public getDefaultBoundCommands(): IBoundCommands {
|
||||
return this._defaultBoundCommands;
|
||||
}
|
||||
|
||||
public getDefaultKeybindings(): string {
|
||||
let out = new OutputBuilder();
|
||||
out.writeLine('[');
|
||||
|
||||
let lastIndex = this._defaultKeybindings.length - 1;
|
||||
this._defaultKeybindings.forEach((k, index) => {
|
||||
IOSupport.writeKeybindingItem(out, k);
|
||||
if (index !== lastIndex) {
|
||||
out.writeLine(',');
|
||||
} else {
|
||||
out.writeLine();
|
||||
}
|
||||
});
|
||||
out.writeLine(']');
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public lookupKeybinding(commandId: string): Keybinding[] {
|
||||
let rawPossibleTriggers = this._lookupMap[commandId]
|
||||
if (!rawPossibleTriggers) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let possibleTriggers = rawPossibleTriggers.map(possibleTrigger => possibleTrigger.keybinding);
|
||||
|
||||
let remove = this._lookupMapUnreachable[commandId];
|
||||
if (remove) {
|
||||
possibleTriggers = possibleTriggers.filter((possibleTrigger) => {
|
||||
return remove.indexOf(possibleTrigger) === -1;
|
||||
});
|
||||
}
|
||||
|
||||
let seenKeys: number[] = [];
|
||||
let result = possibleTriggers.filter((possibleTrigger) => {
|
||||
if (seenKeys.indexOf(possibleTrigger) >= 0) {
|
||||
return false;
|
||||
}
|
||||
seenKeys.push(possibleTrigger);
|
||||
return true;
|
||||
});
|
||||
|
||||
return result.map((trigger) => {
|
||||
return new Keybinding(trigger);
|
||||
}).reverse(); // sort most specific to the top
|
||||
}
|
||||
|
||||
public resolve(context: any, currentChord: number, keypress: number): IResolveResult {
|
||||
// console.log('resolve: ' + Keybinding.toLabel(keypress));
|
||||
let lookupMap: ICommandEntry[] = null;
|
||||
|
||||
if (currentChord !== 0) {
|
||||
let chords = this._chords[currentChord];
|
||||
if (!chords) {
|
||||
return null;
|
||||
}
|
||||
lookupMap = chords[keypress];
|
||||
} else {
|
||||
lookupMap = this._map[keypress];
|
||||
}
|
||||
|
||||
|
||||
let result = this._findCommand(context, lookupMap);
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (currentChord === 0 && BinaryKeybindings.hasChord(result.keybinding)) {
|
||||
return {
|
||||
enterChord: keypress,
|
||||
commandId: null
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
enterChord: 0,
|
||||
commandId: result.commandId
|
||||
};
|
||||
}
|
||||
|
||||
private _findCommand(context: any, matches: ICommandEntry[]): ICommandEntry {
|
||||
if (!matches) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let i = matches.length - 1; i >= 0; i--) {
|
||||
let k = matches[i];
|
||||
|
||||
if (!KeybindingResolver.contextMatchesRules(context, k.context)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static contextMatchesRules(context: any, rules: KbExpr): boolean {
|
||||
if (!rules) {
|
||||
return true;
|
||||
}
|
||||
return rules.evaluate(context);
|
||||
}
|
||||
}
|
||||
|
||||
function rightPaddedString(str: string, minChars: number): string {
|
||||
if (str.length < minChars) {
|
||||
return str + (new Array(minChars - str.length).join(' '));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function sorter(a: IKeybindingItem, b: IKeybindingItem): number {
|
||||
if (a.weight1 !== b.weight1) {
|
||||
return a.weight1 - b.weight1;
|
||||
}
|
||||
if (a.command < b.command) {
|
||||
return -1;
|
||||
}
|
||||
if (a.command > b.command) {
|
||||
return 1;
|
||||
}
|
||||
return a.weight2 - b.weight2;
|
||||
}
|
||||
|
||||
export class OutputBuilder {
|
||||
|
||||
private _lines: string[] = [];
|
||||
private _currentLine: string = '';
|
||||
|
||||
write(str: string): void {
|
||||
this._currentLine += str;
|
||||
}
|
||||
|
||||
writeLine(str: string = ''): void {
|
||||
this._lines.push(this._currentLine + str);
|
||||
this._currentLine = '';
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
this.writeLine();
|
||||
return this._lines.join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
export class IOSupport {
|
||||
|
||||
public static writeKeybindingItem(out: OutputBuilder, item: IKeybindingItem): void {
|
||||
out.write('{ "key": ' + rightPaddedString('"' + IOSupport.writeKeybinding(item.keybinding).replace(/\\/g, '\\\\') + '",', 25) + ' "command": ');
|
||||
let serializedContext = item.context ? item.context.serialize() : '';
|
||||
if (serializedContext.length > 0) {
|
||||
out.write('"' + item.command + '",');
|
||||
out.writeLine();
|
||||
out.write(' "when": "');
|
||||
out.write(serializedContext);
|
||||
out.write('" ');
|
||||
} else {
|
||||
out.write('"' + item.command + '" ');
|
||||
}
|
||||
// out.write(String(item.weight));
|
||||
out.write('}');
|
||||
}
|
||||
|
||||
public static readKeybindingItem(input: IUserFriendlyKeybinding, index:number): IKeybindingItem {
|
||||
let key = IOSupport.readKeybinding(input.key);
|
||||
let context = IOSupport.readKeybindingContexts(input.when);
|
||||
return {
|
||||
keybinding: key,
|
||||
command: input.command,
|
||||
context: context,
|
||||
weight1: 1000,
|
||||
weight2: index
|
||||
};
|
||||
}
|
||||
|
||||
public static writeKeybinding(input: number, Platform: ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding.toUserSettingsLabel(input, Platform);
|
||||
}
|
||||
|
||||
public static readKeybinding(input: string, Platform: ISimplifiedPlatform = defaultPlatform): number {
|
||||
return Keybinding.fromUserSettingsLabel(input, Platform);
|
||||
}
|
||||
|
||||
public static readKeybindingContexts(input: string): KbExpr {
|
||||
return KbExpr.deserialize(input);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {TypeConstraint} from 'vs/base/common/types';
|
||||
import {createDecorator, IInstantiationService, ServiceIdentifier, ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {createDecorator, ServiceIdentifier, ServicesAccessor} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
|
||||
|
@ -168,7 +168,7 @@ export class KbAndExpression implements KbExpr {
|
|||
}
|
||||
|
||||
public evaluate(context:any): boolean {
|
||||
for (var i = 0, len = this.expr.length; i < len; i++) {
|
||||
for (let i = 0, len = this.expr.length; i < len; i++) {
|
||||
if (!this.expr[i].evaluate(context)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ export class KbAndExpression implements KbExpr {
|
|||
}
|
||||
|
||||
|
||||
export var KbExpr = {
|
||||
export let KbExpr = {
|
||||
has: (key:string) => new KbDefinedExpression(key),
|
||||
equals: (key:string, value:any) => new KbEqualsExpression(key, value),
|
||||
notEquals: (key:string, value:any) => new KbNotEqualsExpression(key, value),
|
||||
|
@ -268,7 +268,7 @@ export var KbExpr = {
|
|||
return false;
|
||||
}
|
||||
|
||||
var m = /^'([^']*)'$/.exec(serializedValue);
|
||||
let m = /^'([^']*)'$/.exec(serializedValue);
|
||||
if (m) {
|
||||
return m[1].trim();
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ export interface IKeybindingContextKey<T> {
|
|||
reset(): void;
|
||||
}
|
||||
|
||||
export var IKeybindingService = createDecorator<IKeybindingService>('keybindingService');
|
||||
export let IKeybindingService = createDecorator<IKeybindingService>('keybindingService');
|
||||
|
||||
export interface IKeybindingScopeLocation {
|
||||
setAttribute(attr:string, value:string): void;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import {Registry} from 'vs/platform/platform';
|
||||
import {TypeConstraint, validateConstraints} from 'vs/base/common/types';
|
||||
import {ICommandHandler, ICommandHandlerDescription, ICommandsMap, IKeybindingItem, IKeybindings, KbExpr} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {KeybindingsUtils} from 'vs/platform/keybinding/common/keybindingsUtils';
|
||||
import {KeyMod, KeyCode, BinaryKeybindings} from 'vs/base/common/keyCodes';
|
||||
import Platform = require('vs/base/common/platform');
|
||||
|
||||
|
@ -28,9 +27,6 @@ export interface IKeybindingsRegistry {
|
|||
getCommands(): ICommandsMap;
|
||||
getDefaultKeybindings(): IKeybindingItem[];
|
||||
|
||||
KEYBINDING_CONTEXT_OPERATOR_EQUAL: string;
|
||||
KEYBINDING_CONTEXT_OPERATOR_NOT_EQUAL: string;
|
||||
|
||||
WEIGHT: {
|
||||
editorCore(importance?: number): number;
|
||||
editorContrib(importance?: number): number;
|
||||
|
@ -45,9 +41,6 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
private _keybindings: IKeybindingItem[];
|
||||
private _commands: ICommandsMap;
|
||||
|
||||
public KEYBINDING_CONTEXT_OPERATOR_EQUAL = 'equal';
|
||||
public KEYBINDING_CONTEXT_OPERATOR_NOT_EQUAL = 'not_equal';
|
||||
|
||||
public WEIGHT = {
|
||||
editorCore: (importance: number = 0): number => {
|
||||
return 0 + importance;
|
||||
|
@ -71,8 +64,29 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
this._commands = Object.create(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take current platform into account and reduce to primary & secondary.
|
||||
*/
|
||||
private static bindToCurrentPlatform(kb:IKeybindings): { primary?: number; secondary?: number[]; } {
|
||||
if (Platform.isWindows) {
|
||||
if (kb && kb.win) {
|
||||
return kb.win;
|
||||
}
|
||||
} else if (Platform.isMacintosh) {
|
||||
if (kb && kb.mac) {
|
||||
return kb.mac;
|
||||
}
|
||||
} else {
|
||||
if (kb && kb.linux) {
|
||||
return kb.linux;
|
||||
}
|
||||
}
|
||||
|
||||
return kb;
|
||||
}
|
||||
|
||||
public registerCommandRule(rule:ICommandRule): void {
|
||||
var actualKb = KeybindingsUtils.bindToCurrentPlatform(rule);
|
||||
let actualKb = KeybindingsRegistryImpl.bindToCurrentPlatform(rule);
|
||||
|
||||
if (actualKb && actualKb.primary) {
|
||||
this.registerDefaultKeybinding(actualKb.primary, rule.id, rule.weight, 0, rule.context);
|
||||
|
@ -91,14 +105,13 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
// }
|
||||
// this._commands[desc.id] = desc.handler;
|
||||
|
||||
let {handler} = desc;
|
||||
let handler = desc.handler;
|
||||
let description = desc.description || handler.description;
|
||||
|
||||
// add argument validation if rich command metadata is provided
|
||||
if (typeof description === 'object') {
|
||||
const metadata = <ICommandHandlerDescription>description;
|
||||
const constraints: TypeConstraint[] = [];
|
||||
for (let arg of metadata.args) {
|
||||
let constraints: TypeConstraint[] = [];
|
||||
for (let arg of description.args) {
|
||||
constraints.push(arg.constraint);
|
||||
}
|
||||
handler = function(accesor, args) {
|
||||
|
@ -139,10 +152,10 @@ class KeybindingsRegistryImpl implements IKeybindingsRegistry {
|
|||
return this._keybindings;
|
||||
}
|
||||
}
|
||||
export var KeybindingsRegistry:IKeybindingsRegistry = new KeybindingsRegistryImpl();
|
||||
export let KeybindingsRegistry:IKeybindingsRegistry = new KeybindingsRegistryImpl();
|
||||
|
||||
// Define extension point ids
|
||||
export var Extensions = {
|
||||
export let Extensions = {
|
||||
EditorModes: 'platform.keybindingsRegistry'
|
||||
};
|
||||
Registry.add(Extensions.EditorModes, KeybindingsRegistry);
|
|
@ -1,34 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 nls = require('vs/nls');
|
||||
import Platform = require('vs/base/common/platform');
|
||||
|
||||
import {IKeybindings} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
|
||||
|
||||
export class KeybindingsUtils {
|
||||
/**
|
||||
* Take current platform into account and reduce to primary & secondary.
|
||||
*/
|
||||
public static bindToCurrentPlatform(kb:IKeybindings): { primary?: number; secondary?: number[]; } {
|
||||
if (Platform.isWindows) {
|
||||
if (kb && kb.win) {
|
||||
return kb.win;
|
||||
}
|
||||
} else if (Platform.isMacintosh) {
|
||||
if (kb && kb.mac) {
|
||||
return kb.mac;
|
||||
}
|
||||
} else {
|
||||
if (kb && kb.linux) {
|
||||
return kb.linux;
|
||||
}
|
||||
}
|
||||
|
||||
return kb;
|
||||
}
|
||||
}
|
113
src/vs/platform/keybinding/test/common/keybindingIO.test.ts
Normal file
113
src/vs/platform/keybinding/test/common/keybindingIO.test.ts
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as assert from 'assert';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {KeyMod, KeyCode, ISimplifiedPlatform} from 'vs/base/common/keyCodes';
|
||||
|
||||
suite('Keybinding IO', () => {
|
||||
|
||||
test('serialize/deserialize', function() {
|
||||
const WINDOWS = { isMacintosh: false, isWindows: true };
|
||||
const MACINTOSH = { isMacintosh: true, isWindows: false };
|
||||
const LINUX = { isMacintosh: false, isWindows: false };
|
||||
|
||||
function testOneSerialization(keybinding:number, expected:string, msg:string, Platform:ISimplifiedPlatform): void {
|
||||
let actualSerialized = IOSupport.writeKeybinding(keybinding, Platform);
|
||||
assert.equal(actualSerialized, expected, expected + ' - ' + msg);
|
||||
}
|
||||
function testSerialization(keybinding:number, expectedWin:string, expectedMac:string, expectedLinux:string): void {
|
||||
testOneSerialization(keybinding, expectedWin, 'win', WINDOWS);
|
||||
testOneSerialization(keybinding, expectedMac, 'mac', MACINTOSH);
|
||||
testOneSerialization(keybinding, expectedLinux, 'linux', LINUX);
|
||||
}
|
||||
|
||||
function testOneDeserialization(keybinding:string, expected:number, msg:string, Platform:ISimplifiedPlatform): void {
|
||||
let actualDeserialized = IOSupport.readKeybinding(keybinding, Platform);
|
||||
assert.equal(actualDeserialized, expected, keybinding + ' - ' + msg);
|
||||
}
|
||||
function testDeserialization(inWin:string, inMac:string, inLinux:string, expected:number): void {
|
||||
testOneDeserialization(inWin, expected, 'win', WINDOWS);
|
||||
testOneDeserialization(inMac, expected, 'mac', MACINTOSH);
|
||||
testOneDeserialization(inLinux, expected, 'linux', LINUX);
|
||||
}
|
||||
|
||||
function testRoundtrip(keybinding:number, expectedWin:string, expectedMac:string, expectedLinux:string): void {
|
||||
testSerialization(keybinding, expectedWin, expectedMac, expectedLinux);
|
||||
testDeserialization(expectedWin, expectedMac, expectedLinux, keybinding);
|
||||
}
|
||||
|
||||
testRoundtrip(KeyCode.KEY_0, '0', '0', '0');
|
||||
testRoundtrip(KeyCode.KEY_A, 'a', 'a', 'a');
|
||||
testRoundtrip(KeyCode.UpArrow, 'up', 'up', 'up');
|
||||
testRoundtrip(KeyCode.RightArrow, 'right', 'right', 'right');
|
||||
testRoundtrip(KeyCode.DownArrow, 'down', 'down', 'down');
|
||||
testRoundtrip(KeyCode.LeftArrow, 'left', 'left', 'left');
|
||||
|
||||
// one modifier
|
||||
testRoundtrip(KeyMod.Alt | KeyCode.KEY_A, 'alt+a', 'alt+a', 'alt+a');
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyCode.KEY_A, 'ctrl+a', 'cmd+a', 'ctrl+a');
|
||||
testRoundtrip(KeyMod.Shift | KeyCode.KEY_A, 'shift+a', 'shift+a', 'shift+a');
|
||||
testRoundtrip(KeyMod.WinCtrl | KeyCode.KEY_A, 'win+a', 'ctrl+a', 'meta+a');
|
||||
|
||||
// two modifiers
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_A, 'ctrl+alt+a', 'alt+cmd+a', 'ctrl+alt+a');
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A, 'ctrl+shift+a', 'shift+cmd+a', 'ctrl+shift+a');
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_A, 'ctrl+win+a', 'ctrl+cmd+a', 'ctrl+meta+a');
|
||||
testRoundtrip(KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A, 'shift+alt+a', 'shift+alt+a', 'shift+alt+a');
|
||||
testRoundtrip(KeyMod.Shift | KeyMod.WinCtrl | KeyCode.KEY_A, 'shift+win+a', 'ctrl+shift+a', 'shift+meta+a');
|
||||
testRoundtrip(KeyMod.Alt | KeyMod.WinCtrl | KeyCode.KEY_A, 'alt+win+a', 'ctrl+alt+a', 'alt+meta+a');
|
||||
|
||||
// three modifiers
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.KEY_A, 'ctrl+shift+alt+a', 'shift+alt+cmd+a', 'ctrl+shift+alt+a');
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.WinCtrl | KeyCode.KEY_A, 'ctrl+shift+win+a', 'ctrl+shift+cmd+a', 'ctrl+shift+meta+a');
|
||||
testRoundtrip(KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.KEY_A, 'shift+alt+win+a', 'ctrl+shift+alt+a', 'shift+alt+meta+a');
|
||||
|
||||
// all modifiers
|
||||
testRoundtrip(KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.KEY_A, 'ctrl+shift+alt+win+a', 'ctrl+shift+alt+cmd+a', 'ctrl+shift+alt+meta+a');
|
||||
|
||||
// chords
|
||||
testRoundtrip(KeyMod.chord(KeyMod.CtrlCmd | KeyCode.KEY_A, KeyMod.CtrlCmd | KeyCode.KEY_A), 'ctrl+a ctrl+a', 'cmd+a cmd+a', 'ctrl+a ctrl+a');
|
||||
testRoundtrip(KeyMod.chord(KeyMod.CtrlCmd | KeyCode.UpArrow, KeyMod.CtrlCmd | KeyCode.UpArrow), 'ctrl+up ctrl+up', 'cmd+up cmd+up', 'ctrl+up ctrl+up');
|
||||
|
||||
// OEM keys
|
||||
testRoundtrip(KeyCode.US_SEMICOLON, ';', ';', ';');
|
||||
testRoundtrip(KeyCode.US_EQUAL, '=', '=', '=');
|
||||
testRoundtrip(KeyCode.US_COMMA, ',', ',', ',');
|
||||
testRoundtrip(KeyCode.US_MINUS, '-', '-', '-');
|
||||
testRoundtrip(KeyCode.US_DOT, '.', '.', '.');
|
||||
testRoundtrip(KeyCode.US_SLASH, '/', '/', '/');
|
||||
testRoundtrip(KeyCode.US_BACKTICK, '`', '`', '`');
|
||||
testRoundtrip(KeyCode.US_OPEN_SQUARE_BRACKET, '[', '[', '[');
|
||||
testRoundtrip(KeyCode.US_BACKSLASH, '\\', '\\', '\\');
|
||||
testRoundtrip(KeyCode.US_CLOSE_SQUARE_BRACKET, ']', ']', ']');
|
||||
testRoundtrip(KeyCode.US_QUOTE, '\'', '\'', '\'');
|
||||
testRoundtrip(KeyCode.OEM_8, 'oem_8', 'oem_8', 'oem_8');
|
||||
testRoundtrip(KeyCode.OEM_102, 'oem_102', 'oem_102', 'oem_102');
|
||||
|
||||
// OEM aliases
|
||||
testDeserialization('OEM_1', 'OEM_1', 'OEM_1', KeyCode.US_SEMICOLON);
|
||||
testDeserialization('OEM_PLUS', 'OEM_PLUS', 'OEM_PLUS', KeyCode.US_EQUAL);
|
||||
testDeserialization('OEM_COMMA', 'OEM_COMMA', 'OEM_COMMA', KeyCode.US_COMMA);
|
||||
testDeserialization('OEM_MINUS', 'OEM_MINUS', 'OEM_MINUS', KeyCode.US_MINUS);
|
||||
testDeserialization('OEM_PERIOD', 'OEM_PERIOD', 'OEM_PERIOD', KeyCode.US_DOT);
|
||||
testDeserialization('OEM_2', 'OEM_2', 'OEM_2', KeyCode.US_SLASH);
|
||||
testDeserialization('OEM_3', 'OEM_3', 'OEM_3', KeyCode.US_BACKTICK);
|
||||
testDeserialization('OEM_4', 'OEM_4', 'OEM_4', KeyCode.US_OPEN_SQUARE_BRACKET);
|
||||
testDeserialization('OEM_5', 'OEM_5', 'OEM_5', KeyCode.US_BACKSLASH);
|
||||
testDeserialization('OEM_6', 'OEM_6', 'OEM_6', KeyCode.US_CLOSE_SQUARE_BRACKET);
|
||||
testDeserialization('OEM_7', 'OEM_7', 'OEM_7', KeyCode.US_QUOTE);
|
||||
testDeserialization('OEM_8', 'OEM_8', 'OEM_8', KeyCode.OEM_8);
|
||||
testDeserialization('OEM_102', 'OEM_102', 'OEM_102', KeyCode.OEM_102);
|
||||
|
||||
// accepts '-' as separator
|
||||
testDeserialization('ctrl-shift-alt-win-a', 'ctrl-shift-alt-cmd-a', 'ctrl-shift-alt-meta-a', KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.KEY_A);
|
||||
|
||||
// various input mistakes
|
||||
testDeserialization(' ctrl-shift-alt-win-A ', ' shift-alt-cmd-Ctrl-A ', ' ctrl-shift-alt-META-A ', KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyMod.WinCtrl | KeyCode.KEY_A);
|
||||
});
|
||||
|
||||
});
|
|
@ -4,11 +4,9 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import {CommonKeybindingResolver, IOSupport} from 'vs/platform/keybinding/common/commonKeybindingResolver';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import {KeybindingsUtils} from 'vs/platform/keybinding/common/keybindingsUtils';
|
||||
import Platform = require('vs/base/common/platform');
|
||||
import * as assert from 'assert';
|
||||
import {KeybindingResolver, IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import {KbExpr, KbAndExpression, IKeybindingItem} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {KeyMod, KeyCode, BinaryKeybindings} from 'vs/base/common/keyCodes';
|
||||
|
||||
|
@ -25,10 +23,10 @@ suite('Keybinding Service', () => {
|
|||
weight2: 0
|
||||
};
|
||||
|
||||
assert.equal(CommonKeybindingResolver.contextMatchesRules({ bar: 'baz' }, contextRules), true);
|
||||
assert.equal(CommonKeybindingResolver.contextMatchesRules({ bar: 'bz' }, contextRules), false);
|
||||
assert.equal(KeybindingResolver.contextMatchesRules({ bar: 'baz' }, contextRules), true);
|
||||
assert.equal(KeybindingResolver.contextMatchesRules({ bar: 'bz' }, contextRules), false);
|
||||
|
||||
var resolver = new CommonKeybindingResolver([keybindingItem], []);
|
||||
var resolver = new KeybindingResolver([keybindingItem], []);
|
||||
assert.equal(resolver.resolve({ bar: 'baz' }, 0, keybinding).commandId, 'yes');
|
||||
assert.equal(resolver.resolve({ bar: 'bz' }, 0, keybinding), null);
|
||||
});
|
||||
|
@ -47,10 +45,10 @@ suite('Keybinding Service', () => {
|
|||
|
||||
test('contextIsEntirelyIncluded', function () {
|
||||
var assertIsIncluded = (a: KbExpr[], b: KbExpr[]) => {
|
||||
assert.equal(CommonKeybindingResolver.contextIsEntirelyIncluded(false, new KbAndExpression(a), new KbAndExpression(b)), true);
|
||||
assert.equal(KeybindingResolver.contextIsEntirelyIncluded(false, new KbAndExpression(a), new KbAndExpression(b)), true);
|
||||
};
|
||||
var assertIsNotIncluded = (a: KbExpr[], b: KbExpr[]) => {
|
||||
assert.equal(CommonKeybindingResolver.contextIsEntirelyIncluded(false, new KbAndExpression(a), new KbAndExpression(b)), false);
|
||||
assert.equal(KeybindingResolver.contextIsEntirelyIncluded(false, new KbAndExpression(a), new KbAndExpression(b)), false);
|
||||
};
|
||||
var key1IsTrue = KbExpr.equals('key1', true);
|
||||
var key1IsNotFalse = KbExpr.notEquals('key1', false);
|
||||
|
@ -203,7 +201,7 @@ suite('Keybinding Service', () => {
|
|||
}
|
||||
];
|
||||
|
||||
var resolver = new CommonKeybindingResolver(items, [], false);
|
||||
var resolver = new KeybindingResolver(items, [], false);
|
||||
|
||||
|
||||
|
||||
|
@ -278,7 +276,7 @@ suite('Keybinding Service', () => {
|
|||
};
|
||||
function testExpression(expr:string, expected:boolean): void {
|
||||
let rules = IOSupport.readKeybindingContexts(expr);
|
||||
assert.equal(CommonKeybindingResolver.contextMatchesRules(context, rules), expected, expr);
|
||||
assert.equal(KeybindingResolver.contextMatchesRules(context, rules), expected, expr);
|
||||
}
|
||||
function testBatch(expr:string, value:any): void {
|
||||
testExpression(expr, !!value);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import assert = require('assert');
|
||||
import * as assert from 'assert';
|
||||
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
||||
suite('Keybinding Registry', () => {
|
||||
|
|
|
@ -19,9 +19,7 @@ import {IQuickOpenService} from 'vs/workbench/services/quickopen/common/quickOpe
|
|||
import {INullService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
import ipc = require('ipc');
|
||||
import remote = require('remote');
|
||||
import webFrame = require('web-frame');
|
||||
import {ipcRenderer as ipc, webFrame, remote} from 'electron';
|
||||
|
||||
export class CloseEditorAction extends Action {
|
||||
|
||||
|
@ -74,14 +72,15 @@ export class CloseFolderAction extends Action {
|
|||
id: string,
|
||||
label: string,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IMessageService private messageService: IMessageService
|
||||
@IMessageService private messageService: IMessageService,
|
||||
@IWindowService private windowService: IWindowService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(): Promise {
|
||||
if (this.contextService.getWorkspace()) {
|
||||
ipc.send('vscode:closeFolder', remote.getCurrentWindow().id); // handled from browser process
|
||||
ipc.send('vscode:closeFolder', this.windowService.getWindowId()); // handled from browser process
|
||||
} else {
|
||||
this.messageService.show(Severity.Info, nls.localize('noFolderOpened', "There is currently no folder opened in this instance to close."));
|
||||
}
|
||||
|
@ -95,7 +94,11 @@ export class NewWindowAction extends Action {
|
|||
public static ID = 'workbench.action.newWindow';
|
||||
public static LABEL = nls.localize('newWindow', "New Window");
|
||||
|
||||
constructor(id: string, label: string, @IWindowService private windowService: IWindowService) {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowService private windowService: IWindowService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
|
@ -148,7 +151,7 @@ export class ToggleDevToolsAction extends Action {
|
|||
}
|
||||
|
||||
public run(): Promise {
|
||||
remote.getCurrentWindow().toggleDevTools();
|
||||
remote.getCurrentWindow().webContents.toggleDevTools();
|
||||
|
||||
return Promise.as(true);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ import {IConfigurationService} from 'vs/platform/configuration/common/configurat
|
|||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
|
||||
import crashReporter = require('crash-reporter');
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc, crashReporter} from 'electron';
|
||||
|
||||
let TELEMETRY_SECTION_ID = 'telemetry';
|
||||
|
||||
|
@ -51,7 +50,7 @@ export class CrashReporter {
|
|||
this.config = null;
|
||||
}
|
||||
|
||||
public start(rawConfiguration:ICrashReporterConfigRenderer): void {
|
||||
public start(rawConfiguration:Electron.CrashReporterStartOptions): void {
|
||||
if (!this.isStarted) {
|
||||
if (!this.config) {
|
||||
this.configurationService.loadConfiguration(TELEMETRY_SECTION_ID).done((c) => {
|
||||
|
@ -68,7 +67,7 @@ export class CrashReporter {
|
|||
}
|
||||
}
|
||||
|
||||
private doStart(rawConfiguration:ICrashReporterConfigRenderer): void {
|
||||
private doStart(rawConfiguration:Electron.CrashReporterStartOptions): void {
|
||||
const config = this.toConfiguration(rawConfiguration);
|
||||
|
||||
crashReporter.start(config);
|
||||
|
@ -77,7 +76,7 @@ export class CrashReporter {
|
|||
ipc.send('vscode:startCrashReporter', config);
|
||||
}
|
||||
|
||||
private toConfiguration(rawConfiguration:ICrashReporterConfigRenderer): ICrashReporterConfigRenderer {
|
||||
private toConfiguration(rawConfiguration:Electron.CrashReporterStartOptions): Electron.CrashReporterStartOptions {
|
||||
return JSON.parse(JSON.stringify(rawConfiguration, (key, value) => {
|
||||
if (value === '$(sessionId)') {
|
||||
return this.sessionId;
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
<!-- Helpers -->
|
||||
<script type="text/javascript">
|
||||
var path = require('path');
|
||||
var remote = require('remote');
|
||||
var ipc = require('ipc');
|
||||
var electron = require('electron');
|
||||
var remote = electron.remote;
|
||||
var ipc = electron.ipcRenderer;
|
||||
|
||||
function onError(error, enableDeveloperTools) {
|
||||
if (enableDeveloperTools) {
|
||||
remote.getCurrentWindow().openDevTools();
|
||||
remote.getCurrentWindow().webContents.openDevTools();
|
||||
remote.getCurrentWindow().show();
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,7 @@
|
|||
|
||||
<!-- Startup Code -->
|
||||
<script type="text/javascript">
|
||||
var webFrame = require('web-frame');
|
||||
var webFrame = require('electron').webFrame;
|
||||
|
||||
var mainStarted = false;
|
||||
var args = parseURLQueryArgs();
|
||||
|
|
|
@ -24,9 +24,7 @@ import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceE
|
|||
|
||||
import win = require('vs/workbench/electron-browser/window');
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
import webFrame = require('web-frame');
|
||||
import {ipcRenderer as ipc, webFrame, remote} from 'electron';
|
||||
|
||||
export class ElectronIntegration {
|
||||
|
||||
|
@ -50,12 +48,12 @@ export class ElectronIntegration {
|
|||
this.windowService.registerWindow(activeWindow);
|
||||
|
||||
// Support runAction event
|
||||
ipc.on('vscode:runAction', (actionId: string) => {
|
||||
ipc.on('vscode:runAction', (event, actionId: string) => {
|
||||
this.keybindingService.executeCommand(actionId, { from: 'menu' }).done(undefined, err => this.messageService.show(Severity.Error, err));
|
||||
});
|
||||
|
||||
// Support options change
|
||||
ipc.on('vscode:optionsChange', (options: string) => {
|
||||
ipc.on('vscode:optionsChange', (event, options: string) => {
|
||||
let optionsData = JSON.parse(options);
|
||||
for (let key in optionsData) {
|
||||
if (optionsData.hasOwnProperty(key)) {
|
||||
|
@ -66,7 +64,7 @@ export class ElectronIntegration {
|
|||
});
|
||||
|
||||
// Support resolve keybindings event
|
||||
ipc.on('vscode:resolveKeybindings', (rawActionIds: string) => {
|
||||
ipc.on('vscode:resolveKeybindings', (event, rawActionIds: string) => {
|
||||
let actionIds: string[] = [];
|
||||
try {
|
||||
actionIds = JSON.parse(rawActionIds);
|
||||
|
@ -82,11 +80,11 @@ export class ElectronIntegration {
|
|||
}, () => errors.onUnexpectedError);
|
||||
});
|
||||
|
||||
ipc.on('vscode:telemetry', ({ eventName, data }) => {
|
||||
ipc.on('vscode:telemetry', (event, { eventName, data }) => {
|
||||
this.telemetryService.publicLog(eventName, data);
|
||||
});
|
||||
|
||||
ipc.on('vscode:reportError', (error) => {
|
||||
ipc.on('vscode:reportError', (event, error) => {
|
||||
if (error) {
|
||||
let errorParsed = JSON.parse(error);
|
||||
errorParsed.mainProcess = true;
|
||||
|
@ -100,7 +98,7 @@ export class ElectronIntegration {
|
|||
});
|
||||
|
||||
// Theme changes
|
||||
ipc.on('vscode:changeTheme', (theme: string) => {
|
||||
ipc.on('vscode:changeTheme', (event, theme: string) => {
|
||||
this.storageService.store('workbench.theme', theme, StorageScope.GLOBAL);
|
||||
});
|
||||
|
||||
|
|
|
@ -9,15 +9,12 @@ import nls = require('vs/nls');
|
|||
import severity from 'vs/base/common/severity';
|
||||
import {Promise} from 'vs/base/common/winjs.base';
|
||||
import {Action} from 'vs/base/common/actions';
|
||||
import ipc = require('ipc');
|
||||
import remote = require('remote');
|
||||
import {ipcRenderer as ipc, shell} from 'electron';
|
||||
import {isLinux} from 'vs/base/common/platform';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
|
||||
import {IRequestService} from 'vs/platform/request/common/request';
|
||||
|
||||
const shell = remote.require('shell');
|
||||
|
||||
interface IUpdate {
|
||||
releaseNotes: string;
|
||||
version: string;
|
||||
|
@ -57,7 +54,7 @@ export class Update {
|
|||
) {
|
||||
const env = this.contextService.getConfiguration().env;
|
||||
|
||||
ipc.on('vscode:update-downloaded', (update: IUpdate) => {
|
||||
ipc.on('vscode:update-downloaded', (event, update: IUpdate) => {
|
||||
this.messageService.show(severity.Info, {
|
||||
message: nls.localize('updateAvailable', "{0} will be updated after it restarts.", env.appName),
|
||||
actions: [Update.ShowReleaseNotesAction(env.releaseNotesUrl), Update.NotNowAction, Update.ApplyUpdateAction]
|
||||
|
|
|
@ -18,11 +18,7 @@ import {IStorageService} from 'vs/platform/storage/common/storage';
|
|||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
|
||||
const Shell = remote.require('shell');
|
||||
const Dialog = remote.require('dialog');
|
||||
import {ipcRenderer as ipc, shell, remote} from 'electron';
|
||||
|
||||
export interface IWindowConfiguration {
|
||||
window: {
|
||||
|
@ -33,10 +29,10 @@ export interface IWindowConfiguration {
|
|||
}
|
||||
|
||||
export class ElectronWindow {
|
||||
private win: remote.BrowserWindow;
|
||||
private win: Electron.BrowserWindow;
|
||||
|
||||
constructor(
|
||||
win: remote.BrowserWindow,
|
||||
win: Electron.BrowserWindow,
|
||||
shellContainer: HTMLElement,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IEventService private eventService: IEventService,
|
||||
|
@ -127,10 +123,10 @@ export class ElectronWindow {
|
|||
});
|
||||
|
||||
// Handle window.open() calls
|
||||
window.open = function(url: string, target: string, features: string, replace: boolean) {
|
||||
Shell.openExternal(url);
|
||||
(<any>window).open = function(url: string, target: string, features: string, replace: boolean) {
|
||||
shell.openExternal(url);
|
||||
|
||||
return <Window>null;
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -158,8 +154,8 @@ export class ElectronWindow {
|
|||
this.win.close();
|
||||
}
|
||||
|
||||
public showMessageBox(options: remote.IMessageBoxOptions): number {
|
||||
return Dialog.showMessageBox(this.win, options);
|
||||
public showMessageBox(options: Electron.Dialog.ShowMessageBoxOptions): number {
|
||||
return remote.dialog.showMessageBox(this.win, options);
|
||||
}
|
||||
|
||||
public setFullScreen(fullscreen: boolean): void {
|
||||
|
@ -167,7 +163,7 @@ export class ElectronWindow {
|
|||
}
|
||||
|
||||
public openDevTools(): void {
|
||||
this.win.openDevTools();
|
||||
this.win.webContents.openDevTools();
|
||||
}
|
||||
|
||||
public isFullScreen(): boolean {
|
||||
|
|
2
src/vs/workbench/electron-main/bootstrap.js
vendored
2
src/vs/workbench/electron-main/bootstrap.js
vendored
|
@ -8,7 +8,7 @@
|
|||
// Perf measurements
|
||||
global.vscodeStart = Date.now();
|
||||
|
||||
var app = require('app');
|
||||
var app = require('electron').app;
|
||||
var path = require('path');
|
||||
|
||||
// Change cwd if given via env variable
|
||||
|
|
|
@ -9,7 +9,7 @@ import crypto = require('crypto');
|
|||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import os = require('os');
|
||||
import app = require('app');
|
||||
import {app} from 'electron';
|
||||
|
||||
import arrays = require('vs/base/common/arrays');
|
||||
import strings = require('vs/base/common/strings');
|
||||
|
@ -43,7 +43,7 @@ export interface IProductConfiguration {
|
|||
serviceUrl: string;
|
||||
itemUrl: string;
|
||||
};
|
||||
crashReporter: ICrashReporterConfigBrowser;
|
||||
crashReporter: Electron.CrashReporterStartOptions;
|
||||
welcomePage: string;
|
||||
enableTelemetry: boolean;
|
||||
aiConfig: {
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import app = require('app');
|
||||
import events = require('events');
|
||||
import ipc = require('ipc');
|
||||
import {ipcMain as ipc, app} from 'electron';
|
||||
|
||||
import {TPromise, TValueCallback} from 'vs/base/common/winjs.base';
|
||||
import {ReadyState, VSCodeWindow} from 'vs/workbench/electron-main/window';
|
||||
|
@ -77,7 +76,7 @@ export class Lifecycle {
|
|||
|
||||
// Window Before Closing: Main -> Renderer
|
||||
vscodeWindow.win.on('close', (e) => {
|
||||
let windowId = vscodeWindow.win.id;
|
||||
let windowId = vscodeWindow.id;
|
||||
env.log('Lifecycle#window-before-close', windowId);
|
||||
|
||||
// The window already acknowledged to be closed
|
||||
|
@ -104,7 +103,7 @@ export class Lifecycle {
|
|||
}
|
||||
|
||||
public unload(vscodeWindow: VSCodeWindow): TPromise<boolean /* veto */> {
|
||||
env.log('Lifecycle#unload()', vscodeWindow.win.id);
|
||||
env.log('Lifecycle#unload()', vscodeWindow.id);
|
||||
|
||||
// Always allow to unload a window that is not yet ready
|
||||
if (vscodeWindow.readyState !== ReadyState.READY) {
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import app = require('app');
|
||||
import {app, shell, dialog} from 'electron';
|
||||
import fs = require('fs');
|
||||
import dialog = require('dialog');
|
||||
import shell = require('shell');
|
||||
import nls = require('vs/nls');
|
||||
import {assign} from 'vs/base/common/objects';
|
||||
import platform = require('vs/base/common/platform');
|
||||
|
@ -23,7 +21,7 @@ import {getUserEnvironment} from 'vs/base/node/env';
|
|||
import {Promise, TPromise} from 'vs/base/common/winjs.base';
|
||||
import {GitAskpassService} from 'vs/workbench/parts/git/electron-main/askpassService';
|
||||
import {spawnSharedProcess} from 'vs/workbench/electron-main/sharedProcess';
|
||||
import { Mutex } from 'windows-mutex';
|
||||
import {Mutex} from 'windows-mutex';
|
||||
|
||||
export class LaunchService {
|
||||
public start(args: env.ICommandLineArguments, userEnv: env.IProcessEnvironment): Promise {
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import app = require('app');
|
||||
import Menu = require('menu');
|
||||
import MenuItem = require('menu-item');
|
||||
import Dialog = require('dialog');
|
||||
import shell = require('shell');
|
||||
import ipc = require('ipc');
|
||||
import {ipcMain as ipc, app, shell, dialog, Menu, MenuItem} from 'electron';
|
||||
|
||||
import nls = require('vs/nls');
|
||||
import platform = require('vs/base/common/platform');
|
||||
|
@ -154,7 +149,7 @@ export class VSCodeMenu {
|
|||
let menubar = new Menu();
|
||||
|
||||
// Mac: Application
|
||||
let macApplicationMenuItem: MenuItem;
|
||||
let macApplicationMenuItem: Electron.MenuItem;
|
||||
if (platform.isMacintosh) {
|
||||
let applicationMenu = new Menu();
|
||||
macApplicationMenuItem = new MenuItem({ label: env.product.nameShort, submenu: applicationMenu });
|
||||
|
@ -182,7 +177,7 @@ export class VSCodeMenu {
|
|||
this.setGotoMenu(gotoMenu);
|
||||
|
||||
// Mac: Window
|
||||
let macWindowMenuItem: MenuItem;
|
||||
let macWindowMenuItem: Electron.MenuItem;
|
||||
if (platform.isMacintosh) {
|
||||
let windowMenu = new Menu();
|
||||
macWindowMenuItem = new MenuItem({ label: mnemonicLabel(nls.localize('mWindow', "Window")), submenu: windowMenu, role: 'window' });
|
||||
|
@ -276,7 +271,7 @@ export class VSCodeMenu {
|
|||
return mru;
|
||||
}
|
||||
|
||||
private setMacApplicationMenu(macApplicationMenu: Menu): void {
|
||||
private setMacApplicationMenu(macApplicationMenu: Electron.Menu): void {
|
||||
let about = new MenuItem({ label: nls.localize('mAbout', "About {0}", env.product.nameLong), role: 'about' });
|
||||
let checkForUpdates = this.getUpdateMenuItems();
|
||||
let preferences = this.getPreferencesMenu();
|
||||
|
@ -301,10 +296,10 @@ export class VSCodeMenu {
|
|||
actions.forEach(i => macApplicationMenu.append(i));
|
||||
}
|
||||
|
||||
private setFileMenu(fileMenu: Menu): void {
|
||||
private setFileMenu(fileMenu: Electron.Menu): void {
|
||||
let hasNoWindows = (windows.manager.getWindowCount() === 0);
|
||||
|
||||
let newFile:MenuItem;
|
||||
let newFile: Electron.MenuItem;
|
||||
if (hasNoWindows) {
|
||||
newFile = new MenuItem({ label: mnemonicLabel(nls.localize('miNewFile', "&&New File")), accelerator: this.getAccelerator('workbench.action.files.newUntitledFile'), click: () => windows.manager.openNewWindow() });
|
||||
} else {
|
||||
|
@ -358,7 +353,7 @@ export class VSCodeMenu {
|
|||
]).forEach((item) => fileMenu.append(item));
|
||||
}
|
||||
|
||||
private getPreferencesMenu(): MenuItem {
|
||||
private getPreferencesMenu(): Electron.MenuItem {
|
||||
let userSettings = this.createMenuItem(nls.localize('miOpenSettings', "&&User Settings"), 'workbench.action.openGlobalSettings');
|
||||
let workspaceSettings = this.createMenuItem(nls.localize('miOpenWorkspaceSettings', "&&Workspace Settings"), 'workbench.action.openWorkspaceSettings');
|
||||
let kebindingSettings = this.createMenuItem(nls.localize('miOpenKeymap', "&&Keyboard Shortcuts"), 'workbench.action.openGlobalKeybindings');
|
||||
|
@ -396,7 +391,7 @@ export class VSCodeMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private setOpenRecentMenu(openRecentMenu: Menu): void {
|
||||
private setOpenRecentMenu(openRecentMenu: Electron.Menu): void {
|
||||
let recentList = this.getOpenedPathsList();
|
||||
|
||||
// Folders
|
||||
|
@ -425,7 +420,7 @@ export class VSCodeMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private createOpenRecentMenuItem(path:string): MenuItem {
|
||||
private createOpenRecentMenuItem(path:string): Electron.MenuItem {
|
||||
return new MenuItem({ label: path, click: () => {
|
||||
let success = windows.manager.open({ cli: env.cliArgs, pathsToOpen: [path] });
|
||||
if (!success) {
|
||||
|
@ -435,8 +430,8 @@ export class VSCodeMenu {
|
|||
}});
|
||||
}
|
||||
|
||||
private createRoleMenuItem(label:string, actionId:string, role:string): MenuItem {
|
||||
let options:IMenuItemConfig = {
|
||||
private createRoleMenuItem(label:string, actionId:string, role:string): Electron.MenuItem {
|
||||
let options:Electron.MenuItemOptions = {
|
||||
label: mnemonicLabel(label),
|
||||
accelerator: this.getAccelerator(actionId),
|
||||
role: role,
|
||||
|
@ -446,13 +441,13 @@ export class VSCodeMenu {
|
|||
return new MenuItem(options);
|
||||
}
|
||||
|
||||
private setEditMenu(winLinuxEditMenu: Menu): void {
|
||||
let undo:MenuItem;
|
||||
let redo:MenuItem;
|
||||
let cut:MenuItem;
|
||||
let copy:MenuItem;
|
||||
let paste:MenuItem;
|
||||
let selectAll:MenuItem;
|
||||
private setEditMenu(winLinuxEditMenu: Electron.Menu): void {
|
||||
let undo: Electron.MenuItem;
|
||||
let redo: Electron.MenuItem;
|
||||
let cut: Electron.MenuItem;
|
||||
let copy: Electron.MenuItem;
|
||||
let paste: Electron.MenuItem;
|
||||
let selectAll: Electron.MenuItem;
|
||||
|
||||
if (platform.isMacintosh) {
|
||||
undo = this.createDevToolsAwareMenuItem(nls.localize('miUndo', "&&Undo"), 'undo', (devTools) => devTools.undo());
|
||||
|
@ -490,7 +485,7 @@ export class VSCodeMenu {
|
|||
].forEach((item) => winLinuxEditMenu.append(item));
|
||||
}
|
||||
|
||||
private setViewMenu(viewMenu: Menu): void {
|
||||
private setViewMenu(viewMenu: Electron.Menu): void {
|
||||
let commands = this.createMenuItem(nls.localize('miCommandPalette', "&&Command Palette..."), 'workbench.action.showCommands');
|
||||
let markers = this.createMenuItem(nls.localize('miMarker', "&&Errors and Warnings..."), 'workbench.action.showErrorsWarnings');
|
||||
let output = this.createMenuItem(nls.localize('miToggleOutput', "Toggle &&Output"), 'workbench.action.output.toggleOutput');
|
||||
|
@ -520,7 +515,7 @@ export class VSCodeMenu {
|
|||
]).forEach((item) => viewMenu.append(item));
|
||||
}
|
||||
|
||||
private setGotoMenu(gotoMenu: Menu): void {
|
||||
private setGotoMenu(gotoMenu: Electron.Menu): void {
|
||||
let back = this.createMenuItem(nls.localize('miBack', "&&Back"), 'workbench.action.navigateBack');
|
||||
let forward = this.createMenuItem(nls.localize('miForward', "&&Forward"), 'workbench.action.navigateForward');
|
||||
let navigateHistory = this.createMenuItem(nls.localize('miNavigateHistory', "&&Navigate History"), 'workbench.action.openPreviousEditor');
|
||||
|
@ -542,7 +537,7 @@ export class VSCodeMenu {
|
|||
].forEach((item) => gotoMenu.append(item));
|
||||
}
|
||||
|
||||
private setMacWindowMenu(macWindowMenu: Menu): void {
|
||||
private setMacWindowMenu(macWindowMenu: Electron.Menu): void {
|
||||
let minimize = new MenuItem({ label: nls.localize('mMinimize', "Minimize"), role: 'minimize', accelerator: 'Command+M', enabled: windows.manager.getWindowCount() > 0 });
|
||||
let close = new MenuItem({ label: nls.localize('mClose', "Close"), role: 'close', accelerator: 'Command+W', enabled: windows.manager.getWindowCount() > 0 });
|
||||
let bringAllToFront = new MenuItem({ label: nls.localize('mBringToFront', "Bring All to Front"), role: 'front', enabled: windows.manager.getWindowCount() > 0 });
|
||||
|
@ -555,7 +550,7 @@ export class VSCodeMenu {
|
|||
].forEach((item) => macWindowMenu.append(item));
|
||||
}
|
||||
|
||||
private setHelpMenu(helpMenu: Menu): void {
|
||||
private setHelpMenu(helpMenu: Electron.Menu): void {
|
||||
let toggleDevToolsItem = new MenuItem({
|
||||
label: mnemonicLabel(nls.localize('miToggleDevTools', "&&Toggle Developer Tools")),
|
||||
accelerator: this.getAccelerator('workbench.action.toggleDevTools'),
|
||||
|
@ -590,7 +585,7 @@ export class VSCodeMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private getUpdateMenuItems(): MenuItem[]{
|
||||
private getUpdateMenuItems(): Electron.MenuItem[]{
|
||||
switch (UpdateManager.state) {
|
||||
case um.State.Uninitialized:
|
||||
return [];
|
||||
|
@ -626,9 +621,9 @@ export class VSCodeMenu {
|
|||
}
|
||||
}
|
||||
|
||||
private createMenuItem(label:string, actionId: string, enabled?:boolean): MenuItem;
|
||||
private createMenuItem(label:string, click:() => void, enabled?:boolean): MenuItem;
|
||||
private createMenuItem(arg1:string, arg2:any, arg3?:boolean): MenuItem {
|
||||
private createMenuItem(label:string, actionId: string, enabled?:boolean): Electron.MenuItem;
|
||||
private createMenuItem(label:string, click:() => void, enabled?:boolean): Electron.MenuItem;
|
||||
private createMenuItem(arg1:string, arg2:any, arg3?:boolean): Electron.MenuItem {
|
||||
let label = mnemonicLabel(arg1);
|
||||
let click:() => void = (typeof arg2 === 'function') ? arg2 : () => windows.manager.sendToFocused('vscode:runAction', arg2);
|
||||
let enabled = typeof arg3 === 'boolean' ? arg3 : windows.manager.getWindowCount() > 0;
|
||||
|
@ -638,7 +633,7 @@ export class VSCodeMenu {
|
|||
actionId = arg2;
|
||||
}
|
||||
|
||||
let options:IMenuItemConfig = {
|
||||
let options:Electron.MenuItemOptions = {
|
||||
label: label,
|
||||
accelerator: this.getAccelerator(actionId),
|
||||
click: click,
|
||||
|
@ -648,7 +643,7 @@ export class VSCodeMenu {
|
|||
return new MenuItem(options);
|
||||
}
|
||||
|
||||
private createDevToolsAwareMenuItem(label:string, actionId: string, devToolsFocusedFn: (contents: WebContents) => void): MenuItem {
|
||||
private createDevToolsAwareMenuItem(label:string, actionId: string, devToolsFocusedFn: (contents: Electron.WebContents) => void): Electron.MenuItem {
|
||||
return new MenuItem({
|
||||
label: mnemonicLabel(label),
|
||||
accelerator: this.getAccelerator(actionId),
|
||||
|
@ -659,7 +654,7 @@ export class VSCodeMenu {
|
|||
return;
|
||||
}
|
||||
|
||||
if (windowInFocus.win.isDevToolsFocused()) {
|
||||
if (windowInFocus.win.webContents.isDevToolsFocused()) {
|
||||
devToolsFocusedFn(windowInFocus.win.devToolsWebContents);
|
||||
} else {
|
||||
windows.manager.sendToFocused('vscode:runAction', actionId);
|
||||
|
@ -691,7 +686,7 @@ export class VSCodeMenu {
|
|||
function openAboutDialog(): void {
|
||||
let lastActiveWindow = windows.manager.getFocusedWindow() || windows.manager.getLastActiveWindow();
|
||||
|
||||
Dialog.showMessageBox(lastActiveWindow && lastActiveWindow.win, {
|
||||
dialog.showMessageBox(lastActiveWindow && lastActiveWindow.win, {
|
||||
title: env.product.nameLong,
|
||||
type: 'info',
|
||||
message: env.product.nameLong,
|
||||
|
@ -719,7 +714,7 @@ function openUrl(url: string, id: string): void {
|
|||
function toggleDevTools(): void {
|
||||
let w = windows.manager.getFocusedWindow();
|
||||
if (w && w.win) {
|
||||
w.win.toggleDevTools();
|
||||
w.win.webContents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,7 +722,7 @@ function reportMenuActionTelemetry(id: string): void {
|
|||
windows.manager.sendToFocused('vscode:telemetry', { eventName: 'workbenchActionExecuted', data: { id, from: 'menu' } });
|
||||
}
|
||||
|
||||
function __separator__(): MenuItem {
|
||||
function __separator__(): Electron.MenuItem {
|
||||
return new MenuItem({ type: 'separator' });
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import app = require('app');
|
||||
import {app} from 'electron';
|
||||
|
||||
import env = require('vs/workbench/electron-main/env');
|
||||
import {UserSettings} from 'vs/workbench/node/userSettings';
|
||||
|
|
|
@ -8,6 +8,7 @@ import fs = require('fs');
|
|||
import path = require('path');
|
||||
import events = require('events');
|
||||
|
||||
import electron = require('electron');
|
||||
import platform = require('vs/base/common/platform');
|
||||
import env = require('vs/workbench/electron-main/env');
|
||||
import storage = require('vs/workbench/electron-main/storage');
|
||||
|
@ -37,8 +38,8 @@ export interface IUpdate {
|
|||
quitAndUpdate: () => void;
|
||||
}
|
||||
|
||||
interface IAutoUpdater extends IEventEmitter {
|
||||
setFeedUrl(url: string): void;
|
||||
interface IAutoUpdater extends NodeJS.EventEmitter {
|
||||
setFeedURL(url: string): void;
|
||||
checkForUpdates(): void;
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,7 @@ export class UpdateManager extends events.EventEmitter {
|
|||
if (platform.isWindows) {
|
||||
this.raw = new Win32AutoUpdaterImpl();
|
||||
} else if (platform.isMacintosh) {
|
||||
this.raw = <any>require.__$__nodeRequire('auto-updater'); // https://github.com/atom/electron/issues/3194
|
||||
this.raw = electron.autoUpdater;
|
||||
}
|
||||
|
||||
if (this.raw) {
|
||||
|
@ -141,7 +142,7 @@ export class UpdateManager extends events.EventEmitter {
|
|||
this._channel = channel;
|
||||
this._feedUrl = feedUrl;
|
||||
|
||||
this.raw.setFeedUrl(feedUrl);
|
||||
this.raw.setFeedURL(feedUrl);
|
||||
this.setState(State.Idle);
|
||||
|
||||
// Check for updates on startup after 30 seconds
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
'use strict';
|
||||
|
||||
import events = require('events');
|
||||
import {IAutoUpdater, IUpdate} from 'auto-updater';
|
||||
import path = require('path');
|
||||
import os = require('os');
|
||||
import cp = require('child_process');
|
||||
|
@ -19,7 +18,14 @@ import { getProxyAgent } from 'vs/workbench/node/proxy';
|
|||
import {manager as Settings} from 'vs/workbench/electron-main/settings';
|
||||
import {manager as Lifecycle} from 'vs/workbench/electron-main/lifecycle';
|
||||
|
||||
export class Win32AutoUpdaterImpl extends events.EventEmitter implements IAutoUpdater {
|
||||
export interface IUpdate {
|
||||
url: string;
|
||||
name: string;
|
||||
releaseNotes?: string;
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export class Win32AutoUpdaterImpl extends events.EventEmitter {
|
||||
|
||||
private url: string;
|
||||
private currentRequest: Promise;
|
||||
|
@ -36,7 +42,7 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter implements IAutoUp
|
|||
return new TPromise<string>((c, e) => mkdirp(result, null, err => err ? e(err) : c(result)));
|
||||
}
|
||||
|
||||
public setFeedUrl(url: string): void {
|
||||
public setFeedURL(url: string): void {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
@ -102,7 +108,7 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter implements IAutoUp
|
|||
}
|
||||
|
||||
private getUpdatePackagePath(version: string): TPromise<string> {
|
||||
return this.cachePath.then(cachePath => path.join(cachePath, `CodeSetup-${ version }.exe`));
|
||||
return this.cachePath.then(cachePath => path.join(cachePath, `CodeSetup-${version}.exe`));
|
||||
}
|
||||
|
||||
private quitAndUpdate(updatePackagePath: string): void {
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
import path = require('path');
|
||||
import os = require('os');
|
||||
|
||||
import Shell = require('shell');
|
||||
import screen = require('screen');
|
||||
import BrowserWindow = require('browser-window');
|
||||
import {shell, screen, BrowserWindow} from 'electron';
|
||||
|
||||
import {TPromise, TValueCallback} from 'vs/base/common/winjs.base';
|
||||
import platform = require('vs/base/common/platform');
|
||||
|
@ -108,7 +106,7 @@ export interface IWindowConfiguration extends env.ICommandLineArguments {
|
|||
filesToOpen?: IPath[];
|
||||
filesToCreate?: IPath[];
|
||||
extensionsToInstall: string[];
|
||||
crashReporter: ICrashReporterConfigBrowser;
|
||||
crashReporter: Electron.CrashReporterStartOptions;
|
||||
extensionsGallery: {
|
||||
serviceUrl: string;
|
||||
itemUrl: string;
|
||||
|
@ -139,7 +137,8 @@ export class VSCodeWindow {
|
|||
private static MIN_HEIGHT = 120;
|
||||
|
||||
private showTimeoutHandle: any;
|
||||
private _win: BrowserWindow;
|
||||
private _id: number;
|
||||
private _win: Electron.BrowserWindow;
|
||||
private _lastFocusTime: number;
|
||||
private _readyState: ReadyState;
|
||||
private _isPluginDevelopmentHost: boolean;
|
||||
|
@ -167,14 +166,14 @@ export class VSCodeWindow {
|
|||
global.windowShow = new Date().getTime();
|
||||
}
|
||||
|
||||
let options: IBrowserWindowOptions = {
|
||||
let options: Electron.BrowserWindowOptions = {
|
||||
width: this.windowState.width,
|
||||
height: this.windowState.height,
|
||||
x: this.windowState.x,
|
||||
y: this.windowState.y,
|
||||
'background-color': usesLightTheme ? '#FFFFFF' : '#1E1E1E',
|
||||
'min-width': VSCodeWindow.MIN_WIDTH,
|
||||
'min-height': VSCodeWindow.MIN_HEIGHT,
|
||||
backgroundColor: usesLightTheme ? '#FFFFFF' : '#1E1E1E',
|
||||
minWidth: VSCodeWindow.MIN_WIDTH,
|
||||
minHeight: VSCodeWindow.MIN_HEIGHT,
|
||||
show: showDirectly && this.currentWindowMode !== WindowMode.Maximized, // in case we are maximized, only show later after the call to maximize (see below)
|
||||
title: env.product.nameLong
|
||||
};
|
||||
|
@ -185,6 +184,7 @@ export class VSCodeWindow {
|
|||
|
||||
// Create the browser window.
|
||||
this._win = new BrowserWindow(options);
|
||||
this._id = this._win.id;
|
||||
|
||||
if (showDirectly && this.currentWindowMode === WindowMode.Maximized) {
|
||||
this.win.maximize();
|
||||
|
@ -213,7 +213,11 @@ export class VSCodeWindow {
|
|||
return this.currentConfig;
|
||||
}
|
||||
|
||||
public get win(): BrowserWindow {
|
||||
public get id(): number {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get win(): Electron.BrowserWindow {
|
||||
return this._win;
|
||||
}
|
||||
|
||||
|
@ -321,7 +325,7 @@ export class VSCodeWindow {
|
|||
this._win.webContents.on('new-window', (event: Event, url: string) => {
|
||||
event.preventDefault();
|
||||
|
||||
Shell.openExternal(url);
|
||||
shell.openExternal(url);
|
||||
});
|
||||
|
||||
// Window Focus
|
||||
|
@ -363,7 +367,7 @@ export class VSCodeWindow {
|
|||
}
|
||||
|
||||
// Load URL
|
||||
this._win.loadUrl(this.getUrl(config));
|
||||
this._win.loadURL(this.getUrl(config));
|
||||
|
||||
// Make window visible if it did not open in N seconds because this indicates an error
|
||||
if (!config.isBuilt) {
|
||||
|
@ -371,7 +375,7 @@ export class VSCodeWindow {
|
|||
if (this._win && !this._win.isVisible() && !this._win.isMinimized()) {
|
||||
this._win.show();
|
||||
this._win.focus();
|
||||
this._win.openDevTools();
|
||||
this._win.webContents.openDevTools();
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
@ -534,7 +538,7 @@ export class VSCodeWindow {
|
|||
return null;
|
||||
}
|
||||
|
||||
public getBounds(): IBounds {
|
||||
public getBounds(): Electron.Bounds {
|
||||
let pos = this.win.getPosition();
|
||||
let dimension = this.win.getSize();
|
||||
|
||||
|
|
|
@ -10,12 +10,7 @@ import events = require('events');
|
|||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
|
||||
import BrowserWindow = require('browser-window');
|
||||
import Dialog = require('dialog');
|
||||
import app = require('app');
|
||||
import ipc = require('ipc');
|
||||
import screen = require('screen');
|
||||
import crashReporter = require('crash-reporter');
|
||||
import {ipcMain as ipc, app, screen, crashReporter, BrowserWindow, dialog} from 'electron';
|
||||
|
||||
import platform = require('vs/base/common/platform');
|
||||
import env = require('vs/workbench/electron-main/env');
|
||||
|
@ -157,7 +152,7 @@ export class WindowsManager {
|
|||
crashReporter.start(config);
|
||||
});
|
||||
|
||||
ipc.on('vscode:windowOpen', (event: Event, paths: string[], forceNewWindow?: boolean) => {
|
||||
ipc.on('vscode:windowOpen', (event, paths: string[], forceNewWindow?: boolean) => {
|
||||
env.log('IPC#vscode-windowOpen: ', paths);
|
||||
|
||||
if (paths && paths.length) {
|
||||
|
@ -165,7 +160,7 @@ export class WindowsManager {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:workbenchLoaded', (event: Event, windowId: number) => {
|
||||
ipc.on('vscode:workbenchLoaded', (event, windowId: number) => {
|
||||
env.log('IPC#vscode-workbenchLoaded');
|
||||
|
||||
let win = this.getWindowById(windowId);
|
||||
|
@ -180,19 +175,19 @@ export class WindowsManager {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:openFilePicker', (event: Event) => {
|
||||
ipc.on('vscode:openFilePicker', () => {
|
||||
env.log('IPC#vscode-openFilePicker');
|
||||
|
||||
this.openFilePicker();
|
||||
});
|
||||
|
||||
ipc.on('vscode:openFolderPicker', (event: Event) => {
|
||||
ipc.on('vscode:openFolderPicker', () => {
|
||||
env.log('IPC#vscode-openFolderPicker');
|
||||
|
||||
this.openFolderPicker();
|
||||
});
|
||||
|
||||
ipc.on('vscode:closeFolder', (event: Event, windowId: number) => {
|
||||
ipc.on('vscode:closeFolder', (event, windowId: number) => {
|
||||
env.log('IPC#vscode-closeFolder');
|
||||
|
||||
let win = this.getWindowById(windowId);
|
||||
|
@ -201,19 +196,19 @@ export class WindowsManager {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:openNewWindow', (event: Event) => {
|
||||
ipc.on('vscode:openNewWindow', () => {
|
||||
env.log('IPC#vscode-openNewWindow');
|
||||
|
||||
this.openNewWindow();
|
||||
});
|
||||
|
||||
ipc.on('vscode:openFileFolderPicker', (event: Event) => {
|
||||
ipc.on('vscode:openFileFolderPicker', () => {
|
||||
env.log('IPC#vscode-openFileFolderPicker');
|
||||
|
||||
this.openFolderPicker();
|
||||
});
|
||||
|
||||
ipc.on('vscode:reloadWindow', (event: Event, windowId: number) => {
|
||||
ipc.on('vscode:reloadWindow', (event, windowId: number) => {
|
||||
env.log('IPC#vscode:reloadWindow');
|
||||
|
||||
let vscodeWindow = this.getWindowById(windowId);
|
||||
|
@ -222,7 +217,7 @@ export class WindowsManager {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:toggleFullScreen', (event: Event, windowId: number) => {
|
||||
ipc.on('vscode:toggleFullScreen', (event, windowId: number) => {
|
||||
env.log('IPC#vscode:toggleFullScreen');
|
||||
|
||||
let vscodeWindow = this.getWindowById(windowId);
|
||||
|
@ -231,7 +226,7 @@ export class WindowsManager {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:toggleMenuBar', (event: Event, windowId: number) => {
|
||||
ipc.on('vscode:toggleMenuBar', (event, windowId: number) => {
|
||||
env.log('IPC#vscode:toggleMenuBar');
|
||||
|
||||
// Update in settings
|
||||
|
@ -248,10 +243,10 @@ export class WindowsManager {
|
|||
storage.setItem(window.VSCodeWindow.themeStorageKey, theme);
|
||||
});
|
||||
|
||||
ipc.on('vscode:broadcast', (event: Event, windowId: number, target: string, broadcast: { channel: string; payload: any; }) => {
|
||||
ipc.on('vscode:broadcast', (event, windowId: number, target: string, broadcast: { channel: string; payload: any; }) => {
|
||||
if (broadcast.channel && broadcast.payload) {
|
||||
if (target) {
|
||||
const otherWindowsWithTarget = WindowsManager.WINDOWS.filter(w => w.win.id !== windowId && typeof w.openedWorkspacePath === 'string');
|
||||
const otherWindowsWithTarget = WindowsManager.WINDOWS.filter(w => w.id !== windowId && typeof w.openedWorkspacePath === 'string');
|
||||
const directTargetMatch = otherWindowsWithTarget.filter(w => this.isPathEqual(target, w.openedWorkspacePath));
|
||||
const parentTargetMatch = otherWindowsWithTarget.filter(w => paths.isEqualOrParent(target, w.openedWorkspacePath));
|
||||
|
||||
|
@ -265,7 +260,7 @@ export class WindowsManager {
|
|||
}
|
||||
});
|
||||
|
||||
ipc.on('vscode:log', (event: Event, logEntry: ILogEntry) => {
|
||||
ipc.on('vscode:log', (event, logEntry: ILogEntry) => {
|
||||
let args = [];
|
||||
try {
|
||||
let parsed = JSON.parse(logEntry.arguments);
|
||||
|
@ -277,7 +272,7 @@ export class WindowsManager {
|
|||
console[logEntry.severity].apply(console, args);
|
||||
});
|
||||
|
||||
ipc.on('vscode:exit', (event: Event, code: number) => {
|
||||
ipc.on('vscode:exit', (event, code: number) => {
|
||||
process.exit(code);
|
||||
});
|
||||
|
||||
|
@ -291,7 +286,7 @@ export class WindowsManager {
|
|||
}));
|
||||
});
|
||||
|
||||
ipc.on('vscode:update-apply', (event: Event) => {
|
||||
ipc.on('vscode:update-apply', () => {
|
||||
env.log('IPC#vscode:update-apply');
|
||||
|
||||
if (UpdateManager.availableUpdate) {
|
||||
|
@ -411,9 +406,9 @@ export class WindowsManager {
|
|||
|
||||
let activeWindow = BrowserWindow.getFocusedWindow();
|
||||
if (activeWindow) {
|
||||
Dialog.showMessageBox(activeWindow, options);
|
||||
dialog.showMessageBox(activeWindow, options);
|
||||
} else {
|
||||
Dialog.showMessageBox(options);
|
||||
dialog.showMessageBox(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -801,7 +796,7 @@ export class WindowsManager {
|
|||
//
|
||||
|
||||
// We want the new window to open on the same display that the last active one is in
|
||||
let displayToUse: IDisplay;
|
||||
let displayToUse: Electron.Display;
|
||||
let displays = screen.getAllDisplays();
|
||||
|
||||
// Single Display
|
||||
|
@ -877,7 +872,7 @@ export class WindowsManager {
|
|||
pickerProperties = ['multiSelections', isFolder ? 'openDirectory' : 'openFile', 'createDirectory'];
|
||||
}
|
||||
|
||||
Dialog.showOpenDialog(focussedWindow && focussedWindow.win, {
|
||||
dialog.showOpenDialog(focussedWindow && focussedWindow.win, {
|
||||
defaultPath: workingDir,
|
||||
properties: pickerProperties
|
||||
}, (paths) => {
|
||||
|
@ -973,7 +968,7 @@ export class WindowsManager {
|
|||
|
||||
public sendToAll(channel: string, payload: any, windowIdsToIgnore?: number[]): void {
|
||||
WindowsManager.WINDOWS.forEach((w) => {
|
||||
if (windowIdsToIgnore && windowIdsToIgnore.indexOf(w.win.id) >= 0) {
|
||||
if (windowIdsToIgnore && windowIdsToIgnore.indexOf(w.id) >= 0) {
|
||||
return; // do not send if we are instructed to ignore it
|
||||
}
|
||||
|
||||
|
@ -991,7 +986,7 @@ export class WindowsManager {
|
|||
}
|
||||
|
||||
public getWindowById(windowId: number): window.VSCodeWindow {
|
||||
let res = WindowsManager.WINDOWS.filter((w) => w.win.id === windowId);
|
||||
let res = WindowsManager.WINDOWS.filter((w) => w.id === windowId);
|
||||
if (res && res.length === 1) {
|
||||
return res[0];
|
||||
}
|
||||
|
@ -1007,12 +1002,12 @@ export class WindowsManager {
|
|||
return WindowsManager.WINDOWS.length;
|
||||
}
|
||||
|
||||
private onWindowError(win: BrowserWindow, error: WindowError): void {
|
||||
private onWindowError(win: Electron.BrowserWindow, error: WindowError): void {
|
||||
console.error(error === WindowError.CRASHED ? '[VS Code]: render process crashed!' : '[VS Code]: detected unresponsive');
|
||||
|
||||
// Unresponsive
|
||||
if (error === WindowError.UNRESPONSIVE) {
|
||||
Dialog.showMessageBox(win, {
|
||||
dialog.showMessageBox(win, {
|
||||
title: env.product.nameLong,
|
||||
type: 'warning',
|
||||
buttons: [nls.localize('exit', "Exit"), nls.localize('wait', "Keep Waiting")],
|
||||
|
@ -1029,7 +1024,7 @@ export class WindowsManager {
|
|||
|
||||
// Crashed
|
||||
else {
|
||||
Dialog.showMessageBox(win, {
|
||||
dialog.showMessageBox(win, {
|
||||
title: env.product.nameLong,
|
||||
type: 'warning',
|
||||
buttons: [nls.localize('exit', "Exit")],
|
||||
|
|
|
@ -18,11 +18,9 @@ import model = require('vs/workbench/parts/debug/common/debugModel');
|
|||
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybindingService';
|
||||
|
||||
import remote = require('remote');
|
||||
import {clipboard} from 'electron';
|
||||
import IDebugService = debug.IDebugService;
|
||||
|
||||
const clipboard = remote.require('clipboard');
|
||||
|
||||
export class AbstractDebugAction extends actions.Action {
|
||||
|
||||
protected debugService: IDebugService;
|
||||
|
|
|
@ -27,8 +27,8 @@ import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlighte
|
|||
import { Action } from 'vs/base/common/actions';
|
||||
import * as semver from 'semver';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import remote = require('remote');
|
||||
const shell = remote.require('shell');
|
||||
import { shell } from 'electron';
|
||||
|
||||
const $ = dom.emmet;
|
||||
|
||||
const InstallLabel = nls.localize('install', "Install Extension");
|
||||
|
@ -79,6 +79,12 @@ function extensionEquals(one: IExtension, other: IExtension): boolean {
|
|||
return one.publisher === other.publisher && one.name === other.name;
|
||||
}
|
||||
|
||||
function extensionEntryCompare(one: IExtensionEntry, other: IExtensionEntry): number {
|
||||
const oneName = one.extension.displayName || one.extension.name;
|
||||
const otherName = other.extension.displayName || other.extension.name;
|
||||
return oneName.localeCompare(otherName);
|
||||
}
|
||||
|
||||
class OpenInGalleryAction extends Action {
|
||||
|
||||
constructor(
|
||||
|
@ -284,7 +290,7 @@ class LocalExtensionsModel implements IModel<IExtensionEntry> {
|
|||
highlights,
|
||||
state: ExtensionState.Installed
|
||||
}))
|
||||
.sort((a, b) => a.extension.name.localeCompare(b.extension.name));
|
||||
.sort(extensionEntryCompare);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +363,7 @@ class GalleryExtensionsModel implements IModel<IExtensionEntry> {
|
|||
: ExtensionState.Uninstalled
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.extension.name.localeCompare(b.extension.name));
|
||||
.sort(extensionEntryCompare);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,7 +435,7 @@ class OutdatedExtensionsModel implements IModel<IExtensionEntry> {
|
|||
highlights,
|
||||
state: ExtensionState.Outdated
|
||||
}))
|
||||
.sort((a, b) => a.extension.name.localeCompare(b.extension.name));
|
||||
.sort(extensionEntryCompare);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
|||
import { ListExtensionsAction, InstallExtensionAction, ListOutdatedExtensionsAction } from './extensionsActions';
|
||||
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
|
||||
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc} from 'electron';
|
||||
|
||||
interface IInstallExtensionsRequest {
|
||||
extensionsToInstall: string[];
|
||||
|
@ -83,7 +83,7 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
|
|||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
ipc.on('vscode:installExtensions', (request: IInstallExtensionsRequest) => {
|
||||
ipc.on('vscode:installExtensions', (event, request: IInstallExtensionsRequest) => {
|
||||
if (request.extensionsToInstall) {
|
||||
this.install(request.extensionsToInstall).done(null, errors.onUnexpectedError);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ import {FeedbackDropdown, IFeedback, IFeedbackService} from 'vs/workbench/parts/
|
|||
import {IContextViewService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IRequestService} from 'vs/platform/request/common/request';
|
||||
|
||||
import shell = require('shell');
|
||||
import {shell} from 'electron';
|
||||
|
||||
class TwitterFeedbackService implements IFeedbackService {
|
||||
|
||||
|
|
|
@ -18,11 +18,7 @@ import {asFileEditorInput} from 'vs/workbench/common/editor';
|
|||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {INullService} from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
|
||||
const Shell = remote.require('shell');
|
||||
const Clipboard = remote.require('clipboard');
|
||||
import {ipcRenderer as ipc, shell, clipboard} from 'electron';
|
||||
|
||||
export class RevealInOSAction extends Action {
|
||||
private resource: uri;
|
||||
|
@ -36,7 +32,7 @@ export class RevealInOSAction extends Action {
|
|||
}
|
||||
|
||||
public run(): Promise {
|
||||
Shell.showItemInFolder(paths.normalize(this.resource.fsPath, true));
|
||||
shell.showItemInFolder(paths.normalize(this.resource.fsPath, true));
|
||||
|
||||
return Promise.as(true);
|
||||
}
|
||||
|
@ -59,7 +55,7 @@ export class GlobalRevealInOSAction extends Action {
|
|||
public run(): Promise {
|
||||
let fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
|
||||
if (fileInput) {
|
||||
Shell.showItemInFolder(paths.normalize(fileInput.getResource().fsPath, true));
|
||||
shell.showItemInFolder(paths.normalize(fileInput.getResource().fsPath, true));
|
||||
} else {
|
||||
this.messageService.show(severity.Info, nls.localize('openFileToReveal', "Open a file first to reveal"));
|
||||
}
|
||||
|
@ -80,7 +76,7 @@ export class CopyPathAction extends Action {
|
|||
}
|
||||
|
||||
public run(): Promise {
|
||||
Clipboard.writeText(labels.getPathLabel(this.resource));
|
||||
clipboard.writeText(labels.getPathLabel(this.resource));
|
||||
|
||||
return Promise.as(true);
|
||||
}
|
||||
|
@ -103,7 +99,7 @@ export class GlobalCopyPathAction extends Action {
|
|||
public run(): Promise {
|
||||
let fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true);
|
||||
if (fileInput) {
|
||||
Clipboard.writeText(labels.getPathLabel(fileInput.getResource()));
|
||||
clipboard.writeText(labels.getPathLabel(fileInput.getResource()));
|
||||
this.editorService.focusEditor(); // focus back to editor
|
||||
} else {
|
||||
this.messageService.show(severity.Info, nls.localize('openFileToCopy', "Open a file first to copy its path"));
|
||||
|
|
|
@ -21,8 +21,7 @@ import {IEventService} from 'vs/platform/event/common/event';
|
|||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc, remote} from 'electron';
|
||||
|
||||
export interface IPath {
|
||||
filePath: string;
|
||||
|
@ -82,7 +81,7 @@ export class FileTracker implements IWorkbenchContribution {
|
|||
this.toUnbind.push(() => disposable.dispose());
|
||||
|
||||
// Support openFiles event for existing and new files
|
||||
ipc.on('vscode:openFiles', (request: IOpenFileRequest) => {
|
||||
ipc.on('vscode:openFiles', (event, request: IOpenFileRequest) => {
|
||||
let inputs: IResourceInput[] = [];
|
||||
if (request.filesToOpen) {
|
||||
inputs.push(...this.toInputs(request.filesToOpen, false));
|
||||
|
|
|
@ -29,10 +29,7 @@ import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
|
|||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceEventTypes} from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
|
||||
const Dialog = remote.require('dialog');
|
||||
import {remote} from 'electron';
|
||||
|
||||
export class TextFileService extends AbstractTextFileService {
|
||||
|
||||
|
@ -183,7 +180,7 @@ export class TextFileService extends AbstractTextFileService {
|
|||
buttons.push(cancel, dontSave);
|
||||
}
|
||||
|
||||
let opts: remote.IMessageBoxOptions = {
|
||||
let opts: Electron.Dialog.ShowMessageBoxOptions = {
|
||||
title: this.contextService.getConfiguration().env.appName,
|
||||
message: message.join('\n'),
|
||||
type: 'warning',
|
||||
|
@ -193,7 +190,7 @@ export class TextFileService extends AbstractTextFileService {
|
|||
cancelId: buttons.indexOf(cancel)
|
||||
};
|
||||
|
||||
const choice = Dialog.showMessageBox(remote.getCurrentWindow(), opts);
|
||||
const choice = remote.dialog.showMessageBox(remote.getCurrentWindow(), opts);
|
||||
|
||||
return buttons[choice].result;
|
||||
}
|
||||
|
@ -366,18 +363,18 @@ export class TextFileService extends AbstractTextFileService {
|
|||
|
||||
private promptForPathAsync(defaultPath?: string): TPromise<string> {
|
||||
return new TPromise<string>((c, e) => {
|
||||
Dialog.showSaveDialog(remote.getCurrentWindow(), this.getSaveDialogOptions(defaultPath ? paths.normalize(defaultPath, true) : void 0), (path) => {
|
||||
remote.dialog.showSaveDialog(remote.getCurrentWindow(), this.getSaveDialogOptions(defaultPath ? paths.normalize(defaultPath, true) : void 0), (path) => {
|
||||
c(path);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private promptForPathSync(defaultPath?: string): string {
|
||||
return Dialog.showSaveDialog(remote.getCurrentWindow(), this.getSaveDialogOptions(defaultPath ? paths.normalize(defaultPath, true) : void 0));
|
||||
return remote.dialog.showSaveDialog(remote.getCurrentWindow(), this.getSaveDialogOptions(defaultPath ? paths.normalize(defaultPath, true) : void 0));
|
||||
}
|
||||
|
||||
private getSaveDialogOptions(defaultPath?: string): remote.ISaveDialogOptions {
|
||||
let options: remote.ISaveDialogOptions = {
|
||||
private getSaveDialogOptions(defaultPath?: string): Electron.Dialog.SaveDialogOptions {
|
||||
let options: Electron.Dialog.SaveDialogOptions = {
|
||||
defaultPath: defaultPath
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import { RawGitService, DelayedRawGitService } from 'vs/workbench/parts/git/node
|
|||
import URI from 'vs/base/common/uri';
|
||||
import { spawn, exec } from 'child_process';
|
||||
import { join } from 'path';
|
||||
import * as remote from 'remote';
|
||||
import { remote } from 'electron';
|
||||
|
||||
function findSpecificGit(gitPath: string): Promise {
|
||||
return new Promise((c, e) => {
|
||||
|
@ -110,7 +110,7 @@ export function createNativeRawGitService(workspaceRoot: string, gitPath: string
|
|||
timeout: 1000 * 60,
|
||||
args: [gitPath, workspaceRoot, defaultEncoding, remote.process.execPath],
|
||||
env: {
|
||||
ATOM_SHELL_INTERNAL_RUN_AS_NODE: 1,
|
||||
ELECTRON_RUN_AS_NODE: 1,
|
||||
AMD_ENTRYPOINT: 'vs/workbench/parts/git/electron-browser/gitApp'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import ipc = require('ipc');
|
||||
import { ipcMain as ipc, BrowserWindow} from 'electron';
|
||||
import platform = require('vs/base/common/platform');
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import BrowserWindow = require('browser-window');
|
||||
|
||||
export interface ICredentials {
|
||||
username: string;
|
||||
|
@ -21,7 +20,7 @@ interface ICredentialsResult {
|
|||
|
||||
interface IContext {
|
||||
credentials: ICredentials;
|
||||
window: BrowserWindow;
|
||||
window: Electron.BrowserWindow;
|
||||
}
|
||||
|
||||
export class GitAskpassService {
|
||||
|
@ -47,8 +46,8 @@ export class GitAskpassService {
|
|||
}
|
||||
|
||||
let win = new BrowserWindow({
|
||||
'always-on-top': true,
|
||||
'skip-taskbar': true,
|
||||
alwaysOnTop: true,
|
||||
skipTaskbar: true,
|
||||
resizable: false,
|
||||
width: 450,
|
||||
height: platform.isWindows ? 280 : 260,
|
||||
|
@ -63,7 +62,7 @@ export class GitAskpassService {
|
|||
credentials: null
|
||||
};
|
||||
|
||||
win.loadUrl(require.toUrl('vs/workbench/parts/git/electron-main/index.html'));
|
||||
win.loadURL(require.toUrl('vs/workbench/parts/git/electron-main/index.html'));
|
||||
win.webContents.executeJavaScript('init(' + JSON.stringify({ id, host, command }) + ')');
|
||||
|
||||
win.once('closed', () => {
|
||||
|
|
|
@ -68,9 +68,10 @@
|
|||
}
|
||||
</style>
|
||||
<script>
|
||||
var shell = require('shell');
|
||||
var ipc = require('ipc');
|
||||
var remote = require('remote');
|
||||
var electron = require('electron');
|
||||
var shell = electron.shell;
|
||||
var ipc = electron.ipcRenderer;
|
||||
var remote = electron.remote;
|
||||
var currentWindow = remote.getCurrentWindow();
|
||||
|
||||
function init(context) {
|
||||
|
|
|
@ -10,8 +10,7 @@ import env = require('vs/workbench/electron-main/env');
|
|||
import events = require('vs/base/common/eventEmitter');
|
||||
import platform = require('vs/base/common/platform');
|
||||
|
||||
import BrowserWindow = require('browser-window');
|
||||
import ipc = require('ipc');
|
||||
import { ipcMain as ipc, BrowserWindow } from 'electron';
|
||||
|
||||
interface ICredentialsContext {
|
||||
id: number;
|
||||
|
@ -31,7 +30,7 @@ interface ICredentialsResult {
|
|||
|
||||
interface IContext {
|
||||
credentials: ICredentials;
|
||||
window: BrowserWindow;
|
||||
window: Electron.BrowserWindow;
|
||||
}
|
||||
|
||||
export function configure(bus: events.EventEmitter): void {
|
||||
|
@ -55,8 +54,8 @@ export function configure(bus: events.EventEmitter): void {
|
|||
}
|
||||
|
||||
var win = new BrowserWindow({
|
||||
'always-on-top': true,
|
||||
'skip-taskbar': true,
|
||||
alwaysOnTop: true,
|
||||
skipTaskbar: true,
|
||||
resizable: false,
|
||||
width: 450,
|
||||
height: platform.isWindows ? 280 : 260,
|
||||
|
@ -71,7 +70,7 @@ export function configure(bus: events.EventEmitter): void {
|
|||
credentials: null
|
||||
};
|
||||
|
||||
win.loadUrl(require.toUrl('vs/workbench/parts/git/electron-main/index.html'));
|
||||
win.loadURL(require.toUrl('vs/workbench/parts/git/electron-main/index.html'));
|
||||
win.webContents.executeJavaScript('init(' + JSON.stringify(context) + ')');
|
||||
|
||||
win.once('closed', () => {
|
||||
|
|
|
@ -26,12 +26,12 @@ export interface IExecutionResult {
|
|||
function exec(child: ChildProcess, encoding = 'utf8'): TPromise<IExecutionResult> {
|
||||
const disposables: IDisposable[] = [];
|
||||
|
||||
const once = (ee: EventEmitter, name: string, fn: Function) => {
|
||||
const once = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {
|
||||
ee.once(name, fn);
|
||||
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
|
||||
};
|
||||
|
||||
const on = (ee: EventEmitter, name: string, fn: Function) => {
|
||||
const on = (ee: NodeJS.EventEmitter, name: string, fn: Function) => {
|
||||
ee.on(name, fn);
|
||||
disposables.push(toDisposable(() => ee.removeListener(name, fn)));
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
|||
import * as JSONContributionRegistry from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import {IJSONSchema} from 'vs/base/common/jsonSchema';
|
||||
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc} from 'electron';
|
||||
import fs = require('fs');
|
||||
|
||||
class OpenSnippetsAction extends actions.Action {
|
||||
|
|
|
@ -19,8 +19,6 @@ import {IFileService} from 'vs/platform/files/common/files';
|
|||
import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
import fs = require('fs');
|
||||
|
||||
export class SnippetsTracker implements workbenchExt.IWorkbenchContribution {
|
||||
|
|
|
@ -19,7 +19,7 @@ import {IQuickOpenService, IPickOpenEntry} from 'vs/workbench/services/quickopen
|
|||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {IThemeService, ITheme} from 'vs/workbench/services/themes/node/themeService';
|
||||
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc} from 'electron';
|
||||
|
||||
class SelectThemeAction extends actions.Action {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import severity from 'vs/base/common/severity';
|
||||
import actions = require('vs/base/common/actions');
|
||||
import {Separator} from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
|
@ -16,10 +16,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
|||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
|
||||
import remote = require('remote');
|
||||
|
||||
const Menu = remote.require('menu');
|
||||
const MenuItem = remote.require('menu-item');
|
||||
import {remote} from 'electron';
|
||||
|
||||
export class ContextMenuService implements IContextMenuService {
|
||||
public serviceId = IContextMenuService;
|
||||
|
@ -39,26 +36,26 @@ export class ContextMenuService implements IContextMenuService {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
let menu = new Menu();
|
||||
let menu = new remote.Menu();
|
||||
let actionToRun: actions.IAction = null;
|
||||
|
||||
actions.forEach(a => {
|
||||
if (a instanceof Separator) {
|
||||
menu.append(new MenuItem({ type: 'separator' }));
|
||||
menu.append(new remote.MenuItem({ type: 'separator' }));
|
||||
} else {
|
||||
const keybinding = !!delegate.getKeyBinding ? delegate.getKeyBinding(a) : undefined;
|
||||
const accelerator = keybinding && this.keybindingService.getElectronAcceleratorFor(keybinding);
|
||||
|
||||
const item = new MenuItem({
|
||||
const item = new remote.MenuItem({
|
||||
label: a.label,
|
||||
checked: a.checked,
|
||||
accelerator,
|
||||
enabled: a.enabled,
|
||||
click: () => {
|
||||
actionToRun = a;
|
||||
}
|
||||
});
|
||||
|
||||
item.enabled = a.enabled;
|
||||
menu.append(item);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,9 +19,7 @@ import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceE
|
|||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
import remote = require('remote');
|
||||
|
||||
const Shell = remote.require('shell');
|
||||
import {shell} from 'electron';
|
||||
|
||||
export class FileService implements files.IFileService {
|
||||
public serviceId = files.IFileService;
|
||||
|
@ -176,7 +174,7 @@ export class FileService implements files.IFileService {
|
|||
|
||||
let absolutePath = resource.fsPath;
|
||||
|
||||
let result = Shell.moveItemToTrash(absolutePath);
|
||||
let result = shell.moveItemToTrash(absolutePath);
|
||||
if (!result) {
|
||||
return TPromise.wrapError(new Error(nls.localize('trashFailed', "Failed to move '{0}' to the trash", paths.basename(absolutePath))));
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
|||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {PluginsRegistry, IMessageCollector} from 'vs/platform/plugins/common/pluginsRegistry';
|
||||
import {IPluginService} from 'vs/platform/plugins/common/plugins';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/commonKeybindingResolver';
|
||||
import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {KeybindingService} from 'vs/platform/keybinding/browser/keybindingServiceImpl';
|
||||
import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {ICommandRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
|
|
@ -179,8 +179,8 @@ const NATIVE_KEY_CODE_TO_KEY_CODE: {[nativeKeyCode:string]:KeyCode;} = {
|
|||
VKEY_OEM_5: KeyCode.US_BACKSLASH,
|
||||
VKEY_OEM_6: KeyCode.US_CLOSE_SQUARE_BRACKET,
|
||||
VKEY_OEM_7: KeyCode.US_QUOTE,
|
||||
VKEY_OEM_8: KeyCode.Unknown, // MISSING
|
||||
VKEY_OEM_102: KeyCode.Unknown, // MISSING
|
||||
VKEY_OEM_8: KeyCode.OEM_8,
|
||||
VKEY_OEM_102: KeyCode.OEM_102,
|
||||
VKEY_PROCESSKEY: KeyCode.Unknown, // MISSING
|
||||
VKEY_PACKET: KeyCode.Unknown, // MISSING
|
||||
VKEY_DBE_SBCSCHAR: KeyCode.Unknown, // MISSING
|
||||
|
@ -348,6 +348,8 @@ export function getNativeLabelProvider(): IKeyBindingLabelProvider {
|
|||
VKEY_OEM_5: true,
|
||||
VKEY_OEM_6: true,
|
||||
VKEY_OEM_7: true,
|
||||
VKEY_OEM_8: true,
|
||||
VKEY_OEM_102: true,
|
||||
};
|
||||
|
||||
let remaps:string[] = [];
|
||||
|
|
|
@ -11,7 +11,7 @@ import {BaseLifecycleService} from 'vs/platform/lifecycle/common/baseLifecycleSe
|
|||
import {IWindowService} from 'vs/workbench/services/window/electron-browser/windowService';
|
||||
import severity from 'vs/base/common/severity';
|
||||
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc} from 'electron';
|
||||
|
||||
export class LifecycleService extends BaseLifecycleService {
|
||||
|
||||
|
@ -28,7 +28,7 @@ export class LifecycleService extends BaseLifecycleService {
|
|||
let windowId = this.windowService.getWindowId();
|
||||
|
||||
// Main side indicates that window is about to unload, check for vetos
|
||||
ipc.on('vscode:beforeUnload', (reply: { okChannel: string, cancelChannel: string }) => {
|
||||
ipc.on('vscode:beforeUnload', (event, reply: { okChannel: string, cancelChannel: string }) => {
|
||||
let veto = this.beforeUnload();
|
||||
|
||||
if (typeof veto === 'boolean') {
|
||||
|
|
|
@ -14,8 +14,6 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
|||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
import remote = require('remote');
|
||||
|
||||
export class MessageService extends WorkbenchMessageService {
|
||||
|
||||
constructor(
|
||||
|
@ -36,7 +34,7 @@ export class MessageService extends WorkbenchMessageService {
|
|||
confirmation.secondaryButton = nls.localize('cancelButton', "Cancel");
|
||||
}
|
||||
|
||||
let opts: remote.IMessageBoxOptions = {
|
||||
let opts: Electron.Dialog.ShowMessageBoxOptions = {
|
||||
title: confirmation.title || this.contextService.getConfiguration().env.appName,
|
||||
message: confirmation.message,
|
||||
buttons: [
|
||||
|
|
|
@ -21,7 +21,7 @@ import {IWindowService} from 'vs/workbench/services/window/electron-browser/wind
|
|||
import ports = require('vs/base/node/ports');
|
||||
|
||||
import cp = require('child_process');
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc} from 'electron';
|
||||
|
||||
export const PLUGIN_LOG_BROADCAST_CHANNEL = 'vscode:pluginLog';
|
||||
export const PLUGIN_ATTACH_BROADCAST_CHANNEL = 'vscode:pluginAttach';
|
||||
|
|
|
@ -9,8 +9,7 @@ import {ElectronWindow} from 'vs/workbench/electron-browser/window';
|
|||
import {createDecorator, ServiceIdentifier} from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event, {Emitter} from 'vs/base/common/event';
|
||||
|
||||
import remote = require('remote');
|
||||
import ipc = require('ipc');
|
||||
import {ipcRenderer as ipc, remote} from 'electron';
|
||||
|
||||
export var IWindowService = createDecorator<IWindowService>('windowService');
|
||||
|
||||
|
@ -50,7 +49,7 @@ export class WindowService implements IWindowService {
|
|||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
ipc.on('vscode:broadcast', (b: IBroadcast) => {
|
||||
ipc.on('vscode:broadcast', (event, b: IBroadcast) => {
|
||||
this._onBroadcast.fire(b);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue