Show More
@@ -13,6 +13,7 b' var IPython = (function (IPython) {' | |||||
13 | "use strict"; |
|
13 | "use strict"; | |
14 |
|
14 | |||
15 | var utils = IPython.utils; |
|
15 | var utils = IPython.utils; | |
|
16 | var key = IPython.utils.keycodes; | |||
16 |
|
17 | |||
17 | var CodeCell = function (notebook) { |
|
18 | var CodeCell = function (notebook) { | |
18 | this.code_mirror = null; |
|
19 | this.code_mirror = null; | |
@@ -101,7 +102,7 b' var IPython = (function (IPython) {' | |||||
101 | var cursor = editor.getCursor(); |
|
102 | var cursor = editor.getCursor(); | |
102 | var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'('; |
|
103 | var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'('; | |
103 | that.request_tooltip_after_time(pre_cursor,tooltip_wait_time); |
|
104 | that.request_tooltip_after_time(pre_cursor,tooltip_wait_time); | |
104 |
} else if (event.which === |
|
105 | } else if (event.which === key.upArrow) { | |
105 | // If we are not at the top, let CM handle the up arrow and |
|
106 | // If we are not at the top, let CM handle the up arrow and | |
106 | // prevent the global keydown handler from handling it. |
|
107 | // prevent the global keydown handler from handling it. | |
107 | if (!that.at_top()) { |
|
108 | if (!that.at_top()) { | |
@@ -110,7 +111,7 b' var IPython = (function (IPython) {' | |||||
110 | } else { |
|
111 | } else { | |
111 | return true; |
|
112 | return true; | |
112 | }; |
|
113 | }; | |
113 |
} else if (event.which === |
|
114 | } else if (event.which === key.downArrow) { | |
114 | // If we are not at the bottom, let CM handle the down arrow and |
|
115 | // If we are not at the bottom, let CM handle the down arrow and | |
115 | // prevent the global keydown handler from handling it. |
|
116 | // prevent the global keydown handler from handling it. | |
116 | if (!that.at_bottom()) { |
|
117 | if (!that.at_bottom()) { | |
@@ -119,7 +120,7 b' var IPython = (function (IPython) {' | |||||
119 | } else { |
|
120 | } else { | |
120 | return true; |
|
121 | return true; | |
121 | }; |
|
122 | }; | |
122 |
} else if (event.keyCode === |
|
123 | } else if (event.keyCode === key.tab && event.type == 'keydown') { | |
123 | // Tab completion. |
|
124 | // Tab completion. | |
124 | var cur = editor.getCursor(); |
|
125 | var cur = editor.getCursor(); | |
125 | //Do not trim here because of tooltip |
|
126 | //Do not trim here because of tooltip | |
@@ -139,7 +140,7 b' var IPython = (function (IPython) {' | |||||
139 | this.completer.startCompletion(); |
|
140 | this.completer.startCompletion(); | |
140 | return true; |
|
141 | return true; | |
141 | }; |
|
142 | }; | |
142 |
} else if (event.keyCode === |
|
143 | } else if (event.keyCode === key.backspace && event.type == 'keydown') { | |
143 | // If backspace and the line ends with 4 spaces, remove them. |
|
144 | // If backspace and the line ends with 4 spaces, remove them. | |
144 | var cur = editor.getCursor(); |
|
145 | var cur = editor.getCursor(); | |
145 | var line = editor.getLine(cur.line); |
|
146 | var line = editor.getLine(cur.line); | |
@@ -157,7 +158,7 b' var IPython = (function (IPython) {' | |||||
157 | } else { |
|
158 | } else { | |
158 | // keypress/keyup also trigger on TAB press, and we don't want to |
|
159 | // keypress/keyup also trigger on TAB press, and we don't want to | |
159 | // use those to disable tab completion. |
|
160 | // use those to disable tab completion. | |
160 |
if (this.is_completing && event.keyCode !== |
|
161 | if (this.is_completing && event.keyCode !== key.tab) { | |
161 | var ed_cur = editor.getCursor(); |
|
162 | var ed_cur = editor.getCursor(); | |
162 | var cc_cur = this.completion_cursor; |
|
163 | var cc_cur = this.completion_cursor; | |
163 | if (ed_cur.line !== cc_cur.line || ed_cur.ch !== cc_cur.ch) { |
|
164 | if (ed_cur.line !== cc_cur.line || ed_cur.ch !== cc_cur.ch) { |
@@ -91,11 +91,29 b' IPython.utils = (function (IPython) {' | |||||
91 | } |
|
91 | } | |
92 | }; |
|
92 | }; | |
93 |
|
93 | |||
|
94 | // some keycodes that seem to be platform/browser independant | |||
|
95 | var keycodes ={ | |||
|
96 | backspace: 8, | |||
|
97 | tab : 9, | |||
|
98 | enter : 13, | |||
|
99 | shift : 16, | |||
|
100 | esc : 27, | |||
|
101 | space : 32, | |||
|
102 | pgUp : 33, | |||
|
103 | pgDown : 34, | |||
|
104 | leftArrow: 37, | |||
|
105 | left : 37, | |||
|
106 | upArrow : 38, | |||
|
107 | rightArrow:39, | |||
|
108 | right : 39, | |||
|
109 | downArrow: 40, | |||
|
110 | }; | |||
94 |
|
111 | |||
95 | return { |
|
112 | return { | |
96 | uuid : uuid, |
|
113 | uuid : uuid, | |
97 | fixConsole : fixConsole, |
|
114 | fixConsole : fixConsole, | |
98 | grow : grow |
|
115 | keycodes : keycodes, | |
|
116 | grow : grow, | |||
99 | }; |
|
117 | }; | |
100 |
|
118 | |||
101 | }(IPython)); |
|
119 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now