get-cursor-position
Advanced tools
Comparing version 0.0.2 to 0.0.4
43
index.js
@@ -1,39 +0,9 @@ | ||
var deasync = require('deasync'); | ||
var tty = require('tty'); | ||
var code = '\x1b[6n'; | ||
var tty = require('tty'); | ||
var pos = require('./bin/pos'); | ||
var code = '\x1b[6n'; | ||
module.exports = { | ||
sync : function () { | ||
var sync = true; | ||
var position = null; | ||
// start listening | ||
process.stdin.resume(); | ||
raw(true); | ||
sync: pos.sync, | ||
process.stdin.once('data', function (b) { | ||
var match = /\[(\d+)\;(\d+)R$/.exec(b.toString()); | ||
if (match) { | ||
sync = false; | ||
position = match.slice(1, 3).reverse().map(Number); | ||
} | ||
// cleanup and close stdin | ||
raw(false); | ||
process.stdin.pause(); | ||
}); | ||
process.stdout.write(code); | ||
process.stdout.emit('data', code); | ||
while (sync) { | ||
deasync.sleep(1); | ||
} | ||
return { | ||
row: position[1], | ||
col: position[0] | ||
}; | ||
}, | ||
async: function (callback, context) { | ||
@@ -50,3 +20,6 @@ | ||
callback && callback.call(context, position[1], position[0]); | ||
callback && callback.call(context, { | ||
row: position[1], | ||
col: position[0] | ||
}); | ||
} | ||
@@ -53,0 +26,0 @@ |
{ | ||
"name": "get-cursor-position", | ||
"version": "0.0.2", | ||
"version": "0.0.4", | ||
"description": "Get the cursor's current position in your terminal.", | ||
@@ -27,5 +27,3 @@ "main": "index.js", | ||
"homepage": "https://github.com/bubkoo/get-cursor-position", | ||
"dependencies": { | ||
"deasync": "^0.1.4" | ||
} | ||
"dependencies": {} | ||
} |
@@ -24,5 +24,5 @@ # get-cursor-position | ||
getCursorPosition.async(function(row, col) { | ||
console.log('row: ' + row); | ||
console.log('col: ' + col); | ||
getCursorPosition.async(function(pos) { | ||
console.log('row: ' + pos.row); | ||
console.log('col: ' + pos.col); | ||
}); | ||
@@ -29,0 +29,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19386
0
7
33
2
- Removeddeasync@^0.1.4
- Removedbindings@1.5.0(transitive)
- Removeddeasync@0.1.30(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removednode-addon-api@1.7.2(transitive)