From 66dc2118e7cc176e7c6de17783b13f8ea3cb204e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 10 Aug 2013 09:49:39 -0500 Subject: [PATCH] add fastCSR option. --- README.md | 3 +++ lib/widget.js | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b14e1d..7c3abd2 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,9 @@ The screen on which every other node renders. (not just full-width ones, elements with uniform cells to their sides). this is known to cause flickering with elements that are not full-width, however, it is more optimal for terminal rendering. +- **fastCSR** - do CSR on any element within 20 cols of the screen edge on + either side. faster than smartCSR, but may cause flickering depending on + what is on each side of the element. - **useBCE** - attempt to perform `back_color_erase` optimizations for terminals that support it. it will also work with terminals that don't support it, but only on lines with the default background color. as it stands with the current diff --git a/lib/widget.js b/lib/widget.js index da0ac1a..3e017a1 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -769,6 +769,14 @@ Screen.prototype.cleanSides = function(el) { return pos._cleanSides = true; } + if (this.options.fastCSR) { + // Maybe just do this instead of parsing. + if (this.width - (pos.xl - pos.xi) < 40) { + return pos._cleanSides = true; + } + return pos._cleanSides = false; + } + if (!this.options.smartCSR) { return false; } @@ -777,7 +785,7 @@ Screen.prototype.cleanSides = function(el) { // chance that the scrollbar may get moved around senselessly. // NOTE: In pratice, this doesn't seem to be the case. // if (this.scrollbar) { - // return false; + // return pos._cleanSides = false; // } // Doesn't matter if we're only a height of 1.