##// END OF EJS Templates
Fixes to terminal mode execution (ctrl-enter).
Brian E. Granger -
Show More
@@ -66,7 +66,6 var IPython = (function (IPython) {
66 66 if (this.is_completing && this.completion_cursor !== editor.getCursor()) {
67 67 this.is_completing = false;
68 68 this.completion_cursor = null;
69 console.log("Stopped completing early");
70 69 }
71 70 return false;
72 71 };
@@ -57,11 +57,10 var IPython = (function (IPython) {
57 57 that.select_next();
58 58 };
59 59 } else if (event.which === 13 && event.shiftKey) {
60 that.execute_selected_cell(true);
60 that.execute_selected_cell();
61 61 return false;
62 62 } else if (event.which === 13 && event.ctrlKey) {
63 that.execute_selected_cell(false);
64 that.selected_cell().clear_input();
63 that.execute_selected_cell({terminal:true});
65 64 return false;
66 65 };
67 66 });
@@ -463,8 +462,11 var IPython = (function (IPython) {
463 462 };
464 463
465 464
466 Notebook.prototype.execute_selected_cell = function (add_new) {
467 if (add_new === undefined) {add_new = true;};
465 Notebook.prototype.execute_selected_cell = function (options) {
466 // add_new: should a new cell be added if we are at the end of the nb
467 // terminal: execute in terminal mode, which stays in the current cell
468 default_options = {terminal: false, add_new: true}
469 $.extend(default_options, options)
468 470 var that = this;
469 471 var cell = that.selected_cell();
470 472 var cell_index = that.find_cell_index(cell);
@@ -492,12 +494,16 var IPython = (function (IPython) {
492 494 } else if (cell instanceof IPython.TextCell) {
493 495 cell.render();
494 496 }
495 if ((cell_index === (that.ncells()-1)) && add_new) {
496 that.insert_code_cell_after();
497 // If we are adding a new cell at the end, scroll down to show it.
498 that.scroll_to_bottom();
497 if (default_options.terminal) {
498 cell.clear_input();
499 499 } else {
500 that.select(cell_index+1);
500 if ((cell_index === (that.ncells()-1)) && default_options.add_new) {
501 that.insert_code_cell_after();
502 // If we are adding a new cell at the end, scroll down to show it.
503 that.scroll_to_bottom();
504 } else {
505 that.select(cell_index+1);
506 };
501 507 };
502 508 };
503 509
@@ -506,7 +512,7 var IPython = (function (IPython) {
506 512 var ncells = this.ncells();
507 513 for (var i=0; i<ncells; i++) {
508 514 this.select(i);
509 this.execute_selected_cell(false);
515 this.execute_selected_cell({add_new:false});
510 516 };
511 517 this.scroll_to_bottom();
512 518 };
General Comments 0
You need to be logged in to leave comments. Login now