mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
fix(terminal) maxSize
This commit is contained in:
parent
f5f3ca8168
commit
060cdf2297
1 changed files with 23 additions and 13 deletions
|
|
@ -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 : ' ',
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue