Support focus class on the .xterm element

This commit is contained in:
Daniel Imms 2016-07-12 16:18:05 -07:00
parent fc7b22dc48
commit aaedcfc700
2 changed files with 7 additions and 5 deletions

View File

@ -43,7 +43,7 @@
position: relative; position: relative;
} }
.terminal:focus { .terminal.focus {
outline: none; outline: none;
} }
@ -57,11 +57,11 @@
* HACK: to fix IE's blinking cursor * HACK: to fix IE's blinking cursor
* Move textarea out of the screen to the far left, so that the cursor is not visible. * Move textarea out of the screen to the far left, so that the cursor is not visible.
*/ */
text-indent: -9999em; /*text-indent: -9999em;
opacity: 0; opacity: 0;
width: 0; width: 0;
height: 0; height: 0;
z-index: -10; z-index: -10;*/
} }
.terminal .terminal-cursor { .terminal .terminal-cursor {
@ -69,13 +69,13 @@
color: #000; color: #000;
} }
.terminal:not(:focus) .terminal-cursor { .terminal:not(.focus) .terminal-cursor {
outline: 1px solid #fff; outline: 1px solid #fff;
outline-offset: -1px; outline-offset: -1px;
background-color: transparent; background-color: transparent;
} }
.terminal:focus .terminal-cursor.blinking { .terminal.focus .terminal-cursor.blinking {
animation: blink-cursor 1.2s infinite step-end; animation: blink-cursor 1.2s infinite step-end;
} }

View File

@ -442,6 +442,7 @@
this.send('\x1b[I'); this.send('\x1b[I');
} }
this.element.classList.add('focus');
this.showCursor(); this.showCursor();
this.textarea.focus(); this.textarea.focus();
Terminal.focus = this; Terminal.focus = this;
@ -474,6 +475,7 @@
return; return;
} }
this.element.classList.remove('focus');
this.cursorState = 0; this.cursorState = 0;
this.refresh(this.y, this.y); this.refresh(this.y, this.y);
this.textarea.blur(); this.textarea.blur();