diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index 28e4e14..940db3f 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -157,50 +157,8 @@ var IPython = (function (IPython) { return false; } }, - 'tab' : { - help : 'indent or complete', - help_index : 'ec', - }, - 'shift-tab' : { - help : 'tooltip', - help_index : 'ed', - }, }; - if (platform === 'MacOS') { - default_edit_shortcuts['cmd-/'] = - { - help : 'toggle comment', - help_index : 'ee' - }; - default_edit_shortcuts['cmd-]'] = - { - help : 'indent', - help_index : 'ef' - }; - default_edit_shortcuts['cmd-['] = - { - help : 'dedent', - help_index : 'eg' - }; - } else { - default_edit_shortcuts['ctrl-/'] = - { - help : 'toggle comment', - help_index : 'ee' - }; - default_edit_shortcuts['ctrl-]'] = - { - help : 'indent', - help_index : 'ef' - }; - default_edit_shortcuts['ctrl-['] = - { - help : 'dedent', - help_index : 'eg' - }; - } - // Command mode defaults var default_command_shortcuts = { diff --git a/IPython/html/static/notebook/js/quickhelp.js b/IPython/html/static/notebook/js/quickhelp.js index e2883ca..ce6eea7 100644 --- a/IPython/html/static/notebook/js/quickhelp.js +++ b/IPython/html/static/notebook/js/quickhelp.js @@ -1,9 +1,5 @@ -//---------------------------------------------------------------------------- -// Copyright (C) 2008-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. -//---------------------------------------------------------------------------- +// Copyright (c) IPython Development Team. +// Distributed under the terms of the Modified BSD License. //============================================================================ // QuickHelp button @@ -12,9 +8,55 @@ var IPython = (function (IPython) { "use strict"; + var platform = IPython.utils.platform; + var QuickHelp = function (selector) { }; + var cmd_ctrl = 'Ctrl-'; + var platform_specific; + + if (platform === 'MacOS') { + // Mac OS X specific + cmd_ctrl = 'Cmd-'; + platform_specific = [ + { shortcut: "Cmd-Up", help:"go to cell start" }, + { shortcut: "Cmd-Down", help:"go to cell end" }, + { shortcut: "Opt-Left", help:"go one word left" }, + { shortcut: "Opt-Right", help:"go one word right" }, + { shortcut: "Opt-Backspace", help:"del word before" }, + { shortcut: "Opt-Delete", help:"del word after" }, + ]; + } else { + // PC specific + platform_specific = [ + { shortcut: "Ctrl-Home", help:"go to cell start" }, + { shortcut: "Ctrl-Up", help:"go to cell start" }, + { shortcut: "Ctrl-End", help:"go to cell end" }, + { shortcut: "Ctrl-Down", help:"go to cell end" }, + { shortcut: "Ctrl-Left", help:"go one word left" }, + { shortcut: "Ctrl-Right", help:"go one word right" }, + { shortcut: "Ctrl-Backspace", help:"del word before" }, + { shortcut: "Ctrl-Delete", help:"del word after" }, + ]; + } + + var cm_shortcuts = [ + { shortcut:"Tab", help:"code completion or indent" }, + { shortcut:"Shift-Tab", help:"tooltip" }, + { shortcut: cmd_ctrl + "]", help:"indent" }, + { shortcut: cmd_ctrl + "[", help:"dedent" }, + { shortcut: cmd_ctrl + "a", help:"select all" }, + { shortcut: cmd_ctrl + "z", help:"undo" }, + { shortcut: cmd_ctrl + "Shift-z", help:"redo" }, + { shortcut: cmd_ctrl + "y", help:"redo" }, + ].concat( platform_specific ); + + + + + + QuickHelp.prototype.show_keyboard_shortcuts = function () { // toggles display of keyboard shortcut dialog var that = this; @@ -51,7 +93,7 @@ var IPython = (function (IPython) { element.append(cmd_div); // Edit mode - var edit_div = this.build_edit_help(); + var edit_div = this.build_edit_help(cm_shortcuts); element.append(edit_div); this.shortcut_dialog = IPython.dialog.modal({ @@ -91,10 +133,10 @@ var IPython = (function (IPython) { }; - QuickHelp.prototype.build_edit_help = function () { + QuickHelp.prototype.build_edit_help = function (cm_shortcuts) { var edit_shortcuts = IPython.keyboard_manager.edit_shortcuts.help(); - // Edit mode - return build_div('

Edit Mode (press Enter to enable)

', edit_shortcuts); + jQuery.extend(cm_shortcuts, edit_shortcuts); + return build_div('

Edit Mode (press Enter to enable)

', cm_shortcuts); }; var build_one = function (s) { diff --git a/docs/source/notebook/cm_keyboard.rst b/docs/source/notebook/cm_keyboard.rst deleted file mode 100644 index 05e69b3..0000000 --- a/docs/source/notebook/cm_keyboard.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. _cm_keyboard: - -Some additional Codemirror keyboard shortcuts -============================================= - -Because each cell of the IPython notebook is powered by Codemirror, -you can actually use a set of predetermined keyboard shortcuts to -write and manipulate your content easily: - -================== ============== ================== -Action PC shortcut Mac shortcut -================== ============== ================== -newline & indent Enter Enter -toggle overwrite Insert Insert -code completion Tab Tab -help introspection Shift-Tab Shift-Tab -indent Ctrl-] Cmd-] -dedent Ctrl-[ Cmd-[ -select all Ctrl-A Cmd-A -delete line Ctrl-D Cmd-D -undo Ctrl-Z Cmd-Z -redo Ctrl-Shift-Z Cmd-Shift-Z -redo Ctrl-Y Cmd-Y -go to cell start Ctrl-Home Cmd-Up -go to cell start Alt-Up Cmd-End -go to cell start PageUp PageUp -go to cell end Ctrl-End --- -go to cell end Ctrl-Down Cmd-Down -go to cell end PageDown PageDown -go one word left Ctrl-Left Alt-Left -go one word right Ctrl-Right Alt-Right -go to line start Alt-Left Cmd-Left -go to line start Home Home -go to line end Alt-Right Cmd-Right -go to line end End End -del word before Ctrl-Backspace Alt-Backspace -del word after --- Ctrl-Alt-Backspace -del word after Ctrl-Delete Alt-Delete -================== ============== ================== - -.. note:: - - These shortcuts are valid for US keyboards, so some shortcuts can change - for non-US keyboards. diff --git a/docs/source/notebook/notebook.rst b/docs/source/notebook/notebook.rst index c0a4880..98a930b 100644 --- a/docs/source/notebook/notebook.rst +++ b/docs/source/notebook/notebook.rst @@ -394,10 +394,6 @@ Ctrl-m . restart kernel Ctrl-m h show keyboard shortcuts ============ ========================== -.. seealso:: - - :ref:`Some additional Codemirror keyboard shortcuts ` - Plotting