Show More
@@ -1,73 +1,73 | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | //---------------------------------------------------------------------------- | |
2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
2 | // Copyright (C) 2008-2011 The IPython Development Team | |
3 | // |
|
3 | // | |
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | // Distributed under the terms of the BSD License. The full license is in | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | // the file COPYING, distributed as part of this software. | |
6 | //---------------------------------------------------------------------------- |
|
6 | //---------------------------------------------------------------------------- | |
7 |
|
7 | |||
8 | //============================================================================ |
|
8 | //============================================================================ | |
9 | // QuickHelp button |
|
9 | // QuickHelp button | |
10 | //============================================================================ |
|
10 | //============================================================================ | |
11 |
|
11 | |||
12 | var IPython = (function (IPython) { |
|
12 | var IPython = (function (IPython) { | |
13 |
|
13 | |||
14 | var QuickHelp = function (selector) { |
|
14 | var QuickHelp = function (selector) { | |
15 | }; |
|
15 | }; | |
16 |
|
16 | |||
17 | QuickHelp.prototype.show_keyboard_shortcuts = function () { |
|
17 | QuickHelp.prototype.show_keyboard_shortcuts = function () { | |
18 | // toggles display of keyboard shortcut dialog |
|
18 | // toggles display of keyboard shortcut dialog | |
19 | var that = this; |
|
19 | var that = this; | |
20 | if ( this.shortcut_dialog ){ |
|
20 | if ( this.shortcut_dialog ){ | |
21 | // if dialog is already shown, close it |
|
21 | // if dialog is already shown, close it | |
22 | this.shortcut_dialog.dialog("close"); |
|
22 | this.shortcut_dialog.dialog("close"); | |
23 | this.shortcut_dialog = null; |
|
23 | this.shortcut_dialog = null; | |
24 | return; |
|
24 | return; | |
25 | } |
|
25 | } | |
26 | var dialog = $('<div/>'); |
|
26 | var dialog = $('<div/>'); | |
27 | this.shortcut_dialog = dialog; |
|
27 | this.shortcut_dialog = dialog; | |
28 | var shortcuts = [ |
|
28 | var shortcuts = [ | |
29 | {key: 'Shift-Enter', help: 'run cell'}, |
|
29 | {key: 'Shift-Enter', help: 'run cell'}, | |
30 | {key: 'Ctrl-Enter', help: 'run cell in-place'}, |
|
30 | {key: 'Ctrl-Enter', help: 'run cell in-place'}, | |
31 | {key: 'Alt-Enter', help: 'run cell, insert below'}, |
|
31 | {key: 'Alt-Enter', help: 'run cell, insert below'}, | |
32 | {key: 'Ctrl-m x', help: 'cut cell'}, |
|
32 | {key: 'Ctrl-m x', help: 'cut cell'}, | |
33 | {key: 'Ctrl-m c', help: 'copy cell'}, |
|
33 | {key: 'Ctrl-m c', help: 'copy cell'}, | |
34 | {key: 'Ctrl-m v', help: 'paste cell'}, |
|
34 | {key: 'Ctrl-m v', help: 'paste cell'}, | |
35 | {key: 'Ctrl-m d', help: 'delete cell'}, |
|
35 | {key: 'Ctrl-m d', help: 'delete cell'}, | |
|
36 | {key: 'Ctrl-m z', help: 'undo last cell deletion'}, | |||
36 | {key: 'Ctrl-m a', help: 'insert cell above'}, |
|
37 | {key: 'Ctrl-m a', help: 'insert cell above'}, | |
37 | {key: 'Ctrl-m b', help: 'insert cell below'}, |
|
38 | {key: 'Ctrl-m b', help: 'insert cell below'}, | |
38 | {key: 'Ctrl-m o', help: 'toggle output'}, |
|
39 | {key: 'Ctrl-m o', help: 'toggle output'}, | |
39 | {key: 'Ctrl-m O', help: 'toggle output scroll'}, |
|
40 | {key: 'Ctrl-m O', help: 'toggle output scroll'}, | |
40 | {key: 'Ctrl-m l', help: 'toggle line numbers'}, |
|
41 | {key: 'Ctrl-m l', help: 'toggle line numbers'}, | |
41 | {key: 'Ctrl-m s', help: 'save notebook'}, |
|
42 | {key: 'Ctrl-m s', help: 'save notebook'}, | |
42 | {key: 'Ctrl-m j', help: 'move cell down'}, |
|
43 | {key: 'Ctrl-m j', help: 'move cell down'}, | |
43 | {key: 'Ctrl-m k', help: 'move cell up'}, |
|
44 | {key: 'Ctrl-m k', help: 'move cell up'}, | |
44 | {key: 'Ctrl-m y', help: 'code cell'}, |
|
45 | {key: 'Ctrl-m y', help: 'code cell'}, | |
45 | {key: 'Ctrl-m m', help: 'markdown cell'}, |
|
46 | {key: 'Ctrl-m m', help: 'markdown cell'}, | |
46 | {key: 'Ctrl-m t', help: 'raw cell'}, |
|
47 | {key: 'Ctrl-m t', help: 'raw cell'}, | |
47 | {key: 'Ctrl-m 1-6', help: 'heading 1-6 cell'}, |
|
48 | {key: 'Ctrl-m 1-6', help: 'heading 1-6 cell'}, | |
48 | {key: 'Ctrl-m p', help: 'select previous'}, |
|
49 | {key: 'Ctrl-m p', help: 'select previous'}, | |
49 | {key: 'Ctrl-m n', help: 'select next'}, |
|
50 | {key: 'Ctrl-m n', help: 'select next'}, | |
50 | {key: 'Ctrl-m i', help: 'interrupt kernel'}, |
|
51 | {key: 'Ctrl-m i', help: 'interrupt kernel'}, | |
51 | {key: 'Ctrl-m .', help: 'restart kernel'}, |
|
52 | {key: 'Ctrl-m .', help: 'restart kernel'}, | |
52 |
{key: 'Ctrl-m h', help: 'show keyboard shortcuts'} |
|
53 | {key: 'Ctrl-m h', help: 'show keyboard shortcuts'} | |
53 | {key: 'Ctrl-m z', help: 'undo last cell deletion'} |
|
|||
54 | ]; |
|
54 | ]; | |
55 | for (var i=0; i<shortcuts.length; i++) { |
|
55 | for (var i=0; i<shortcuts.length; i++) { | |
56 | dialog.append($('<div>'). |
|
56 | dialog.append($('<div>'). | |
57 | append($('<span/>').addClass('shortcut_key').html(shortcuts[i].key)). |
|
57 | append($('<span/>').addClass('shortcut_key').html(shortcuts[i].key)). | |
58 | append($('<span/>').addClass('shortcut_descr').html(' : ' + shortcuts[i].help)) |
|
58 | append($('<span/>').addClass('shortcut_descr').html(' : ' + shortcuts[i].help)) | |
59 | ); |
|
59 | ); | |
60 | }; |
|
60 | }; | |
61 | dialog.bind('dialogclose', function(event) { |
|
61 | dialog.bind('dialogclose', function(event) { | |
62 | // dialog has been closed, allow it to be drawn again. |
|
62 | // dialog has been closed, allow it to be drawn again. | |
63 | that.shortcut_dialog = null; |
|
63 | that.shortcut_dialog = null; | |
64 | }); |
|
64 | }); | |
65 | dialog.dialog({title: 'Keyboard shortcuts', closeText: ''}); |
|
65 | dialog.dialog({title: 'Keyboard shortcuts', closeText: ''}); | |
66 | }; |
|
66 | }; | |
67 |
|
67 | |||
68 | // Set module variables |
|
68 | // Set module variables | |
69 | IPython.QuickHelp = QuickHelp; |
|
69 | IPython.QuickHelp = QuickHelp; | |
70 |
|
70 | |||
71 | return IPython; |
|
71 | return IPython; | |
72 |
|
72 | |||
73 | }(IPython)); |
|
73 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now