##// END OF EJS Templates
prettify combo keyboard shortcuts
Paul Ivanov -
Show More
@@ -79,7 +79,7 var IPython = (function (IPython) {
79 half = ~~(n/2); // Truncate :)
79 half = ~~(n/2); // Truncate :)
80 for (i=0; i<half; i++) {
80 for (i=0; i<half; i++) {
81 help = command_shortcuts[i]['help'];
81 help = command_shortcuts[i]['help'];
82 shortcut = shortcut_name(command_shortcuts[i]['shortcut']);
82 shortcut = prettify(command_shortcuts[i]['shortcut']);
83 cmd_col1.append($('<div>').addClass('quickhelp').
83 cmd_col1.append($('<div>').addClass('quickhelp').
84 append($('<span/>').addClass('shortcut_key').text(shortcut)).
84 append($('<span/>').addClass('shortcut_key').text(shortcut)).
85 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
85 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
@@ -87,7 +87,7 var IPython = (function (IPython) {
87 };
87 };
88 for (i=half; i<n; i++) {
88 for (i=half; i<n; i++) {
89 help = command_shortcuts[i]['help'];
89 help = command_shortcuts[i]['help'];
90 shortcut = shortcut_name(command_shortcuts[i]['shortcut']);
90 shortcut = prettify(command_shortcuts[i]['shortcut']);
91 cmd_col2.append($('<div>').addClass('quickhelp').
91 cmd_col2.append($('<div>').addClass('quickhelp').
92 append($('<span/>').addClass('shortcut_key').text(shortcut)).
92 append($('<span/>').addClass('shortcut_key').text(shortcut)).
93 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
93 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
@@ -99,8 +99,15 var IPython = (function (IPython) {
99 }
99 }
100
100
101 var special_case = { pageup: "PageUp", pagedown: "Page Down" };
101 var special_case = { pageup: "PageUp", pagedown: "Page Down" };
102 var shortcut_name = function (s) {
102 var prettify = function (s) {
103 return ( special_case[s] ? special_case[s] : s.charAt(0).toUpperCase() + s.slice(1) );
103 var keys = s.split('+');
104 var k, i;
105 for (i in keys) {
106 k = keys[i];
107 if ( k.length == 1 ) continue; // leave individual keys lower-cased
108 keys[i] = ( special_case[k] ? special_case[k] : k.charAt(0).toUpperCase() + k.slice(1) );
109 }
110 return keys.join('-');
104
111
105
112
106 };
113 };
@@ -119,7 +126,7 var IPython = (function (IPython) {
119 half = ~~(n/2); // Truncate :)
126 half = ~~(n/2); // Truncate :)
120 for (i=0; i<half; i++) {
127 for (i=0; i<half; i++) {
121 help = edit_shortcuts[i]['help'];
128 help = edit_shortcuts[i]['help'];
122 shortcut = shortcut_name(edit_shortcuts[i]['shortcut']);
129 shortcut = prettify(edit_shortcuts[i]['shortcut']);
123 edit_col1.append($('<div>').addClass('quickhelp').
130 edit_col1.append($('<div>').addClass('quickhelp').
124 append($('<span/>').addClass('shortcut_key').text(shortcut)).
131 append($('<span/>').addClass('shortcut_key').text(shortcut)).
125 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
132 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
@@ -127,7 +134,7 var IPython = (function (IPython) {
127 };
134 };
128 for (i=half; i<n; i++) {
135 for (i=half; i<n; i++) {
129 help = edit_shortcuts[i]['help'];
136 help = edit_shortcuts[i]['help'];
130 shortcut = shortcut_name(edit_shortcuts[i]['shortcut']);
137 shortcut = prettify(edit_shortcuts[i]['shortcut']);
131 edit_col2.append($('<div>').addClass('quickhelp').
138 edit_col2.append($('<div>').addClass('quickhelp').
132 append($('<span/>').addClass('shortcut_key').text(shortcut)).
139 append($('<span/>').addClass('shortcut_key').text(shortcut)).
133 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
140 append($('<span/>').addClass('shortcut_descr').text(' : ' + help))
General Comments 0
You need to be logged in to leave comments. Login now