Show More
@@ -84,7 +84,6 b' var IPython = (function (IPython) {' | |||
|
84 | 84 | help_index : 'aa', |
|
85 | 85 | handler : function (event) { |
|
86 | 86 | IPython.notebook.command_mode(); |
|
87 | IPython.notebook.focus_cell(); | |
|
88 | 87 | return false; |
|
89 | 88 | } |
|
90 | 89 | }, |
@@ -93,7 +92,6 b' var IPython = (function (IPython) {' | |||
|
93 | 92 | help_index : 'ab', |
|
94 | 93 | handler : function (event) { |
|
95 | 94 | IPython.notebook.command_mode(); |
|
96 | IPython.notebook.focus_cell(); | |
|
97 | 95 | return false; |
|
98 | 96 | } |
|
99 | 97 | }, |
@@ -116,11 +116,11 b' var IPython = (function (IPython) {' | |||
|
116 | 116 | }); |
|
117 | 117 | |
|
118 | 118 | $([IPython.events]).on('edit_mode.Cell', function (event, data) { |
|
119 |
that.handle_edit_mode( |
|
|
119 | that.handle_edit_mode(data.cell); | |
|
120 | 120 | }); |
|
121 | 121 | |
|
122 | 122 | $([IPython.events]).on('command_mode.Cell', function (event, data) { |
|
123 | that.command_mode(); | |
|
123 | that.handle_command_mode(data.cell); | |
|
124 | 124 | }); |
|
125 | 125 | |
|
126 | 126 | $([IPython.events]).on('status_autorestarting.Kernel', function () { |
@@ -519,20 +519,15 b' var IPython = (function (IPython) {' | |||
|
519 | 519 | }; |
|
520 | 520 | |
|
521 | 521 | /** |
|
522 |
* |
|
|
522 | * Handle when a a cell blurs and the notebook should enter command mode. | |
|
523 | 523 | * |
|
524 | * @method command_mode | |
|
524 | * @method handle_command_mode | |
|
525 | * @param [cell] {Cell} Cell to enter command mode on. | |
|
525 | 526 | **/ |
|
526 | Notebook.prototype.command_mode = function () { | |
|
527 | // Make sure there isn't an edit mode cell lingering around. | |
|
528 | var cell = this.get_cell(this.get_edit_index()); | |
|
529 | if (cell) { | |
|
530 | cell.command_mode(); | |
|
531 | } | |
|
532 | ||
|
533 | // Notify the keyboard manager if this is a change of mode for the | |
|
534 | // notebook as a whole. | |
|
527 | Notebook.prototype.handle_command_mode = function (cell) { | |
|
528 | if (cell === null) { return; } // TODO: do I really need this? | |
|
535 | 529 | if (this.mode !== 'command') { |
|
530 | cell.command_mode(); // TODO: is this OK here? | |
|
536 | 531 | this.mode = 'command'; |
|
537 | 532 | $([IPython.events]).trigger('command_mode.Notebook'); |
|
538 | 533 | IPython.keyboard_manager.command_mode(); |
@@ -540,19 +535,28 b' var IPython = (function (IPython) {' | |||
|
540 | 535 | }; |
|
541 | 536 | |
|
542 | 537 | /** |
|
538 | * Make the notebook enter command mode. | |
|
539 | * | |
|
540 | * @method command_mode | |
|
541 | **/ | |
|
542 | Notebook.prototype.command_mode = function () { | |
|
543 | var cell = this.get_cell(this.get_edit_index()); | |
|
544 | if (cell && this.mode !== 'command') { | |
|
545 | // We don't call cell.command_mode, but rather call cell.focus_cell() | |
|
546 | // which will blur and CM editor and trigger the call to | |
|
547 | // handle_command_mode. | |
|
548 | cell.focus_cell(); | |
|
549 | } | |
|
550 | }; | |
|
551 | ||
|
552 | /** | |
|
543 | 553 | * Handle when a cell fires it's edit_mode event. |
|
544 | 554 | * |
|
545 | 555 | * @method handle_edit_mode |
|
546 | * @param [index] {int} Cell index to select. If no index is provided, | |
|
547 | * the current selected cell is used. | |
|
556 | * @param [cell] {Cell} Cell to enter edit mode on. | |
|
548 | 557 | **/ |
|
549 |
Notebook.prototype.handle_edit_mode = function ( |
|
|
550 | // Make sure the cell exists. | |
|
551 | var cell = this.get_cell(index); | |
|
552 | if (cell === null) { return; } | |
|
553 | ||
|
554 | // Set the cell to edit mode and notify the keyboard manager if this | |
|
555 | // is a change of mode for the notebook as a whole. | |
|
558 | Notebook.prototype.handle_edit_mode = function (cell) { | |
|
559 | if (cell === null) { return; } // TODO: do I really need this? | |
|
556 | 560 | if (this.mode !== 'edit') { |
|
557 | 561 | cell.edit_mode(); |
|
558 | 562 | this.mode = 'edit'; |
@@ -1449,7 +1453,6 b' var IPython = (function (IPython) {' | |||
|
1449 | 1453 | var cell_index = this.find_cell_index(cell); |
|
1450 | 1454 | |
|
1451 | 1455 | cell.execute(); |
|
1452 | cell.focus_cell(); | |
|
1453 | 1456 | this.command_mode(); |
|
1454 | 1457 | this.set_dirty(true); |
|
1455 | 1458 | }; |
@@ -1501,7 +1504,6 b' var IPython = (function (IPython) {' | |||
|
1501 | 1504 | } |
|
1502 | 1505 | |
|
1503 | 1506 | this.select(cell_index+1); |
|
1504 | this.get_cell(cell_index+1).focus_cell(); | |
|
1505 | 1507 | this.command_mode(); |
|
1506 | 1508 | this.set_dirty(true); |
|
1507 | 1509 | }; |
@@ -1972,7 +1974,7 b' var IPython = (function (IPython) {' | |||
|
1972 | 1974 | this.edit_mode(0); |
|
1973 | 1975 | } else { |
|
1974 | 1976 | this.select(0); |
|
1975 | this.command_mode(); | |
|
1977 | this.handle_command_mode(this.get_cell(0)); | |
|
1976 | 1978 | } |
|
1977 | 1979 | this.set_dirty(false); |
|
1978 | 1980 | this.scroll_to_top(); |
General Comments 0
You need to be logged in to leave comments.
Login now