Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

cursorPosition.js 640B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env node
  2. var tty = require('tty')
  3. var cursor = require('../')(process.stdout)
  4. // listen for the queryPosition report on stdin
  5. process.stdin.resume()
  6. raw(true)
  7. process.stdin.once('data', function (b) {
  8. var match = /\[(\d+)\;(\d+)R$/.exec(b.toString())
  9. if (match) {
  10. var xy = match.slice(1, 3).reverse().map(Number)
  11. console.error(xy)
  12. }
  13. // cleanup and close stdin
  14. raw(false)
  15. process.stdin.pause()
  16. })
  17. // send the query position request code to stdout
  18. cursor.queryPosition()
  19. function raw (mode) {
  20. if (process.stdin.setRawMode) {
  21. process.stdin.setRawMode(mode)
  22. } else {
  23. tty.setRawMode(mode)
  24. }
  25. }