Show More
@@ -0,0 +1,39 b'' | |||
|
1 | //---------------------------------------------------------------------------- | |
|
2 | // Copyright (C) 2008-2011 The IPython Development Team | |
|
3 | // | |
|
4 | // Distributed under the terms of the BSD License. The full license is in | |
|
5 | // the file COPYING, distributed as part of this software. | |
|
6 | //---------------------------------------------------------------------------- | |
|
7 | ||
|
8 | //============================================================================ | |
|
9 | // QuickHelp button | |
|
10 | //============================================================================ | |
|
11 | ||
|
12 | var IPython = (function (IPython) { | |
|
13 | ||
|
14 | var QuickHelp = function (selector) { | |
|
15 | this.selector = selector; | |
|
16 | if (this.selector !== undefined) { | |
|
17 | this.element = $(selector); | |
|
18 | this.style(); | |
|
19 | this.bind_events(); | |
|
20 | } | |
|
21 | }; | |
|
22 | ||
|
23 | QuickHelp.prototype.style = function () { | |
|
24 | this.element.find('button#quick_help').button(); | |
|
25 | }; | |
|
26 | ||
|
27 | QuickHelp.prototype.bind_events = function () { | |
|
28 | var that = this; | |
|
29 | this.element.find("button#quick_help").click(function () { | |
|
30 | IPython.notebook.toggle_keyboard_shortcuts(); | |
|
31 | }); | |
|
32 | }; | |
|
33 | ||
|
34 | // Set module variables | |
|
35 | IPython.QuickHelp = QuickHelp; | |
|
36 | ||
|
37 | return IPython; | |
|
38 | ||
|
39 | }(IPython)); |
@@ -1,7 +1,7 b'' | |||
|
1 | 1 | |
|
2 | 2 | |
|
3 | 3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;} |
|
4 |
.cm-s-ipython span.cm-number {color: # |
|
|
4 | .cm-s-ipython span.cm-number {color: #0A32C8;} | |
|
5 | 5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;} |
|
6 | 6 | .cm-s-ipython span.cm-meta {color: #AA22FF;} |
|
7 | 7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;} |
@@ -22,7 +22,7 b' div#header {' | |||
|
22 | 22 | /* Initially hidden to prevent FLOUC */ |
|
23 | 23 | display: none; |
|
24 | 24 | position: relative; |
|
25 |
height: 4 |
|
|
25 | height: 40px; | |
|
26 | 26 | padding: 5px; |
|
27 | 27 | margin: 0px; |
|
28 | 28 | width: 100%; |
@@ -35,7 +35,7 b' span#ipython_notebook {' | |||
|
35 | 35 | |
|
36 | 36 | span#ipython_notebook h1 { |
|
37 | 37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; |
|
38 |
font-size: 1 |
|
|
38 | font-size: 150%; | |
|
39 | 39 | display: inline; |
|
40 | 40 | color: black; |
|
41 | 41 | } |
@@ -1,4 +1,3 b'' | |||
|
1 | ||
|
2 | 1 |
|
|
3 | 2 | * Primary styles |
|
4 | 3 | * |
@@ -19,12 +18,18 b' body {' | |||
|
19 | 18 | } |
|
20 | 19 | |
|
21 | 20 | span#save_widget { |
|
22 |
position: |
|
|
21 | position: static; | |
|
23 | 22 | left: 0px; |
|
24 | 23 | padding: 5px 0px; |
|
25 | 24 | margin: 0px 0px 0px 0px; |
|
26 | 25 | } |
|
27 | 26 | |
|
27 | span#quick_help_area { | |
|
28 | position: static; | |
|
29 | padding: 5px 0px; | |
|
30 | margin: 0px 0px 0px 0px; | |
|
31 | } | |
|
32 | ||
|
28 | 33 | input#notebook_name { |
|
29 | 34 | height: 1em; |
|
30 | 35 | line-height: 1em; |
@@ -35,9 +40,10 b' span#kernel_status {' | |||
|
35 | 40 | position: absolute; |
|
36 | 41 | padding: 8px 5px 5px 5px; |
|
37 | 42 | right: 10px; |
|
38 |
|
|
|
43 | font-weight: bold; | |
|
39 | 44 | } |
|
40 | 45 | |
|
46 | ||
|
41 | 47 | .status_idle { |
|
42 | 48 | color: gray; |
|
43 | 49 | } |
@@ -156,7 +162,7 b' div#notebook {' | |||
|
156 | 162 | overflow-x: auto; |
|
157 | 163 | width: 100%; |
|
158 | 164 | /* This spaces the cell away from the edge of the notebook area */ |
|
159 |
padding: |
|
|
165 | padding: 5px 5px 15px 5px; | |
|
160 | 166 | margin: 0px |
|
161 | 167 | background-color: white; |
|
162 | 168 | } |
@@ -172,9 +178,9 b' div#pager {' | |||
|
172 | 178 | |
|
173 | 179 | div.cell { |
|
174 | 180 | width: 100%; |
|
175 | padding: 5px; | |
|
181 | padding: 5px 5px 5px 0px; | |
|
176 | 182 | /* This acts as a spacer between cells, that is outside the border */ |
|
177 |
margin: |
|
|
183 | margin: 2px 0px 2px 0px; | |
|
178 | 184 | } |
|
179 | 185 | |
|
180 | 186 | div.code_cell { |
@@ -200,7 +206,7 b' div.input_area {' | |||
|
200 | 206 | color: black; |
|
201 | 207 | border: 1px solid #ddd; |
|
202 | 208 | border-radius: 3px; |
|
203 |
background: #f |
|
|
209 | background: #f7f7f7; | |
|
204 | 210 | } |
|
205 | 211 | |
|
206 | 212 | div.input_prompt { |
@@ -330,9 +336,10 b' div.text_cell_render {' | |||
|
330 | 336 | |
|
331 | 337 | .shortcut_key { |
|
332 | 338 | display: inline-block; |
|
333 |
width: 1 |
|
|
339 | width: 13ex; | |
|
334 | 340 | text-align: right; |
|
341 | font-family: monospace; | |
|
335 | 342 | } |
|
336 | 343 | |
|
337 | 344 | .shortcut_descr { |
|
338 | } No newline at end of file | |
|
345 | } |
@@ -48,9 +48,10 b' var IPython = (function (IPython) {' | |||
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) { |
|
51 |
// This method gets called in CodeMirror's onKeyDown/onKeyPress |
|
|
52 |
// is used to provide custom key handling. Its return |
|
|
53 |
// if CodeMirror should ignore the event: |
|
|
51 | // This method gets called in CodeMirror's onKeyDown/onKeyPress | |
|
52 | // handlers and is used to provide custom key handling. Its return | |
|
53 | // value is used to determine if CodeMirror should ignore the event: | |
|
54 | // true = ignore, false = don't ignore. | |
|
54 | 55 | if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { |
|
55 | 56 | // Always ignore shift-enter in CodeMirror as we handle it. |
|
56 | 57 | return true; |
@@ -59,8 +60,8 b' var IPython = (function (IPython) {' | |||
|
59 | 60 | var cur = editor.getCursor(); |
|
60 | 61 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim(); |
|
61 | 62 | if (pre_cursor === "") { |
|
62 |
// Don't autocomplete if the part of the line before the cursor |
|
|
63 | // In this case, let CodeMirror handle indentation. | |
|
63 | // Don't autocomplete if the part of the line before the cursor | |
|
64 | // is empty. In this case, let CodeMirror handle indentation. | |
|
64 | 65 | return false; |
|
65 | 66 | } else { |
|
66 | 67 | // Autocomplete the current line. |
@@ -86,9 +87,14 b' var IPython = (function (IPython) {' | |||
|
86 | 87 | } else { |
|
87 | 88 | return false; |
|
88 | 89 | }; |
|
89 | } else { | |
|
90 | // keypress/keyup also trigger on TAB press, and we don't want to use those | |
|
91 | // to disable tab completion. | |
|
90 | } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey | |
|
91 | && event.type == 'keydown') { | |
|
92 | // toggle line numbers with Ctrl-Shift-L | |
|
93 | this.toggle_line_numbers(); | |
|
94 | } | |
|
95 | else { | |
|
96 | // keypress/keyup also trigger on TAB press, and we don't want to | |
|
97 | // use those to disable tab completion. | |
|
92 | 98 | if (this.is_completing && event.keyCode !== 9) { |
|
93 | 99 | var ed_cur = editor.getCursor(); |
|
94 | 100 | var cc_cur = this.completion_cursor; |
@@ -177,6 +183,14 b' var IPython = (function (IPython) {' | |||
|
177 | 183 | select.focus(); |
|
178 | 184 | }; |
|
179 | 185 | |
|
186 | CodeCell.prototype.toggle_line_numbers = function () { | |
|
187 | if (this.code_mirror.getOption('lineNumbers') == false) { | |
|
188 | this.code_mirror.setOption('lineNumbers', true); | |
|
189 | } else { | |
|
190 | this.code_mirror.setOption('lineNumbers', false); | |
|
191 | } | |
|
192 | this.code_mirror.refresh() | |
|
193 | }; | |
|
180 | 194 | |
|
181 | 195 | CodeCell.prototype.select = function () { |
|
182 | 196 | IPython.Cell.prototype.select.apply(this); |
@@ -470,4 +484,3 b' var IPython = (function (IPython) {' | |||
|
470 | 484 | |
|
471 | 485 | return IPython; |
|
472 | 486 | }(IPython)); |
|
473 |
@@ -130,9 +130,24 b' var IPython = (function (IPython) {' | |||
|
130 | 130 | that.select_next(); |
|
131 | 131 | that.control_key_active = false; |
|
132 | 132 | return false; |
|
133 | } else if (event.which === 76 && that.control_key_active) { | |
|
134 | // Toggle line numbers = l | |
|
135 | that.cell_toggle_line_numbers(); | |
|
136 | that.control_key_active = false; | |
|
137 | return false; | |
|
138 | } else if (event.which === 73 && that.control_key_active) { | |
|
139 | // Interrupt kernel = i | |
|
140 | IPython.notebook.kernel.interrupt(); | |
|
141 | that.control_key_active = false; | |
|
142 | return false; | |
|
143 | } else if (event.which === 190 && that.control_key_active) { | |
|
144 | // Restart kernel = . # matches qt console | |
|
145 | IPython.notebook.restart_kernel(); | |
|
146 | that.control_key_active = false; | |
|
147 | return false; | |
|
133 | 148 | } else if (event.which === 72 && that.control_key_active) { |
|
134 | 149 | // Show keyboard shortcuts = h |
|
135 |
that. |
|
|
150 | that.toggle_keyboard_shortcuts(); | |
|
136 | 151 | that.control_key_active = false; |
|
137 | 152 | return false; |
|
138 | 153 | } else if (that.control_key_active) { |
@@ -181,15 +196,25 b' var IPython = (function (IPython) {' | |||
|
181 | 196 | }; |
|
182 | 197 | |
|
183 | 198 | |
|
184 |
Notebook.prototype. |
|
|
199 | Notebook.prototype.toggle_keyboard_shortcuts = function () { | |
|
200 | // toggles display of keyboard shortcut dialog | |
|
201 | var that = this; | |
|
202 | if ( this.shortcut_dialog ){ | |
|
203 | // if dialog is already shown, close it | |
|
204 | this.shortcut_dialog.dialog("close"); | |
|
205 | this.shortcut_dialog = null; | |
|
206 | return; | |
|
207 | } | |
|
185 | 208 | var dialog = $('<div/>'); |
|
209 | this.shortcut_dialog = dialog; | |
|
186 | 210 | var shortcuts = [ |
|
187 | 211 | {key: 'Shift-Enter', help: 'run cell'}, |
|
188 |
{key: 'Ctrl-Enter', help: 'run cell in |
|
|
212 | {key: 'Ctrl-Enter', help: 'run cell in-place'}, | |
|
189 | 213 | {key: 'Ctrl-m d', help: 'delete cell'}, |
|
190 | 214 | {key: 'Ctrl-m a', help: 'insert cell above'}, |
|
191 | 215 | {key: 'Ctrl-m b', help: 'insert cell below'}, |
|
192 | 216 | {key: 'Ctrl-m t', help: 'toggle output'}, |
|
217 | {key: 'Ctrl-m l', help: 'toggle line numbers'}, | |
|
193 | 218 | {key: 'Ctrl-m s', help: 'save notebook'}, |
|
194 | 219 | {key: 'Ctrl-m j', help: 'move cell down'}, |
|
195 | 220 | {key: 'Ctrl-m k', help: 'move cell up'}, |
@@ -197,7 +222,9 b' var IPython = (function (IPython) {' | |||
|
197 | 222 | {key: 'Ctrl-m m', help: 'markdown cell'}, |
|
198 | 223 | {key: 'Ctrl-m p', help: 'select previous'}, |
|
199 | 224 | {key: 'Ctrl-m n', help: 'select next'}, |
|
200 |
{key: 'Ctrl-m |
|
|
225 | {key: 'Ctrl-m i', help: 'interrupt kernel'}, | |
|
226 | {key: 'Ctrl-m .', help: 'restart kernel'}, | |
|
227 | {key: 'Ctrl-m h', help: 'show keyboard shortcuts'} | |
|
201 | 228 | ]; |
|
202 | 229 | for (var i=0; i<shortcuts.length; i++) { |
|
203 | 230 | dialog.append($('<div>'). |
@@ -205,6 +232,10 b' var IPython = (function (IPython) {' | |||
|
205 | 232 | append($('<span/>').addClass('shortcut_descr').html(' : ' + shortcuts[i].help)) |
|
206 | 233 | ); |
|
207 | 234 | }; |
|
235 | dialog.bind('dialogclose', function(event) { | |
|
236 | // dialog has been closed, allow it to be drawn again. | |
|
237 | that.shortcut_dialog = null; | |
|
238 | }); | |
|
208 | 239 | dialog.dialog({title: 'Keyboard shortcuts'}); |
|
209 | 240 | }; |
|
210 | 241 | |
@@ -602,6 +633,11 b' var IPython = (function (IPython) {' | |||
|
602 | 633 | this.dirty = true; |
|
603 | 634 | }; |
|
604 | 635 | |
|
636 | // Other cell functions: line numbers, ... | |
|
637 | ||
|
638 | Notebook.prototype.cell_toggle_line_numbers = function() { | |
|
639 | this.selected_cell().toggle_line_numbers() | |
|
640 | }; | |
|
605 | 641 | |
|
606 | 642 | // Kernel related things |
|
607 | 643 | |
@@ -613,8 +649,26 b' var IPython = (function (IPython) {' | |||
|
613 | 649 | |
|
614 | 650 | |
|
615 | 651 | Notebook.prototype.restart_kernel = function () { |
|
652 | var that = this; | |
|
616 | 653 | var notebook_id = IPython.save_widget.get_notebook_id(); |
|
617 | this.kernel.restart($.proxy(this.kernel_started, this)); | |
|
654 | ||
|
655 | var dialog = $('<div/>'); | |
|
656 | dialog.html('Do you want to restart the current kernel? You will lose all variables defined in it.'); | |
|
657 | $(document).append(dialog); | |
|
658 | dialog.dialog({ | |
|
659 | resizable: false, | |
|
660 | modal: true, | |
|
661 | title: "Restart kernel or continue running?", | |
|
662 | buttons : { | |
|
663 | "Restart": function () { | |
|
664 | that.kernel.restart($.proxy(that.kernel_started, that)); | |
|
665 | $(this).dialog('close'); | |
|
666 | }, | |
|
667 | "Continue running": function () { | |
|
668 | $(this).dialog('close'); | |
|
669 | } | |
|
670 | } | |
|
671 | }); | |
|
618 | 672 | }; |
|
619 | 673 | |
|
620 | 674 | |
@@ -694,11 +748,11 b' var IPython = (function (IPython) {' | |||
|
694 | 748 | modal: true, |
|
695 | 749 | title: "Dead kernel", |
|
696 | 750 | buttons : { |
|
697 |
" |
|
|
751 | "Restart": function () { | |
|
698 | 752 | that.start_kernel(); |
|
699 | 753 | $(this).dialog('close'); |
|
700 | 754 | }, |
|
701 |
" |
|
|
755 | "Continue running": function () { | |
|
702 | 756 | $(this).dialog('close'); |
|
703 | 757 | } |
|
704 | 758 | } |
@@ -32,6 +32,7 b' $(document).ready(function () {' | |||
|
32 | 32 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); |
|
33 | 33 | IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter'); |
|
34 | 34 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); |
|
35 | IPython.quick_help = new IPython.QuickHelp('span#quick_help_area'); | |
|
35 | 36 | IPython.print_widget = new IPython.PrintWidget('span#print_widget'); |
|
36 | 37 | IPython.notebook = new IPython.Notebook('div#notebook'); |
|
37 | 38 | IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); |
@@ -56,13 +56,16 b'' | |||
|
56 | 56 | <span id="notebook_id" style="display:none">{{notebook_id}}</span> |
|
57 | 57 | <button id="save_notebook"><u>S</u>ave</button> |
|
58 | 58 | </span> |
|
59 | <span id="quick_help_area"> | |
|
60 | <button id="quick_help">Quick<u>H</u>elp</button> | |
|
61 | </span> | |
|
59 | 62 | <span id="kernel_status">Idle</span> |
|
60 | 63 | </div> |
|
61 | 64 | |
|
62 | 65 | <div id="MathJaxFetchingWarning" |
|
63 | 66 | style="width:80%; margin:auto;padding-top:20%;text-align: justify; display:none"> |
|
64 | 67 | <p style="font-size:26px;">There was an issue trying to fetch MathJax.js |
|
65 |
|
|
|
68 | from the internet.</p> | |
|
66 | 69 | |
|
67 | 70 | <p style="padding:0.2em"> With a working internet connection, you can run |
|
68 | 71 | the following at a Python or IPython prompt, which will install a local |
@@ -176,7 +179,7 b'' | |||
|
176 | 179 | <div class="section_content"> |
|
177 | 180 | <div class="section_row"> |
|
178 | 181 | <span id="int_restart" class="section_row_buttons"> |
|
179 | <button id="int_kernel">Interrupt</button> | |
|
182 | <button id="int_kernel"><u>I</u>nterrupt</button> | |
|
180 | 183 | <button id="restart_kernel">Restart</button> |
|
181 | 184 | </span> |
|
182 | 185 | <span class="section_row_header">Actions</span> |
@@ -217,7 +220,7 b'' | |||
|
217 | 220 | <span class="help_string_label">Shift-Enter :</span> |
|
218 | 221 | </div> |
|
219 | 222 | <div class="section_row"> |
|
220 |
<span class="help_string">run |
|
|
223 | <span class="help_string">run selected cell in-place</span> | |
|
221 | 224 | <span class="help_string_label">Ctrl-Enter :</span> |
|
222 | 225 | </div> |
|
223 | 226 | <div class="section_row"> |
@@ -263,6 +266,7 b'' | |||
|
263 | 266 | <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script> |
|
264 | 267 | <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script> |
|
265 | 268 | <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script> |
|
269 | <script src="static/js/quickhelp.js" type="text/javascript" charset="utf-8"></script> | |
|
266 | 270 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> |
|
267 | 271 | <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script> |
|
268 | 272 | <script src="static/js/printwidget.js" type="text/javascript" charset="utf-8"></script> |
@@ -274,5 +278,3 b'' | |||
|
274 | 278 | </body> |
|
275 | 279 | |
|
276 | 280 | </html> |
|
277 | ||
|
278 |
General Comments 0
You need to be logged in to leave comments.
Login now