##// END OF EJS Templates
Add comment explaining 1.02 factor
Thomas Kluyver -
Show More
@@ -1,52 +1,53
1 1 // Copyright (c) IPython Development Team.
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 require([
5 5 'jquery',
6 6 'termjs',
7 7 'base/js/utils',
8 8 'base/js/page',
9 9 'terminal/js/terminado',
10 10 'custom/custom',
11 11 ], function(
12 12 $,
13 13 termjs,
14 14 utils,
15 15 page,
16 16 terminado
17 17 ){
18 18 page = new page.Page();
19 19 // Test size: 25x80
20 20 var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
21 // 1.02 here arrived at by trial and error to make the spacing look right
21 22 var termColWidth = function() { return 1.02 * $("#dummy-screen-rows")[0].offsetWidth / 80;};
22 23
23 24 var base_url = utils.get_body_data('baseUrl');
24 25 var ws_path = utils.get_body_data('wsPath');
25 26 var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host
26 27 + base_url + ws_path;
27 28
28 29 var header = $("#header")[0]
29 30 function calculate_size() {
30 31 height = window.innerHeight - header.offsetHeight;
31 32 width = window.innerWidth;
32 33 var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1));
33 34 var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1));
34 35 console.log("resize to :", rows , 'rows by ', cols, 'columns');
35 36 return {rows: rows, cols: cols};
36 37 }
37 38
38 39 page.show_header();
39 40
40 41 size = calculate_size();
41 42 var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url);
42 43
43 44 page.show_site();
44 45
45 46 window.onresize = function() {
46 47 var geom = calculate_size();
47 48 terminal.term.resize(geom.cols, geom.rows);
48 49 terminal.socket.send(JSON.stringify(["set_size", geom.rows, geom.cols,
49 50 window.innerHeight, window.innerWidth]));
50 51 };
51 52
52 53 });
General Comments 0
You need to be logged in to leave comments. Login now