Merge pull request #479 from Tyriar/478_cursorBlink_refresh

Apply cursorBlink via setOption
This commit is contained in:
Daniel Imms
2017-01-15 02:35:30 -08:00
committed by GitHub
4 changed files with 16 additions and 9 deletions
+3 -1
View File
@@ -28,7 +28,9 @@ function setTerminalSize () {
colsElement.addEventListener('change', setTerminalSize); colsElement.addEventListener('change', setTerminalSize);
rowsElement.addEventListener('change', setTerminalSize); rowsElement.addEventListener('change', setTerminalSize);
optionElements.cursorBlink.addEventListener('change', createTerminal); optionElements.cursorBlink.addEventListener('change', function () {
term.setOption('cursorBlink', optionElements.cursorBlink.checked);
});
optionElements.scrollback.addEventListener('change', function () { optionElements.scrollback.addEventListener('change', function () {
terminal.setOption('scrollback', parseInt(optionElements.scrollback.value, 10)); terminal.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));
}); });
+5
View File
@@ -23,6 +23,11 @@ describe('xterm.js', function() {
xterm.writeBuffer.push(data); xterm.writeBuffer.push(data);
xterm.innerWrite(); xterm.innerWrite();
}; };
xterm.element = {
classList: {
toggle: function(){}
}
};
}); });
describe('getOption', function() { describe('getOption', function() {
+3 -3
View File
@@ -82,11 +82,11 @@
background-color: transparent; background-color: transparent;
} }
.terminal.focus .terminal-cursor.blinking { .terminal.focus.xterm-cursor-blink .terminal-cursor {
animation: blink-cursor 1.2s infinite step-end; animation: cursor-blink 1.2s infinite step-end;
} }
@keyframes blink-cursor { @keyframes cursor-blink {
0% { 0% {
background-color: #fff; background-color: #fff;
color: #000; color: #000;
+5 -5
View File
@@ -425,6 +425,9 @@ Terminal.prototype.setOption = function(key, value) {
} }
this[key] = value; this[key] = value;
this.options[key] = value; this.options[key] = value;
switch (key) {
case 'cursorBlink': this.element.classList.toggle('xterm-cursor-blink', value); break;
}
}; };
/** /**
@@ -581,6 +584,7 @@ Terminal.prototype.open = function(parent) {
this.element.classList.add('terminal'); this.element.classList.add('terminal');
this.element.classList.add('xterm'); this.element.classList.add('xterm');
this.element.classList.add('xterm-theme-' + this.theme); this.element.classList.add('xterm-theme-' + this.theme);
this.element.classList.toggle('xterm-cursor-blink', this.options.cursorBlink);
this.element.style.height this.element.style.height
this.element.setAttribute('tabindex', 0); this.element.setAttribute('tabindex', 0);
@@ -1193,11 +1197,7 @@ Terminal.prototype.refresh = function(start, end) {
} }
if (data !== this.defAttr) { if (data !== this.defAttr) {
if (data === -1) { if (data === -1) {
out += '<span class="reverse-video terminal-cursor'; out += '<span class="reverse-video terminal-cursor">';
if (this.cursorBlink) {
out += ' blinking';
}
out += '">';
} else { } else {
var classNames = []; var classNames = [];