Show More
@@ -22,6 +22,9 var IPython = (function (IPython) { | |||||
22 | this.next_prompt_number = 1; |
|
22 | this.next_prompt_number = 1; | |
23 | this.kernel = null; |
|
23 | this.kernel = null; | |
24 | this.clipboard = null; |
|
24 | this.clipboard = null; | |
|
25 | this.undelete_backup = null; | |||
|
26 | this.undelete_index = null; | |||
|
27 | this.undelete_below = false; | |||
25 | this.paste_enabled = false; |
|
28 | this.paste_enabled = false; | |
26 | this.dirty = false; |
|
29 | this.dirty = false; | |
27 | this.metadata = {}; |
|
30 | this.metadata = {}; | |
@@ -257,6 +260,10 var IPython = (function (IPython) { | |||||
257 | IPython.quick_help.show_keyboard_shortcuts(); |
|
260 | IPython.quick_help.show_keyboard_shortcuts(); | |
258 | that.control_key_active = false; |
|
261 | that.control_key_active = false; | |
259 | return false; |
|
262 | return false; | |
|
263 | } else if (event.which === 90 && that.control_key_active) { | |||
|
264 | that.undelete(); | |||
|
265 | that.control_key_active = false; | |||
|
266 | return false; | |||
260 | } else if (that.control_key_active) { |
|
267 | } else if (that.control_key_active) { | |
261 | that.control_key_active = false; |
|
268 | that.control_key_active = false; | |
262 | return true; |
|
269 | return true; | |
@@ -536,13 +543,19 var IPython = (function (IPython) { | |||||
536 |
|
543 | |||
537 | Notebook.prototype.delete_cell = function (index) { |
|
544 | Notebook.prototype.delete_cell = function (index) { | |
538 | var i = this.index_or_selected(index); |
|
545 | var i = this.index_or_selected(index); | |
|
546 | var cell = this.get_selected_cell(); | |||
|
547 | this.undelete_backup = cell.toJSON(); | |||
539 | if (this.is_valid_cell_index(i)) { |
|
548 | if (this.is_valid_cell_index(i)) { | |
540 | var ce = this.get_cell_element(i); |
|
549 | var ce = this.get_cell_element(i); | |
541 | ce.remove(); |
|
550 | ce.remove(); | |
542 | if (i === (this.ncells())) { |
|
551 | if (i === (this.ncells())) { | |
543 | this.select(i-1); |
|
552 | this.select(i-1); | |
|
553 | this.undelete_index = i - 1; | |||
|
554 | this.undelete_below = true; | |||
544 | } else { |
|
555 | } else { | |
545 | this.select(i); |
|
556 | this.select(i); | |
|
557 | this.undelete_index = i; | |||
|
558 | this.undelete_below = false; | |||
546 | }; |
|
559 | }; | |
547 | this.dirty = true; |
|
560 | this.dirty = true; | |
548 | }; |
|
561 | }; | |
@@ -818,6 +831,33 var IPython = (function (IPython) { | |||||
818 | }; |
|
831 | }; | |
819 | }; |
|
832 | }; | |
820 |
|
833 | |||
|
834 | // Cell undelete | |||
|
835 | ||||
|
836 | Notebook.prototype.undelete = function() { | |||
|
837 | if (this.undelete_backup !== null && this.undelete_index !== null) { | |||
|
838 | var current_index = this.get_selected_index(); | |||
|
839 | if (this.undelete_index < current_index) { | |||
|
840 | current_index = current_index + 1; | |||
|
841 | } | |||
|
842 | if (this.undelete_index >= this.ncells()) { | |||
|
843 | this.select(this.ncells() - 1); | |||
|
844 | } | |||
|
845 | else { | |||
|
846 | this.select(this.undelete_index); | |||
|
847 | } | |||
|
848 | var cell_data = this.undelete_backup; | |||
|
849 | var new_cell = null; | |||
|
850 | if (this.undelete_below) { | |||
|
851 | new_cell = this.insert_cell_below(cell_data.cell_type); | |||
|
852 | } else { | |||
|
853 | new_cell = this.insert_cell_above(cell_data.cell_type); | |||
|
854 | } | |||
|
855 | new_cell.fromJSON(cell_data); | |||
|
856 | this.select(current_index); | |||
|
857 | this.undelete_backup = null; | |||
|
858 | this.undelete_index = null; | |||
|
859 | } | |||
|
860 | } | |||
821 |
|
861 | |||
822 | // Split/merge |
|
862 | // Split/merge | |
823 |
|
863 |
@@ -49,7 +49,8 var IPython = (function (IPython) { | |||||
49 | {key: 'Ctrl-m n', help: 'select next'}, |
|
49 | {key: 'Ctrl-m n', help: 'select next'}, | |
50 | {key: 'Ctrl-m i', help: 'interrupt kernel'}, |
|
50 | {key: 'Ctrl-m i', help: 'interrupt kernel'}, | |
51 | {key: 'Ctrl-m .', help: 'restart kernel'}, |
|
51 | {key: 'Ctrl-m .', help: 'restart kernel'}, | |
52 | {key: 'Ctrl-m h', help: 'show keyboard shortcuts'} |
|
52 | {key: 'Ctrl-m h', help: 'show keyboard shortcuts'}, | |
|
53 | {key: 'Ctrl-m z', help: 'undo last cell deletion'} | |||
53 | ]; |
|
54 | ]; | |
54 | for (var i=0; i<shortcuts.length; i++) { |
|
55 | for (var i=0; i<shortcuts.length; i++) { | |
55 | dialog.append($('<div>'). |
|
56 | dialog.append($('<div>'). |
General Comments 0
You need to be logged in to leave comments.
Login now