mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 13:03:42 +01:00
screenshot support
This commit is contained in:
@@ -20,6 +20,7 @@ import { Emitter, toPromise } from 'vs/base/common/event';
|
||||
// TODO@joao: bad layering!
|
||||
import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO';
|
||||
import { ScanCodeBinding } from 'vs/workbench/services/keybinding/common/scanCode';
|
||||
import { NativeImage } from 'electron';
|
||||
|
||||
class WindowRouter implements IClientRouter {
|
||||
|
||||
@@ -63,6 +64,17 @@ export class Driver implements IDriver, IWindowDriverRegistry {
|
||||
.filter(id => this.registeredWindowIds.has(id) && !this.reloadingWindowIds.has(id));
|
||||
}
|
||||
|
||||
async capturePage(windowId: number): TPromise<string> {
|
||||
await this.whenUnfrozen(windowId);
|
||||
|
||||
const window = this.windowsService.getWindowById(windowId);
|
||||
const webContents = window.win.webContents;
|
||||
const image = await new Promise<NativeImage>(c => webContents.capturePage(c));
|
||||
const buffer = image.toPNG();
|
||||
|
||||
return buffer.toString('base64');
|
||||
}
|
||||
|
||||
async reloadWindow(windowId: number): TPromise<void> {
|
||||
await this.whenUnfrozen(windowId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user