-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of simple clipboard API, #217
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/vs/workbench/api/electron-browser/mainThreadClipboard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { clipboard } from 'electron'; | ||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; | ||
import { MainContext, MainThreadClipboardShape } from '../node/extHost.protocol'; | ||
|
||
@extHostNamedCustomer(MainContext.MainThreadClipboard) | ||
export class MainThreadCommands implements MainThreadClipboardShape { | ||
|
||
dispose(): void { | ||
// nothing | ||
} | ||
|
||
$readText(): Promise<string> { | ||
return Promise.resolve(clipboard.readText()); | ||
} | ||
|
||
$writeText(value: string): Promise<void> { | ||
clipboard.writeText(value); | ||
return undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { IMainContext, MainContext, MainThreadClipboardShape } from 'vs/workbench/api/node/extHost.protocol'; | ||
import * as vscode from 'vscode'; | ||
|
||
export class ExtHostClipboard implements vscode.Clipboard { | ||
|
||
private readonly _proxy: MainThreadClipboardShape; | ||
|
||
constructor(mainContext: IMainContext) { | ||
this._proxy = mainContext.getProxy(MainContext.MainThreadClipboard); | ||
} | ||
|
||
readText(): Promise<string> { | ||
return this._proxy.$readText(); | ||
} | ||
|
||
writeText(value: string): Promise<void> { | ||
return this._proxy.$writeText(value); | ||
} | ||
} |