// Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. define([ 'base/js/namespace', 'jquery', 'base/js/utils', 'base/js/dialog', ], function(IPython, $, utils, dialog) { "use strict"; var platform = utils.platform; var QuickHelp = function (selector, keyboard_manager, events) { this.keyboard_manager = keyboard_manager; keyboard_manager.quick_help = this; this.events = events; }; 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; if ( this.force_rebuild ) { this.shortcut_dialog.remove(); delete(this.shortcut_dialog); this.force_rebuild = false; } if ( this.shortcut_dialog ){ // if dialog is already shown, close it $(this.shortcut_dialog).modal("toggle"); return; } var command_shortcuts = this.keyboard_manager.command_shortcuts.help(); var edit_shortcuts = this.keyboard_manager.edit_shortcuts.help(); var help, shortcut; var i, half, n; var element = $('
'); // The documentation var doc = $('
').addClass('alert alert-warning'); doc.append( $('