]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/ansi/examples/cursorPosition.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / ansi / examples / cursorPosition.js
1 #!/usr/bin/env node
2
3 var tty = require('tty')
4 var cursor = require('../')(process.stdout)
5
6 // listen for the queryPosition report on stdin
7 process.stdin.resume()
8 raw(true)
9
10 process.stdin.once('data', function (b) {
11   var match = /\[(\d+)\;(\d+)R$/.exec(b.toString())
12   if (match) {
13     var xy = match.slice(1, 3).reverse().map(Number)
14     console.error(xy)
15   }
16
17   // cleanup and close stdin
18   raw(false)
19   process.stdin.pause()
20 })
21
22
23 // send the query position request code to stdout
24 cursor.queryPosition()
25
26 function raw (mode) {
27   if (process.stdin.setRawMode) {
28     process.stdin.setRawMode(mode)
29   } else {
30     tty.setRawMode(mode)
31   }
32 }