From: Daniel Imms Date: Wed, 13 Jul 2016 00:02:11 +0000 (-0700) Subject: Merge remote-tracking branch 'upstream/master' into 124_add_textarea_back X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=7d8e28a7ddaa890947f8aa497fb75f69af7b35f2;p=mirror_xterm.js.git Merge remote-tracking branch 'upstream/master' into 124_add_textarea_back --- 7d8e28a7ddaa890947f8aa497fb75f69af7b35f2 diff --cc src/xterm.js index 6682f83,7211dde..a6cdd8d --- a/src/xterm.js +++ b/src/xterm.js @@@ -430,22 -435,9 +435,20 @@@ /** * Focus the terminal. Delegates focus handling to the terminal's DOM element. - * - * @public */ Terminal.prototype.focus = function() { - return this.element.focus(); + if (document.activeElement === this.textarea) { + return; + } + + if (this.sendFocus) { + this.send('\x1b[I'); + } + + this.element.classList.add('focus'); + this.showCursor(); + this.textarea.focus(); + Terminal.focus = this; }; /** @@@ -467,22 -459,9 +470,20 @@@ /** * Blur the terminal. Delegates blur handling to the terminal's DOM element. - * - * @public */ Terminal.prototype.blur = function() { - return this.element.blur(); + if (Terminal.focus !== this) { + return; + } + + this.element.classList.remove('focus'); + this.cursorState = 0; + this.refresh(this.y, this.y); + this.textarea.blur(); + if (this.sendFocus) { + this.send('\x1b[0]'); + } + Terminal.focus = null; }; /** @@@ -2475,11 -2529,13 +2480,15 @@@ this.write(data + '\r\n'); }; - // Key Resources: - // https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent + /** + * Handle a keydown event + * Key Resources: + * - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent + * @param {KeyboardEvent} ev The keydown event to be handled. + */ Terminal.prototype.keyDown = function(ev) { + // TODO: Ignore event if currently composing text + var self = this; var result = this.evaluateKeyEscapeSequence(ev);