Show More
@@ -1,53 +1,53 | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | require([ |
|
4 | require([ | |
5 | 'jquery', |
|
5 | 'jquery', | |
6 | 'termjs', |
|
6 | 'termjs', | |
7 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
8 | 'base/js/page', |
|
8 | 'base/js/page', | |
9 | 'terminal/js/terminado', |
|
9 | 'terminal/js/terminado', | |
10 | 'custom/custom', |
|
10 | 'custom/custom', | |
11 | ], function( |
|
11 | ], function( | |
12 | $, |
|
12 | $, | |
13 | termjs, |
|
13 | termjs, | |
14 | utils, |
|
14 | utils, | |
15 | page, |
|
15 | page, | |
16 | terminado |
|
16 | terminado | |
17 | ){ |
|
17 | ){ | |
18 | page = new page.Page(); |
|
18 | page = new page.Page(); | |
19 | // Test size: 25x80 |
|
19 | // Test size: 25x80 | |
20 | var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;}; |
|
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 | // 1.02 here arrived at by trial and error to make the spacing look right | |
22 | var termColWidth = function() { return 1.02 * $("#dummy-screen-rows")[0].offsetWidth / 80;}; |
|
22 | var termColWidth = function() { return 1.02 * $("#dummy-screen-rows")[0].offsetWidth / 80;}; | |
23 |
|
23 | |||
24 | var base_url = utils.get_body_data('baseUrl'); |
|
24 | var base_url = utils.get_body_data('baseUrl'); | |
25 | var ws_path = utils.get_body_data('wsPath'); |
|
25 | var ws_path = utils.get_body_data('wsPath'); | |
26 | var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host |
|
26 | var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host | |
27 | + base_url + ws_path; |
|
27 | + base_url + ws_path; | |
28 |
|
28 | |||
29 | var header = $("#header")[0] |
|
29 | var header = $("#header")[0] | |
30 | function calculate_size() { |
|
30 | function calculate_size() { | |
31 | height = window.innerHeight - header.offsetHeight; |
|
31 | height = window.innerHeight - header.offsetHeight; | |
32 |
width = |
|
32 | width = $('#terminado-container').width(); | |
33 | var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1)); |
|
33 | var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1)); | |
34 | var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1)); |
|
34 | var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1)); | |
35 | console.log("resize to :", rows , 'rows by ', cols, 'columns'); |
|
35 | console.log("resize to :", rows , 'rows by ', cols, 'columns'); | |
36 | return {rows: rows, cols: cols}; |
|
36 | return {rows: rows, cols: cols}; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | page.show_header(); |
|
39 | page.show_header(); | |
40 |
|
40 | |||
41 | size = calculate_size(); |
|
41 | size = calculate_size(); | |
42 | var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url); |
|
42 | var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url); | |
43 |
|
43 | |||
44 | page.show_site(); |
|
44 | page.show_site(); | |
45 |
|
45 | |||
46 | window.onresize = function() { |
|
46 | window.onresize = function() { | |
47 | var geom = calculate_size(); |
|
47 | var geom = calculate_size(); | |
48 | terminal.term.resize(geom.cols, geom.rows); |
|
48 | terminal.term.resize(geom.cols, geom.rows); | |
49 | terminal.socket.send(JSON.stringify(["set_size", geom.rows, geom.cols, |
|
49 | terminal.socket.send(JSON.stringify(["set_size", geom.rows, geom.cols, | |
50 | window.innerHeight, window.innerWidth])); |
|
50 | window.innerHeight, window.innerWidth])); | |
51 | }; |
|
51 | }; | |
52 |
|
52 | |||
53 | }); |
|
53 | }); |
@@ -1,17 +1,26 | |||||
1 | .terminal { |
|
1 | .terminal { | |
2 | float: left; |
|
2 | float: left; | |
3 | border: black solid 5px; |
|
3 | border: black solid 5px; | |
4 | font-family: "DejaVu Sans Mono", "Liberation Mono", monospace; |
|
4 | font-family: monospace; | |
5 | font-size: 11px; |
|
5 | font-size: 11px; | |
6 | color: white; |
|
6 | color: white; | |
7 | background: black; |
|
7 | background: black; | |
|
8 | border-radius: 2px; | |||
|
9 | box-shadow: 0px 4px 11px 0px gray; | |||
|
10 | border: 0px; | |||
|
11 | padding: @code_padding; | |||
|
12 | ||||
|
13 | &, dummy-screen { | |||
|
14 | line-height: @code_line_height; | |||
|
15 | font-size: @notebook_font_size; | |||
|
16 | } | |||
8 | } |
|
17 | } | |
9 |
|
18 | |||
10 | .terminal-cursor { |
|
19 | .terminal-cursor { | |
11 | color: black; |
|
20 | color: black; | |
12 | background: white; |
|
21 | background: white; | |
13 | } |
|
22 | } | |
14 |
|
23 | |||
15 | #terminado-container { |
|
24 | #terminado-container { | |
16 | margin: 8px; |
|
25 | padding-top: 20px; | |
17 | } |
|
26 | } |
@@ -1,7 +1,7 | |||||
1 | /*This file contains any manual css for this page that needs to override the global styles. |
|
1 | /*This file contains any manual css for this page that needs to override the global styles. | |
2 | This is only required when different pages style the same element differently. This is just |
|
2 | This is only required when different pages style the same element differently. This is just | |
3 | a hack to deal with our current css styles and no new styling should be added in this file.*/ |
|
3 | a hack to deal with our current css styles and no new styling should be added in this file.*/ | |
4 |
|
4 | |||
5 | #ipython-main-app { |
|
5 | #ipython-main-app { | |
6 |
margin: 2 |
|
6 | margin: 20px auto 0px auto; | |
7 | } |
|
7 | } |
@@ -1,57 +1,57 | |||||
1 | {% extends "page.html" %} |
|
1 | {% extends "page.html" %} | |
2 |
|
2 | |||
3 | {% block title %}{{page_title}}{% endblock %} |
|
3 | {% block title %}{{page_title}}{% endblock %} | |
4 |
|
4 | |||
5 | {% block params %} |
|
5 | {% block params %} | |
6 |
|
6 | |||
7 | data-base-url="{{base_url}}" |
|
7 | data-base-url="{{base_url}}" | |
8 | data-ws-path="{{ws_path}}" |
|
8 | data-ws-path="{{ws_path}}" | |
9 |
|
9 | |||
10 | {% endblock %} |
|
10 | {% endblock %} | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | {% block site %} |
|
13 | {% block site %} | |
14 |
|
14 | |||
15 | <div id="terminado-container"></div> |
|
15 | <div id="terminado-container" class="container"></div> | |
16 |
|
16 | |||
17 | {% endblock %} |
|
17 | {% endblock %} | |
18 |
|
18 | |||
19 | {% block script %} |
|
19 | {% block script %} | |
20 |
|
20 | |||
21 | <!-- Hack: this needs to be outside the display:none block, so we can measure |
|
21 | <!-- Hack: this needs to be outside the display:none block, so we can measure | |
22 | its size in JS in setting up the page. It is still invisible. Putting in |
|
22 | its size in JS in setting up the page. It is still invisible. Putting in | |
23 | the script block gets it outside the initially undisplayed region. --> |
|
23 | the script block gets it outside the initially undisplayed region. --> | |
24 | <!-- test size: 25x80 --> |
|
24 | <!-- test size: 25x80 --> | |
25 | <div style='position:absolute; left:-1000em'> |
|
25 | <div style='position:absolute; left:-1000em'> | |
26 | <pre id="dummy-screen" style="border: solid 5px white;" class="terminal">0 |
|
26 | <pre id="dummy-screen" style="border: solid 5px white;" class="terminal">0 | |
27 | 1 |
|
27 | 1 | |
28 | 2 |
|
28 | 2 | |
29 | 3 |
|
29 | 3 | |
30 | 4 |
|
30 | 4 | |
31 | 5 |
|
31 | 5 | |
32 | 6 |
|
32 | 6 | |
33 | 7 |
|
33 | 7 | |
34 | 8 |
|
34 | 8 | |
35 | 9 |
|
35 | 9 | |
36 | 0 |
|
36 | 0 | |
37 | 1 |
|
37 | 1 | |
38 | 2 |
|
38 | 2 | |
39 | 3 |
|
39 | 3 | |
40 | 4 |
|
40 | 4 | |
41 | 5 |
|
41 | 5 | |
42 | 6 |
|
42 | 6 | |
43 | 7 |
|
43 | 7 | |
44 | 8 |
|
44 | 8 | |
45 | 9 |
|
45 | 9 | |
46 | 0 |
|
46 | 0 | |
47 | 1 |
|
47 | 1 | |
48 | 2 |
|
48 | 2 | |
49 | 3 |
|
49 | 3 | |
50 | <span id="dummy-screen-rows" style="">01234567890123456789012345678901234567890123456789012345678901234567890123456789</span> |
|
50 | <span id="dummy-screen-rows" style="">01234567890123456789012345678901234567890123456789012345678901234567890123456789</span> | |
51 | </pre> |
|
51 | </pre> | |
52 | </div> |
|
52 | </div> | |
53 |
|
53 | |||
54 | {{super()}} |
|
54 | {{super()}} | |
55 |
|
55 | |||
56 | <script src="{{ static_url("terminal/js/main.js") }}" type="text/javascript" charset="utf-8"></script> |
|
56 | <script src="{{ static_url("terminal/js/main.js") }}" type="text/javascript" charset="utf-8"></script> | |
57 | {% endblock %} |
|
57 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now