2015-02-04 05:20:41 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2013-07-14 13:06:47 +00:00
|
|
|
var blessed = require('../')
|
2015-02-01 17:21:07 +00:00
|
|
|
, util = require('util')
|
2013-07-28 19:29:07 +00:00
|
|
|
, program;
|
|
|
|
|
|
|
|
program = blessed.program({
|
|
|
|
dump: __dirname + '/logs/mouse.log'
|
|
|
|
});
|
2013-07-14 13:06:47 +00:00
|
|
|
|
|
|
|
// program.setMouse({
|
|
|
|
// allMotion: true,
|
|
|
|
// //utfMouse: true
|
|
|
|
// urxvtMouse: true
|
|
|
|
// }, true);
|
|
|
|
|
|
|
|
program.alternateBuffer();
|
|
|
|
program.enableMouse();
|
|
|
|
program.hideCursor();
|
|
|
|
|
2015-07-04 10:30:26 +00:00
|
|
|
program.setMouse({ sendFocus: true }, true);
|
|
|
|
//program._currentMouse.sendFocus = true;
|
|
|
|
//program.enableMouse(program._currentMouse);
|
|
|
|
//program.write('\x1b[?1004h');
|
|
|
|
|
2013-07-14 13:06:47 +00:00
|
|
|
program.on('mouse', function(data) {
|
|
|
|
program.cup(data.y, data.x);
|
|
|
|
program.write(' ', 'blue bg');
|
|
|
|
program.cup(0, 0);
|
2015-02-01 17:21:07 +00:00
|
|
|
program.write(util.inspect(data));
|
2013-07-14 13:06:47 +00:00
|
|
|
});
|
|
|
|
|
2015-07-04 10:30:26 +00:00
|
|
|
program.on('resize', function(data) {
|
|
|
|
setTimeout(function() {
|
|
|
|
program.clear();
|
|
|
|
program.cup(0, 0);
|
|
|
|
program.write(util.inspect({ cols: program.cols, rows: program.rows }));
|
|
|
|
}, 200);
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('SIGWINCH', function(data) {
|
|
|
|
setTimeout(function() {
|
|
|
|
program.cup(1, 0);
|
|
|
|
program.write(util.inspect({ winch: true, cols: program.cols, rows: program.rows }));
|
|
|
|
}, 200);
|
|
|
|
});
|
|
|
|
|
|
|
|
program.on('focus', function(data) {
|
|
|
|
program.clear();
|
|
|
|
program.cup(0, 0);
|
|
|
|
program.write('FOCUSIN');
|
|
|
|
});
|
|
|
|
|
|
|
|
program.on('blur', function(data) {
|
|
|
|
program.clear();
|
|
|
|
program.cup(0, 0);
|
|
|
|
program.write('FOCUSOUT');
|
|
|
|
});
|
|
|
|
|
2013-07-14 13:06:47 +00:00
|
|
|
program.key(['q', 'escape', 'C-c'], function() {
|
|
|
|
program.showCursor();
|
|
|
|
program.disableMouse();
|
|
|
|
program.normalBuffer();
|
|
|
|
process.exit(0);
|
|
|
|
});
|
2013-08-13 16:18:31 +00:00
|
|
|
|
|
|
|
program.on('keypress', function(ch, data) {
|
2013-08-13 16:30:44 +00:00
|
|
|
if (data.name === 'mouse') return;
|
2013-08-13 16:18:31 +00:00
|
|
|
program.clear();
|
2015-01-31 09:51:12 +00:00
|
|
|
program.cup(0, 0);
|
2015-02-01 17:21:07 +00:00
|
|
|
program.write(util.inspect(data));
|
2013-08-13 16:18:31 +00:00
|
|
|
});
|
2015-01-31 20:57:21 +00:00
|
|
|
|
|
|
|
// program.getCursor(function(err, data) {
|
2015-02-01 17:21:07 +00:00
|
|
|
// program.write(util.inspect(data));
|
2015-01-31 20:57:21 +00:00
|
|
|
// });
|
2015-03-14 23:14:39 +00:00
|
|
|
|
|
|
|
// program.manipulateWindow(18, function(err, data) {
|
|
|
|
// program.write(util.inspect(data));
|
|
|
|
// });
|