|
|
|
|
@ -1976,26 +1976,48 @@ define(function (require) {
|
|
|
|
|
dialog.modal(options.dialog);
|
|
|
|
|
return promise;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute or render cell outputs and go into command mode.
|
|
|
|
|
* Execute cells corresponding to the given indices.
|
|
|
|
|
*
|
|
|
|
|
* @param {list} indices - indices of the cells to execute
|
|
|
|
|
*/
|
|
|
|
|
Notebook.prototype.execute_cell = function () {
|
|
|
|
|
// mode = shift, ctrl, alt
|
|
|
|
|
var cell = this.get_selected_cell();
|
|
|
|
|
|
|
|
|
|
cell.execute();
|
|
|
|
|
Notebook.prototype.execute_cells = function (indices) {
|
|
|
|
|
if (indices.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.command_mode();
|
|
|
|
|
this.set_dirty(true);
|
|
|
|
|
|
|
|
|
|
var cell;
|
|
|
|
|
for (var i = 0; i < indices.length; i++) {
|
|
|
|
|
this.select(indices[i]);
|
|
|
|
|
cell = this.get_cell(indices[i]);
|
|
|
|
|
cell.execute();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute or render cell outputs and go into command mode.
|
|
|
|
|
*/
|
|
|
|
|
Notebook.prototype.execute_cell = function () {
|
|
|
|
|
this.execute_cells(this.get_marked_indices());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute or render cell outputs and insert a new cell below.
|
|
|
|
|
*/
|
|
|
|
|
Notebook.prototype.execute_cell_and_insert_below = function () {
|
|
|
|
|
// execute the marked cells, and don't insert anything
|
|
|
|
|
var indices = this.get_marked_indices();
|
|
|
|
|
if (indices.length > 1) {
|
|
|
|
|
this.execute_cells(indices);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cell = this.get_selected_cell();
|
|
|
|
|
var cell_index = this.find_cell_index(cell);
|
|
|
|
|
|
|
|
|
|
cell.execute();
|
|
|
|
|
|
|
|
|
|
// If we are at the end always insert a new cell and return
|
|
|
|
|
@ -2020,10 +2042,15 @@ define(function (require) {
|
|
|
|
|
* Execute or render cell outputs and select the next cell.
|
|
|
|
|
*/
|
|
|
|
|
Notebook.prototype.execute_cell_and_select_below = function () {
|
|
|
|
|
// execute the marked cells, and don't select anything
|
|
|
|
|
var indices = this.get_marked_indices();
|
|
|
|
|
if (indices.length > 1) {
|
|
|
|
|
this.execute_cells(indices);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cell = this.get_selected_cell();
|
|
|
|
|
var cell_index = this.find_cell_index(cell);
|
|
|
|
|
|
|
|
|
|
cell.execute();
|
|
|
|
|
|
|
|
|
|
// If we are at the end always insert a new cell and return
|
|
|
|
|
@ -2073,11 +2100,11 @@ define(function (require) {
|
|
|
|
|
* @param {integer} end - index of the last cell to execute (exclusive)
|
|
|
|
|
*/
|
|
|
|
|
Notebook.prototype.execute_cell_range = function (start, end) {
|
|
|
|
|
this.command_mode();
|
|
|
|
|
var indices = [];
|
|
|
|
|
for (var i=start; i<end; i++) {
|
|
|
|
|
this.select(i);
|
|
|
|
|
this.execute_cell();
|
|
|
|
|
indices.push(i);
|
|
|
|
|
}
|
|
|
|
|
this.execute_cells(indices);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Persistance and loading
|
|
|
|
|
|