Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic #68

Open
Xierip opened this issue May 16, 2015 · 3 comments
Open

dynamic #68

Xierip opened this issue May 16, 2015 · 3 comments

Comments

@Xierip
Copy link

Xierip commented May 16, 2015

Hi, how i can create dynamic console (auto scale)
my css is in 100% automatic, check it http://scr.hu/6gnm/hf54f && http://scr.hu/6gnm/cmryo

code:

var doc = document.getElementById('panel-body');
var term = new Terminal({
cols: (doc.clientWidth/6.36),
rows: 40,
useStyle: true,
});

    term.on('data', function(data) {
        socket.emit('data', data);
    });
    socket.on('data', function(data) {
        term.write(data);
    });
    term.on('close', function(data) {
        console.log('konsola zamknięta');
    });
    term.open(doc || document.body);
    socket.on('disconnect', function() {
        term.destroy();
    });
@liuzheng
Copy link

You can do it like this

if ($('#terminal span').length>0 && $('#terminal span')[0].children.length==0  ) {
    var boy = $('#terminal span')[0];
    var perW = boy.offsetWidth / boy.textContent.length;
    var col = Math.floor($('#terminal')[0].offsetWidth / perW);
    term.resize(30, col);
}

any question @ me

@soichih
Copy link

soichih commented Sep 12, 2015

Is there a way to do this without jQuery?

It would be really nice if term.js automatically calculated the row/col if no parameters were given for .resize() to fit the size of the container element.

Like.
.

term.resize();

@scallyw4g
Copy link

If you have not figured this out already, you can do this without jQuery. Just use native JS to select the elements, the rest is the same. ie. document.getElementById("terminal");

Then submit a PR with new resize() API ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants