Show More
@@ -4,7 +4,8 | |||||
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 | |||||
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 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 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 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 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 | |||||
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 () { | |
@@ -538,6 +539,20 define([ | |||||
538 | msg += ajax_error_msg(jqXHR); |
|
539 | msg += ajax_error_msg(jqXHR); | |
539 | console.log(msg); |
|
540 | console.log(msg); | |
540 | }; |
|
541 | }; | |
|
542 | ||||
|
543 | var requireCodeMirrorMode = function (mode, callback, errback) { | |||
|
544 | // load a mode with requirejs | |||
|
545 | if (typeof mode != "string") mode = mode.name; | |||
|
546 | if (CodeMirror.modes.hasOwnProperty(mode)) { | |||
|
547 | callback(CodeMirror.modes.mode); | |||
|
548 | return; | |||
|
549 | } | |||
|
550 | require([ | |||
|
551 | // might want to use CodeMirror.modeURL here | |||
|
552 | ['codemirror/mode', mode, mode].join('/'), | |||
|
553 | ], callback, errback | |||
|
554 | ); | |||
|
555 | }; | |||
541 |
|
556 | |||
542 | var utils = { |
|
557 | var utils = { | |
543 | regex_split : regex_split, |
|
558 | regex_split : regex_split, | |
@@ -563,6 +578,7 define([ | |||||
563 | mergeopt: mergeopt, |
|
578 | mergeopt: mergeopt, | |
564 | ajax_error_msg : ajax_error_msg, |
|
579 | ajax_error_msg : ajax_error_msg, | |
565 | log_ajax_error : log_ajax_error, |
|
580 | log_ajax_error : log_ajax_error, | |
|
581 | requireCodeMirrorMode : requireCodeMirrorMode, | |||
566 | }; |
|
582 | }; | |
567 |
|
583 | |||
568 | // Backwards compatability. |
|
584 | // Backwards compatability. |
@@ -1,1 +1,1 | |||||
1 | Subproject commit b3909af1b61ca7a412481759fdb441ecdfb3ab66 |
|
1 | Subproject commit b52bd7d838e0f66a792a3a94af457406c3973df2 |
@@ -1,44 +1,39 | |||||
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 | |||
12 | // monkey patch CM to be able to syntax highlight cell magics |
|
|||
13 | // bug reported upstream, |
|
|||
14 | // see https://github.com/codemirror/CodeMirror/issues/670 |
|
|||
15 | if(CodeMirror.getMode(1,'text/plain').indent === undefined ){ |
|
|||
16 | CodeMirror.modes.null = function() { |
|
|||
17 | return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}}; |
|
|||
18 | }; |
|
|||
19 | } |
|
|||
20 |
|
||||
21 | CodeMirror.patchedGetMode = function(config, mode){ |
|
|||
22 | var cmmode = CodeMirror.getMode(config, mode); |
|
|||
23 | if(cmmode.indent === null) { |
|
|||
24 | console.log('patch mode "' , mode, '" on the fly'); |
|
|||
25 | cmmode.indent = function(){return 0;}; |
|
|||
26 | } |
|
|||
27 | return cmmode; |
|
|||
28 | }; |
|
|||
29 | // end monkey patching CodeMirror |
|
|||
30 |
|
||||
31 | var Cell = function (options) { |
|
25 | var Cell = function (options) { | |
32 |
/ |
|
26 | /* Constructor | |
33 |
|
|
27 | * | |
34 |
|
|
28 | * The Base `Cell` class from which to inherit. | |
35 | // |
|
29 | * @constructor | |
36 |
|
|
30 | * @param: | |
37 |
|
|
31 | * options: dictionary | |
38 |
|
|
32 | * Dictionary of keyword arguments. | |
39 |
|
|
33 | * events: $(Events) instance | |
40 |
|
|
34 | * config: dictionary | |
41 |
|
|
35 | * keyboard_manager: KeyboardManager instance | |
|
36 | */ | |||
42 | options = options || {}; |
|
37 | options = options || {}; | |
43 | this.keyboard_manager = options.keyboard_manager; |
|
38 | this.keyboard_manager = options.keyboard_manager; | |
44 | this.events = options.events; |
|
39 | this.events = options.events; | |
@@ -184,9 +179,22 define([ | |||||
184 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { |
|
179 | Cell.prototype.handle_codemirror_keyevent = function (editor, event) { | |
185 | var shortcuts = this.keyboard_manager.edit_shortcuts; |
|
180 | var shortcuts = this.keyboard_manager.edit_shortcuts; | |
186 |
|
181 | |||
|
182 | var cur = editor.getCursor(); | |||
|
183 | if((cur.line !== 0 || cur.ch !==0) && event.keyCode === 38){ | |||
|
184 | event._ipkmIgnore = true; | |||
|
185 | } | |||
|
186 | var nLastLine = editor.lastLine() | |||
|
187 | if( ( event.keyCode === 40) | |||
|
188 | && (( cur.line !== nLastLine) | |||
|
189 | || ( cur.ch !== editor.getLineHandle(nLastLine).text.length)) | |||
|
190 | ){ | |||
|
191 | event._ipkmIgnore = true; | |||
|
192 | } | |||
187 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut |
|
193 | // if this is an edit_shortcuts shortcut, the global keyboard/shortcut | |
188 | // manager will handle it |
|
194 | // manager will handle it | |
189 |
if (shortcuts.handles(event)) { |
|
195 | if (shortcuts.handles(event)) { | |
|
196 | return true; | |||
|
197 | } | |||
190 |
|
198 | |||
191 | return false; |
|
199 | return false; | |
192 | }; |
|
200 | }; | |
@@ -277,9 +285,6 define([ | |||||
277 | * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise |
|
285 | * @return {Boolean} `true` if CodeMirror should ignore the event, `false` Otherwise | |
278 | */ |
|
286 | */ | |
279 | Cell.prototype.handle_keyevent = function (editor, event) { |
|
287 | Cell.prototype.handle_keyevent = function (editor, event) { | |
280 |
|
||||
281 | // console.log('CM', this.mode, event.which, event.type) |
|
|||
282 |
|
||||
283 | if (this.mode === 'command') { |
|
288 | if (this.mode === 'command') { | |
284 | return true; |
|
289 | return true; | |
285 | } else if (this.mode === 'edit') { |
|
290 | } else if (this.mode === 'edit') { | |
@@ -509,6 +514,7 define([ | |||||
509 | **/ |
|
514 | **/ | |
510 | Cell.prototype._auto_highlight = function (modes) { |
|
515 | Cell.prototype._auto_highlight = function (modes) { | |
511 | //Here we handle manually selected modes |
|
516 | //Here we handle manually selected modes | |
|
517 | var that = this; | |||
512 | var mode; |
|
518 | var mode; | |
513 | if( this.user_highlight !== undefined && this.user_highlight != 'auto' ) |
|
519 | if( this.user_highlight !== undefined && this.user_highlight != 'auto' ) | |
514 | { |
|
520 | { | |
@@ -530,33 +536,34 define([ | |||||
530 | return; |
|
536 | return; | |
531 | } |
|
537 | } | |
532 | if (mode.search('magic_') !== 0) { |
|
538 | if (mode.search('magic_') !== 0) { | |
533 |
t |
|
539 | utils.requireCodeMirrorMode(mode, function () { | |
534 |
|
|
540 | that.code_mirror.setOption('mode', mode); | |
|
541 | }); | |||
535 | return; |
|
542 | return; | |
536 | } |
|
543 | } | |
537 | var open = modes[mode].open || "%%"; |
|
544 | var open = modes[mode].open || "%%"; | |
538 | var close = modes[mode].close || "%%end"; |
|
545 | var close = modes[mode].close || "%%end"; | |
539 | var mmode = mode; |
|
546 | var magic_mode = mode; | |
540 | mode = mmode.substr(6); |
|
547 | mode = magic_mode.substr(6); | |
541 | if(current_mode == mode){ |
|
548 | if(current_mode == magic_mode){ | |
542 | return; |
|
549 | return; | |
543 | } |
|
550 | } | |
544 | CodeMirror.autoLoadMode(this.code_mirror, mode); |
|
551 | utils.requireCodeMirrorMode(mode, function () { | |
545 |
// create on the fly a mode that sw |
|
552 | // create on the fly a mode that switch between | |
546 | // plain/text and smth else otherwise `%%` is |
|
553 | // plain/text and something else, otherwise `%%` is | |
547 | // source of some highlight issues. |
|
554 | // source of some highlight issues. | |
548 | // we use patchedGetMode to circumvent a bug in CM |
|
555 | CodeMirror.defineMode(magic_mode, function(config) { | |
549 | CodeMirror.defineMode(mmode , function(config) { |
|
556 | return CodeMirror.multiplexingMode( | |
550 |
|
|
557 | CodeMirror.getMode(config, 'text/plain'), | |
551 | CodeMirror.patchedGetMode(config, 'text/plain'), |
|
558 | // always set something on close | |
552 |
|
|
559 | {open: open, close: close, | |
553 | {open: open, close: close, |
|
560 | mode: CodeMirror.getMode(config, mode), | |
554 | mode: CodeMirror.patchedGetMode(config, mode), |
|
561 | delimStyle: "delimit" | |
555 |
|
|
562 | } | |
556 |
|
|
563 | ); | |
557 | ); |
|
564 | }); | |
|
565 | that.code_mirror.setOption('mode', magic_mode); | |||
558 | }); |
|
566 | }); | |
559 | this.code_mirror.setOption('mode', mmode); |
|
|||
560 | return; |
|
567 | return; | |
561 | } |
|
568 | } | |
562 | } |
|
569 | } |
@@ -114,7 +114,7 define([ | |||||
114 | * @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name |
|
114 | * @param name {String} name to use to refer to the callback. It is advised to use a prefix with the name | |
115 | * for easier sorting and avoid collision |
|
115 | * for easier sorting and avoid collision | |
116 | * @param callback {function(div, cell)} callback that will be called to generate the ui element |
|
116 | * @param callback {function(div, cell)} callback that will be called to generate the ui element | |
117 |
* @param [cell_types] {List |
|
117 | * @param [cell_types] {List_of_String|undefined} optional list of cell types. If present the UI element | |
118 | * will be added only to cells of types in the list. |
|
118 | * will be added only to cells of types in the list. | |
119 | * |
|
119 | * | |
120 | * |
|
120 | * | |
@@ -163,7 +163,7 define([ | |||||
163 | * @method register_preset |
|
163 | * @method register_preset | |
164 | * @param name {String} name to use to refer to the preset. It is advised to use a prefix with the name |
|
164 | * @param name {String} name to use to refer to the preset. It is advised to use a prefix with the name | |
165 | * for easier sorting and avoid collision |
|
165 | * for easier sorting and avoid collision | |
166 |
* @param preset_list {List |
|
166 | * @param preset_list {List_of_String} reverse order of the button in the toolbar. Each String of the list | |
167 | * should correspond to a name of a registerd callback. |
|
167 | * should correspond to a name of a registerd callback. | |
168 | * |
|
168 | * | |
169 | * @private |
|
169 | * @private | |
@@ -288,8 +288,6 define([ | |||||
288 | }; |
|
288 | }; | |
289 |
|
289 | |||
290 |
|
290 | |||
291 | /** |
|
|||
292 | */ |
|
|||
293 | CellToolbar.utils = {}; |
|
291 | CellToolbar.utils = {}; | |
294 |
|
292 | |||
295 |
|
293 | |||
@@ -385,7 +383,7 define([ | |||||
385 | * @method utils.select_ui_generator |
|
383 | * @method utils.select_ui_generator | |
386 | * @static |
|
384 | * @static | |
387 | * |
|
385 | * | |
388 |
* @param list_list {list |
|
386 | * @param list_list {list_of_sublist} List of sublist of metadata value and name in the dropdown list. | |
389 | * subslit shoud contain 2 element each, first a string that woul be displayed in the dropdown list, |
|
387 | * subslit shoud contain 2 element each, first a string that woul be displayed in the dropdown list, | |
390 | * and second the corresponding value to be passed to setter/return by getter. the corresponding value |
|
388 | * and second the corresponding value to be passed to setter/return by getter. the corresponding value | |
391 | * should not be "undefined" or behavior can be unexpected. |
|
389 | * should not be "undefined" or behavior can be unexpected. |
@@ -1,5 +1,13 | |||||
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 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 | |||
@@ -72,11 +83,7 define([ | |||||
72 | this.completer = null; |
|
83 | this.completer = null; | |
73 |
|
84 | |||
74 |
|
85 | |||
75 | var cm_overwrite_options = { |
|
86 | var config = utils.mergeopt(CodeCell, this.config); | |
76 | onKeyEvent: $.proxy(this.handle_keyevent,this) |
|
|||
77 | }; |
|
|||
78 |
|
||||
79 | var config = utils.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options}); |
|
|||
80 | Cell.apply(this,[{ |
|
87 | Cell.apply(this,[{ | |
81 | config: config, |
|
88 | config: config, | |
82 | keyboard_manager: options.keyboard_manager, |
|
89 | keyboard_manager: options.keyboard_manager, | |
@@ -102,9 +109,7 define([ | |||||
102 | }, |
|
109 | }, | |
103 | mode: 'ipython', |
|
110 | mode: 'ipython', | |
104 | theme: 'ipython', |
|
111 | theme: 'ipython', | |
105 |
matchBrackets: true |
|
112 | matchBrackets: true | |
106 | // don't auto-close strings because of CodeMirror #2385 |
|
|||
107 | autoCloseBrackets: "()[]{}" |
|
|||
108 | } |
|
113 | } | |
109 | }; |
|
114 | }; | |
110 |
|
115 | |||
@@ -135,6 +140,7 define([ | |||||
135 | inner_cell.append(this.celltoolbar.element); |
|
140 | inner_cell.append(this.celltoolbar.element); | |
136 | var input_area = $('<div/>').addClass('input_area'); |
|
141 | var input_area = $('<div/>').addClass('input_area'); | |
137 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); |
|
142 | this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); | |
|
143 | this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this)) | |||
138 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); |
|
144 | $(this.code_mirror.getInputField()).attr("spellcheck", "false"); | |
139 | inner_cell.append(input_area); |
|
145 | inner_cell.append(input_area); | |
140 | input.append(prompt).append(inner_cell); |
|
146 | input.append(prompt).append(inner_cell); | |
@@ -220,10 +226,11 define([ | |||||
220 | } |
|
226 | } | |
221 | // If we closed the tooltip, don't let CM or the global handlers |
|
227 | // If we closed the tooltip, don't let CM or the global handlers | |
222 | // handle this event. |
|
228 | // handle this event. | |
223 | event.stop(); |
|
229 | event.codemirrorIgnore = true; | |
|
230 | event.preventDefault(); | |||
224 | return true; |
|
231 | return true; | |
225 | } else if (event.keyCode === keycodes.tab && event.type === 'keydown' && event.shiftKey) { |
|
232 | } else if (event.keyCode === keycodes.tab && event.type === 'keydown' && event.shiftKey) { | |
226 | if (editor.somethingSelected()){ |
|
233 | if (editor.somethingSelected() || editor.getSelections().length !== 1){ | |
227 | var anchor = editor.getCursor("anchor"); |
|
234 | var anchor = editor.getCursor("anchor"); | |
228 | var head = editor.getCursor("head"); |
|
235 | var head = editor.getCursor("head"); | |
229 | if( anchor.line != head.line){ |
|
236 | if( anchor.line != head.line){ | |
@@ -231,12 +238,15 define([ | |||||
231 | } |
|
238 | } | |
232 | } |
|
239 | } | |
233 | this.tooltip.request(that); |
|
240 | this.tooltip.request(that); | |
234 |
event. |
|
241 | event.codemirrorIgnore = true; | |
|
242 | event.preventDefault(); | |||
235 | return true; |
|
243 | return true; | |
236 | } else if (event.keyCode === keycodes.tab && event.type == 'keydown') { |
|
244 | } else if (event.keyCode === keycodes.tab && event.type == 'keydown') { | |
237 | // Tab completion. |
|
245 | // Tab completion. | |
238 | this.tooltip.remove_and_cancel_tooltip(); |
|
246 | this.tooltip.remove_and_cancel_tooltip(); | |
239 | if (editor.somethingSelected()) { |
|
247 | ||
|
248 | // completion does not work on multicursor, it might be possible though in some cases | |||
|
249 | if (editor.somethingSelected() || editor.getSelections().length > 1) { | |||
240 | return false; |
|
250 | return false; | |
241 | } |
|
251 | } | |
242 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur); |
|
252 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur); | |
@@ -245,7 +255,8 define([ | |||||
245 | // is empty. In this case, let CodeMirror handle indentation. |
|
255 | // is empty. In this case, let CodeMirror handle indentation. | |
246 | return false; |
|
256 | return false; | |
247 | } else { |
|
257 | } else { | |
248 |
event. |
|
258 | event.codemirrorIgnore = true; | |
|
259 | event.preventDefault(); | |||
249 | this.completer.startCompletion(); |
|
260 | this.completer.startCompletion(); | |
250 | return true; |
|
261 | return true; | |
251 | } |
|
262 | } |
@@ -3,7 +3,18 | |||||
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) { |
@@ -1,44 +1,62 | |||||
1 |
// IPython GFM (GitHub Flavored Markdown) mode is just a slightly altered GFM |
|
1 | // IPython GFM (GitHub Flavored Markdown) mode is just a slightly altered GFM | |
2 |
// Mode with support for latex. |
|
2 | // Mode with support for latex. | |
3 | // |
|
3 | // | |
4 |
// Latex support was supported by Codemirror GFM as of |
|
4 | // Latex support was supported by Codemirror GFM as of | |
5 | // https://github.com/codemirror/CodeMirror/pull/567 |
|
5 | // https://github.com/codemirror/CodeMirror/pull/567 | |
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 | { |
|
33 | ||
34 | open: "\\[", close: "\\]", |
|
34 | return CodeMirror.multiplexingMode( | |
35 |
|
|
35 | gfm_mode, | |
36 | delimStyle: "delimit" |
|
36 | { | |
37 | } |
|
37 | open: "$", close: "$", | |
38 | // .. more multiplexed styles can follow here |
|
38 | mode: tex_mode, | |
39 | ); |
|
39 | delimStyle: "delimit" | |
40 |
}, |
|
40 | }, | |
41 |
|
41 | { | ||
42 | CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm"); |
|
42 | // not sure this works as $$ is interpreted at (opening $, closing $, as defined just above) | |
43 | }); |
|
43 | open: "$$", close: "$$", | |
44 | }); |
|
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 | }) |
@@ -7,7 +7,8 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 | |
@@ -93,7 +94,7 define([ | |||||
93 | Completer.prototype.startCompletion = function () { |
|
94 | Completer.prototype.startCompletion = function () { | |
94 | // call for a 'first' completion, that will set the editor and do some |
|
95 | // call for a 'first' completion, that will set the editor and do some | |
95 | // special behavior like autopicking if only one completion available. |
|
96 | // special behavior like autopicking if only one completion available. | |
96 | if (this.editor.somethingSelected()) return; |
|
97 | if (this.editor.somethingSelected()|| this.editor.getSelections().length > 1) return; | |
97 | this.done = false; |
|
98 | this.done = false; | |
98 | // use to get focus back on opera |
|
99 | // use to get focus back on opera | |
99 | this.carry_on_completion(true); |
|
100 | this.carry_on_completion(true); | |
@@ -142,7 +143,7 define([ | |||||
142 | } |
|
143 | } | |
143 |
|
144 | |||
144 | // We want a single cursor position. |
|
145 | // We want a single cursor position. | |
145 | if (this.editor.somethingSelected()) { |
|
146 | if (this.editor.somethingSelected()|| this.editor.getSelections().length > 1) { | |
146 | return; |
|
147 | return; | |
147 | } |
|
148 | } | |
148 |
|
149 | |||
@@ -316,11 +317,15 define([ | |||||
316 |
|
317 | |||
317 | // Enter |
|
318 | // Enter | |
318 | if (code == keycodes.enter) { |
|
319 | if (code == keycodes.enter) { | |
319 |
|
|
320 | event.codemirrorIgnore = true; | |
|
321 | event._ipkmIgnore = true; | |||
|
322 | event.preventDefault(); | |||
320 | this.pick(); |
|
323 | this.pick(); | |
321 | // Escape or backspace |
|
324 | // Escape or backspace | |
322 | } else if (code == keycodes.esc || code == keycodes.backspace) { |
|
325 | } else if (code == keycodes.esc || code == keycodes.backspace) { | |
323 |
|
|
326 | event.codemirrorIgnore = true; | |
|
327 | event._ipkmIgnore = true; | |||
|
328 | event.preventDefault(); | |||
324 | this.close(); |
|
329 | this.close(); | |
325 | } else if (code == keycodes.tab) { |
|
330 | } else if (code == keycodes.tab) { | |
326 | //all the fastforwarding operation, |
|
331 | //all the fastforwarding operation, | |
@@ -339,7 +344,9 define([ | |||||
339 | } else if (code == keycodes.up || code == keycodes.down) { |
|
344 | } else if (code == keycodes.up || code == keycodes.down) { | |
340 | // need to do that to be able to move the arrow |
|
345 | // need to do that to be able to move the arrow | |
341 | // when on the first or last line ofo a code cell |
|
346 | // when on the first or last line ofo a code cell | |
342 |
|
|
347 | event.codemirrorIgnore = true; | |
|
348 | event._ipkmIgnore = true; | |||
|
349 | event.preventDefault(); | |||
343 |
|
350 | |||
344 | var options = this.sel.find('option'); |
|
351 | var options = this.sel.find('option'); | |
345 | var index = this.sel[0].selectedIndex; |
|
352 | var index = this.sel[0].selectedIndex; | |
@@ -352,7 +359,7 define([ | |||||
352 | index = Math.min(Math.max(index, 0), options.length-1); |
|
359 | index = Math.min(Math.max(index, 0), options.length-1); | |
353 | this.sel[0].selectedIndex = index; |
|
360 | this.sel[0].selectedIndex = index; | |
354 | } else if (code == keycodes.pageup || code == keycodes.pagedown) { |
|
361 | } else if (code == keycodes.pageup || code == keycodes.pagedown) { | |
355 | CodeMirror.e_stop(event); |
|
362 | event._ipkmIgnore = true; | |
356 |
|
363 | |||
357 | var options = this.sel.find('option'); |
|
364 | var options = this.sel.find('option'); | |
358 | var index = this.sel[0].selectedIndex; |
|
365 | var index = this.sel[0].selectedIndex; |
@@ -1,6 +1,15 | |||||
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 | |||||
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 | |||||
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 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 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 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 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--' : { | |
@@ -488,6 +508,10 define([ | |||||
488 | KeyboardManager.prototype.bind_events = function () { |
|
508 | KeyboardManager.prototype.bind_events = function () { | |
489 | var that = this; |
|
509 | var that = this; | |
490 | $(document).keydown(function (event) { |
|
510 | $(document).keydown(function (event) { | |
|
511 | ||||
|
512 | if(event._ipkmIgnore==true||(event.originalEvent||{})._ipkmIgnore==true){ | |||
|
513 | return false; | |||
|
514 | } | |||
491 | return that.handle_keydown(event); |
|
515 | return that.handle_keydown(event); | |
492 | }); |
|
516 | }); | |
493 | }; |
|
517 | }; |
@@ -19,8 +19,9 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 | // only loaded, not used, please keep sure this is loaded last | |
|
24 | 'custom/custom' | |||
24 | ], function( |
|
25 | ], function( | |
25 | IPython, |
|
26 | IPython, | |
26 | $, |
|
27 | $, | |
@@ -38,13 +39,19 require([ | |||||
38 | savewidget, |
|
39 | savewidget, | |
39 | keyboardmanager, |
|
40 | keyboardmanager, | |
40 | config, |
|
41 | config, | |
41 | kernelselector |
|
42 | kernelselector, | |
|
43 | CodeMirror, | |||
|
44 | // please keep sure that even if not used, this is loaded last | |||
|
45 | custom | |||
42 | ) { |
|
46 | ) { | |
43 | "use strict"; |
|
47 | "use strict"; | |
44 |
|
48 | |||
|
49 | // compat with old IPython, remove for IPython > 3.0 | |||
|
50 | window.CodeMirror = CodeMirror; | |||
|
51 | ||||
45 | var common_options = { |
|
52 | var common_options = { | |
|
53 | ws_url : utils.get_body_data("wsUrl"), | |||
46 | base_url : utils.get_body_data("baseUrl"), |
|
54 | base_url : utils.get_body_data("baseUrl"), | |
47 | ws_url : IPython.utils.get_body_data("wsUrl"), |
|
|||
48 | notebook_path : utils.get_body_data("notebookPath"), |
|
55 | notebook_path : utils.get_body_data("notebookPath"), | |
49 | notebook_name : utils.get_body_data('notebookName') |
|
56 | notebook_name : utils.get_body_data('notebookName') | |
50 | }; |
|
57 | }; |
@@ -893,7 +893,7 define([ | |||||
893 | * Insert an element at given cell index. |
|
893 | * Insert an element at given cell index. | |
894 | * |
|
894 | * | |
895 | * @method _insert_element_at_index |
|
895 | * @method _insert_element_at_index | |
896 |
* @param element {dom |
|
896 | * @param element {dom_element} a cell element | |
897 | * @param [index] {int} a valid index where to inser cell |
|
897 | * @param [index] {int} a valid index where to inser cell | |
898 | * @private |
|
898 | * @private | |
899 | * |
|
899 | * | |
@@ -1532,7 +1532,7 define([ | |||||
1532 | modename = newmode.name || newmode |
|
1532 | modename = newmode.name || newmode | |
1533 |
|
1533 | |||
1534 | that = this; |
|
1534 | that = this; | |
1535 |
|
|
1535 | utils.requireCodeMirrorMode(modename, function () { | |
1536 | $.map(that.get_cells(), function(cell, i) { |
|
1536 | $.map(that.get_cells(), function(cell, i) { | |
1537 | if (cell.cell_type === 'code'){ |
|
1537 | if (cell.cell_type === 'code'){ | |
1538 | cell.code_mirror.setOption('mode', newmode); |
|
1538 | cell.code_mirror.setOption('mode', newmode); |
@@ -10,7 +10,10 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 |
@@ -11,7 +11,7 define([ | |||||
11 | * A generic toolbar on which one can add button |
|
11 | * A generic toolbar on which one can add button | |
12 | * @class ToolBar |
|
12 | * @class ToolBar | |
13 | * @constructor |
|
13 | * @constructor | |
14 |
* @param {Dom |
|
14 | * @param {Dom_object} selector | |
15 | */ |
|
15 | */ | |
16 | var ToolBar = function (selector, layout_manager) { |
|
16 | var ToolBar = function (selector, layout_manager) { | |
17 | this.selector = selector; |
|
17 | this.selector = selector; |
@@ -117,8 +117,7 define([ | |||||
117 |
|
117 | |||
118 | Tooltip.prototype.showInPager = function (cell) { |
|
118 | Tooltip.prototype.showInPager = function (cell) { | |
119 | // reexecute last call in pager by appending ? to show back in pager |
|
119 | // reexecute last call in pager by appending ? to show back in pager | |
120 | var that = this; |
|
120 | this.events.trigger('open_with_text.Pager', this._reply.content); | |
121 | this.events.trigger('open_with_text.Pager', that._reply.content); |
|
|||
122 | this.remove_and_cancel_tooltip(); |
|
121 | this.remove_and_cancel_tooltip(); | |
123 | }; |
|
122 | }; | |
124 |
|
123 | |||
@@ -208,7 +207,7 define([ | |||||
208 | var msg_id = cell.kernel.inspect(text, cursor_pos, callbacks); |
|
207 | var msg_id = cell.kernel.inspect(text, cursor_pos, callbacks); | |
209 | }; |
|
208 | }; | |
210 |
|
209 | |||
211 | // make an imediate completion request |
|
210 | // make an immediate completion request | |
212 | Tooltip.prototype.request = function (cell, hide_if_no_docstring) { |
|
211 | Tooltip.prototype.request = function (cell, hide_if_no_docstring) { | |
213 | // request(codecell) |
|
212 | // request(codecell) | |
214 | // Deal with extracting the text from the cell and counting |
|
213 | // Deal with extracting the text from the cell and counting | |
@@ -222,10 +221,11 define([ | |||||
222 | this._hide_if_no_docstring = hide_if_no_docstring; |
|
221 | this._hide_if_no_docstring = hide_if_no_docstring; | |
223 |
|
222 | |||
224 | if(editor.somethingSelected()){ |
|
223 | if(editor.somethingSelected()){ | |
|
224 | // get only the most recent selection. | |||
225 | text = editor.getSelection(); |
|
225 | text = editor.getSelection(); | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 |
// need a permanent hand |
|
228 | // need a permanent handle to code_mirror for future auto recall | |
229 | this.code_mirror = editor; |
|
229 | this.code_mirror = editor; | |
230 |
|
230 | |||
231 | // now we treat the different number of keypress |
|
231 | // now we treat the different number of keypress | |
@@ -325,7 +325,7 define([ | |||||
325 | this.text.scrollTop(0); |
|
325 | this.text.scrollTop(0); | |
326 | }; |
|
326 | }; | |
327 |
|
327 | |||
328 |
// Backwards compat |
|
328 | // Backwards compatibility. | |
329 | IPython.Tooltip = Tooltip; |
|
329 | IPython.Tooltip = Tooltip; | |
330 |
|
330 | |||
331 | return {'Tooltip': Tooltip}; |
|
331 | return {'Tooltip': Tooltip}; |
@@ -311,25 +311,6 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> |
|
|||
315 | <script type="text/javascript"> |
|
|||
316 | CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}"; |
|
|||
317 | </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 |
|
314 | |||
334 | <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script> |
|
315 | <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script> | |
335 |
|
316 |
@@ -28,6 +28,7 | |||||
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