mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-10 19:16:20 +00:00
major reimplementation of sgr and urxvt mouse. mousewheel not yet tested.
This commit is contained in:
parent
1d67e23993
commit
89b2dfc373
@ -480,13 +480,6 @@ Program.prototype._bindMouse = function(s, buf) {
|
||||
: 'unknown';
|
||||
}
|
||||
|
||||
// It's a movement
|
||||
// Wrong
|
||||
//if (b > 32 && b < 64) {
|
||||
// delete key.button;
|
||||
// key.action = 'mousemove';
|
||||
//}
|
||||
|
||||
// Probably a movement.
|
||||
if (key.action === 'mousedown' && key.button === 'unknown') {
|
||||
delete key.button;
|
||||
@ -514,25 +507,20 @@ Program.prototype._bindMouse = function(s, buf) {
|
||||
|
||||
if (this.zero) key.x--, key.y--;
|
||||
|
||||
// NOTE: Duplicate of the above.
|
||||
mod = b >> 3;
|
||||
key.shift = mod & 4;
|
||||
key.meta = mod & 8;
|
||||
key.ctrl = mod & 16;
|
||||
mod = b >> 2;
|
||||
key.shift = !!(mod & 1);
|
||||
key.meta = !!((mod >> 1) & 1);
|
||||
key.ctrl = !!((mod >> 2) & 1);
|
||||
|
||||
b -= 32;
|
||||
|
||||
if (b === 64) {
|
||||
key.action = 'wheelup';
|
||||
if ((b >> 6) & 1) {
|
||||
key.action = b & 1 ? 'wheeldown' : 'wheelup';
|
||||
key.button = 'middle';
|
||||
} else if (b === 65) {
|
||||
key.action = 'wheeldown';
|
||||
key.button = 'middle';
|
||||
} else if (b === 3) {
|
||||
// Could also be a movement.
|
||||
key.action = 'mouseup';
|
||||
key.button = 'unknown';
|
||||
// } else if (b === 3) {
|
||||
// // Could also be a movement.
|
||||
// key.action = 'mouseup';
|
||||
// key.button = 'unknown';
|
||||
} else {
|
||||
// XXX Normally here:
|
||||
key.action = 'mousedown';
|
||||
key.button =
|
||||
b === 0 ? 'left'
|
||||
@ -541,13 +529,6 @@ Program.prototype._bindMouse = function(s, buf) {
|
||||
: 'unknown';
|
||||
}
|
||||
|
||||
// It's a movement
|
||||
// Wrong
|
||||
//if (b > 32 && b < 64) {
|
||||
// delete key.button;
|
||||
// key.action = 'movement';
|
||||
//}
|
||||
|
||||
// Probably a movement.
|
||||
if (key.action === 'mousedown' && key.button === 'unknown') {
|
||||
delete key.button;
|
||||
@ -576,19 +557,35 @@ Program.prototype._bindMouse = function(s, buf) {
|
||||
|
||||
if (this.zero) key.x--, key.y--;
|
||||
|
||||
b &= 3;
|
||||
mod = b >> 2;
|
||||
key.shift = !!(mod & 1);
|
||||
key.meta = !!((mod >> 1) & 1);
|
||||
key.ctrl = !!((mod >> 2) & 1);
|
||||
|
||||
// NOTE: Get mod. And wheel.
|
||||
if ((b >> 6) & 1) {
|
||||
key.action = b & 1 ? 'wheeldown' : 'wheelup';
|
||||
key.button = 'middle';
|
||||
// } else if (b === 3) {
|
||||
// // Could also be a movement.
|
||||
// key.action = 'mouseup';
|
||||
// key.button = 'unknown';
|
||||
} else {
|
||||
// XXX Normally here:
|
||||
key.action = down
|
||||
? 'mousedown'
|
||||
: 'mouseup';
|
||||
key.button =
|
||||
b === 0 ? 'left'
|
||||
: b === 1 ? 'middle'
|
||||
: b === 2 ? 'right'
|
||||
: 'unknown';
|
||||
}
|
||||
|
||||
key.action = down
|
||||
? 'mousedown'
|
||||
: 'mouseup';
|
||||
|
||||
key.button =
|
||||
b === 0 ? 'left'
|
||||
: b === 1 ? 'middle'
|
||||
: b === 2 ? 'right'
|
||||
: 'unknown';
|
||||
// Probably a movement.
|
||||
if (key.action === 'mousedown' && key.button === 'unknown') {
|
||||
delete key.button;
|
||||
key.action = 'mousemove';
|
||||
}
|
||||
|
||||
self.emit('keypress', null, key);
|
||||
self.emit('mouse', key);
|
||||
@ -2875,6 +2872,8 @@ Program.prototype.enableMouse = function() {
|
||||
// X10 UTF extension, later versions do support SGR however
|
||||
if (this.isVTE) {
|
||||
return this.setMouse({
|
||||
// XXX May be better to use URXVT mouse here since
|
||||
// it was originally better implemented?
|
||||
sgrMouse: true,
|
||||
allMotion: true
|
||||
}, true);
|
||||
|
2
test/program-mouse.js
Normal file → Executable file
2
test/program-mouse.js
Normal file → Executable file
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var blessed = require('../')
|
||||
, util = require('util')
|
||||
, program;
|
||||
|
Loading…
x
Reference in New Issue
Block a user