setMouse improvements. do not allow fg changes on selected items. do not bubble render events.
This commit is contained in:
parent
8efe06e8f4
commit
7a8a0d2591
|
@ -2694,23 +2694,26 @@ Program.prototype.normalBuffer = function() {
|
||||||
Program.prototype.enableMouse = function() {
|
Program.prototype.enableMouse = function() {
|
||||||
if (this.term('rxvt-unicode')) {
|
if (this.term('rxvt-unicode')) {
|
||||||
return this.setMouse({
|
return this.setMouse({
|
||||||
allMotion: true,
|
urxvtMouse: true,
|
||||||
urxvtMouse: true
|
allMotion: true
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.term('linux')) {
|
||||||
|
return this.setMouse({
|
||||||
|
vt200Mouse: true
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.term('xterm')
|
if (this.term('xterm')
|
||||||
|| this.term('screen')
|
|| this.term('screen')
|
||||||
|| this.term('rxvt-unicode')) {
|
|| (this.tput && this.tput.strings.key_mouse)) {
|
||||||
return this.setMouse({
|
return this.setMouse({
|
||||||
allMotion: true,
|
vt200Mouse: true,
|
||||||
utfMouse: true
|
utfMouse: true,
|
||||||
|
allMotion: true
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.term('vt')) {
|
|
||||||
return this.setMouse({ vt200Mouse: true }, true);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Program.prototype.disableMouse = function() {
|
Program.prototype.disableMouse = function() {
|
||||||
|
@ -2728,10 +2731,14 @@ Program.prototype.disableMouse = function() {
|
||||||
// Set Mouse
|
// Set Mouse
|
||||||
Program.prototype.setMouse = function(opt, enable) {
|
Program.prototype.setMouse = function(opt, enable) {
|
||||||
if (opt.normalMouse != null) {
|
if (opt.normalMouse != null) {
|
||||||
opt.cellMotion = opt.normalMouse;
|
opt.vt200Mouse = opt.normalMouse;
|
||||||
opt.allMotion = opt.normalMouse;
|
opt.allMotion = opt.normalMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt.hiliteTracking != null) {
|
||||||
|
opt.vt200Hilite = opt.hiliteTracking;
|
||||||
|
}
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
this._currentMouse = opt;
|
this._currentMouse = opt;
|
||||||
this.mouseEnabled = true;
|
this.mouseEnabled = true;
|
||||||
|
@ -2768,8 +2775,8 @@ Program.prototype.setMouse = function(opt, enable) {
|
||||||
|
|
||||||
// Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.
|
// Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.
|
||||||
// Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
|
// Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
|
||||||
if (opt.hiliteTracking != null) {
|
if (opt.vt200Hilite != null) {
|
||||||
if (opt.hiliteTracking) this.setMode('?1001');
|
if (opt.vt200Hilite) this.setMode('?1001');
|
||||||
else this.resetMode('?1001');
|
else this.resetMode('?1001');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1301,6 +1301,11 @@ Screen.prototype.attrCode = function(code, cur, def) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore foreground changes for selected items.
|
||||||
|
// if (el && el.parent._isList && el.parent.items[el.parent.selected] === el) {
|
||||||
|
// fg = (def >> 9) & 0x1ff;
|
||||||
|
// }
|
||||||
|
|
||||||
return (flags << 18) | (fg << 9) | bg;
|
return (flags << 18) | (fg << 9) | bg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2971,7 +2976,7 @@ Element.prototype._getCoords = function(get) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Element.prototype.render = function() {
|
Element.prototype.render = function() {
|
||||||
this.emit('prerender');
|
this._emit('prerender');
|
||||||
|
|
||||||
this.parseContent();
|
this.parseContent();
|
||||||
|
|
||||||
|
@ -3058,6 +3063,11 @@ Element.prototype.render = function() {
|
||||||
if (c = /^\x1b\[[\d;]*m/.exec(content.substring(ci - 1))) {
|
if (c = /^\x1b\[[\d;]*m/.exec(content.substring(ci - 1))) {
|
||||||
ci += c[0].length - 1;
|
ci += c[0].length - 1;
|
||||||
attr = this.screen.attrCode(c[0], attr, dattr);
|
attr = this.screen.attrCode(c[0], attr, dattr);
|
||||||
|
// Ignore foreground changes for selected items.
|
||||||
|
if (this.parent._isList
|
||||||
|
&& this.parent.items[this.parent.selected] === this) {
|
||||||
|
attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9));
|
||||||
|
}
|
||||||
ch = content[ci] || ' ';
|
ch = content[ci] || ' ';
|
||||||
ci++;
|
ci++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3222,7 +3232,7 @@ Element.prototype.render = function() {
|
||||||
el.render();
|
el.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.emit('render', coords);
|
this._emit('render', [coords]);
|
||||||
|
|
||||||
return coords;
|
return coords;
|
||||||
};
|
};
|
||||||
|
@ -3620,7 +3630,7 @@ ScrollableBox.prototype._scrollBottom = function() {
|
||||||
|
|
||||||
// We could just calculate the children, but we can
|
// We could just calculate the children, but we can
|
||||||
// optimize for lists by just returning the items.length.
|
// optimize for lists by just returning the items.length.
|
||||||
if (this.type === 'list') {
|
if (this._isList) {
|
||||||
return this.items ? this.items.length : 0;
|
return this.items ? this.items.length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3797,6 +3807,7 @@ function List(options) {
|
||||||
this.items = [];
|
this.items = [];
|
||||||
this.ritems = [];
|
this.ritems = [];
|
||||||
this.selected = 0;
|
this.selected = 0;
|
||||||
|
this._isList = true;
|
||||||
|
|
||||||
if (!this.style.selected) {
|
if (!this.style.selected) {
|
||||||
this.style.selected = {};
|
this.style.selected = {};
|
||||||
|
|
Loading…
Reference in New Issue