From d9ca7112bc2a7db432a914a6a09edf75f07c4a1d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 27 Jul 2013 06:58:50 -0500 Subject: [PATCH] scrollbar track. --- lib/widget.js | 26 +++++++++++++++++++++++++- test/widget.js | 7 ++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index 3de83ad..013ff56 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -918,7 +918,7 @@ Screen.prototype.draw = function(start, end) { // : '\x1b[' + (xx - x) + 'C'; // this.fillRegion(data, ' ', // x, this.tput && this.tput.strings.erase_chars ? xx : this.cols, - // y, y); + // y, y + 1); // x = xx - 1; // continue; // } @@ -2842,6 +2842,7 @@ Element.prototype.render = function() { } // Draw the scrollbar. + // Could possibly draw this after all child elements. if (this.scrollbar) { i = Math.max(this._clines.length, this._scrollBottom()); } @@ -2858,6 +2859,13 @@ Element.prototype.render = function() { if (y >= yl) y = yl - 1; cell = lines[y] && lines[y][x]; if (cell) { + if (this.track) { + ch = this.track.ch || ' '; + attr = this.sattr(this.style.track, + this.style.track.fg || this.style.fg, + this.style.track.bg || this.style.bg); + this.screen.fillRegion(attr, ch, x, x + 1, yi, yl); + } ch = this.scrollbar.ch || ' '; attr = this.sattr(this.style.scrollbar, this.style.scrollbar.fg || this.style.fg, @@ -3256,6 +3264,22 @@ function ScrollableBox(options) { this.style.scrollbar.invisible = this.scrollbar.invisible; } this.scrollbar.style = this.style.scrollbar; + if (this.track || this.scrollbar.track) { + this.track = this.scrollbar.track || this.track; + this.style.track = this.style.scrollbar.track || this.style.track; + this.track.ch = this.track.ch || ' '; + this.style.track = this.style.track || this.track.style; + if (!this.style.track) { + this.style.track = {}; + this.style.track.fg = this.track.fg; + this.style.track.bg = this.track.bg; + this.style.track.bold = this.track.bold; + this.style.track.underline = this.track.underline; + this.style.track.inverse = this.track.inverse; + this.style.track.invisible = this.track.invisible; + } + this.track.style = this.style.track; + } } if (options.mouse) { diff --git a/test/widget.js b/test/widget.js index 26e56f4..6a9aa87 100644 --- a/test/widget.js +++ b/test/widget.js @@ -82,7 +82,12 @@ var list = blessed.list({ ], scrollbar: { ch: ' ', - inverse: true + track: { + bg: 'yellow' + }, + style: { + inverse: true + } } });