Show More
@@ -4,7 +4,8 b'' | |||||
4 | define([ |
|
4 | define([ | |
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'jquery', |
|
6 | 'jquery', | |
7 | ], function(IPython, $) { |
|
7 | 'codemirror/lib/codemirror', | |
|
8 | ], function(IPython, $, CodeMirror) { | |||
8 | "use strict"; |
|
9 | "use strict"; | |
9 |
|
10 | |||
10 | var modal = function (options) { |
|
11 | var modal = function (options) { |
@@ -1,5 +1,12 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
|
3 | /** | |||
|
4 | * | |||
|
5 | * | |||
|
6 | * @module keyboard | |||
|
7 | * @namespace keyboard | |||
|
8 | * @class ShortcutManager | |||
|
9 | */ | |||
3 |
|
10 | |||
4 | define([ |
|
11 | define([ | |
5 | 'base/js/namespace', |
|
12 | 'base/js/namespace', | |
@@ -126,6 +133,12 b' define([' | |||||
126 | // Shortcut manager class |
|
133 | // Shortcut manager class | |
127 |
|
134 | |||
128 | var ShortcutManager = function (delay, events) { |
|
135 | var ShortcutManager = function (delay, events) { | |
|
136 | /** | |||
|
137 | * A class to deal with keyboard event and shortcut | |||
|
138 | * | |||
|
139 | * @class ShortcutManager | |||
|
140 | * @constructor | |||
|
141 | */ | |||
129 | this._shortcuts = {}; |
|
142 | this._shortcuts = {}; | |
130 | this._counts = {}; |
|
143 | this._counts = {}; | |
131 | this._timers = {}; |
|
144 | this._timers = {}; | |
@@ -201,6 +214,16 b' define([' | |||||
201 | }; |
|
214 | }; | |
202 |
|
215 | |||
203 | ShortcutManager.prototype.count_handler = function (shortcut, event, data) { |
|
216 | ShortcutManager.prototype.count_handler = function (shortcut, event, data) { | |
|
217 | /** | |||
|
218 | * Seem to allow to call an handler only after several key press. | |||
|
219 | * like, I suppose `dd` that delete the current cell only after | |||
|
220 | * `d` has been pressed twice.. | |||
|
221 | * @method count_handler | |||
|
222 | * @return {Boolean} `true|false`, whether or not the event has been handled. | |||
|
223 | * @param shortcut {shortcut} | |||
|
224 | * @param event {event} | |||
|
225 | * @param data {data} | |||
|
226 | */ | |||
204 | var that = this; |
|
227 | var that = this; | |
205 | var c = this._counts; |
|
228 | var c = this._counts; | |
206 | var t = this._timers; |
|
229 | var t = this._timers; | |
@@ -221,6 +244,12 b' define([' | |||||
221 | }; |
|
244 | }; | |
222 |
|
245 | |||
223 | ShortcutManager.prototype.call_handler = function (event) { |
|
246 | ShortcutManager.prototype.call_handler = function (event) { | |
|
247 | /** | |||
|
248 | * Call the corresponding shortcut handler for a keyboard event | |||
|
249 | * @method call_handler | |||
|
250 | * @return {Boolean} `true|false`, `false` if no handler was found, otherwise the value return by the handler. | |||
|
251 | * @param event {event} | |||
|
252 | */ | |||
224 | var shortcut = event_to_shortcut(event); |
|
253 | var shortcut = event_to_shortcut(event); | |
225 | var data = this._shortcuts[shortcut]; |
|
254 | var data = this._shortcuts[shortcut]; | |
226 | if (data) { |
|
255 | if (data) { | |
@@ -252,7 +281,7 b' define([' | |||||
252 | event_to_shortcut : event_to_shortcut |
|
281 | event_to_shortcut : event_to_shortcut | |
253 | }; |
|
282 | }; | |
254 |
|
283 | |||
255 |
// For backwards compat |
|
284 | // For backwards compatibility. | |
256 | IPython.keyboard = keyboard; |
|
285 | IPython.keyboard = keyboard; | |
257 |
|
286 | |||
258 | return keyboard; |
|
287 | return keyboard; |
@@ -4,7 +4,8 b'' | |||||
4 | define([ |
|
4 | define([ | |
5 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
6 | 'jquery', |
|
6 | 'jquery', | |
7 | ], function(IPython, $){ |
|
7 | 'codemirror/lib/codemirror', | |
|
8 | ], function(IPython, $, CodeMirror){ | |||
8 | "use strict"; |
|
9 | "use strict"; | |
9 |
|
10 | |||
10 | IPython.load_extensions = function () { |
|
11 | IPython.load_extensions = function () { |
@@ -1,1 +1,1 b'' | |||||
1 | Subproject commit b3909af1b61ca7a412481759fdb441ecdfb3ab66 |
|
1 | Subproject commit 1760cce3697b0535efb598fbd609abd6caebf920 |
@@ -1,11 +1,24 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
|
4 | /** | |||
|
5 | * | |||
|
6 | * | |||
|
7 | * @module cell | |||
|
8 | * @namespace cell | |||
|
9 | * @class Cell | |||
|
10 | */ | |||
|
11 | ||||
|
12 | ||||
4 | define([ |
|
13 | define([ | |
5 | 'base/js/namespace', |
|
14 | 'base/js/namespace', | |
6 | 'jquery', |
|
15 | 'jquery', | |
7 | 'base/js/utils', |
|
16 | 'base/js/utils', | |
8 | ], function(IPython, $, utils) { |
|
17 | 'codemirror/lib/codemirror', | |
|
18 | 'codemirror/addon/edit/matchbrackets', | |||
|
19 | 'codemirror/addon/edit/closebrackets', | |||
|
20 | 'codemirror/addon/comment/comment' | |||
|
21 | ], function(IPython, $, utils, CodeMirror, cm_match, cm_closeb, cm_comment) { | |||
9 | // TODO: remove IPython dependency here |
|
22 | // TODO: remove IPython dependency here | |
10 | "use strict"; |
|
23 | "use strict"; | |
11 |
|
24 | |||
@@ -29,16 +42,17 b' define([' | |||||
29 | // end monkey patching CodeMirror |
|
42 | // end monkey patching CodeMirror | |
30 |
|
43 | |||
31 | var Cell = function (options) { |
|
44 | var Cell = function (options) { | |
32 |
/ |
|
45 | /* Constructor | |
33 |
|
|
46 | * | |
34 |
|
|
47 | * The Base `Cell` class from which to inherit. | |
35 | // |
|
48 | * @constructor | |
36 |
|
|
49 | * @param: | |
37 |
|
|
50 | * options: dictionary | |
38 |
|
|
51 | * Dictionary of keyword arguments. | |
39 |
|
|
52 | * events: $(Events) instance | |
40 |
|
|
53 | * config: dictionary | |
41 |
|
|
54 | * keyboard_manager: KeyboardManager instance | |
|
55 | */ | |||
42 | options = options || {}; |
|
56 | options = options || {}; | |
43 | this.keyboard_manager = options.keyboard_manager; |
|
57 | this.keyboard_manager = options.keyboard_manager; | |
44 | this.events = options.events; |
|
58 | this.events = options.events; | |
@@ -278,8 +292,6 b' define([' | |||||
278 | */ |
|
292 | */ | |
279 | Cell.prototype.handle_keyevent = function (editor, event) { |
|
293 | Cell.prototype.handle_keyevent = function (editor, event) { | |
280 |
|
294 | |||
281 | // console.log('CM', this.mode, event.which, event.type) |
|
|||
282 |
|
||||
283 | if (this.mode === 'command') { |
|
295 | if (this.mode === 'command') { | |
284 | return true; |
|
296 | return true; | |
285 | } else if (this.mode === 'edit') { |
|
297 | } else if (this.mode === 'edit') { |
@@ -1,5 +1,13 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
|
3 | /** | |||
|
4 | * | |||
|
5 | * | |||
|
6 | * @module codecell | |||
|
7 | * @namespace codecell | |||
|
8 | * @class CodeCell | |||
|
9 | */ | |||
|
10 | ||||
3 |
|
11 | |||
4 | define([ |
|
12 | define([ | |
5 | 'base/js/namespace', |
|
13 | 'base/js/namespace', | |
@@ -10,7 +18,10 b' define([' | |||||
10 | 'notebook/js/outputarea', |
|
18 | 'notebook/js/outputarea', | |
11 | 'notebook/js/completer', |
|
19 | 'notebook/js/completer', | |
12 | 'notebook/js/celltoolbar', |
|
20 | 'notebook/js/celltoolbar', | |
13 | ], function(IPython, $, utils, keyboard, cell, outputarea, completer, celltoolbar) { |
|
21 | 'codemirror/lib/codemirror', | |
|
22 | 'codemirror/mode/python/python', | |||
|
23 | 'notebook/js/codemirror-ipython' | |||
|
24 | ], function(IPython, $, utils, keyboard, cell, outputarea, completer, celltoolbar, CodeMirror, cmpython, cmip) { | |||
14 | "use strict"; |
|
25 | "use strict"; | |
15 | var Cell = cell.Cell; |
|
26 | var Cell = cell.Cell; | |
16 |
|
27 | |||
@@ -102,9 +113,7 b' define([' | |||||
102 | }, |
|
113 | }, | |
103 | mode: 'ipython', |
|
114 | mode: 'ipython', | |
104 | theme: 'ipython', |
|
115 | theme: 'ipython', | |
105 |
matchBrackets: true |
|
116 | matchBrackets: true | |
106 | // don't auto-close strings because of CodeMirror #2385 |
|
|||
107 | autoCloseBrackets: "()[]{}" |
|
|||
108 | } |
|
117 | } | |
109 | }; |
|
118 | }; | |
110 |
|
119 | |||
@@ -135,6 +144,7 b' define([' | |||||
135 | inner_cell.append(this.celltoolbar.element); |
|
144 | inner_cell.append(this.celltoolbar.element); | |
136 | var input_area = $('<div/>').addClass('input_area'); |
|
145 | var input_area = $('<div/>').addClass('input_area'); | |
137 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); |
|
146 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); | |
|
147 | this.code_mirror.on('keydown', $.proxy(this.handle_codemirror_keyevent,this)) | |||
138 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); |
|
148 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); | |
139 | inner_cell.append(input_area); |
|
149 | inner_cell.append(input_area); | |
140 | input.append(prompt).append(inner_cell); |
|
150 | input.append(prompt).append(inner_cell); | |
@@ -220,7 +230,8 b' define([' | |||||
220 | } |
|
230 | } | |
221 | // If we closed the tooltip, don't let CM or the global handlers |
|
231 | // If we closed the tooltip, don't let CM or the global handlers | |
222 | // handle this event. |
|
232 | // handle this event. | |
223 | event.stop(); |
|
233 | event.codemirrorIgnore = true; | |
|
234 | event.preventDefault(); | |||
224 | return true; |
|
235 | return true; | |
225 | } else if (event.keyCode === keycodes.tab && event.type === 'keydown' && event.shiftKey) { |
|
236 | } else if (event.keyCode === keycodes.tab && event.type === 'keydown' && event.shiftKey) { | |
226 | if (editor.somethingSelected()){ |
|
237 | if (editor.somethingSelected()){ | |
@@ -231,7 +242,8 b' define([' | |||||
231 | } |
|
242 | } | |
232 | } |
|
243 | } | |
233 | this.tooltip.request(that); |
|
244 | this.tooltip.request(that); | |
234 |
event. |
|
245 | event.codemirrorIgnore = true; | |
|
246 | event.preventDefault(); | |||
235 | return true; |
|
247 | return true; | |
236 | } else if (event.keyCode === keycodes.tab && event.type == 'keydown') { |
|
248 | } else if (event.keyCode === keycodes.tab && event.type == 'keydown') { | |
237 | // Tab completion. |
|
249 | // Tab completion. | |
@@ -245,7 +257,8 b' define([' | |||||
245 | // is empty. In this case, let CodeMirror handle indentation. |
|
257 | // is empty. In this case, let CodeMirror handle indentation. | |
246 | return false; |
|
258 | return false; | |
247 | } else { |
|
259 | } else { | |
248 |
event. |
|
260 | event.codemirrorIgnore = true; | |
|
261 | event.preventDefault(); | |||
249 | this.completer.startCompletion(); |
|
262 | this.completer.startCompletion(); | |
250 | return true; |
|
263 | return true; | |
251 | } |
|
264 | } |
@@ -3,9 +3,20 b'' | |||||
3 | // callback to auto-load python mode, which is more likely not the best things |
|
3 | // callback to auto-load python mode, which is more likely not the best things | |
4 | // to do, but at least the simple one for now. |
|
4 | // to do, but at least the simple one for now. | |
5 |
|
5 | |||
6 | CodeMirror.requireMode('python',function(){ |
|
6 | (function(mod) { | |
|
7 | if (typeof exports == "object" && typeof module == "object"){ // CommonJS | |||
|
8 | mod(require("codemirror/lib/codemirror"), | |||
|
9 | require("codemirror/mode/python/python") | |||
|
10 | ); | |||
|
11 | } else if (typeof define == "function" && define.amd){ // AMD | |||
|
12 | define(["codemirror/lib/codemirror", | |||
|
13 | "codemirror/mode/python/python"], mod); | |||
|
14 | } else {// Plain browser env | |||
|
15 | mod(CodeMirror); | |||
|
16 | } | |||
|
17 | })(function(CodeMirror) { | |||
7 | "use strict"; |
|
18 | "use strict"; | |
8 |
|
19 | |||
9 | CodeMirror.defineMode("ipython", function(conf, parserConf) { |
|
20 | CodeMirror.defineMode("ipython", function(conf, parserConf) { | |
10 | var pythonConf = {}; |
|
21 | var pythonConf = {}; | |
11 | for (var prop in parserConf) { |
|
22 | for (var prop in parserConf) { | |
@@ -25,3 +36,4 b" CodeMirror.requireMode('python',function(){" | |||||
25 |
|
36 | |||
26 | CodeMirror.defineMIME("text/x-ipython", "ipython"); |
|
37 | CodeMirror.defineMIME("text/x-ipython", "ipython"); | |
27 | }) |
|
38 | }) | |
|
39 |
@@ -6,39 +6,59 b'' | |||||
6 | // But was later removed in |
|
6 | // But was later removed in | |
7 | // https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c |
|
7 | // https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c | |
8 |
|
8 | |||
9 | CodeMirror.requireMode('gfm', function(){ |
|
9 | ||
10 | CodeMirror.requireMode('stex', function(){ |
|
10 | (function(mod) { | |
11 | CodeMirror.defineMode("ipythongfm", function(config, parserConfig) { |
|
11 | if (typeof exports == "object" && typeof module == "object"){ // CommonJS | |
12 |
|
12 | mod(require("codemirror/lib/codemirror") | ||
13 | var gfm_mode = CodeMirror.getMode(config, "gfm"); |
|
13 | ,require("codemirror/addon/mode/multiplex") | |
14 | var tex_mode = CodeMirror.getMode(config, "stex"); |
|
14 | ,require("codemirror/mode/gfm/gfm") | |
15 |
|
15 | ,require("codemirror/mode/stex/stex") | ||
16 | return CodeMirror.multiplexingMode( |
|
16 | ); | |
17 | gfm_mode, |
|
17 | } else if (typeof define == "function" && define.amd){ // AMD | |
18 | { |
|
18 | define(["codemirror/lib/codemirror" | |
19 | open: "$", close: "$", |
|
19 | ,"codemirror/addon/mode/multiplex" | |
20 | mode: tex_mode, |
|
20 | ,"codemirror/mode/python/python" | |
21 | delimStyle: "delimit" |
|
21 | ,"codemirror/mode/stex/stex" | |
22 |
|
|
22 | ], mod); | |
23 | { |
|
23 | } else {// Plain browser env | |
24 | open: "$$", close: "$$", |
|
24 | mod(CodeMirror); | |
25 | mode: tex_mode, |
|
25 | } | |
26 | delimStyle: "delimit" |
|
26 | })( function(CodeMirror){ | |
27 | }, |
|
27 | "use strict"; | |
28 | { |
|
28 | ||
29 | open: "\\(", close: "\\)", |
|
29 | CodeMirror.defineMode("ipythongfm", function(config, parserConfig) { | |
30 | mode: tex_mode, |
|
30 | ||
31 | delimStyle: "delimit" |
|
31 | var gfm_mode = CodeMirror.getMode(config, "gfm"); | |
32 | }, |
|
32 | var tex_mode = CodeMirror.getMode(config, "stex"); | |
33 | { |
|
|||
34 | open: "\\[", close: "\\]", |
|
|||
35 | mode: tex_mode, |
|
|||
36 | delimStyle: "delimit" |
|
|||
37 | } |
|
|||
38 | // .. more multiplexed styles can follow here |
|
|||
39 | ); |
|
|||
40 | }, 'gfm'); |
|
|||
41 |
|
33 | |||
42 | CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm"); |
|
34 | return CodeMirror.multiplexingMode( | |
43 | }); |
|
35 | gfm_mode, | |
44 | }); |
|
36 | { | |
|
37 | open: "$", close: "$", | |||
|
38 | mode: tex_mode, | |||
|
39 | delimStyle: "delimit" | |||
|
40 | }, | |||
|
41 | { | |||
|
42 | // not sure this works as $$ is interpreted at (opening $, closing $, as defined just above) | |||
|
43 | open: "$$", close: "$$", | |||
|
44 | mode: tex_mode, | |||
|
45 | delimStyle: "delimit" | |||
|
46 | }, | |||
|
47 | { | |||
|
48 | open: "\\(", close: "\\)", | |||
|
49 | mode: tex_mode, | |||
|
50 | delimStyle: "delimit" | |||
|
51 | }, | |||
|
52 | { | |||
|
53 | open: "\\[", close: "\\]", | |||
|
54 | mode: tex_mode, | |||
|
55 | delimStyle: "delimit" | |||
|
56 | } | |||
|
57 | // .. more multiplexed styles can follow here | |||
|
58 | ); | |||
|
59 | }, 'gfm'); | |||
|
60 | ||||
|
61 | CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm"); | |||
|
62 | ||||
|
63 | ||||
|
64 | }) |
@@ -7,7 +7,8 b' define([' | |||||
7 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
8 | 'base/js/keyboard', |
|
8 | 'base/js/keyboard', | |
9 | 'notebook/js/contexthint', |
|
9 | 'notebook/js/contexthint', | |
10 | ], function(IPython, $, utils, keyboard) { |
|
10 | 'codemirror/lib/codemirror', | |
|
11 | ], function(IPython, $, utils, keyboard, CodeMirror) { | |||
11 | "use strict"; |
|
12 | "use strict"; | |
12 |
|
13 | |||
13 | // easier key mapping |
|
14 | // easier key mapping | |
@@ -316,11 +317,13 b' define([' | |||||
316 |
|
317 | |||
317 | // Enter |
|
318 | // Enter | |
318 | if (code == keycodes.enter) { |
|
319 | if (code == keycodes.enter) { | |
319 |
|
|
320 | event.codemirrorIgnore = true; | |
|
321 | event.preventDefault(); | |||
320 | this.pick(); |
|
322 | this.pick(); | |
321 | // Escape or backspace |
|
323 | // Escape or backspace | |
322 | } else if (code == keycodes.esc || code == keycodes.backspace) { |
|
324 | } else if (code == keycodes.esc || code == keycodes.backspace) { | |
323 |
|
|
325 | event.codemirrorIgnore = true; | |
|
326 | event.preventDefault(); | |||
324 | this.close(); |
|
327 | this.close(); | |
325 | } else if (code == keycodes.tab) { |
|
328 | } else if (code == keycodes.tab) { | |
326 | //all the fastforwarding operation, |
|
329 | //all the fastforwarding operation, | |
@@ -339,7 +342,8 b' define([' | |||||
339 | } else if (code == keycodes.up || code == keycodes.down) { |
|
342 | } else if (code == keycodes.up || code == keycodes.down) { | |
340 | // need to do that to be able to move the arrow |
|
343 | // need to do that to be able to move the arrow | |
341 | // when on the first or last line ofo a code cell |
|
344 | // when on the first or last line ofo a code cell | |
342 |
|
|
345 | event.codemirrorIgnore = true; | |
|
346 | event.preventDefault(); | |||
343 |
|
347 | |||
344 | var options = this.sel.find('option'); |
|
348 | var options = this.sel.find('option'); | |
345 | var index = this.sel[0].selectedIndex; |
|
349 | var index = this.sel[0].selectedIndex; |
@@ -1,6 +1,15 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
|
4 | /** | |||
|
5 | * | |||
|
6 | * | |||
|
7 | * @module config | |||
|
8 | * @namespace config | |||
|
9 | * @class Config | |||
|
10 | */ | |||
|
11 | ||||
|
12 | ||||
4 | define([], function() { |
|
13 | define([], function() { | |
5 | "use strict"; |
|
14 | "use strict"; | |
6 |
|
15 |
@@ -2,7 +2,7 b'' | |||||
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | // highly adapted for codemiror jshint |
|
4 | // highly adapted for codemiror jshint | |
5 | define([], function() { |
|
5 | define(['codemirror/lib/codemirror'], function(CodeMirror) { | |
6 | "use strict"; |
|
6 | "use strict"; | |
7 |
|
7 | |||
8 | var forEach = function(arr, f) { |
|
8 | var forEach = function(arr, f) { |
@@ -1,5 +1,12 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
|
3 | /** | |||
|
4 | * | |||
|
5 | * | |||
|
6 | * @module keyboardmanager | |||
|
7 | * @namespace keyboardmanager | |||
|
8 | * @class KeyboardManager | |||
|
9 | */ | |||
3 |
|
10 | |||
4 | define([ |
|
11 | define([ | |
5 | 'base/js/namespace', |
|
12 | 'base/js/namespace', | |
@@ -16,13 +23,15 b' define([' | |||||
16 | var keycodes = keyboard.keycodes; |
|
23 | var keycodes = keyboard.keycodes; | |
17 |
|
24 | |||
18 | var KeyboardManager = function (options) { |
|
25 | var KeyboardManager = function (options) { | |
19 | // Constructor |
|
26 | /** | |
20 | // |
|
27 | * A class to deal with keyboard event and shortcut | |
21 | // Parameters: |
|
28 | * | |
22 | // options: dictionary |
|
29 | * @class KeyboardManager | |
23 | // Dictionary of keyword arguments. |
|
30 | * @constructor | |
24 | // events: $(Events) instance |
|
31 | * @param options {dict} Dictionary of keyword arguments : | |
25 | // pager: Pager instance |
|
32 | * @param options.events {$(Events)} instance | |
|
33 | * @param options.pager: {Pager} pager instance | |||
|
34 | */ | |||
26 | this.mode = 'command'; |
|
35 | this.mode = 'command'; | |
27 | this.enabled = true; |
|
36 | this.enabled = true; | |
28 | this.pager = options.pager; |
|
37 | this.pager = options.pager; | |
@@ -37,6 +46,22 b' define([' | |||||
37 | this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts()); |
|
46 | this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts()); | |
38 | }; |
|
47 | }; | |
39 |
|
48 | |||
|
49 | /** | |||
|
50 | * Return a dict of common shortcut | |||
|
51 | * @method get_default_common_shortcuts | |||
|
52 | * | |||
|
53 | * @example Example of returned shortcut | |||
|
54 | * ``` | |||
|
55 | * 'shortcut-key': // a string representing the shortcut as dash separated value. | |||
|
56 | * // e.g. 'shift' , 'shift-enter', 'cmd-t' | |||
|
57 | * { | |||
|
58 | * help: String // user facing help string | |||
|
59 | * help_index: String // string used internally to order the shortcut on the quickhelp | |||
|
60 | * handler: function(event){return true|false} // function that takes an even as first and only parameter | |||
|
61 | * // and return a boolean indicating whether or not the event should been handled further. | |||
|
62 | * } | |||
|
63 | *``` | |||
|
64 | */ | |||
40 | KeyboardManager.prototype.get_default_common_shortcuts = function() { |
|
65 | KeyboardManager.prototype.get_default_common_shortcuts = function() { | |
41 | var that = this; |
|
66 | var that = this; | |
42 | var shortcuts = { |
|
67 | var shortcuts = { | |
@@ -125,19 +150,17 b' define([' | |||||
125 | handler : function (event) { |
|
150 | handler : function (event) { | |
126 | var index = that.notebook.get_selected_index(); |
|
151 | var index = that.notebook.get_selected_index(); | |
127 | var cell = that.notebook.get_cell(index); |
|
152 | var cell = that.notebook.get_cell(index); | |
128 | if (cell && cell.at_top() && index !== 0) { |
|
153 | var cm = that.notebook.get_selected_cell().code_mirror; | |
|
154 | var cur = cm.getCursor() | |||
|
155 | if (cell && cell.at_top() && index !== 0 && cur.ch === 0) { | |||
129 | event.preventDefault(); |
|
156 | event.preventDefault(); | |
130 | that.notebook.command_mode(); |
|
157 | that.notebook.command_mode(); | |
131 | that.notebook.select_prev(); |
|
158 | that.notebook.select_prev(); | |
132 | that.notebook.edit_mode(); |
|
159 | that.notebook.edit_mode(); | |
133 | var cm = that.notebook.get_selected_cell().code_mirror; |
|
160 | var cm = that.notebook.get_selected_cell().code_mirror; | |
134 | cm.setCursor(cm.lastLine(), 0); |
|
161 | cm.setCursor(cm.lastLine(), 0); | |
135 | return false; |
|
|||
136 | } else if (cell) { |
|
|||
137 | var cm = cell.code_mirror; |
|
|||
138 | cm.execCommand('goLineUp'); |
|
|||
139 | return false; |
|
|||
140 | } |
|
162 | } | |
|
163 | return false; | |||
141 | } |
|
164 | } | |
142 | }, |
|
165 | }, | |
143 | 'down' : { |
|
166 | 'down' : { | |
@@ -154,11 +177,8 b' define([' | |||||
154 | var cm = that.notebook.get_selected_cell().code_mirror; |
|
177 | var cm = that.notebook.get_selected_cell().code_mirror; | |
155 | cm.setCursor(0, 0); |
|
178 | cm.setCursor(0, 0); | |
156 | return false; |
|
179 | return false; | |
157 | } else { |
|
|||
158 | var cm = cell.code_mirror; |
|
|||
159 | cm.execCommand('goLineDown'); |
|
|||
160 | return false; |
|
|||
161 | } |
|
180 | } | |
|
181 | return false; | |||
162 | } |
|
182 | } | |
163 | }, |
|
183 | }, | |
164 | 'ctrl-shift--' : { |
|
184 | 'ctrl-shift--' : { |
@@ -19,8 +19,10 b' require([' | |||||
19 | 'notebook/js/keyboardmanager', |
|
19 | 'notebook/js/keyboardmanager', | |
20 | 'notebook/js/config', |
|
20 | 'notebook/js/config', | |
21 | 'notebook/js/kernelselector', |
|
21 | 'notebook/js/kernelselector', | |
22 | // only loaded, not used: |
|
22 | 'codemirror/lib/codemirror', | |
23 | 'custom/custom', |
|
23 | 'codemirror/addon/mode/loadmode', | |
|
24 | // only loaded, not used, please keep sure this is loaded last | |||
|
25 | 'custom/custom' | |||
24 | ], function( |
|
26 | ], function( | |
25 | IPython, |
|
27 | IPython, | |
26 | $, |
|
28 | $, | |
@@ -38,10 +40,18 b' require([' | |||||
38 | savewidget, |
|
40 | savewidget, | |
39 | keyboardmanager, |
|
41 | keyboardmanager, | |
40 | config, |
|
42 | config, | |
41 | kernelselector |
|
43 | kernelselector, | |
|
44 | CodeMirror, | |||
|
45 | cm_loadmode, | |||
|
46 | // please keep sure that even if not used, this is loaded last | |||
|
47 | custom | |||
42 | ) { |
|
48 | ) { | |
43 | "use strict"; |
|
49 | "use strict"; | |
44 |
|
50 | |||
|
51 | window.CodeMirror = CodeMirror; | |||
|
52 | $('#ipython-main-app').addClass('border-box-sizing'); | |||
|
53 | $('div#notebook_panel').addClass('border-box-sizing'); | |||
|
54 | ||||
45 | var common_options = { |
|
55 | var common_options = { | |
46 | base_url : utils.get_body_data("baseUrl"), |
|
56 | base_url : utils.get_body_data("baseUrl"), | |
47 | ws_url : IPython.utils.get_body_data("wsUrl"), |
|
57 | ws_url : IPython.utils.get_body_data("wsUrl"), |
@@ -10,7 +10,10 b' define([' | |||||
10 | 'notebook/js/mathjaxutils', |
|
10 | 'notebook/js/mathjaxutils', | |
11 | 'notebook/js/celltoolbar', |
|
11 | 'notebook/js/celltoolbar', | |
12 | 'components/marked/lib/marked', |
|
12 | 'components/marked/lib/marked', | |
13 | ], function(IPython, utils, $, cell, security, mathjaxutils, celltoolbar, marked) { |
|
13 | 'codemirror/lib/codemirror', | |
|
14 | 'codemirror/mode/gfm/gfm', | |||
|
15 | 'notebook/js/codemirror-ipythongfm' | |||
|
16 | ], function(IPython,utils , $, cell, security, mathjaxutils, celltoolbar, marked, CodeMirror, gfm, ipgfm) { | |||
14 | "use strict"; |
|
17 | "use strict"; | |
15 | var Cell = cell.Cell; |
|
18 | var Cell = cell.Cell; | |
16 |
|
19 |
@@ -311,25 +311,17 b' class="notebook_app"' | |||||
311 | {% block script %} |
|
311 | {% block script %} | |
312 | {{super()}} |
|
312 | {{super()}} | |
313 |
|
313 | |||
314 | <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script> |
|
314 | ||
315 | <script type="text/javascript"> |
|
315 | <script type="text/javascript"> | |
316 | CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}"; |
|
316 | require(['codemirror/lib/codemirror', | |
|
317 | ], function(CodeMirror){ | |||
|
318 | CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}"; | |||
|
319 | // require([ | |||
|
320 | // 'notebook/js/codemirror-ipython', | |||
|
321 | // 'notebook/js/codemirror-ipythongfm' | |||
|
322 | //], function(){}) | |||
|
323 | }); | |||
317 | </script> |
|
324 | </script> | |
318 | <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script> |
|
|||
319 | <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script> |
|
|||
320 | <script src="{{ static_url("components/codemirror/addon/mode/overlay.js") }}" charset="utf-8"></script> |
|
|||
321 | <script src="{{ static_url("components/codemirror/addon/edit/matchbrackets.js") }}" charset="utf-8"></script> |
|
|||
322 | <script src="{{ static_url("components/codemirror/addon/edit/closebrackets.js") }}" charset="utf-8"></script> |
|
|||
323 | <script src="{{ static_url("components/codemirror/addon/comment/comment.js") }}" charset="utf-8"></script> |
|
|||
324 | <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script> |
|
|||
325 | <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script> |
|
|||
326 | <script src="{{ static_url("components/codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script> |
|
|||
327 | <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script> |
|
|||
328 | <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script> |
|
|||
329 | <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script> |
|
|||
330 | <script src="{{ static_url("components/codemirror/mode/python/python.js") }}" charset="utf-8"></script> |
|
|||
331 | <script src="{{ static_url("notebook/js/codemirror-ipython.js") }}" charset="utf-8"></script> |
|
|||
332 | <script src="{{ static_url("notebook/js/codemirror-ipythongfm.js") }}" charset="utf-8"></script> |
|
|||
333 |
|
325 | |||
334 | <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script> |
|
326 | <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script> | |
335 |
|
327 |
@@ -28,6 +28,7 b'' | |||||
28 | jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min', |
|
28 | jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min', | |
29 | highlight: 'components/highlight.js/build/highlight.pack', |
|
29 | highlight: 'components/highlight.js/build/highlight.pack', | |
30 | moment: "components/moment/moment", |
|
30 | moment: "components/moment/moment", | |
|
31 | codemirror: 'components/codemirror', | |||
31 | }, |
|
32 | }, | |
32 | shim: { |
|
33 | shim: { | |
33 | underscore: { |
|
34 | underscore: { |
General Comments 0
You need to be logged in to leave comments.
Login now