From a8955791887e52f7f3abdaeb479924cdf0a160cf 2014-03-08 01:48:34 From: Paul Ivanov Date: 2014-03-08 01:48:34 Subject: [PATCH] up and down keys no longer need special casing --- diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 469e6a2..daf1001 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -174,28 +174,7 @@ var IPython = (function (IPython) { // if this is an edit_shortcuts shortcut, we've already handled it. if (shortcuts.use_shortcut(event)) { return true; } - if (event.keyCode === keycodes.enter && (event.shiftKey || event.ctrlKey || event.altKey)) { - // Always ignore shift-enter in CodeMirror as we handle it. - return true; - } else if (event.which === keycodes.up && event.type === 'keydown') { - // If we are not at the top, let CM handle the up arrow and - // prevent the global keydown handler from handling it. - if (!that.at_top()) { - event.stop(); - return false; - } else { - return true; - }; - } else if (event.which === keycodes.down && event.type === 'keydown') { - // If we are not at the bottom, let CM handle the down arrow and - // prevent the global keydown handler from handling it. - if (!that.at_bottom()) { - event.stop(); - return false; - } else { - return true; - }; - } else if (event.which === keycodes.esc && event.type === 'keydown') { + if (event.which === keycodes.esc && event.type === 'keydown') { if (that.code_mirror.options.keyMap === "vim-insert") { // vim keyMap is active and in insert mode. In this case we leave vim // insert mode, but remain in notebook edit mode. diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index d9c3145..9e78cdd 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -108,6 +108,11 @@ var IPython = (function (IPython) { IPython.notebook.select_prev(); IPython.notebook.edit_mode(); return false; + } else if (cell) { + var cm = cell.code_mirror + var cursor = cm.getCursor() + cursor.line -= 1 + cm.setCursor(cursor); } } } @@ -125,6 +130,11 @@ var IPython = (function (IPython) { IPython.notebook.select_next(); IPython.notebook.edit_mode(); return false; + } else if (cell) { + var cm = cell.code_mirror + var cursor = cm.getCursor() + cursor.line += 1 + cm.setCursor(cursor); } } }