##// END OF EJS Templates
merge separate input/expected notebooks for execute preprocessor
merge separate input/expected notebooks for execute preprocessor

File last commit:

r16778:bfd1fa3e
r17101:945ec056
Show More
keyboardmanager.js
562 lines | 17.6 KiB | application/javascript | JavascriptLexer
Brian E. Granger
Adding keyboard manager logic....
r14020 //----------------------------------------------------------------------------
// Copyright (C) 2011 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// Keyboard management
//============================================================================
var IPython = (function (IPython) {
"use strict";
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 var browser = IPython.utils.browser[0];
Brian E. Granger
Added platform dep. logic.
r14816 var platform = IPython.utils.platform;
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036
// Default keyboard shortcuts
var default_common_shortcuts = {
'shift' : {
help : '',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : '',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
// ignore shift keydown
return true;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'shift-enter' : {
Brian E. Granger
Fixing help strings for shift|ctrl+enter.
r14946 help : 'run cell, select below',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ba',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
shift+enter and ctrl+enter swapped.
r14945 IPython.notebook.execute_cell_and_select_below();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'ctrl-enter' : {
Brian E. Granger
Fixing help strings for shift|ctrl+enter.
r14946 help : 'run cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'bb',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
shift+enter and ctrl+enter swapped.
r14945 IPython.notebook.execute_cell();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'alt-enter' : {
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help : 'run cell, insert below',
help_index : 'bc',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 IPython.notebook.execute_cell_and_insert_below();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
}
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036
Brian E. Granger
Added platform dep. logic.
r14816 if (platform === 'MacOS') {
Paul Ivanov
fix MacOS specific shortcuts, thanks @minrk
r15890 default_common_shortcuts['cmd-s'] =
Brian E. Granger
Added platform dep. logic.
r14816 {
help : 'save notebook',
help_index : 'fb',
handler : function (event) {
IPython.notebook.save_checkpoint();
event.preventDefault();
return false;
}
};
} else {
Paul Ivanov
use - for shortcut separators
r15873 default_common_shortcuts['ctrl-s'] =
Brian E. Granger
Added platform dep. logic.
r14816 {
help : 'save notebook',
help_index : 'fb',
handler : function (event) {
IPython.notebook.save_checkpoint();
event.preventDefault();
return false;
}
};
}
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 // Edit mode defaults
var default_edit_shortcuts = {
'esc' : {
help : 'command mode',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'aa',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.command_mode();
return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'ctrl-m' : {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 help : 'command mode',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ab',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.command_mode();
return false;
}
},
'up' : {
Brian E. Granger
Minor changes to KB handling.
r14099 help : '',
help_index : '',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Jonathan Frederic
Don't allow edit mode up arrow to continue past index == 0
r15593 var index = IPython.notebook.get_selected_index();
Paul Ivanov
fix up and down arrows in the top and bottom cells
r15837 var cell = IPython.notebook.get_cell(index);
if (cell && cell.at_top() && index !== 0) {
event.preventDefault();
IPython.notebook.command_mode();
IPython.notebook.select_prev();
IPython.notebook.edit_mode();
var cm = IPython.notebook.get_selected_cell().code_mirror;
cm.setCursor(cm.lastLine(), 0);
return false;
} else if (cell) {
var cm = cell.code_mirror;
Paul Ivanov
fix cursor keys in long lines wrapped in markdown
r16522 cm.execCommand('goLineUp');
Paul Ivanov
fix up and down arrows in the top and bottom cells
r15837 return false;
Jonathan Frederic
jshint
r15491 }
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 }
},
'down' : {
Brian E. Granger
Minor changes to KB handling.
r14099 help : '',
help_index : '',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Jonathan Frederic
Check down too.
r15594 var index = IPython.notebook.get_selected_index();
Paul Ivanov
fix up and down arrows in the top and bottom cells
r15837 var cell = IPython.notebook.get_cell(index);
if (cell.at_bottom() && index !== (IPython.notebook.ncells()-1)) {
event.preventDefault();
IPython.notebook.command_mode();
IPython.notebook.select_next();
IPython.notebook.edit_mode();
var cm = IPython.notebook.get_selected_cell().code_mirror;
cm.setCursor(0, 0);
return false;
} else {
var cm = cell.code_mirror;
Paul Ivanov
fix cursor keys in long lines wrapped in markdown
r16522 cm.execCommand('goLineDown');
Paul Ivanov
fix up and down arrows in the top and bottom cells
r15837 return false;
Jonathan Frederic
jshint
r15491 }
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 }
},
MinRK
remove alt-- shortcut...
r15898 'ctrl-shift--' : {
Brian E. Granger
Ongoing work on cell splitting.
r14057 help : 'split cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ea',
Brian E. Granger
Ongoing work on cell splitting.
r14057 handler : function (event) {
IPython.notebook.split_cell();
return false;
}
},
MinRK
remove alt-- shortcut...
r15898 'ctrl-shift-subtract' : {
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help : '',
help_index : 'eb',
Brian E. Granger
Fixing a few keyboard codes and shortcuts.
r14076 handler : function (event) {
IPython.notebook.split_cell();
return false;
}
},
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Added platform dep. logic.
r14816
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 // Command mode defaults
var default_command_shortcuts = {
'enter' : {
help : 'edit mode',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'aa',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Jonathan Frederic
s/trigger_edit_mode/edit_mode
r15541 IPython.notebook.edit_mode();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'up' : {
help : 'select previous cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'da',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
var index = IPython.notebook.get_selected_index();
if (index !== 0 && index !== null) {
IPython.notebook.select_prev();
Jonathan Frederic
Added comments to kbm and shrunk focus_cell lines
r15539 IPython.notebook.focus_cell();
Jonathan Frederic
jshint
r15491 }
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'down' : {
help : 'select next cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'db',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
var index = IPython.notebook.get_selected_index();
if (index !== (IPython.notebook.ncells()-1) && index !== null) {
IPython.notebook.select_next();
Jonathan Frederic
Added comments to kbm and shrunk focus_cell lines
r15539 IPython.notebook.focus_cell();
Jonathan Frederic
jshint
r15491 }
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
Brian E. Granger
Adding j/k for select next/prev. Faster than up/down.
r14038 'k' : {
help : 'select previous cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'dc',
Brian E. Granger
Adding j/k for select next/prev. Faster than up/down.
r14038 handler : function (event) {
var index = IPython.notebook.get_selected_index();
if (index !== 0 && index !== null) {
IPython.notebook.select_prev();
Jonathan Frederic
Added comments to kbm and shrunk focus_cell lines
r15539 IPython.notebook.focus_cell();
Jonathan Frederic
jshint
r15491 }
Brian E. Granger
Adding j/k for select next/prev. Faster than up/down.
r14038 return false;
}
},
'j' : {
help : 'select next cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'dd',
Brian E. Granger
Adding j/k for select next/prev. Faster than up/down.
r14038 handler : function (event) {
var index = IPython.notebook.get_selected_index();
if (index !== (IPython.notebook.ncells()-1) && index !== null) {
IPython.notebook.select_next();
Jonathan Frederic
Added comments to kbm and shrunk focus_cell lines
r15539 IPython.notebook.focus_cell();
Jonathan Frederic
jshint
r15491 }
Brian E. Granger
Adding j/k for select next/prev. Faster than up/down.
r14038 return false;
}
},
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 'x' : {
help : 'cut cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ee',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 IPython.notebook.cut_cell();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'c' : {
help : 'copy cell',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ef',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 IPython.notebook.copy_cell();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'shift-v' : {
Brian E. Granger
Misc work on shortcuts:...
r14810 help : 'paste cell above',
help_index : 'eg',
handler : function (event) {
IPython.notebook.paste_cell_above();
return false;
}
},
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 'v' : {
help : 'paste cell below',
Brian E. Granger
Misc work on shortcuts:...
r14810 help_index : 'eh',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
Fixing bugs and adding automatic KB shortcut help.
r14037 IPython.notebook.paste_cell_below();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'd' : {
help : 'delete cell (press twice)',
Brian E. Granger
Misc work on shortcuts:...
r14810 help_index : 'ej',
count: 2,
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Brian E. Granger
Misc work on shortcuts:...
r14810 IPython.notebook.delete_cell();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'a' : {
help : 'insert cell above',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ec',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Paul Ivanov
inserting new cells preserves type closes #4917
r16778 IPython.notebook.insert_cell_above();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 IPython.notebook.select_prev();
Brian E. Granger
Focus cells after they are inserted.
r14075 IPython.notebook.focus_cell();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'b' : {
help : 'insert cell below',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ed',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
Paul Ivanov
inserting new cells preserves type closes #4917
r16778 IPython.notebook.insert_cell_below();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 IPython.notebook.select_next();
Brian E. Granger
Focus cells after they are inserted.
r14075 IPython.notebook.focus_cell();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return false;
}
},
'y' : {
help : 'to code',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ca',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_code();
return false;
}
},
'm' : {
help : 'to markdown',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'cb',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_markdown();
return false;
}
},
Brian E. Granger
Misc work on shortcuts:...
r14810 'r' : {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 help : 'to raw',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'cc',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_raw();
return false;
}
},
'1' : {
help : 'to heading 1',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'cd',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_heading(undefined, 1);
return false;
}
},
'2' : {
help : 'to heading 2',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ce',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_heading(undefined, 2);
return false;
}
},
'3' : {
help : 'to heading 3',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'cf',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_heading(undefined, 3);
return false;
}
},
'4' : {
help : 'to heading 4',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'cg',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_heading(undefined, 4);
return false;
}
},
'5' : {
help : 'to heading 5',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ch',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_heading(undefined, 5);
return false;
}
},
'6' : {
help : 'to heading 6',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ci',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.to_heading(undefined, 6);
return false;
}
},
'o' : {
help : 'toggle output',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'gb',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.toggle_output();
return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'shift-o' : {
Brian E. Granger
Simplified Cell menu items related to output.
r14871 help : 'toggle output scrolling',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'gc',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.toggle_output_scroll();
return false;
}
},
's' : {
help : 'save notebook',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'fa',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.save_checkpoint();
return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'ctrl-j' : {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 help : 'move cell down',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'eb',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.move_cell_down();
return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'ctrl-k' : {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 help : 'move cell up',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ea',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.move_cell_up();
return false;
}
},
'l' : {
help : 'toggle line numbers',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ga',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.cell_toggle_line_numbers();
return false;
}
},
'i' : {
Brian E. Granger
Misc work on shortcuts:...
r14810 help : 'interrupt kernel (press twice)',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'ha',
Brian E. Granger
Misc work on shortcuts:...
r14810 count: 2,
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.kernel.interrupt();
return false;
}
},
Brian E. Granger
Misc work on shortcuts:...
r14810 '0' : {
help : 'restart kernel (press twice)',
Brian E. Granger
Adding sorting and better layout to the KB shortcuts.
r14093 help_index : 'hb',
Brian E. Granger
Misc work on shortcuts:...
r14810 count: 2,
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.restart_kernel();
return false;
}
},
'h' : {
help : 'keyboard shortcuts',
Brian E. Granger
Add q to toggle the pager.
r15194 help_index : 'ge',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.quick_help.show_keyboard_shortcuts();
return false;
}
},
'z' : {
help : 'undo last delete',
Brian E. Granger
Misc work on shortcuts:...
r14810 help_index : 'ei',
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 handler : function (event) {
IPython.notebook.undelete_cell();
return false;
}
},
Paul Ivanov
use - for shortcut separators
r15873 'shift-m' : {
Brian E. Granger
Added platform dep. logic.
r14816 help : 'merge cell below',
help_index : 'ek',
handler : function (event) {
IPython.notebook.merge_cell_below();
return false;
}
},
Brian E. Granger
Add q to toggle the pager.
r15194 'q' : {
Brian E. Granger
Just close the pager with q, not toggle.
r15195 help : 'close pager',
Brian E. Granger
Add q to toggle the pager.
r15194 help_index : 'gd',
handler : function (event) {
Brian E. Granger
Just close the pager with q, not toggle.
r15195 IPython.pager.collapse();
Brian E. Granger
Add q to toggle the pager.
r15194 return false;
}
},
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036
Brian E. Granger
Creating new base/js/keyboard.js
r15615 // Main keyboard manager for the notebook
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036
Brian E. Granger
Creating new base/js/keyboard.js
r15615 var ShortcutManager = IPython.keyboard.ShortcutManager;
var keycodes = IPython.keyboard.keycodes;
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036
Brian E. Granger
Adding keyboard manager logic....
r14020 var KeyboardManager = function () {
Brian E. Granger
Lots of updates and changes....
r14021 this.mode = 'command';
Brian E. Granger
Removing KBN null mode and replacing with enable/disable.
r14023 this.enabled = true;
Brian E. Granger
Adding keyboard manager logic....
r14020 this.bind_events();
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 this.command_shortcuts = new ShortcutManager();
this.command_shortcuts.add_shortcuts(default_common_shortcuts);
this.command_shortcuts.add_shortcuts(default_command_shortcuts);
this.edit_shortcuts = new ShortcutManager();
this.edit_shortcuts.add_shortcuts(default_common_shortcuts);
this.edit_shortcuts.add_shortcuts(default_edit_shortcuts);
Brian E. Granger
Adding keyboard manager logic....
r14020 };
KeyboardManager.prototype.bind_events = function () {
var that = this;
$(document).keydown(function (event) {
return that.handle_keydown(event);
});
};
KeyboardManager.prototype.handle_keydown = function (event) {
var notebook = IPython.notebook;
Brian E. Granger
Cleaning up console log messages.
r14089
Jonathan Frederic
jshint
r15491 if (event.which === keycodes.esc) {
Brian E. Granger
Adding keyboard manager logic....
r14020 // Intercept escape at highest level to avoid closing
// websocket connection with firefox
event.preventDefault();
}
Brian E. Granger
Removing KBN null mode and replacing with enable/disable.
r14023 if (!this.enabled) {
Jonathan Frederic
jshint
r15491 if (event.which === keycodes.esc) {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 // ESC
notebook.command_mode();
return false;
}
Brian E. Granger
Removing KBN null mode and replacing with enable/disable.
r14023 return true;
Brian E. Granger
Adding keyboard manager logic....
r14020 }
if (this.mode === 'edit') {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 return this.edit_shortcuts.call_handler(event);
} else if (this.mode === 'command') {
return this.command_shortcuts.call_handler(event);
Brian E. Granger
Adding keyboard manager logic....
r14020 }
return true;
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Adding keyboard manager logic....
r14020
KeyboardManager.prototype.edit_mode = function () {
this.last_mode = this.mode;
this.mode = 'edit';
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Adding keyboard manager logic....
r14020
KeyboardManager.prototype.command_mode = function () {
this.last_mode = this.mode;
this.mode = 'command';
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Adding keyboard manager logic....
r14020
Brian E. Granger
Adding missing enable/disable methods.
r14024 KeyboardManager.prototype.enable = function () {
Brian E. Granger
Fixing bug in KeyboardManager.enable/disable.
r14030 this.enabled = true;
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Adding missing enable/disable methods.
r14024
KeyboardManager.prototype.disable = function () {
Brian E. Granger
Fixing bug in KeyboardManager.enable/disable.
r14030 this.enabled = false;
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Adding missing enable/disable methods.
r14024
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 KeyboardManager.prototype.register_events = function (e) {
var that = this;
Jonathan Frederic
Fixed rebase problems
r15496 var handle_focus = function () {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 that.disable();
Jonathan Frederic
Fixed rebase problems
r15496 };
var handle_blur = function () {
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 that.enable();
Jonathan Frederic
Fixed rebase problems
r15496 };
e.on('focusin', handle_focus);
e.on('focusout', handle_blur);
Jonathan Frederic
Re-added widget textbox blur fix FF
r15507 // TODO: Very strange. The focusout event does not seem fire for the
Jonathan Frederic
Added comments to kbm and shrunk focus_cell lines
r15539 // bootstrap textboxes on FF25&26... This works around that by
// registering focus and blur events recursively on all inputs within
// registered element.
Jonathan Frederic
Re-added widget textbox blur fix FF
r15507 e.find('input').blur(handle_blur);
e.on('DOMNodeInserted', function (event) {
var target = $(event.target);
if (target.is('input')) {
target.blur(handle_blur);
} else {
target.find('input').blur(handle_blur);
}
});
Brian E. Granger
Fix raw_input.
r14046 // There are times (raw_input) where we remove the element from the DOM before
// focusout is called. In this case we bind to the remove event of jQueryUI,
MinRK
fix remove event in KeyboardManager.register_events...
r15328 // which gets triggered upon removal, iff it is focused at the time.
Jonathan Frederic
Added comments to kbm and shrunk focus_cell lines
r15539 // is_focused must be used to check for the case where an element within
// the element being removed is focused.
Brian E. Granger
Fix raw_input.
r14046 e.on('remove', function () {
Jonathan Frederic
Use is_focused for element kbman removal event
r15494 if (IPython.utils.is_focused(e[0])) {
MinRK
fix remove event in KeyboardManager.register_events...
r15328 that.enable();
}
Brian E. Granger
Fix raw_input.
r14046 });
Jonathan Frederic
jshint
r15491 };
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036
Brian E. Granger
Adding missing enable/disable methods.
r14024
Brian E. Granger
Like, OMG, keyboardmanager.js is a beast.
r14036 IPython.default_common_shortcuts = default_common_shortcuts;
IPython.default_edit_shortcuts = default_edit_shortcuts;
IPython.default_command_shortcuts = default_command_shortcuts;
Brian E. Granger
Adding keyboard manager logic....
r14020 IPython.KeyboardManager = KeyboardManager;
return IPython;
}(IPython));