From 7679475bfe0452446bb8eadaaa09dbe7e7d65b88 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 13 Jan 2017 21:31:31 -0800 Subject: [PATCH 1/3] Apply cursorBlink via setOption Fixes #478 --- demo/main.js | 4 +++- src/xterm.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/demo/main.js b/demo/main.js index 86fbd3148..7425c0511 100644 --- a/demo/main.js +++ b/demo/main.js @@ -27,7 +27,9 @@ function setTerminalSize () { colsElement.addEventListener('change', setTerminalSize); rowsElement.addEventListener('change', setTerminalSize); -optionElements.cursorBlink.addEventListener('change', createTerminal); +optionElements.cursorBlink.addEventListener('change', function () { + term.setOption('cursorBlink', optionElements.cursorBlink.checked); +}); createTerminal(); diff --git a/src/xterm.js b/src/xterm.js index b6c659c30..482d69a15 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -407,6 +407,9 @@ Terminal.prototype.setOption = function(key, value) { } this[key] = value; this.options[key] = value; + switch (key) { + case 'cursorBlink': this.refresh(this.y, this.y); break; + } }; /** From d1dac57f7af5017b4b96696dc8722480fac2905e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 14 Jan 2017 21:26:49 -0800 Subject: [PATCH 2/3] Move cursor blink style to class on .terminal --- src/xterm.css | 6 +++--- src/xterm.js | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/xterm.css b/src/xterm.css index 3f4f4bbe0..4ef61fdfe 100644 --- a/src/xterm.css +++ b/src/xterm.css @@ -82,11 +82,11 @@ background-color: transparent; } -.terminal.focus .terminal-cursor.blinking { - animation: blink-cursor 1.2s infinite step-end; +.terminal.focus.xterm-cursor-blink .terminal-cursor { + animation: cursor-blink 1.2s infinite step-end; } -@keyframes blink-cursor { +@keyframes cursor-blink { 0% { background-color: #fff; color: #000; diff --git a/src/xterm.js b/src/xterm.js index 482d69a15..a62033ddf 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -408,7 +408,7 @@ Terminal.prototype.setOption = function(key, value) { this[key] = value; this.options[key] = value; switch (key) { - case 'cursorBlink': this.refresh(this.y, this.y); break; + case 'cursorBlink': this.element.classList.toggle('xterm-cursor-blink', value); break; } }; @@ -566,6 +566,7 @@ Terminal.prototype.open = function(parent) { this.element.classList.add('terminal'); this.element.classList.add('xterm'); this.element.classList.add('xterm-theme-' + this.theme); + this.element.classList.toggle('xterm-cursor-blink', this.options.cursorBlink); this.element.style.height this.element.setAttribute('tabindex', 0); @@ -1170,11 +1171,7 @@ Terminal.prototype.refresh = function(start, end) { } if (data !== this.defAttr) { if (data === -1) { - out += ''; + out += ''; } else { var classNames = []; From 12160a50cbd7b9c46485fa69fc75cf53d2458aff Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 15 Jan 2017 02:27:34 -0800 Subject: [PATCH 3/3] Fake xterm.element in tests --- src/test/test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/test.js b/src/test/test.js index 7c716b2ab..4f9342e5b 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -23,6 +23,11 @@ describe('xterm.js', function() { xterm.writeBuffer.push(data); xterm.innerWrite(); }; + xterm.element = { + classList: { + toggle: function(){} + } + }; }); describe('getOption', function() {