diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 340cf6ac..c7cfb1e4 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -44,7 +44,8 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal; function show(callback) { - var socket = CloudCmd.Socket; + var size, + socket = CloudCmd.Socket; if (!Loading) { Images.showLoad({top:true}); @@ -56,10 +57,17 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal; style : 'height :100%' }); + /* hack to determine console size + * inspired with + * + * https://github.com/petethepig/devtools-terminal + */ Cell = DOM.anyload({ name : 'div', inner : ' ', - parent : Element + parent : Element, + style : 'position: absolute;' + + 'top : -1000px;' }); DOM.cssSet({ @@ -69,12 +77,13 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal; '}' }); + size = getSize(); - Term = new Terminal({ + Term = new Terminal({ screenKeys: true, cursorBlink: false, - cols: 80, - rows: 25 + cols: size.cols, + rows: size.rows }); Term.open(Element); @@ -93,21 +102,11 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal; Term.write(data); } - function listener(event) { - var keyCode = event.keyCode; - - if (keyCode === ESC) - CloudCmd.View.hide(); - } - function addListeners(callback) { - var socket = CloudCmd.Socket, - size = maxSize(); + var socket = CloudCmd.Socket; socket.on(CHANNEL, write); - Term.on('keydown', listener); - Term.on('data', function(data) { var code; @@ -128,7 +127,7 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal; Util.exec(callback); } - function maxSize() { + function getSize() { var wSubs = Element.offsetWidth - Element.clientWidth, w = Element.clientWidth - wSubs,