setMouse improvements. do not allow fg changes on selected items. do not bubble render events.

This commit is contained in:
Christopher Jeffrey 2013-08-02 05:57:58 -05:00
parent 8efe06e8f4
commit 7a8a0d2591
2 changed files with 33 additions and 15 deletions

View File

@ -2694,23 +2694,26 @@ Program.prototype.normalBuffer = function() {
Program.prototype.enableMouse = function() {
if (this.term('rxvt-unicode')) {
return this.setMouse({
allMotion: true,
urxvtMouse: true
urxvtMouse: true,
allMotion: true
}, true);
}
if (this.term('linux')) {
return this.setMouse({
vt200Mouse: true
}, true);
}
if (this.term('xterm')
|| this.term('screen')
|| this.term('rxvt-unicode')) {
|| (this.tput && this.tput.strings.key_mouse)) {
return this.setMouse({
allMotion: true,
utfMouse: true
vt200Mouse: true,
utfMouse: true,
allMotion: true
}, true);
}
if (this.term('vt')) {
return this.setMouse({ vt200Mouse: true }, true);
}
};
Program.prototype.disableMouse = function() {
@ -2728,10 +2731,14 @@ Program.prototype.disableMouse = function() {
// Set Mouse
Program.prototype.setMouse = function(opt, enable) {
if (opt.normalMouse != null) {
opt.cellMotion = opt.normalMouse;
opt.vt200Mouse = opt.normalMouse;
opt.allMotion = opt.normalMouse;
}
if (opt.hiliteTracking != null) {
opt.vt200Hilite = opt.hiliteTracking;
}
if (enable) {
this._currentMouse = opt;
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 -> Don't use Hilite Mouse Tracking.
if (opt.hiliteTracking != null) {
if (opt.hiliteTracking) this.setMode('?1001');
if (opt.vt200Hilite != null) {
if (opt.vt200Hilite) this.setMode('?1001');
else this.resetMode('?1001');
}

View File

@ -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;
};
@ -2971,7 +2976,7 @@ Element.prototype._getCoords = function(get) {
};
Element.prototype.render = function() {
this.emit('prerender');
this._emit('prerender');
this.parseContent();
@ -3058,6 +3063,11 @@ Element.prototype.render = function() {
if (c = /^\x1b\[[\d;]*m/.exec(content.substring(ci - 1))) {
ci += c[0].length - 1;
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] || ' ';
ci++;
} else {
@ -3222,7 +3232,7 @@ Element.prototype.render = function() {
el.render();
});
this.emit('render', coords);
this._emit('render', [coords]);
return coords;
};
@ -3620,7 +3630,7 @@ ScrollableBox.prototype._scrollBottom = function() {
// We could just calculate the children, but we can
// optimize for lists by just returning the items.length.
if (this.type === 'list') {
if (this._isList) {
return this.items ? this.items.length : 0;
}
@ -3797,6 +3807,7 @@ function List(options) {
this.items = [];
this.ritems = [];
this.selected = 0;
this._isList = true;
if (!this.style.selected) {
this.style.selected = {};