##// END OF EJS Templates
Renaming execute methods.
Brian E. Granger -
Show More
@@ -104,21 +104,21 var IPython = (function (IPython) {
104 'shift+enter' : {
104 'shift+enter' : {
105 help : 'run cell',
105 help : 'run cell',
106 handler : function (event) {
106 handler : function (event) {
107 IPython.notebook.execute_selected_cell('shift');
107 IPython.notebook.execute_cell();
108 return false;
108 return false;
109 }
109 }
110 },
110 },
111 'alt+enter' : {
111 'alt+enter' : {
112 help : 'run cell, insert below',
112 help : 'run cell, insert below',
113 handler : function (event) {
113 handler : function (event) {
114 IPython.notebook.execute_selected_cell('alt');
114 IPython.notebook.execute_cell_and_insert_below();
115 return false;
115 return false;
116 }
116 }
117 },
117 },
118 'ctrl+enter' : {
118 'ctrl+enter' : {
119 help : 'run cell, select below',
119 help : 'run cell, select below',
120 handler : function (event) {
120 handler : function (event) {
121 IPython.notebook.execute_selected_cell('ctrl');
121 IPython.notebook.execute_cell_and_select_below();
122 return false;
122 return false;
123 }
123 }
124 }
124 }
@@ -100,7 +100,7 var IPython = (function (IPython) {
100 label : 'Run Cell',
100 label : 'Run Cell',
101 icon : 'icon-play',
101 icon : 'icon-play',
102 callback : function () {
102 callback : function () {
103 IPython.notebook.execute_selected_cell();
103 IPython.notebook.execute_cell();
104 }
104 }
105 },
105 },
106 {
106 {
@@ -208,10 +208,13 var IPython = (function (IPython) {
208 });
208 });
209 // Cell
209 // Cell
210 this.element.find('#run_cell').click(function () {
210 this.element.find('#run_cell').click(function () {
211 IPython.notebook.execute_selected_cell();
211 IPython.notebook.execute_cell();
212 });
212 });
213 this.element.find('#run_cell_in_place').click(function () {
213 this.element.find('#run_cell_select_below').click(function () {
214 IPython.notebook.execute_selected_cell({terminal:true});
214 IPython.notebook.execute_cell_and_select_below();
215 });
216 this.element.find('#run_cell_insert_below').click(function () {
217 IPython.notebook.execute_cell_and_insert_below();
215 });
218 });
216 this.element.find('#run_all_cells').click(function () {
219 this.element.find('#run_all_cells').click(function () {
217 IPython.notebook.execute_all_cells();
220 IPython.notebook.execute_all_cells();
@@ -1336,49 +1336,78 var IPython = (function (IPython) {
1336 };
1336 };
1337
1337
1338 /**
1338 /**
1339 * Run the selected cell.
1339 * Execute or render cell outputs and go into command mode.
1340 *
1340 *
1341 * Execute or render cell outputs.
1341 * @method execute_cell
1342 *
1343 * @method execute_selected_cell
1344 * @param {Object} options Customize post-execution behavior
1345 */
1342 */
1346 Notebook.prototype.execute_selected_cell = function (mode) {
1343 Notebook.prototype.execute_cell = function () {
1347 // mode = shift, ctrl, alt
1344 // mode = shift, ctrl, alt
1348 mode = mode || 'shift'
1345 var cell = this.get_selected_cell();
1346 var cell_index = this.find_cell_index(cell);
1347
1348 cell.execute();
1349 this.command_mode();
1350 this.set_dirty(true);
1351 }
1352
1353 /**
1354 * Execute or render cell outputs and insert a new cell below.
1355 *
1356 * @method execute_cell_and_insert_below
1357 */
1358 Notebook.prototype.execute_cell_and_insert_below = function () {
1349 var cell = this.get_selected_cell();
1359 var cell = this.get_selected_cell();
1350 var cell_index = this.find_cell_index(cell);
1360 var cell_index = this.find_cell_index(cell);
1351
1361
1352 cell.execute();
1362 cell.execute();
1353
1363
1354 // If we are at the end always insert a new cell and return
1364 // If we are at the end always insert a new cell and return
1355 if (cell_index === (this.ncells()-1) && mode !== 'shift') {
1365 if (cell_index === (this.ncells()-1)) {
1356 this.insert_cell_below('code');
1366 this.insert_cell_below('code');
1357 this.select(cell_index+1);
1367 this.select(cell_index+1);
1358 this.edit_mode();
1368 this.edit_mode();
1359 this.scroll_to_bottom();
1369 this.scroll_to_bottom();
1360 this.set_dirty(true);
1370 this.set_dirty(true);
1361 return;
1371 return;
1362 }
1372 }
1363
1373
1364 if (mode === 'shift') {
1374 // Only insert a new cell, if we ended up in an already populated cell
1365 this.command_mode();
1375 var next_text = this.get_cell(cell_index+1).get_text();
1366 } else if (mode === 'ctrl') {
1376 if (/\S/.test(next_text) === true) {
1367 this.select(cell_index+1);
1377 this.insert_cell_below('code');
1368 this.get_cell(cell_index+1).focus_cell();
1378 }
1369 } else if (mode === 'alt') {
1379 this.select(cell_index+1);
1370 // Only insert a new cell, if we ended up in an already populated cell
1380 this.edit_mode();
1371 var next_text = this.get_cell(cell_index+1).get_text();
1381 this.set_dirty(true);
1372 if (/\S/.test(next_text) === true) {
1382 };
1373 this.insert_cell_below('code');
1383
1374 }
1384 /**
1385 * Execute or render cell outputs and select the next cell.
1386 *
1387 * @method execute_cell_and_select_below
1388 */
1389 Notebook.prototype.execute_cell_and_select_below = function () {
1390
1391 var cell = this.get_selected_cell();
1392 var cell_index = this.find_cell_index(cell);
1393
1394 cell.execute();
1395
1396 // If we are at the end always insert a new cell and return
1397 if (cell_index === (this.ncells()-1)) {
1398 this.insert_cell_below('code');
1375 this.select(cell_index+1);
1399 this.select(cell_index+1);
1376 this.edit_mode();
1400 this.edit_mode();
1401 this.scroll_to_bottom();
1402 this.set_dirty(true);
1403 return;
1377 }
1404 }
1405
1406 this.select(cell_index+1);
1407 this.get_cell(cell_index+1).focus_cell();
1378 this.set_dirty(true);
1408 this.set_dirty(true);
1379 };
1409 };
1380
1410
1381
1382 /**
1411 /**
1383 * Execute all cells below the selected cell.
1412 * Execute all cells below the selected cell.
1384 *
1413 *
@@ -1418,7 +1447,7 var IPython = (function (IPython) {
1418 Notebook.prototype.execute_cell_range = function (start, end) {
1447 Notebook.prototype.execute_cell_range = function (start, end) {
1419 for (var i=start; i<end; i++) {
1448 for (var i=start; i<end; i++) {
1420 this.select(i);
1449 this.select(i);
1421 this.execute_selected_cell({add_new:false});
1450 this.execute_cell();
1422 };
1451 };
1423 };
1452 };
1424
1453
@@ -140,8 +140,10 class="notebook_app"
140 <ul class="dropdown-menu">
140 <ul class="dropdown-menu">
141 <li id="run_cell" title="Run this cell, and move cursor to the next one">
141 <li id="run_cell" title="Run this cell, and move cursor to the next one">
142 <a href="#">Run</a></li>
142 <a href="#">Run</a></li>
143 <li id="run_cell_in_place" title="Run this cell, without moving to the next one">
143 <li id="run_cell_select_below" title="Run this cell, select below">
144 <a href="#">Run in Place</a></li>
144 <a href="#">Run and Select Below</a></li>
145 <li id="run_cell_insert_below" title="Run this cell, insert below">
146 <a href="#">Run and Insert Below</a></li>
145 <li id="run_all_cells" title="Run all cells in the notebook">
147 <li id="run_all_cells" title="Run all cells in the notebook">
146 <a href="#">Run All</a></li>
148 <a href="#">Run All</a></li>
147 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
149 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
General Comments 0
You need to be logged in to leave comments. Login now