##// END OF EJS Templates
Special handling for CM's vim keyboard mapping.
Brian E. Granger -
Show More
@@ -172,8 +172,9 b' var IPython = (function (IPython) {'
172 172 var that = this;
173 173 // whatever key is pressed, first, cancel the tooltip request before
174 174 // they are sent, and remove tooltip if any, except for tab again
175 var tooltip_closed = null;
175 176 if (event.type === 'keydown' && event.which != key.TAB ) {
176 IPython.tooltip.remove_and_cancel_tooltip();
177 tooltip_closed = IPython.tooltip.remove_and_cancel_tooltip();
177 178 }
178 179
179 180 var cur = editor.getCursor();
@@ -200,8 +201,32 b' var IPython = (function (IPython) {'
200 201 } else {
201 202 return true;
202 203 }
203 } else if (event.which === key.ESC) {
204 return IPython.tooltip.remove_and_cancel_tooltip(true);
204 } else if (event.which === key.ESC && event.type === 'keydown') {
205 // First see if the tooltip is active and if so cancel it.
206 if (tooltip_closed) {
207 // The call to remove_and_cancel_tooltip above in L177 doesn't pass
208 // force=true. Because of this it won't actually close the tooltip
209 // if it is in sticky mode. Thus, we have to check again if it is open
210 // and close it with force=true.
211 if (!IPython.tooltip._hidden) {
212 IPython.tooltip.remove_and_cancel_tooltip(true);
213 }
214 // If we closed the tooltip, don't let CM or the global handlers
215 // handle this event.
216 event.stop();
217 return true;
218 }
219 if (that.code_mirror.options.keyMap === "vim-insert") {
220 // vim keyMap is active and in insert mode. In this case we leave vim
221 // insert mode, but remain in notebook edit mode.
222 // Let' CM handle this event and prevent global handling.
223 event.stop();
224 return false;
225 } else {
226 // vim keyMap is not active. Leave notebook edit mode.
227 // Don't let CM handle the event, defer to global handling.
228 return true;
229 }
205 230 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
206 231 // If we are not at the bottom, let CM handle the down arrow and
207 232 // prevent the global keydown handler from handling it.
@@ -211,7 +236,7 b' var IPython = (function (IPython) {'
211 236 } else {
212 237 return true;
213 238 }
214 } else if (event.keyCode === key.TAB && event.type == 'keydown' && event.shiftKey) {
239 } else if (event.keyCode === key.TAB && event.type === 'keydown' && event.shiftKey) {
215 240 if (editor.somethingSelected()){
216 241 var anchor = editor.getCursor("anchor");
217 242 var head = editor.getCursor("head");
@@ -155,6 +155,18 b' var IPython = (function (IPython) {'
155 155 } else {
156 156 return true;
157 157 };
158 } else if (event.which === key.ESC && event.type === 'keydown') {
159 if (that.code_mirror.options.keyMap === "vim-insert") {
160 // vim keyMap is active and in insert mode. In this case we leave vim
161 // insert mode, but remain in notebook edit mode.
162 // Let' CM handle this event and prevent global handling.
163 event.stop();
164 return false;
165 } else {
166 // vim keyMap is not active. Leave notebook edit mode.
167 // Don't let CM handle the event, defer to global handling.
168 return true;
169 }
158 170 }
159 171 return false;
160 172 };
General Comments 0
You need to be logged in to leave comments. Login now