Merge pull request #5436 from ivanov/cm-shorcuts-quickhelp

CodeMirror shortcuts in QuickHelp
Min RK 12 years ago
commit 3f3f3c136e

@ -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 = {

@ -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('<h4>Edit Mode (press <code>Enter</code> to enable)</h4>', edit_shortcuts);
jQuery.extend(cm_shortcuts, edit_shortcuts);
return build_div('<h4>Edit Mode (press <code>Enter</code> to enable)</h4>', cm_shortcuts);
};
var build_one = function (s) {

@ -394,10 +394,6 @@ Ctrl-m . restart kernel
Ctrl-m h show keyboard shortcuts
============ ==========================
.. seealso::
:ref:`Some additional Codemirror keyboard shortcuts <cm_keyboard>`
Plotting

Loading…
Cancel
Save