@ -22,6 +22,9 @@ var IPython = (function (IPython) {
this . next _prompt _number = 1 ;
this . kernel = null ;
this . clipboard = null ;
this . undelete _backup = null ;
this . undelete _index = null ;
this . undelete _below = false ;
this . paste _enabled = false ;
this . dirty = false ;
this . metadata = { } ;
@ -257,6 +260,10 @@ var IPython = (function (IPython) {
IPython . quick _help . show _keyboard _shortcuts ( ) ;
that . control _key _active = false ;
return false ;
} else if ( event . which === 90 && that . control _key _active ) {
that . undelete ( ) ;
that . control _key _active = false ;
return false ;
} else if ( that . control _key _active ) {
that . control _key _active = false ;
return true ;
@ -536,13 +543,19 @@ var IPython = (function (IPython) {
Notebook . prototype . delete _cell = function ( index ) {
var i = this . index _or _selected ( index ) ;
var cell = this . get _selected _cell ( ) ;
this . undelete _backup = cell . toJSON ( ) ;
if ( this . is _valid _cell _index ( i ) ) {
var ce = this . get _cell _element ( i ) ;
ce . remove ( ) ;
if ( i === ( this . ncells ( ) ) ) {
this . select ( i - 1 ) ;
this . undelete _index = i - 1 ;
this . undelete _below = true ;
} else {
this . select ( i ) ;
this . undelete _index = i ;
this . undelete _below = false ;
} ;
this . dirty = true ;
} ;
@ -818,6 +831,33 @@ var IPython = (function (IPython) {
} ;
} ;
// Cell undelete
Notebook . prototype . undelete = function ( ) {
if ( this . undelete _backup !== null && this . undelete _index !== null ) {
var current _index = this . get _selected _index ( ) ;
if ( this . undelete _index < current _index ) {
current _index = current _index + 1 ;
}
if ( this . undelete _index >= this . ncells ( ) ) {
this . select ( this . ncells ( ) - 1 ) ;
}
else {
this . select ( this . undelete _index ) ;
}
var cell _data = this . undelete _backup ;
var new _cell = null ;
if ( this . undelete _below ) {
new _cell = this . insert _cell _below ( cell _data . cell _type ) ;
} else {
new _cell = this . insert _cell _above ( cell _data . cell _type ) ;
}
new _cell . fromJSON ( cell _data ) ;
this . select ( current _index ) ;
this . undelete _backup = null ;
this . undelete _index = null ;
}
}
// Split/merge