From a2665ef3418adc988c6ac4aaaec7d5c74cfa2d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20V=C3=B6r=C3=B6s?= Date: Tue, 3 Jul 2012 20:55:02 +0200 Subject: [PATCH 1/4] Added new short key for cell execution --- IPython/frontend/html/notebook/static/js/notebook.js | 4 ++++ IPython/frontend/html/notebook/static/js/quickhelp.js | 1 + 2 files changed, 5 insertions(+) diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 88bc6c832..3ff730f0f 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -114,6 +114,10 @@ var IPython = (function (IPython) { } else if (event.which === key.ENTER && event.shiftKey) { that.execute_selected_cell(); return false; + } else if (event.which === key.ENTER && event.altKey) { + that.execute_selected_cell(); + that.insert_cell_above('code'); + return false; } else if (event.which === key.ENTER && event.ctrlKey) { that.execute_selected_cell({terminal:true}); return false; diff --git a/IPython/frontend/html/notebook/static/js/quickhelp.js b/IPython/frontend/html/notebook/static/js/quickhelp.js index d609e704b..e88df2f33 100644 --- a/IPython/frontend/html/notebook/static/js/quickhelp.js +++ b/IPython/frontend/html/notebook/static/js/quickhelp.js @@ -28,6 +28,7 @@ var IPython = (function (IPython) { var shortcuts = [ {key: 'Shift-Enter', help: 'run cell'}, {key: 'Ctrl-Enter', help: 'run cell in-place'}, + {key: 'Alt-Enter', help: 'run cell, insert below'}, {key: 'Ctrl-m x', help: 'cut cell'}, {key: 'Ctrl-m c', help: 'copy cell'}, {key: 'Ctrl-m v', help: 'paste cell'}, From eb47f0eb8db5cb5d45537b2f593a82f1b7285ca8 Mon Sep 17 00:00:00 2001 From: v923z Date: Thu, 19 Jul 2012 22:35:38 +0300 Subject: [PATCH 2/4] Added some comments to the Alt-Enter code part, and also added checking whether a new code cell is really needed. --- IPython/frontend/html/notebook/static/js/notebook.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 3ff730f0f..39f61e857 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -115,8 +115,12 @@ var IPython = (function (IPython) { that.execute_selected_cell(); return false; } else if (event.which === key.ENTER && event.altKey) { + // Execute code cell, and insert new in place that.execute_selected_cell(); - that.insert_cell_above('code'); + // Only insert a new cell, if we ended up in an already populated cell + if (that.get_selected_cell().toJSON().input !== "") { + that.insert_cell_above('code'); + } return false; } else if (event.which === key.ENTER && event.ctrlKey) { that.execute_selected_cell({terminal:true}); From 0e4dbb28800ded4e17d300d2ed4510d4ee344f9c Mon Sep 17 00:00:00 2001 From: v923z Date: Fri, 20 Jul 2012 15:03:33 +0300 Subject: [PATCH 3/4] Added checking for emptiness of cell below. --- IPython/frontend/html/notebook/static/js/notebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 39f61e857..9a8e84823 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -118,7 +118,7 @@ var IPython = (function (IPython) { // Execute code cell, and insert new in place that.execute_selected_cell(); // Only insert a new cell, if we ended up in an already populated cell - if (that.get_selected_cell().toJSON().input !== "") { + if (/\S/.test(that.get_selected_cell().toJSON().input) == true) { that.insert_cell_above('code'); } return false; From eaf53eeb9a7bc4a4f046a13f3cc53659045729cb Mon Sep 17 00:00:00 2001 From: v923z Date: Fri, 20 Jul 2012 16:07:23 +0300 Subject: [PATCH 4/4] Replaced .toJSON().input by .get_text() --- IPython/frontend/html/notebook/static/js/notebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 9a8e84823..bc0bb78d6 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -118,7 +118,7 @@ var IPython = (function (IPython) { // Execute code cell, and insert new in place that.execute_selected_cell(); // Only insert a new cell, if we ended up in an already populated cell - if (/\S/.test(that.get_selected_cell().toJSON().input) == true) { + if (/\S/.test(that.get_selected_cell().get_text()) == true) { that.insert_cell_above('code'); } return false;