From 5519c01de33ee5e53df8ed2056b02abf7b2b1211 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Wed, 27 Jul 2011 09:13:29 -0700 Subject: [PATCH] CTRL-ENTER now runs a cell in "terminal mode" In this mode, a new cell is not created after the current cell is run. Once the cell is run, the current input is cleared, so it acts just like the terminal. --- IPython/frontend/html/notebook/static/js/codecell.js | 5 +++++ IPython/frontend/html/notebook/static/js/notebook.js | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 309506c4d..587087f6a 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -228,6 +228,11 @@ var IPython = (function (IPython) { }; + CodeCell.prototype.clear_input = function () { + this.code_mirror.setValue(''); + }; + + CodeCell.prototype.collapse = function () { this.element.find('div.output').hide(); }; diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 8c9a7a0a5..a3947474b 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -59,6 +59,10 @@ var IPython = (function (IPython) { } else if (event.which === 13 && event.shiftKey) { that.execute_selected_cell(true); return false; + } else if (event.which === 13 && event.ctrlKey) { + that.execute_selected_cell(false); + that.selected_cell().clear_input(); + return false; }; });