-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Upgrade xterm.js to 3.1.0 #3189
Changes from 13 commits
ad23737
85cd514
538a89f
94f6382
131502d
4616250
e5d393a
c5fcd74
a770f83
bb7dd0a
2d5cd35
dab784f
2424f97
2baa5d3
91794ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,13 +29,6 @@ requirejs([ | |
var common_config = new configmod.ConfigSection('common', common_options); | ||
common_config.load(); | ||
|
||
var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options); | ||
|
||
// Test size: 25x80 | ||
var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;}; | ||
// 1.02 here arrived at by trial and error to make the spacing look right | ||
var termColWidth = function() { return 1.02 * $("#dummy-screen-rows")[0].offsetWidth / 80;}; | ||
|
||
var base_url = utils.get_body_data('baseUrl').replace(/\/?$/, '/'); | ||
var ws_path = utils.get_body_data('wsPath'); | ||
var ws_url = utils.get_body_data('wsUrl'); | ||
|
@@ -45,32 +38,17 @@ requirejs([ | |
} | ||
ws_url = ws_url + base_url + ws_path; | ||
|
||
var header = $("#header")[0]; | ||
|
||
function calculate_size() { | ||
var height = $(window).height() - header.offsetHeight; | ||
var width = $('#terminado-container').width(); | ||
var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1)); | ||
var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1)); | ||
console.log("resize to :", rows , 'rows by ', cols, 'columns'); | ||
return {rows: rows, cols: cols}; | ||
} | ||
|
||
page.show_header(); | ||
|
||
var size = calculate_size(); | ||
var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url); | ||
var terminal = terminado.make_terminal($("#terminado-container")[0], ws_url); | ||
|
||
page.show_site(); | ||
|
||
utils.load_extensions_from_config(config); | ||
utils.load_extensions_from_config(common_config); | ||
|
||
window.onresize = function() { | ||
var geom = calculate_size(); | ||
terminal.term.resize(geom.cols, geom.rows); | ||
terminal.socket.send(JSON.stringify(["set_size", geom.rows, geom.cols, | ||
$(window).height(), $(window).width()])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to send the new size to the server so that it can trigger a resize in the running process. Try running a full-screen program like |
||
window.onresize = function() { | ||
terminal.term.fit(); | ||
}; | ||
|
||
// Expose terminal for fiddling with in the browser | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
define (["xterm"], function(Terminal) { | ||
define (["xterm", "xtermjs-fit"], function(Terminal, fit) { | ||
"use strict"; | ||
function make_terminal(element, size, ws_url) { | ||
function make_terminal(element, ws_url) { | ||
var ws = new WebSocket(ws_url); | ||
var term = new Terminal({ | ||
cols: size.cols, | ||
rows: size.rows | ||
}); | ||
Terminal.applyAddon(fit); | ||
var term = new Terminal(); | ||
ws.onopen = function(event) { | ||
ws.send(JSON.stringify(["set_size", size.rows, size.cols, | ||
window.innerHeight, window.innerWidth])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll still need to send this as well, so it knows how big the initial window is. |
||
term.on('data', function(data) { | ||
ws.send(JSON.stringify(['stdin', data])); | ||
}); | ||
|
@@ -18,7 +14,8 @@ define (["xterm"], function(Terminal) { | |
}); | ||
|
||
term.open(element); | ||
|
||
term.fit(); | ||
|
||
ws.onmessage = function(event) { | ||
var json_msg = JSON.parse(event.data); | ||
switch(json_msg[0]) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave this in place - it makes the 'logout' button in the top right work.