mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
fix(terminal) resizing
This commit is contained in:
parent
5ec1b7833a
commit
4e8c524dcb
2 changed files with 20 additions and 14 deletions
|
|
@ -119,7 +119,10 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
|
|||
},
|
||||
};
|
||||
|
||||
options[CHANNEL] = write;
|
||||
options[CHANNEL] = write;
|
||||
options[CHANNEL_RESIZE] = function(size) {
|
||||
Term.resize(size.cols, size.rows);
|
||||
};
|
||||
|
||||
socket.on(options);
|
||||
|
||||
|
|
@ -163,7 +166,7 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal;
|
|||
if (Size.cols !== cols || Size.rows !== rows) {
|
||||
Size = size;
|
||||
|
||||
Term.resize(size.cols, size.rows);
|
||||
//Term.resize(size.cols, size.rows);
|
||||
Term.emit('resize', size);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
if (pty)
|
||||
ret = socket.on('connection', function(clientSocket) {
|
||||
onConnection(clientSocket, function(data) {
|
||||
socket.emit(CHANNEL, data, clientSocket);
|
||||
onConnection(clientSocket, function(channel, data) {
|
||||
socket.emit(channel, data, clientSocket);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
term = getTerm(callback);
|
||||
dataFunc = onData.bind(null, term);
|
||||
resizeFunc = onResize.bind(null, term);
|
||||
resizeFunc = onResize.bind(null, term, callback);
|
||||
|
||||
onDisconnect = function(conNum, term) {
|
||||
Clients[conNum] = null;
|
||||
|
|
@ -71,8 +71,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
function onResize(term, size) {
|
||||
function onResize(term, callback, size) {
|
||||
term.resize(size.cols, size.rows);
|
||||
Util.exec(callback, CHANNEL_RESIZE, size);
|
||||
}
|
||||
|
||||
function onData(term, data) {
|
||||
|
|
@ -80,15 +81,17 @@
|
|||
}
|
||||
|
||||
function getTerm(callback) {
|
||||
var term = pty.spawn('bash', [], {
|
||||
name: 'xterm-color',
|
||||
cols: 80,
|
||||
rows: 25,
|
||||
cwd : DIR,
|
||||
env : process.env
|
||||
});
|
||||
var onData = Util.exec.bind(Util, callback, CHANNEL),
|
||||
|
||||
term = pty.spawn('bash', [], {
|
||||
name: 'xterm-color',
|
||||
cols: 80,
|
||||
rows: 25,
|
||||
cwd : DIR,
|
||||
env : process.env
|
||||
});
|
||||
|
||||
term.on('data', Util.exec.bind(Util, callback));
|
||||
term.on('data', onData);
|
||||
|
||||
return term;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue