Show More
@@ -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,19 b' var IPython = (function (IPython) {' | |||
|
86 | 87 | } else { |
|
87 | 88 | return false; |
|
88 | 89 | }; |
|
90 | } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey | |
|
91 | && event.type == 'keydown') { | |
|
92 | // toggle line numbers with Ctrl-Shift-L | |
|
93 | if (this.code_mirror.getOption('lineNumbers') == false) { | |
|
94 | this.code_mirror.setOption('lineNumbers', true); | |
|
89 | 95 |
|
|
90 | // keypress/keyup also trigger on TAB press, and we don't want to use those | |
|
91 | // to disable tab completion. | |
|
96 | this.code_mirror.setOption('lineNumbers', false); | |
|
97 | } | |
|
98 | this.code_mirror.refresh() | |
|
99 | } | |
|
100 | else { | |
|
101 | // keypress/keyup also trigger on TAB press, and we don't want to | |
|
102 | // use those to disable tab completion. | |
|
92 | 103 | if (this.is_completing && event.keyCode !== 9) { |
|
93 | 104 | var ed_cur = editor.getCursor(); |
|
94 | 105 | var cc_cur = this.completion_cursor; |
@@ -470,4 +481,3 b' var IPython = (function (IPython) {' | |||
|
470 | 481 | |
|
471 | 482 | return IPython; |
|
472 | 483 | }(IPython)); |
|
473 |
@@ -186,6 +186,7 b' var IPython = (function (IPython) {' | |||
|
186 | 186 | var shortcuts = [ |
|
187 | 187 | {key: 'Shift-Enter', help: 'run cell'}, |
|
188 | 188 | {key: 'Ctrl-Enter', help: 'run cell in terminal mode'}, |
|
189 | {key: 'Ctrl-Shift-L', help: 'toggle line numbering'}, | |
|
189 | 190 | {key: 'Ctrl-m d', help: 'delete cell'}, |
|
190 | 191 | {key: 'Ctrl-m a', help: 'insert cell above'}, |
|
191 | 192 | {key: 'Ctrl-m b', help: 'insert cell below'}, |
General Comments 0
You need to be logged in to leave comments.
Login now