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