mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Merge pull request #4916 from ellisonbg/modalbehavior
Fine tuning the behavior of the modal UI swap back shift- and ctrl-enter, to their rightful places.
This commit is contained in:
commit
7f9ee9cba7
@ -88,18 +88,18 @@ var IPython = (function (IPython) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'shift+enter' : {
|
'shift+enter' : {
|
||||||
help : 'run cell',
|
help : 'run cell, select below',
|
||||||
help_index : 'ba',
|
help_index : 'ba',
|
||||||
handler : function (event) {
|
handler : function (event) {
|
||||||
IPython.notebook.execute_cell();
|
IPython.notebook.execute_cell_and_select_below();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'ctrl+enter' : {
|
'ctrl+enter' : {
|
||||||
help : 'run cell, select below',
|
help : 'run cell',
|
||||||
help_index : 'bb',
|
help_index : 'bb',
|
||||||
handler : function (event) {
|
handler : function (event) {
|
||||||
IPython.notebook.execute_cell_and_select_below();
|
IPython.notebook.execute_cell();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -847,7 +847,6 @@ var IPython = (function (IPython) {
|
|||||||
target_cell.code_mirror.clearHistory();
|
target_cell.code_mirror.clearHistory();
|
||||||
source_element.remove();
|
source_element.remove();
|
||||||
this.select(i);
|
this.select(i);
|
||||||
this.edit_mode();
|
|
||||||
this.set_dirty(true);
|
this.set_dirty(true);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -878,7 +877,9 @@ var IPython = (function (IPython) {
|
|||||||
target_cell.code_mirror.clearHistory();
|
target_cell.code_mirror.clearHistory();
|
||||||
source_element.remove();
|
source_element.remove();
|
||||||
this.select(i);
|
this.select(i);
|
||||||
this.edit_mode();
|
if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) {
|
||||||
|
target_cell.render();
|
||||||
|
}
|
||||||
this.set_dirty(true);
|
this.set_dirty(true);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -910,7 +911,6 @@ var IPython = (function (IPython) {
|
|||||||
target_cell.code_mirror.clearHistory();
|
target_cell.code_mirror.clearHistory();
|
||||||
source_element.remove();
|
source_element.remove();
|
||||||
this.select(i);
|
this.select(i);
|
||||||
this.edit_mode();
|
|
||||||
this.set_dirty(true);
|
this.set_dirty(true);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -947,8 +947,10 @@ var IPython = (function (IPython) {
|
|||||||
target_cell.code_mirror.clearHistory();
|
target_cell.code_mirror.clearHistory();
|
||||||
source_element.remove();
|
source_element.remove();
|
||||||
this.select(i);
|
this.select(i);
|
||||||
|
if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) {
|
||||||
|
target_cell.render();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.edit_mode();
|
|
||||||
this.set_dirty(true);
|
this.set_dirty(true);
|
||||||
$([IPython.events]).trigger('selected_cell_type_changed.Notebook',
|
$([IPython.events]).trigger('selected_cell_type_changed.Notebook',
|
||||||
{'cell_type':'heading',level:level}
|
{'cell_type':'heading',level:level}
|
||||||
@ -1441,11 +1443,7 @@ var IPython = (function (IPython) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only insert a new cell, if we ended up in an already populated cell
|
this.insert_cell_below('code');
|
||||||
var next_text = this.get_cell(cell_index+1).get_text();
|
|
||||||
if (/\S/.test(next_text) === true) {
|
|
||||||
this.insert_cell_below('code');
|
|
||||||
}
|
|
||||||
this.select(cell_index+1);
|
this.select(cell_index+1);
|
||||||
this.edit_mode();
|
this.edit_mode();
|
||||||
this.set_dirty(true);
|
this.set_dirty(true);
|
||||||
|
@ -22,7 +22,7 @@ casper.notebook_test(function () {
|
|||||||
var cell = IPython.notebook.get_cell(0);
|
var cell = IPython.notebook.get_cell(0);
|
||||||
cell.set_text('a=11; print(a)');
|
cell.set_text('a=11; print(a)');
|
||||||
cell.clear_output();
|
cell.clear_output();
|
||||||
IPython.utils.press_ctrl_enter();
|
IPython.utils.press_shift_enter();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wait_for_output(0);
|
this.wait_for_output(0);
|
||||||
@ -31,7 +31,7 @@ casper.notebook_test(function () {
|
|||||||
var result = this.get_output_cell(0);
|
var result = this.get_output_cell(0);
|
||||||
var num_cells = this.get_cells_length();
|
var num_cells = this.get_cells_length();
|
||||||
this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)');
|
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
|
// do it again with the keyboard shortcut
|
||||||
@ -41,7 +41,7 @@ casper.notebook_test(function () {
|
|||||||
var cell = IPython.notebook.get_cell(0);
|
var cell = IPython.notebook.get_cell(0);
|
||||||
cell.set_text('a=12; print(a)');
|
cell.set_text('a=12; print(a)');
|
||||||
cell.clear_output();
|
cell.clear_output();
|
||||||
IPython.utils.press_shift_enter();
|
IPython.utils.press_ctrl_enter();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wait_for_output(0);
|
this.wait_for_output(0);
|
||||||
@ -50,7 +50,7 @@ casper.notebook_test(function () {
|
|||||||
var result = this.get_output_cell(0);
|
var result = this.get_output_cell(0);
|
||||||
var num_cells = this.get_cells_length();
|
var num_cells = this.get_cells_length();
|
||||||
this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)');
|
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
|
// press the "play" triangle button in the toolbar
|
||||||
|
Loading…
Reference in New Issue
Block a user