@ -40,22 +40,52 @@ define(function(require){
*
* * /
var _actions = {
'toggle-toolbar' : {
help : 'hide/show the toolbar' ,
handler : function ( env ) {
$ ( 'div#maintoolbar' ) . toggle ( ) ;
events . trigger ( 'resize-header.Page' ) ;
'restart-kernel' : {
help : 'restart the kernel (no confirmation dialog)' ,
handler : function ( env ) {
env . notebook . restart _kernel ( { confirm : false } ) ;
} ,
} ,
'confirm-restart-kernel' : {
icon : 'fa-repeat' ,
help _index : 'hb' ,
help : 'restart the kernel (with dialog)' ,
handler : function ( env ) {
env . notebook . restart _kernel ( ) ;
}
} ,
'toggle-header' : {
help : 'hide/show the header' ,
handler : function ( env ) {
$ ( '#header-container' ) . toggle ( ) ;
$ ( '.header-bar' ) . toggle ( ) ;
events . trigger ( 'resize-header.Page' ) ;
'restart-kernel-and-run-all-cells' : {
help : 'restart the kernel, then re-run the whole notebook (no confirmation dialog)' ,
handler : function ( env ) {
env . notebook . restart _run _all ( { confirm : false } ) ;
}
} ,
'confirm-restart-kernel-and-run-all-cells' : {
help : 'restart the kernel, then re-run the whole notebook (with dialog)' ,
handler : function ( env ) {
env . notebook . restart _run _all ( ) ;
}
} ,
'restart-kernel-and-clear-output' : {
help : 'restart the kernel and clear all output (no confirmation dialog)' ,
handler : function ( env ) {
env . notebook . restart _clear _output ( { confirm : false } ) ;
}
} ,
'confirm-restart-kernel-and-clear-output' : {
help : 'restart the kernel and clear all output (with dialog)' ,
handler : function ( env ) {
env . notebook . restart _clear _output ( ) ;
}
} ,
'run-select-next' : {
'interrupt-kernel' : {
icon : 'fa-stop' ,
help _index : 'ha' ,
handler : function ( env ) {
env . notebook . kernel . interrupt ( ) ;
}
} ,
'run-cell-and-select-next' : {
icon : 'fa-step-forward' ,
help : 'run cell, select below' ,
help _index : 'ba' ,
@ -63,14 +93,14 @@ define(function(require){
env . notebook . execute _cell _and _select _below ( ) ;
}
} ,
' execute-in-place ': {
' run-cell ': {
help : 'run cell' ,
help _index : 'bb' ,
handler : function ( env ) {
env . notebook . execute _cell ( ) ;
}
} ,
' execute-and-insert-after ': {
' run-cell-and-insert-below ': {
help : 'run cell, insert below' ,
help _index : 'bc' ,
handler : function ( env ) {
@ -84,43 +114,6 @@ define(function(require){
env . notebook . execute _all _cells ( ) ;
}
} ,
'restart-run-all-dialog' : {
help : 'restart the kernel, then re-run the whole notebook (with dialog)' ,
handler : function ( env ) {
env . notebook . restart _run _all ( ) ;
}
} ,
'restart-clear-output-dialog' : {
help : 'restart the kernel and clear all output (with dialog)' ,
handler : function ( env ) {
env . notebook . restart _clear _output ( ) ;
}
} ,
'restart-dialog' : {
help : 'restart the kernel (with dialog)' ,
help _index : 'bf' ,
handler : function ( env ) {
env . notebook . restart _kernel ( ) ;
} ,
} ,
'restart-run-all' : {
help : 'restart the kernel, then re-run the whole notebook (no confirmation dialog)' ,
handler : function ( env ) {
env . notebook . restart _run _all ( { confirm : false } ) ;
}
} ,
'restart-clear-output' : {
help : 'restart the kernel and clear all output (no confirmation dialog)' ,
handler : function ( env ) {
env . notebook . restart _clear _output ( { confirm : false } ) ;
}
} ,
'restart' : {
help : 'restart the kernel (no confirmation dialog)' ,
handler : function ( env ) {
env . notebook . restart _kernel ( { confirm : false } ) ;
} ,
} ,
'run-all-cells-above' : {
handler : function ( env ) {
env . notebook . execute _cells _above ( ) ;
@ -131,7 +124,7 @@ define(function(require){
env . notebook . execute _cells _below ( ) ;
}
} ,
' go-to -command-mode': {
' enter -command-mode': {
help : 'command mode' ,
help _index : 'aa' ,
handler : function ( env ) {
@ -187,7 +180,7 @@ define(function(require){
env . notebook . extend _marked ( 1 ) ;
}
} ,
'cut- selected- cell' : {
'cut- cell' : {
icon : 'fa-cut' ,
help _index : 'ee' ,
handler : function ( env ) {
@ -196,21 +189,21 @@ define(function(require){
env . notebook . select ( index ) ;
}
} ,
'copy- selected- cell' : {
'copy- cell' : {
icon : 'fa-copy' ,
help _index : 'ef' ,
handler : function ( env ) {
env . notebook . copy _cell ( ) ;
}
} ,
'paste-cell- befor e' : {
'paste-cell- abov e' : {
help : 'paste cell above' ,
help _index : 'eg' ,
handler : function ( env ) {
env . notebook . paste _cell _above ( ) ;
}
} ,
'paste-cell- after ' : {
'paste-cell- below ' : {
help : 'paste cell below' ,
icon : 'fa-paste' ,
help _index : 'eh' ,
@ -218,7 +211,7 @@ define(function(require){
env . notebook . paste _cell _below ( ) ;
}
} ,
'insert-cell- befor e' : {
'insert-cell- abov e' : {
help : 'insert cell above' ,
help _index : 'ec' ,
handler : function ( env ) {
@ -227,7 +220,7 @@ define(function(require){
env . notebook . focus _cell ( ) ;
}
} ,
'insert-cell- after ' : {
'insert-cell- below ' : {
help : 'insert cell below' ,
icon : 'fa-plus' ,
help _index : 'ed' ,
@ -237,110 +230,110 @@ define(function(require){
env . notebook . focus _cell ( ) ;
}
} ,
'change- selected- cell-to-code-cell ' : {
'change- cell-to-code' : {
help : 'to code' ,
help _index : 'ca' ,
handler : function ( env ) {
env . notebook . to _code ( ) ;
}
} ,
'change- selected- cell-to-markdown-cell ' : {
'change- cell-to-markdown' : {
help : 'to markdown' ,
help _index : 'cb' ,
handler : function ( env ) {
env . notebook . to _markdown ( ) ;
}
} ,
'change- selected- cell-to-raw-cell ' : {
'change- cell-to-raw' : {
help : 'to raw' ,
help _index : 'cc' ,
handler : function ( env ) {
env . notebook . to _raw ( ) ;
}
} ,
'change- selected- cell-to-heading-1' : {
'change- cell-to-heading-1' : {
help : 'to heading 1' ,
help _index : 'cd' ,
handler : function ( env ) {
env . notebook . to _heading ( undefined , 1 ) ;
}
} ,
'change- selected- cell-to-heading-2' : {
'change- cell-to-heading-2' : {
help : 'to heading 2' ,
help _index : 'ce' ,
handler : function ( env ) {
env . notebook . to _heading ( undefined , 2 ) ;
}
} ,
'change- selected- cell-to-heading-3' : {
'change- cell-to-heading-3' : {
help : 'to heading 3' ,
help _index : 'cf' ,
handler : function ( env ) {
env . notebook . to _heading ( undefined , 3 ) ;
}
} ,
'change- selected- cell-to-heading-4' : {
'change- cell-to-heading-4' : {
help : 'to heading 4' ,
help _index : 'cg' ,
handler : function ( env ) {
env . notebook . to _heading ( undefined , 4 ) ;
}
} ,
'change- selected- cell-to-heading-5' : {
'change- cell-to-heading-5' : {
help : 'to heading 5' ,
help _index : 'ch' ,
handler : function ( env ) {
env . notebook . to _heading ( undefined , 5 ) ;
}
} ,
'change- selected- cell-to-heading-6' : {
'change- cell-to-heading-6' : {
help : 'to heading 6' ,
help _index : 'ci' ,
handler : function ( env ) {
env . notebook . to _heading ( undefined , 6 ) ;
}
} ,
'toggle- output-visibility-selected-cell ' : {
'toggle- cell- output-visibility' : {
help : 'toggle output' ,
help _index : 'gb' ,
handler : function ( env ) {
env . notebook . toggle _output ( ) ;
}
} ,
'toggle- output-scrolling-selected-cell ' : {
'toggle- cell- output-scrolling' : {
help : 'toggle output scrolling' ,
help _index : 'gc' ,
handler : function ( env ) {
env . notebook . toggle _output _scroll ( ) ;
}
} ,
'clear- output-selected-cell ' : {
'clear- cell- output' : {
handler : function ( env ) {
env . notebook . clear _output ( ) ;
}
} ,
'move- selected- cell-down' : {
'move- cell-down' : {
icon : 'fa-arrow-down' ,
help _index : 'eb' ,
handler : function ( env ) {
env . notebook . move _cell _down ( ) ;
}
} ,
'move- selected- cell-up' : {
'move- cell-up' : {
icon : 'fa-arrow-up' ,
help _index : 'ea' ,
handler : function ( env ) {
env . notebook . move _cell _up ( ) ;
}
} ,
'toggle- line-number- selected-cell ' : {
'toggle- cell- line-numbers' : {
help : 'toggle line numbers' ,
help _index : 'ga' ,
handler : function ( env ) {
env . notebook . cell _toggle _line _numbers ( ) ;
}
} ,
'show-keyboard-shortcut -help-dialog ' : {
'show-keyboard-shortcut s ' : {
help _index : 'ge' ,
handler : function ( env ) {
env . quick _help . show _keyboard _shortcuts ( ) ;
@ -353,21 +346,7 @@ define(function(require){
env . notebook . delete _cell ( ) ;
}
} ,
'interrupt-kernel' : {
icon : 'fa-stop' ,
help _index : 'ha' ,
handler : function ( env ) {
env . notebook . kernel . interrupt ( ) ;
}
} ,
'restart-kernel' : {
icon : 'fa-repeat' ,
help _index : 'hb' ,
handler : function ( env ) {
env . notebook . restart _kernel ( ) ;
}
} ,
'undo-last-cell-deletion' : {
'undo-cell-deletion' : {
help _index : 'ei' ,
handler : function ( env ) {
env . notebook . undelete _cell ( ) ;
@ -375,12 +354,12 @@ define(function(require){
} ,
// TODO reminder
// open an issue, merge with above merge with last cell of notebook if at top.
'merge- selected- cell-with-cell-before ' : {
'merge- cell-with-previous- cell' : {
handler : function ( env ) {
env . notebook . merge _cell _above ( ) ;
}
} ,
'merge- selected- cell-with-cell-after ' : {
'merge- cell-with-next- cell' : {
help : 'merge cell below' ,
help _index : 'ek' ,
handler : function ( env ) {
@ -400,7 +379,7 @@ define(function(require){
env . pager . collapse ( ) ;
}
} ,
' command-palette': {
' show- command-palette': {
help _index : 'aa' ,
help : 'open the command palette' ,
icon : 'fa-keyboard-o' ,
@ -417,6 +396,21 @@ define(function(require){
env . notebook . get _selected _cell ( ) . marked ^= true ;
}
} ,
'toggle-toolbar' : {
help : 'hide/show the toolbar' ,
handler : function ( env ) {
$ ( 'div#maintoolbar' ) . toggle ( ) ;
events . trigger ( 'resize-header.Page' ) ;
}
} ,
'toggle-header' : {
help : 'hide/show the header' ,
handler : function ( env ) {
$ ( '#header-container' ) . toggle ( ) ;
$ ( '.header-bar' ) . toggle ( ) ;
events . trigger ( 'resize-header.Page' ) ;
}
}
} ;
/ * *
@ -438,7 +432,7 @@ define(function(require){
return true ;
}
} ,
'move-cursor-up -or-previous-cell ': {
'move-cursor-up ': {
handler : function ( env , event ) {
var index = env . notebook . get _selected _index ( ) ;
var cell = env . notebook . get _cell ( index ) ;
@ -457,7 +451,7 @@ define(function(require){
return false ;
}
} ,
'move-cursor-down -or-next-cell ': {
'move-cursor-down ': {
handler : function ( env , event ) {
var index = env . notebook . get _selected _index ( ) ;
var cell = env . notebook . get _cell ( index ) ;
@ -474,7 +468,7 @@ define(function(require){
return false ;
}
} ,
'scroll- down': {
'scroll- notebook- down': {
handler : function ( env , event ) {
if ( event ) {
event . preventDefault ( ) ;
@ -482,7 +476,7 @@ define(function(require){
return env . notebook . scroll _manager . scroll ( 1 ) ;
} ,
} ,
'scroll- up': {
'scroll- notebook- up': {
handler : function ( env , event ) {
if ( event ) {
event . preventDefault ( ) ;
@ -539,13 +533,13 @@ define(function(require){
} ,
} ;
// private stuff that prepend ` .ipython ` to actions names
// private stuff that prepend ` jupyter-notebook: ` to actions names
// and uniformize/fill in missing pieces in of an action.
var _prepare _handler = function ( registry , subkey , source ) {
registry [ ' ipython. '+ subkey ] = { } ;
registry [ ' ipython. '+ subkey ] . help = source [ subkey ] . help || subkey . replace ( /-/g , ' ' ) ;
registry [ ' ipython. '+ subkey ] . help _index = source [ subkey ] . help _index ;
registry [ ' ipython. '+ subkey ] . icon = source [ subkey ] . icon ;
registry [ ' jupyter-notebook: '+ subkey ] = { } ;
registry [ ' jupyter-notebook: '+ subkey ] . help = source [ subkey ] . help || subkey . replace ( /-/g , ' ' ) ;
registry [ ' jupyter-notebook: '+ subkey ] . help _index = source [ subkey ] . help _index ;
registry [ ' jupyter-notebook: '+ subkey ] . icon = source [ subkey ] . icon ;
return source [ subkey ] . handler ;
} ;
@ -556,11 +550,11 @@ define(function(require){
for ( k in _actions ) {
if ( _actions . hasOwnProperty ( k ) ) {
// Js closure are function level not block level need to wrap in a IIFE
// and append ipython to event name these things do intercept event so are wrapped
// and append jupyter-notebook: to event name these things do intercept event so are wrapped
// in a function that return false.
var handler = _prepare _handler ( final _actions , k , _actions ) ;
( function ( key , handler ) {
final _actions [ ' ipython. '+ key ] . handler = function ( env , event ) {
final _actions [ ' jupyter-notebook: '+ key ] . handler = function ( env , event ) {
handler ( env ) ;
if ( event ) {
event . preventDefault ( ) ;
@ -577,7 +571,7 @@ define(function(require){
if ( custom _ignore . hasOwnProperty ( k ) ) {
var handler = _prepare _handler ( final _actions , k , custom _ignore ) ;
( function ( key , handler ) {
final _actions [ ' ipython. '+ key ] . handler = function ( env , event ) {
final _actions [ ' jupyter-notebook: '+ key ] . handler = function ( env , event ) {
return handler ( env , event ) ;
} ;
} ) ( k , handler ) ;
@ -612,7 +606,7 @@ define(function(require){
name = 'autogenerated-' + String ( action . handler ) ;
}
prefix = prefix || 'auto' ;
var full _name = prefix + ' . '+ name ;
var full _name = prefix + ' : '+ name ;
this . _actions [ full _name ] = action ;
return full _name ;