From b5f259d1f607820cd838ceefd8f885aa30478ae5 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Tue, 28 Jan 2014 20:05:29 -0800 Subject: [PATCH 1/5] Don't enter edit mode when changing cell type and preserve renderd. --- IPython/html/static/notebook/js/notebook.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 61c80e9f330..6db709905c3 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -847,7 +847,6 @@ var IPython = (function (IPython) { target_cell.code_mirror.clearHistory(); source_element.remove(); this.select(i); - this.edit_mode(); this.set_dirty(true); }; }; @@ -878,7 +877,9 @@ var IPython = (function (IPython) { target_cell.code_mirror.clearHistory(); source_element.remove(); this.select(i); - this.edit_mode(); + if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) { + target_cell.render(); + } this.set_dirty(true); }; }; @@ -910,7 +911,6 @@ var IPython = (function (IPython) { target_cell.code_mirror.clearHistory(); source_element.remove(); this.select(i); - this.edit_mode(); this.set_dirty(true); }; }; @@ -947,8 +947,10 @@ var IPython = (function (IPython) { target_cell.code_mirror.clearHistory(); source_element.remove(); this.select(i); + if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) { + target_cell.render(); + } }; - this.edit_mode(); this.set_dirty(true); $([IPython.events]).trigger('selected_cell_type_changed.Notebook', {'cell_type':'heading',level:level} From fd0f68e1bec22d9fb0b57d564e0dbe48e6d00e67 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Tue, 28 Jan 2014 20:14:11 -0800 Subject: [PATCH 2/5] alt+enter should always insert below --- IPython/html/static/notebook/js/notebook.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 6db709905c3..729557c7219 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -1443,11 +1443,7 @@ var IPython = (function (IPython) { return; } - // Only insert a new cell, if we ended up in an already populated cell - var next_text = this.get_cell(cell_index+1).get_text(); - if (/\S/.test(next_text) === true) { - this.insert_cell_below('code'); - } + this.insert_cell_below('code'); this.select(cell_index+1); this.edit_mode(); this.set_dirty(true); From 1f2335e522beb9660c504269c643eab5862f09b2 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Tue, 28 Jan 2014 20:16:50 -0800 Subject: [PATCH 3/5] shift+enter and ctrl+enter swapped. --- IPython/html/static/notebook/js/keyboardmanager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index 1e6a50cdd52..675bf886f29 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -91,7 +91,7 @@ var IPython = (function (IPython) { help : 'run cell', help_index : 'ba', handler : function (event) { - IPython.notebook.execute_cell(); + IPython.notebook.execute_cell_and_select_below(); return false; } }, @@ -99,7 +99,7 @@ var IPython = (function (IPython) { help : 'run cell, select below', help_index : 'bb', handler : function (event) { - IPython.notebook.execute_cell_and_select_below(); + IPython.notebook.execute_cell(); return false; } }, From dd93fddecb8a0b93c95e0534a56d5c665a7b3e46 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Wed, 29 Jan 2014 21:40:52 -0800 Subject: [PATCH 4/5] Fixing help strings for shift|ctrl+enter. --- IPython/html/static/notebook/js/keyboardmanager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index 675bf886f29..5a8c3bcc823 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -88,7 +88,7 @@ var IPython = (function (IPython) { } }, 'shift+enter' : { - help : 'run cell', + help : 'run cell, select below', help_index : 'ba', handler : function (event) { IPython.notebook.execute_cell_and_select_below(); @@ -96,7 +96,7 @@ var IPython = (function (IPython) { } }, 'ctrl+enter' : { - help : 'run cell, select below', + help : 'run cell', help_index : 'bb', handler : function (event) { IPython.notebook.execute_cell(); From 0a3461f4700dccb4ec7fdc98fd56c75e4b2da24d Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Thu, 30 Jan 2014 12:53:52 -0800 Subject: [PATCH 5/5] Fixing tests from shift and ctrl enter swap. --- .../html/tests/casperjs/test_cases/execute_code_cell.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js index 5a415dcf53c..14db3577faf 100644 --- a/IPython/html/tests/casperjs/test_cases/execute_code_cell.js +++ b/IPython/html/tests/casperjs/test_cases/execute_code_cell.js @@ -22,7 +22,7 @@ casper.notebook_test(function () { var cell = IPython.notebook.get_cell(0); cell.set_text('a=11; print(a)'); cell.clear_output(); - IPython.utils.press_ctrl_enter(); + IPython.utils.press_shift_enter(); }); this.wait_for_output(0); @@ -31,7 +31,7 @@ casper.notebook_test(function () { var result = this.get_output_cell(0); var num_cells = this.get_cells_length(); this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)'); - this.test.assertEquals(num_cells, 2, 'ctrl-enter adds a new cell at the bottom') + this.test.assertEquals(num_cells, 2, 'shift-enter adds a new cell at the bottom') }); // do it again with the keyboard shortcut @@ -41,7 +41,7 @@ casper.notebook_test(function () { var cell = IPython.notebook.get_cell(0); cell.set_text('a=12; print(a)'); cell.clear_output(); - IPython.utils.press_shift_enter(); + IPython.utils.press_ctrl_enter(); }); this.wait_for_output(0); @@ -50,7 +50,7 @@ casper.notebook_test(function () { var result = this.get_output_cell(0); var num_cells = this.get_cells_length(); this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)'); - this.test.assertEquals(num_cells, 1, 'shift-enter adds no new cell at the bottom') + this.test.assertEquals(num_cells, 1, 'ctrl-enter adds no new cell at the bottom') }); // press the "play" triangle button in the toolbar