mouse changes.

This commit is contained in:
Christopher Jeffrey
2013-08-10 14:40:32 -05:00
parent 86922c7c8b
commit 49d3a20f3c
+16 -10
View File
@@ -805,24 +805,26 @@ Terminal.prototype.bindMouse = function() {
// should probably check offsetParent
// but this is more portable
while (el !== self.document.documentElement) {
while (el && el !== self.document.documentElement) {
x -= el.offsetLeft;
y -= el.offsetTop;
el = el.parentNode;
el = 'offsetParent' in el
? el.offsetParent
: el.parentNode;
}
// convert to cols/rows
w = self.element.clientWidth;
h = self.element.clientHeight;
x = ((x / w) * self.cols) | 0;
y = ((y / h) * self.rows) | 0;
x = Math.round((x / w) * self.cols);
y = Math.round((y / h) * self.rows);
// be sure to avoid sending
// bad positions to the program
if (x < 0) x = 0;
if (x > self.cols) x = self.cols;
if (x >= self.cols) x = self.cols - 1;
if (y < 0) y = 0;
if (y > self.rows) y = self.rows;
if (y >= self.rows) y = self.rows - 1;
// xterm sends raw bytes and
// starts at 32 (SP) for each.
@@ -832,10 +834,9 @@ Terminal.prototype.bindMouse = function() {
return {
x: x,
y: y,
down: ev.type === 'mousedown',
up: ev.type === 'mouseup',
wheel: ev.type === wheelEvent,
move: ev.type === 'mousemove'
type: ev.type === wheelEvent
? 'mousewheel'
: ev.type
};
}
@@ -849,6 +850,7 @@ Terminal.prototype.bindMouse = function() {
self.focus();
// fix for odd bug
//if (self.vt200Mouse && !self.normalMouse) {
if (self.vt200Mouse) {
sendButton({ __proto__: ev, type: 'mouseup' });
return cancel(ev);
@@ -870,6 +872,10 @@ Terminal.prototype.bindMouse = function() {
return cancel(ev);
});
//if (self.normalMouse) {
// on(self.document, 'mousemove', sendMove);
//}
on(el, wheelEvent, function(ev) {
if (!self.mouseEvents) return;
if (self.x10Mouse