From 6a2c4121f989d64b9cc4d775cade051678cf7434 Mon Sep 17 00:00:00 2001 From: Paul Ivanov Date: Fri, 7 Mar 2014 17:27:27 -0800 Subject: [PATCH] up and down keys no longer need special casing --- IPython/html/static/notebook/js/cell.js | 23 +------------------ .../static/notebook/js/keyboardmanager.js | 10 ++++++++ 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 469e6a205..daf1001de 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 d9c314542..9e78cdd8a 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); } } }