fix(terminal) maxSize

This commit is contained in:
coderaiser 2014-02-04 09:34:40 -05:00
parent f5f3ca8168
commit 060cdf2297

View file

@ -1,7 +1,7 @@
var CloudCmd, Util, DOM, CloudFunc, Terminal;
(function(CloudCmd, Util, DOM, CloudFunc) {
'use strict';
CloudCmd.Terminal = TerminalProto;
function TerminalProto(CallBack) {
@ -10,6 +10,7 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
Element,
MouseBinded,
Term,
Cell,
Key = CloudCmd.Key,
ESC = Key.ESC,
Images = DOM.Images,
@ -55,6 +56,12 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
style : 'height :100%'
});
Cell = DOM.anyload({
name : 'div',
inner : '&nbsp',
parent : Element
});
DOM.cssSet({
id : 'terminal-css',
inner : '#terminal, .terminal, #view {' +
@ -95,10 +102,7 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
function addListeners(callback) {
var socket = CloudCmd.Socket,
size = {
cols: 80,
rows: 25
};
size = maxSize();
socket.on(CHANNEL, write);
@ -113,23 +117,29 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
/* when back to term
* first simbol wasn't wrote
*/
if (code !== ESC)
socket.emit(CHANNEL, data);
socket.emit(CHANNEL, data);
}
});
//Term.resize(size.cols, size.rows);
//socket.emit(CHANNEL_RESIZE, size);
Term.on(CHANNEL_RESIZE, function() {
socket.emit(CHANNEL_RESIZE, size);
});
Util.exec(callback);
}
function maxSize() {
var w = Term.element.clientWidth - (Term.offsetWidth - Term.clientWidth),
h = Term.element.clientHeight - (Term.offsetHeight - Term.clientHeight),
var wSubs = Element.offsetWidth - Element.clientWidth,
w = Element.clientWidth - wSubs,
cols = Math.max(Math.floor(w), 10),
rows = Math.max(Math.floor(h), 10),
hSubs = Element.offsetHeight - Element.clientHeight,
h = Element.clientHeight - hSubs,
x = Cell.clientWidth,
y = Cell.clientHeight,
cols = Math.max(Math.floor(w / x), 10),
rows = Math.max(Math.floor(h / y), 10),
size = {
cols: cols,