Show More
@@ -48,9 +48,10 b' var IPython = (function (IPython) {' | |||||
48 |
|
48 | |||
49 |
|
49 | |||
50 | CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) { |
|
50 | CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) { | |
51 |
// This method gets called in CodeMirror's onKeyDown/onKeyPress |
|
51 | // This method gets called in CodeMirror's onKeyDown/onKeyPress | |
52 |
// is used to provide custom key handling. Its return |
|
52 | // handlers and is used to provide custom key handling. Its return | |
53 |
// if CodeMirror should ignore the event: |
|
53 | // value is used to determine if CodeMirror should ignore the event: | |
|
54 | // true = ignore, false = don't ignore. | |||
54 | if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { |
|
55 | if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) { | |
55 | // Always ignore shift-enter in CodeMirror as we handle it. |
|
56 | // Always ignore shift-enter in CodeMirror as we handle it. | |
56 | return true; |
|
57 | return true; | |
@@ -59,8 +60,8 b' var IPython = (function (IPython) {' | |||||
59 | var cur = editor.getCursor(); |
|
60 | var cur = editor.getCursor(); | |
60 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim(); |
|
61 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur).trim(); | |
61 | if (pre_cursor === "") { |
|
62 | if (pre_cursor === "") { | |
62 |
// Don't autocomplete if the part of the line before the cursor |
|
63 | // Don't autocomplete if the part of the line before the cursor | |
63 | // In this case, let CodeMirror handle indentation. |
|
64 | // is empty. In this case, let CodeMirror handle indentation. | |
64 | return false; |
|
65 | return false; | |
65 | } else { |
|
66 | } else { | |
66 | // Autocomplete the current line. |
|
67 | // Autocomplete the current line. | |
@@ -86,9 +87,19 b' var IPython = (function (IPython) {' | |||||
86 | } else { |
|
87 | } else { | |
87 | return false; |
|
88 | return false; | |
88 | }; |
|
89 | }; | |
89 | } else { |
|
90 | } else if (event.keyCode === 76 && event.ctrlKey && event.shiftKey | |
90 | // keypress/keyup also trigger on TAB press, and we don't want to use those |
|
91 | && event.type == 'keydown') { | |
91 | // to disable tab completion. |
|
92 | // toggle line numbers with Ctrl-Shift-L | |
|
93 | if (this.code_mirror.getOption('lineNumbers') == false) { | |||
|
94 | this.code_mirror.setOption('lineNumbers', true); | |||
|
95 | } else { | |||
|
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 | if (this.is_completing && event.keyCode !== 9) { |
|
103 | if (this.is_completing && event.keyCode !== 9) { | |
93 | var ed_cur = editor.getCursor(); |
|
104 | var ed_cur = editor.getCursor(); | |
94 | var cc_cur = this.completion_cursor; |
|
105 | var cc_cur = this.completion_cursor; | |
@@ -470,4 +481,3 b' var IPython = (function (IPython) {' | |||||
470 |
|
481 | |||
471 | return IPython; |
|
482 | return IPython; | |
472 | }(IPython)); |
|
483 | }(IPython)); | |
473 |
|
@@ -186,6 +186,7 b' var IPython = (function (IPython) {' | |||||
186 | var shortcuts = [ |
|
186 | var shortcuts = [ | |
187 | {key: 'Shift-Enter', help: 'run cell'}, |
|
187 | {key: 'Shift-Enter', help: 'run cell'}, | |
188 | {key: 'Ctrl-Enter', help: 'run cell in terminal mode'}, |
|
188 | {key: 'Ctrl-Enter', help: 'run cell in terminal mode'}, | |
|
189 | {key: 'Ctrl-Shift-L', help: 'toggle line numbering'}, | |||
189 | {key: 'Ctrl-m d', help: 'delete cell'}, |
|
190 | {key: 'Ctrl-m d', help: 'delete cell'}, | |
190 | {key: 'Ctrl-m a', help: 'insert cell above'}, |
|
191 | {key: 'Ctrl-m a', help: 'insert cell above'}, | |
191 | {key: 'Ctrl-m b', help: 'insert cell below'}, |
|
192 | {key: 'Ctrl-m b', help: 'insert cell below'}, |
General Comments 0
You need to be logged in to leave comments.
Login now