Show More
@@ -457,6 +457,11 b' var IPython = (function (IPython) {' | |||
|
457 | 457 | if (this.is_valid_cell_index(index)) { |
|
458 | 458 | var sindex = this.get_selected_index(); |
|
459 | 459 | if (sindex !== null && index !== sindex) { |
|
460 | // If we are about to select a different cell, make sure we are | |
|
461 | // first in command mode. | |
|
462 | if (this.mode !== 'command') { | |
|
463 | this.command_mode(); | |
|
464 | } | |
|
460 | 465 | this.get_cell(sindex).unselect(); |
|
461 | 466 | } |
|
462 | 467 | var cell = this.get_cell(index); |
@@ -526,7 +531,7 b' var IPython = (function (IPython) {' | |||
|
526 | 531 | **/ |
|
527 | 532 | Notebook.prototype.handle_command_mode = function (cell) { |
|
528 | 533 | if (this.mode !== 'command') { |
|
529 |
cell.command_mode(); |
|
|
534 | cell.command_mode(); | |
|
530 | 535 | this.mode = 'command'; |
|
531 | 536 | $([IPython.events]).trigger('command_mode.Notebook'); |
|
532 | 537 | IPython.keyboard_manager.command_mode(); |
@@ -555,7 +560,7 b' var IPython = (function (IPython) {' | |||
|
555 | 560 | * @param [cell] {Cell} Cell to enter edit mode on. |
|
556 | 561 | **/ |
|
557 | 562 | Notebook.prototype.handle_edit_mode = function (cell) { |
|
558 | if (this.mode !== 'edit') { | |
|
563 | if (cell && this.mode !== 'edit') { | |
|
559 | 564 | cell.edit_mode(); |
|
560 | 565 | this.mode = 'edit'; |
|
561 | 566 | $([IPython.events]).trigger('edit_mode.Notebook'); |
@@ -567,17 +572,10 b' var IPython = (function (IPython) {' | |||
|
567 | 572 | * Make a cell enter edit mode. |
|
568 | 573 | * |
|
569 | 574 | * @method edit_mode |
|
570 | * @param [index] {int} Cell index to select. If no index is provided, | |
|
571 | * the current selected cell is used. | |
|
572 | 575 | **/ |
|
573 |
Notebook.prototype.edit_mode = function ( |
|
|
574 | if (index===undefined) { | |
|
575 | index = this.get_selected_index(); | |
|
576 | } | |
|
577 | // Make sure the cell exists. | |
|
578 | var cell = this.get_cell(index); | |
|
579 | if (cell === null) { return; } | |
|
580 | if (cell.mode != 'edit') { | |
|
576 | Notebook.prototype.edit_mode = function () { | |
|
577 | var cell = this.get_selected_cell(); | |
|
578 | if (cell && this.mode !== 'edit') { | |
|
581 | 579 | cell.unrender(); |
|
582 | 580 | cell.focus_editor(); |
|
583 | 581 | } |
@@ -1468,15 +1466,19 b' var IPython = (function (IPython) {' | |||
|
1468 | 1466 | |
|
1469 | 1467 | // If we are at the end always insert a new cell and return |
|
1470 | 1468 | if (cell_index === (this.ncells()-1)) { |
|
1469 | this.command_mode(); | |
|
1471 | 1470 | this.insert_cell_below('code'); |
|
1472 |
this. |
|
|
1471 | this.select(cell_index+1); | |
|
1472 | this.edit_mode(); | |
|
1473 | 1473 | this.scroll_to_bottom(); |
|
1474 | 1474 | this.set_dirty(true); |
|
1475 | 1475 | return; |
|
1476 | 1476 | } |
|
1477 | ||
|
1477 | ||
|
1478 | this.command_mode(); | |
|
1478 | 1479 | this.insert_cell_below('code'); |
|
1479 |
this. |
|
|
1480 | this.select(cell_index+1); | |
|
1481 | this.edit_mode(); | |
|
1480 | 1482 | this.set_dirty(true); |
|
1481 | 1483 | }; |
|
1482 | 1484 | |
@@ -1494,15 +1496,17 b' var IPython = (function (IPython) {' | |||
|
1494 | 1496 | |
|
1495 | 1497 | // If we are at the end always insert a new cell and return |
|
1496 | 1498 | if (cell_index === (this.ncells()-1)) { |
|
1499 | this.command_mode(); | |
|
1497 | 1500 | this.insert_cell_below('code'); |
|
1498 |
this. |
|
|
1501 | this.select(cell_index+1); | |
|
1502 | this.edit_mode(); | |
|
1499 | 1503 | this.scroll_to_bottom(); |
|
1500 | 1504 | this.set_dirty(true); |
|
1501 | 1505 | return; |
|
1502 | 1506 | } |
|
1503 | 1507 | |
|
1504 | this.select(cell_index+1); | |
|
1505 | 1508 | this.command_mode(); |
|
1509 | this.select(cell_index+1); | |
|
1506 | 1510 | this.set_dirty(true); |
|
1507 | 1511 | }; |
|
1508 | 1512 | |
@@ -1543,6 +1547,7 b' var IPython = (function (IPython) {' | |||
|
1543 | 1547 | * @param {Number} end Index of the last cell to execute (exclusive) |
|
1544 | 1548 | */ |
|
1545 | 1549 | Notebook.prototype.execute_cell_range = function (start, end) { |
|
1550 | this.command_mode(); | |
|
1546 | 1551 | for (var i=start; i<end; i++) { |
|
1547 | 1552 | this.select(i); |
|
1548 | 1553 | this.execute_cell(); |
General Comments 0
You need to be logged in to leave comments.
Login now