diff --git a/.gitignore b/.gitignore index 8a85a5a8..2cdc1abe 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ _templates _static + # gitignore / Node.gitignore # ############################## lib-cov @@ -35,6 +36,7 @@ build .grunt sample/__issue.js package-lock.json +yarn.lock node_modules diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..037d814c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "test.file", + "runtimeArgs": [ + "--inspect-brk", + "--trace-warnings", + "${relativeFile}", + ], + "port": 9229, + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen" + } + ] +} \ No newline at end of file diff --git a/lib/extClipboard.js b/lib/extClipboard.js index 6aafb3a2..f1e9689c 100644 --- a/lib/extClipboard.js +++ b/lib/extClipboard.js @@ -29,7 +29,7 @@ const Promise = require( 'seventh' ) ; -const string = require( 'string-kit' ) ; +const clipboardy = require('clipboardy'); require( './patches.js' ) ; const execAsync = require( 'child_process' ).execAsync ; @@ -45,37 +45,12 @@ const XCLIP_SELECTION_ARG = { } ; +exports.getClipboard = () => { + return new Promise.resolve(clipboardy.readSync()) +} -if ( process.platform === 'linux' ) { - exports.getClipboard = async ( source ) => { - var arg = XCLIP_SELECTION_ARG[ source[ 0 ] ] || 'clipboard' ; - return await execFileAsync( 'xclip' , [ '-o' , '-selection' , arg ] ) ; - } ; - - exports.setClipboard = async ( str , source ) => { - var promise = new Promise() ; - var arg = XCLIP_SELECTION_ARG[ source[ 0 ] ] || 'clipboard' ; - var xclip = spawn( 'xclip' , [ '-i' , '-selection' , arg ] ) ; - - xclip.on( 'error' , error => { - //console.error( 'xclip error:' , error ) ; - promise.reject( error ) ; - } ) ; - - xclip.on( 'exit' , code => { - //console.log( 'xclip exited with code:' , code ) ; - if ( code !== 0 ) { promise.reject( code ) ; } - else { promise.resolve() ; } - } ) ; - - // Send the string to push to the clipboard - xclip.stdin.end( str ) ; +exports.setClipboard = (data) => { + return new Promise.resolve(clipboardy.writeSync(data)) +} - return promise ; - } ; -} -else { - exports.getClipboard = () => Promise.reject( new Error( 'No clipboard manipulation program found' ) ) ; - exports.setClipboard = () => Promise.reject( new Error( 'No clipboard manipulation program found' ) ) ; -} diff --git a/package.json b/package.json index beabd106..e5fb9d69 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "@cronvel/get-pixels": "^3.4.0", "chroma-js": "^2.1.0", + "clipboardy": "^2.3.0", "lazyness": "^1.2.0", "ndarray": "^1.0.19", "nextgen-events": "^1.3.0",