Show More
@@ -17,7 +17,7 b'' | |||||
17 |
|
17 | |||
18 |
|
18 | |||
19 | /* local util for codemirror */ |
|
19 | /* local util for codemirror */ | |
20 | var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;} |
|
20 | var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}; | |
21 |
|
21 | |||
22 |
|
|
22 | /** | |
23 | * |
|
23 | * | |
@@ -27,16 +27,16 b' var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}' | |||||
27 | */ |
|
27 | */ | |
28 | CodeMirror.commands.delSpaceToPrevTabStop = function(cm){ |
|
28 | CodeMirror.commands.delSpaceToPrevTabStop = function(cm){ | |
29 | var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to); |
|
29 | var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to); | |
30 | if (!posEq(from, to)) {cm.replaceRange("", from, to); return} |
|
30 | if (!posEq(from, to)) { cm.replaceRange("", from, to); return; } | |
31 | var cur = cm.getCursor(), line = cm.getLine(cur.line); |
|
31 | var cur = cm.getCursor(), line = cm.getLine(cur.line); | |
32 | var tabsize = cm.getOption('tabSize'); |
|
32 | var tabsize = cm.getOption('tabSize'); | |
33 | var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize; |
|
33 | var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize; | |
34 |
|
|
34 | from = {ch:cur.ch-chToPrevTabStop,line:cur.line}; | |
35 | var select = cm.getRange(from,cur) |
|
35 | var select = cm.getRange(from,cur); | |
36 | if( select.match(/^\ +$/) != null){ |
|
36 | if( select.match(/^\ +$/) !== null){ | |
37 | cm.replaceRange("",from,cur) |
|
37 | cm.replaceRange("",from,cur); | |
38 | } else { |
|
38 | } else { | |
39 | cm.deleteH(-1,"char") |
|
39 | cm.deleteH(-1,"char"); | |
40 | } |
|
40 | } | |
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
@@ -104,7 +104,7 b' var IPython = (function (IPython) {' | |||||
104 | * @method auto_highlight |
|
104 | * @method auto_highlight | |
105 | */ |
|
105 | */ | |
106 | CodeCell.prototype.auto_highlight = function () { |
|
106 | CodeCell.prototype.auto_highlight = function () { | |
107 | this._auto_highlight(IPython.config.cell_magic_highlight) |
|
107 | this._auto_highlight(IPython.config.cell_magic_highlight); | |
108 | }; |
|
108 | }; | |
109 |
|
109 | |||
110 | /** @method create_element */ |
|
110 | /** @method create_element */ | |
@@ -117,7 +117,7 b' var IPython = (function (IPython) {' | |||||
117 | this.celltoolbar = new IPython.CellToolbar(this); |
|
117 | this.celltoolbar = new IPython.CellToolbar(this); | |
118 |
|
118 | |||
119 | var input = $('<div></div>').addClass('input'); |
|
119 | var input = $('<div></div>').addClass('input'); | |
120 | var vbox = $('<div/>').addClass('vbox box-flex1') |
|
120 | var vbox = $('<div/>').addClass('vbox box-flex1'); | |
121 | input.append($('<div/>').addClass('prompt input_prompt')); |
|
121 | input.append($('<div/>').addClass('prompt input_prompt')); | |
122 | vbox.append(this.celltoolbar.element); |
|
122 | vbox.append(this.celltoolbar.element); | |
123 | var input_area = $('<div/>').addClass('input_area'); |
|
123 | var input_area = $('<div/>').addClass('input_area'); | |
@@ -152,7 +152,7 b' var IPython = (function (IPython) {' | |||||
152 | // they are sent, and remove tooltip if any, except for tab again |
|
152 | // they are sent, and remove tooltip if any, except for tab again | |
153 | if (event.type === 'keydown' && event.which != key.TAB ) { |
|
153 | if (event.type === 'keydown' && event.which != key.TAB ) { | |
154 | IPython.tooltip.remove_and_cancel_tooltip(); |
|
154 | IPython.tooltip.remove_and_cancel_tooltip(); | |
155 |
} |
|
155 | } | |
156 |
|
156 | |||
157 | var cur = editor.getCursor(); |
|
157 | var cur = editor.getCursor(); | |
158 | if (event.keyCode === key.ENTER){ |
|
158 | if (event.keyCode === key.ENTER){ | |
@@ -177,7 +177,7 b' var IPython = (function (IPython) {' | |||||
177 | return false; |
|
177 | return false; | |
178 | } else { |
|
178 | } else { | |
179 | return true; |
|
179 | return true; | |
180 |
} |
|
180 | } | |
181 | } else if (event.which === key.ESC) { |
|
181 | } else if (event.which === key.ESC) { | |
182 | return IPython.tooltip.remove_and_cancel_tooltip(true); |
|
182 | return IPython.tooltip.remove_and_cancel_tooltip(true); | |
183 | } else if (event.which === key.DOWNARROW && event.type === 'keydown') { |
|
183 | } else if (event.which === key.DOWNARROW && event.type === 'keydown') { | |
@@ -188,7 +188,7 b' var IPython = (function (IPython) {' | |||||
188 | return false; |
|
188 | return false; | |
189 | } else { |
|
189 | } else { | |
190 | return true; |
|
190 | return true; | |
191 |
} |
|
191 | } | |
192 | } else if (event.keyCode === key.TAB && event.type == 'keydown' && event.shiftKey) { |
|
192 | } else if (event.keyCode === key.TAB && event.type == 'keydown' && event.shiftKey) { | |
193 | if (editor.somethingSelected()){ |
|
193 | if (editor.somethingSelected()){ | |
194 | var anchor = editor.getCursor("anchor"); |
|
194 | var anchor = editor.getCursor("anchor"); | |
@@ -203,7 +203,7 b' var IPython = (function (IPython) {' | |||||
203 | } else if (event.keyCode === key.TAB && event.type == 'keydown') { |
|
203 | } else if (event.keyCode === key.TAB && event.type == 'keydown') { | |
204 | // Tab completion. |
|
204 | // Tab completion. | |
205 | //Do not trim here because of tooltip |
|
205 | //Do not trim here because of tooltip | |
206 | if (editor.somethingSelected()){return false} |
|
206 | if (editor.somethingSelected()) { return false; } | |
207 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur); |
|
207 | var pre_cursor = editor.getRange({line:cur.line,ch:0},cur); | |
208 | if (pre_cursor.trim() === "") { |
|
208 | if (pre_cursor.trim() === "") { | |
209 | // Don't autocomplete if the part of the line before the cursor |
|
209 | // Don't autocomplete if the part of the line before the cursor | |
@@ -219,12 +219,12 b' var IPython = (function (IPython) {' | |||||
219 | event.stop(); |
|
219 | event.stop(); | |
220 | this.completer.startCompletion(); |
|
220 | this.completer.startCompletion(); | |
221 | return true; |
|
221 | return true; | |
222 |
} |
|
222 | } | |
223 | } else { |
|
223 | } else { | |
224 | // keypress/keyup also trigger on TAB press, and we don't want to |
|
224 | // keypress/keyup also trigger on TAB press, and we don't want to | |
225 | // use those to disable tab completion. |
|
225 | // use those to disable tab completion. | |
226 | return false; |
|
226 | return false; | |
227 |
} |
|
227 | } | |
228 | return false; |
|
228 | return false; | |
229 | }; |
|
229 | }; | |
230 |
|
230 | |||
@@ -233,7 +233,7 b' var IPython = (function (IPython) {' | |||||
233 |
|
233 | |||
234 | CodeCell.prototype.set_kernel = function (kernel) { |
|
234 | CodeCell.prototype.set_kernel = function (kernel) { | |
235 | this.kernel = kernel; |
|
235 | this.kernel = kernel; | |
236 | } |
|
236 | }; | |
237 |
|
237 | |||
238 | /** |
|
238 | /** | |
239 | * Execute current code cell to the kernel |
|
239 | * Execute current code cell to the kernel | |
@@ -258,7 +258,7 b' var IPython = (function (IPython) {' | |||||
258 | clear_output : $.proxy(this.output_area.handle_clear_output, this.output_area), |
|
258 | clear_output : $.proxy(this.output_area.handle_clear_output, this.output_area), | |
259 | }, |
|
259 | }, | |
260 | input : $.proxy(this._handle_input_request, this) |
|
260 | input : $.proxy(this._handle_input_request, this) | |
261 | } |
|
261 | }; | |
262 |
|
262 | |||
263 | this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true}); |
|
263 | this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true}); | |
264 | }; |
|
264 | }; | |
@@ -271,16 +271,16 b' var IPython = (function (IPython) {' | |||||
271 | this.set_input_prompt(msg.content.execution_count); |
|
271 | this.set_input_prompt(msg.content.execution_count); | |
272 | this.element.removeClass("running"); |
|
272 | this.element.removeClass("running"); | |
273 | $([IPython.events]).trigger('set_dirty.Notebook', {value: true}); |
|
273 | $([IPython.events]).trigger('set_dirty.Notebook', {value: true}); | |
274 | } |
|
274 | }; | |
275 |
|
275 | |||
276 | /** |
|
276 | /** | |
277 | * @method _handle_set_next_input |
|
277 | * @method _handle_set_next_input | |
278 | * @private |
|
278 | * @private | |
279 | */ |
|
279 | */ | |
280 | CodeCell.prototype._handle_set_next_input = function (payload) { |
|
280 | CodeCell.prototype._handle_set_next_input = function (payload) { | |
281 | var data = {'cell': this, 'text': payload.text} |
|
281 | var data = {'cell': this, 'text': payload.text}; | |
282 | $([IPython.events]).trigger('set_next_input.Notebook', data); |
|
282 | $([IPython.events]).trigger('set_next_input.Notebook', data); | |
283 | } |
|
283 | }; | |
284 |
|
284 | |||
285 | /** |
|
285 | /** | |
286 | * @method _handle_input_request |
|
286 | * @method _handle_input_request | |
@@ -288,7 +288,7 b' var IPython = (function (IPython) {' | |||||
288 | */ |
|
288 | */ | |
289 | CodeCell.prototype._handle_input_request = function (msg) { |
|
289 | CodeCell.prototype._handle_input_request = function (msg) { | |
290 | this.output_area.append_raw_input(msg); |
|
290 | this.output_area.append_raw_input(msg); | |
291 | } |
|
291 | }; | |
292 |
|
292 | |||
293 |
|
293 | |||
294 | // Basic cell manipulation. |
|
294 | // Basic cell manipulation. | |
@@ -338,21 +338,23 b' var IPython = (function (IPython) {' | |||||
338 |
|
338 | |||
339 | CodeCell.input_prompt_classical = function (prompt_value, lines_number) { |
|
339 | CodeCell.input_prompt_classical = function (prompt_value, lines_number) { | |
340 | var ns = prompt_value || " "; |
|
340 | var ns = prompt_value || " "; | |
341 | return 'In [' + ns + ']:' |
|
341 | return 'In [' + ns + ']:'; | |
342 | }; |
|
342 | }; | |
343 |
|
343 | |||
344 | CodeCell.input_prompt_continuation = function (prompt_value, lines_number) { |
|
344 | CodeCell.input_prompt_continuation = function (prompt_value, lines_number) { | |
345 | var html = [CodeCell.input_prompt_classical(prompt_value, lines_number)]; |
|
345 | var html = [CodeCell.input_prompt_classical(prompt_value, lines_number)]; | |
346 |
for(var i=1; i < lines_number; i++){ |
|
346 | for(var i=1; i < lines_number; i++) { | |
347 | return html.join('</br>') |
|
347 | html.push(['...:']); | |
|
348 | } | |||
|
349 | return html.join('<br/>'); | |||
348 | }; |
|
350 | }; | |
349 |
|
351 | |||
350 | CodeCell.input_prompt_function = CodeCell.input_prompt_classical; |
|
352 | CodeCell.input_prompt_function = CodeCell.input_prompt_classical; | |
351 |
|
353 | |||
352 |
|
354 | |||
353 | CodeCell.prototype.set_input_prompt = function (number) { |
|
355 | CodeCell.prototype.set_input_prompt = function (number) { | |
354 | var nline = 1 |
|
356 | var nline = 1; | |
355 |
if( |
|
357 | if (this.code_mirror !== undefined) { | |
356 | nline = this.code_mirror.lineCount(); |
|
358 | nline = this.code_mirror.lineCount(); | |
357 | } |
|
359 | } | |
358 | this.input_prompt_number = number; |
|
360 | this.input_prompt_number = number; | |
@@ -417,16 +419,16 b' var IPython = (function (IPython) {' | |||||
417 | this.set_input_prompt(data.prompt_number); |
|
419 | this.set_input_prompt(data.prompt_number); | |
418 | } else { |
|
420 | } else { | |
419 | this.set_input_prompt(); |
|
421 | this.set_input_prompt(); | |
420 |
} |
|
422 | } | |
421 | this.output_area.fromJSON(data.outputs); |
|
423 | this.output_area.fromJSON(data.outputs); | |
422 | if (data.collapsed !== undefined) { |
|
424 | if (data.collapsed !== undefined) { | |
423 | if (data.collapsed) { |
|
425 | if (data.collapsed) { | |
424 | this.collapse(); |
|
426 | this.collapse(); | |
425 | } else { |
|
427 | } else { | |
426 | this.expand(); |
|
428 | this.expand(); | |
427 |
} |
|
429 | } | |
428 |
} |
|
430 | } | |
429 |
} |
|
431 | } | |
430 | }; |
|
432 | }; | |
431 |
|
433 | |||
432 |
|
434 | |||
@@ -436,7 +438,7 b' var IPython = (function (IPython) {' | |||||
436 | data.cell_type = 'code'; |
|
438 | data.cell_type = 'code'; | |
437 | if (this.input_prompt_number) { |
|
439 | if (this.input_prompt_number) { | |
438 | data.prompt_number = this.input_prompt_number; |
|
440 | data.prompt_number = this.input_prompt_number; | |
439 |
} |
|
441 | } | |
440 | var outputs = this.output_area.toJSON(); |
|
442 | var outputs = this.output_area.toJSON(); | |
441 | data.outputs = outputs; |
|
443 | data.outputs = outputs; | |
442 | data.language = 'python'; |
|
444 | data.language = 'python'; |
General Comments 0
You need to be logged in to leave comments.
Login now