diff --git a/js/term/ttyrawtest.js b/js/term/ttyrawtest.js new file mode 100644 index 0000000..338eb93 --- /dev/null +++ b/js/term/ttyrawtest.js @@ -0,0 +1,71 @@ +// Test TTY raw mode with xterm-vt100 escape sequences +var util=require('util'); +function exec(cmds) { + var top=cmds.shift(); + if (top==undefined) return; + if (top.write) { + process.stdout.write(top.write); + return exec(cmds); + } + if (top.sleep) setTimeout(function () {exec(cmds)},top.sleep); + if (top.exit) { + process.stdout.write('\x1b[?1000l'); // disable mouse tracking + console.log('DONE'); + process.stdin.setRawMode(false); + process.exit(); + } +} +process.stdout.write('hello world\n'); +console.log(process.stdout.columns+' * '+process.stdout.rows); +console.log('Setting raw mode ..') +process.stdin.setRawMode(true); +console.log('Installing event listener .. ') +process.stdin.on('keypress',function (ch,key) { + console.log('X: '+ch+' <'+key+'>'); +}); +if (process.argv.indexOf('event')!=-1) + process.stdin.on('data',function (ch) { + var key={}; + console.log('DATA: <'+ch.length+'>'); + for(var i=0;i