##// END OF EJS Templates
Added platform dep. logic.
Brian E. Granger -
Show More
@@ -459,6 +459,16 b' IPython.utils = (function (IPython) {'
459 return M;
459 return M;
460 })();
460 })();
461
461
462 // http://stackoverflow.com/questions/11219582/how-to-detect-my-browser-version-and-operating-system-using-javascript
463 var platform = (function () {
464 var OSName="Unknown OS";
465 if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
466 if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
467 if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
468 if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
469 return OSName
470 })();
471
462 var is_or_has = function (a, b) {
472 var is_or_has = function (a, b) {
463 // Is b a child of a or a itself?
473 // Is b a child of a or a itself?
464 return a.has(b).length !==0 || a.is(b);
474 return a.has(b).length !==0 || a.is(b);
@@ -500,6 +510,7 b' IPython.utils = (function (IPython) {'
500 splitext : splitext,
510 splitext : splitext,
501 always_new : always_new,
511 always_new : always_new,
502 browser : browser,
512 browser : browser,
513 platform: platform,
503 is_or_has : is_or_has,
514 is_or_has : is_or_has,
504 is_focused : is_focused
515 is_focused : is_focused
505 };
516 };
@@ -50,6 +50,7 b' var IPython = (function (IPython) {'
50 }
50 }
51
51
52 var browser = IPython.utils.browser[0];
52 var browser = IPython.utils.browser[0];
53 var platform = IPython.utils.platform;
53
54
54 if (browser === 'Firefox' || browser === 'Opera') {
55 if (browser === 'Firefox' || browser === 'Opera') {
55 $.extend(_keycodes, _mozilla_keycodes);
56 $.extend(_keycodes, _mozilla_keycodes);
@@ -78,24 +79,6 b' var IPython = (function (IPython) {'
78 // Default keyboard shortcuts
79 // Default keyboard shortcuts
79
80
80 var default_common_shortcuts = {
81 var default_common_shortcuts = {
81 'meta+s' : {
82 help : 'save notebook',
83 help_index : 'fb',
84 handler : function (event) {
85 IPython.notebook.save_checkpoint();
86 event.preventDefault();
87 return false;
88 }
89 },
90 'ctrl+s' : {
91 help : 'save notebook',
92 help_index : 'fc',
93 handler : function (event) {
94 IPython.notebook.save_checkpoint();
95 event.preventDefault();
96 return false;
97 }
98 },
99 'shift' : {
82 'shift' : {
100 help : '',
83 help : '',
101 help_index : '',
84 help_index : '',
@@ -130,6 +113,30 b' var IPython = (function (IPython) {'
130 }
113 }
131 }
114 }
132
115
116 if (platform === 'MacOS') {
117 default_common_shortcuts['cmd+s'] =
118 {
119 help : 'save notebook',
120 help_index : 'fb',
121 handler : function (event) {
122 IPython.notebook.save_checkpoint();
123 event.preventDefault();
124 return false;
125 }
126 };
127 } else {
128 default_common_shortcuts['ctrl+s'] =
129 {
130 help : 'save notebook',
131 help_index : 'fb',
132 handler : function (event) {
133 IPython.notebook.save_checkpoint();
134 event.preventDefault();
135 return false;
136 }
137 };
138 }
139
133 // Edit mode defaults
140 // Edit mode defaults
134
141
135 var default_edit_shortcuts = {
142 var default_edit_shortcuts = {
@@ -195,6 +202,48 b' var IPython = (function (IPython) {'
195 return false;
202 return false;
196 }
203 }
197 },
204 },
205 'tab' : {
206 help : 'indent or complete',
207 help_index : 'ec',
208 },
209 'shift+tab' : {
210 help : 'tooltip',
211 help_index : 'ed',
212 },
213 }
214
215 if (platform === 'MacOS') {
216 default_edit_shortcuts['cmd+/'] =
217 {
218 help : 'toggle comment',
219 help_index : 'ee'
220 };
221 default_edit_shortcuts['cmd+]'] =
222 {
223 help : 'indent',
224 help_index : 'ef'
225 };
226 default_edit_shortcuts['cmd+['] =
227 {
228 help : 'dedent',
229 help_index : 'eg'
230 };
231 } else {
232 default_edit_shortcuts['ctrl+/'] =
233 {
234 help : 'toggle comment',
235 help_index : 'ee'
236 };
237 default_edit_shortcuts['ctrl+]'] =
238 {
239 help : 'indent',
240 help_index : 'ef'
241 };
242 default_edit_shortcuts['ctrl+['] =
243 {
244 help : 'dedent',
245 help_index : 'eg'
246 };
198 }
247 }
199
248
200 // Command mode defaults
249 // Command mode defaults
@@ -402,7 +451,7 b' var IPython = (function (IPython) {'
402 }
451 }
403 },
452 },
404 'shift+o' : {
453 'shift+o' : {
405 help : 'toggle output',
454 help : 'toggle output scroll',
406 help_index : 'gc',
455 help_index : 'gc',
407 handler : function (event) {
456 handler : function (event) {
408 IPython.notebook.toggle_output_scroll();
457 IPython.notebook.toggle_output_scroll();
@@ -483,6 +532,14 b' var IPython = (function (IPython) {'
483 return false;
532 return false;
484 }
533 }
485 },
534 },
535 'shift+m' : {
536 help : 'merge cell below',
537 help_index : 'ek',
538 handler : function (event) {
539 IPython.notebook.merge_cell_below();
540 return false;
541 }
542 },
486 }
543 }
487
544
488
545
@@ -500,6 +557,9 b' var IPython = (function (IPython) {'
500 var help_string = this._shortcuts[shortcut]['help'];
557 var help_string = this._shortcuts[shortcut]['help'];
501 var help_index = this._shortcuts[shortcut]['help_index'];
558 var help_index = this._shortcuts[shortcut]['help_index'];
502 if (help_string) {
559 if (help_string) {
560 if (platform === 'MacOS') {
561 shortcut = shortcut.replace('meta', 'cmd');
562 }
503 help.push({
563 help.push({
504 shortcut: shortcut,
564 shortcut: shortcut,
505 help: help_string,
565 help: help_string,
@@ -523,6 +583,7 b' var IPython = (function (IPython) {'
523
583
524 ShortcutManager.prototype.normalize_shortcut = function (shortcut) {
584 ShortcutManager.prototype.normalize_shortcut = function (shortcut) {
525 // Sort a sequence of + separated modifiers into the order alt+ctrl+meta+shift
585 // Sort a sequence of + separated modifiers into the order alt+ctrl+meta+shift
586 shortcut = shortcut.replace('cmd', 'meta').toLowerCase();
526 var values = shortcut.split("+");
587 var values = shortcut.split("+");
527 if (values.length === 1) {
588 if (values.length === 1) {
528 return this.normalize_key(values[0])
589 return this.normalize_key(values[0])
@@ -88,7 +88,7 b' var IPython = (function (IPython) {'
88 });
88 });
89
89
90 $([IPython.events]).on('status_interrupting.Kernel',function () {
90 $([IPython.events]).on('status_interrupting.Kernel',function () {
91 knw.set_message("Interrupting kernel");
91 knw.set_message("Interrupting kernel", 2000);
92 });
92 });
93
93
94 $([IPython.events]).on('status_dead.Kernel',function () {
94 $([IPython.events]).on('status_dead.Kernel',function () {
General Comments 0
You need to be logged in to leave comments. Login now