Merge pull request #121 from Tyriar/119_fix_cursor_blink

Fix cursor blinking when enabled
This commit is contained in:
Paris Kasidiaris
2016-06-15 09:51:49 +03:00
committed by GitHub
2 changed files with 20 additions and 28 deletions
+15
View File
@@ -57,6 +57,21 @@
background-color: transparent;
}
.terminal .terminal-cursor.blinking {
animation: blink-cursor 1.2s infinite step-end;
}
@keyframes blink-cursor {
0% {
background-color: #fff;
color: #000;
}
50% {
background-color: transparent;
color: #FFF;
}
}
/*
* Determine default colors for xterm.js
*/
+5 -28
View File
@@ -765,9 +765,6 @@
// Ensure there is a Terminal.focus.
this.focus();
// Start blinking the cursor.
this.startBlink();
on(this.element, 'mouseup', function() {
var selection = document.getSelection(),
collapsed = selection.isCollapsed,
@@ -1250,7 +1247,11 @@
}
if (data !== this.defAttr) {
if (data === -1) {
out += '<span class="reverse-video terminal-cursor">';
out += '<span class="reverse-video terminal-cursor';
if (this.cursorBlink) {
out += ' blinking';
}
out += '">';
} else {
var classNames = [];
@@ -1363,37 +1364,13 @@
this.emit('refresh', {element: this.element, start: start, end: end});
};
Terminal.prototype._cursorBlink = function() {
if (Terminal.focus !== this) return;
this.cursorState ^= 1;
this.refresh(this.y, this.y);
};
Terminal.prototype.showCursor = function() {
if (!this.cursorState) {
this.cursorState = 1;
this.refresh(this.y, this.y);
} else {
// Temporarily disabled:
// this.refreshBlink();
}
};
Terminal.prototype.startBlink = function() {
if (!this.cursorBlink) return;
var self = this;
this._blinker = function() {
self._cursorBlink();
};
this._blink = setInterval(this._blinker, 500);
};
Terminal.prototype.refreshBlink = function() {
if (!this.cursorBlink) return;
clearInterval(this._blink);
this._blink = setInterval(this._blinker, 500);
};
Terminal.prototype.scroll = function() {
var row;