diff --git a/addons/attach/attach.js b/addons/attach/attach.js new file mode 100644 index 0000000000..12eb1359e4 --- /dev/null +++ b/addons/attach/attach.js @@ -0,0 +1,23 @@ +/* + * Implements the attach method, that + * attaches the terminal to a WebSocket stream. + * + * The bidirectional argument indicates, whether the terminal should + * send data to the socket as well and is true, by default. + */ +Terminal.prototype.attach = function (socket, bidirectional) { + var term = this; + + bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional; + this.socket = socket; + + socket.addEventListener('message', function (ev) { + term.write(ev.data); + }); + + if (bidirectional) { + this.on('data', function (data) { + socket.send(data); + }); + } +} \ No newline at end of file diff --git a/addons/attach/index.html b/addons/attach/index.html new file mode 100644 index 0000000000..654a024521 --- /dev/null +++ b/addons/attach/index.html @@ -0,0 +1,38 @@ + + + + + + + + + +
+ + +
+
+ + + \ No newline at end of file diff --git a/addons/fullscreen/fullscreen.css b/addons/fullscreen/fullscreen.css new file mode 100644 index 0000000000..ced6c529d8 --- /dev/null +++ b/addons/fullscreen/fullscreen.css @@ -0,0 +1,10 @@ +.xterm.fullscreen { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: auto; + height: auto; + z-index: 255; +} \ No newline at end of file diff --git a/addons/fullscreen/fullscreen.js b/addons/fullscreen/fullscreen.js new file mode 100644 index 0000000000..a3012a7e40 --- /dev/null +++ b/addons/fullscreen/fullscreen.js @@ -0,0 +1,25 @@ +/* + * Fullscreen addon for xterm.js + * + * Implements the toggleFullscreen function. + * + * If the `fullscreen` argument has been supplied, then + * if it is true, the fullscreen mode gets turned on, + * if it is false or null, the fullscreen mode gets turned off. + * + * If the `fullscreen` argument has not been supplied, the + * fullscreen mode is being toggled. + */ +Terminal.prototype.toggleFullscreen = function (fullscreen) { + var fn; + + if (typeof fullscreen == 'undefined') { + fn = (this.element.classList.contains('fullscreen')) ? 'remove' : 'add'; + } else if (!fullscreen) { + fn = 'remove'; + } else { + fn = 'add'; + } + + this.element.classList[fn]('fullscreen'); +} \ No newline at end of file diff --git a/bower.json b/bower.json index f61a3395a0..c7aa76f4fa 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { "name": "xterm.js", - "version": "0.6", + "version": "0.8", "ignore": ["demo", "docs", "test", ".gitignore"] -} \ No newline at end of file +} diff --git a/demo/index.html b/demo/index.html index 36016c1d19..73aa304a06 100644 --- a/demo/index.html +++ b/demo/index.html @@ -3,8 +3,10 @@ xterm.js demo + + diff --git a/demo/main.js b/demo/main.js index b03edf7dbd..67a2180b91 100644 --- a/demo/main.js +++ b/demo/main.js @@ -17,7 +17,6 @@ term.on('key', function (key, ev) { var printable = (!ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey); if (ev.keyIdentifier == 'Enter') { - ev.preventDefault(); term.prompt(); } else if (ev.keyCode == 8) { term.write('\b \b'); diff --git a/src/xterm.js b/src/xterm.js index 90caaad93c..bddef3c920 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -542,6 +542,10 @@ Terminal.prototype.open = function(parent) { this.element.appendChild(this.helperContainer); this.textarea = document.createElement('textarea'); this.textarea.classList.add('xterm-helper-textarea'); + this.textarea.setAttribute('autocorrect', 'off'); + this.textarea.setAttribute('autocapitalize', 'off'); + this.textarea.setAttribute('spellcheck', 'false'); + this.textarea.tabIndex = 0; this.helperContainer.appendChild(this.textarea); for (; i < this.rows; i++) { @@ -2173,14 +2177,17 @@ Terminal.prototype.keyDown = function(ev) { break; } key = '\t'; + this.cancel(ev, true); break; // return/enter case 13: key = '\r'; + this.cancel(ev, true); break; // escape case 27: key = '\x1b'; + this.cancel(ev, true); break; // left-arrow case 37: @@ -2354,7 +2361,7 @@ Terminal.prototype.keyDown = function(ev) { this.emit('keydown', ev); this.emit('key', key, ev); - + console.log('keydown'); this.showCursor(); this.handler(key); @@ -2396,7 +2403,7 @@ Terminal.prototype.keyPress = function(ev) { this.emit('keypress', key, ev); this.emit('key', key, ev); - + console.log('keypress'); this.showCursor(); this.handler(key); @@ -4660,17 +4667,12 @@ function off(el, type, handler, capture) { el.removeEventListener(type, handler, capture || false); } -function cancel(ev) { - if (!this.cancelEvents) { +function cancel(ev, force) { + if (!this.cancelEvents && !force) { return; } - if (ev.preventDefault) { - ev.preventDefault(); - } - if (ev.stopPropagation) { - ev.stopPropagation(); - } - ev.cancelBubble = true; + ev.preventDefault(); + ev.stopPropagation(); return false; }