Show More
@@ -61,11 +61,11 b' var IPython = (function (IPython) {' | |||||
61 | // handlers and is used to provide custom key handling. Its return |
|
61 | // handlers and is used to provide custom key handling. Its return | |
62 | // value is used to determine if CodeMirror should ignore the event: |
|
62 | // value is used to determine if CodeMirror should ignore the event: | |
63 | // true = ignore, false = don't ignore. |
|
63 | // true = ignore, false = don't ignore. | |
64 |
|
64 | |||
65 | if (this.read_only){ |
|
65 | if (this.read_only){ | |
66 | return false; |
|
66 | return false; | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | var that = this; |
|
69 | var that = this; | |
70 | // whatever key is pressed, first, cancel the tooltip request before |
|
70 | // whatever key is pressed, first, cancel the tooltip request before | |
71 | // they are sent, and remove tooltip if any, except for tab again |
|
71 | // they are sent, and remove tooltip if any, except for tab again | |
@@ -90,7 +90,7 b' var IPython = (function (IPython) {' | |||||
90 | event.stop(); |
|
90 | event.stop(); | |
91 | return false; |
|
91 | return false; | |
92 | } else { |
|
92 | } else { | |
93 |
return true; |
|
93 | return true; | |
94 | }; |
|
94 | }; | |
95 | } else if (event.which === key.ESC) { |
|
95 | } else if (event.which === key.ESC) { | |
96 | IPython.tooltip.remove_and_cancel_tooltip(true); |
|
96 | IPython.tooltip.remove_and_cancel_tooltip(true); | |
@@ -102,7 +102,7 b' var IPython = (function (IPython) {' | |||||
102 | event.stop(); |
|
102 | event.stop(); | |
103 | return false; |
|
103 | return false; | |
104 | } else { |
|
104 | } else { | |
105 |
return true; |
|
105 | return true; | |
106 | }; |
|
106 | }; | |
107 | } else if (event.keyCode === key.TAB && event.type == 'keydown') { |
|
107 | } else if (event.keyCode === key.TAB && event.type == 'keydown') { | |
108 | // Tab completion. |
|
108 | // Tab completion. |
@@ -181,11 +181,7 b' var IPython = (function (IPython) {' | |||||
181 | if (json.stream == undefined){ |
|
181 | if (json.stream == undefined){ | |
182 | json.stream = 'stdout'; |
|
182 | json.stream = 'stdout'; | |
183 | } |
|
183 | } | |
184 |
|
|
184 | var text = utils.fixConsole(json.text); | |
185 | // fixConsole gives nothing (empty string, \r, etc.) |
|
|||
186 | // so don't append any elements, which might add undesirable space |
|
|||
187 | return; |
|
|||
188 | } |
|
|||
189 | var subclass = "output_"+json.stream; |
|
185 | var subclass = "output_"+json.stream; | |
190 | if (this.outputs.length > 0){ |
|
186 | if (this.outputs.length > 0){ | |
191 | // have at least one output to consider |
|
187 | // have at least one output to consider | |
@@ -194,15 +190,23 b' var IPython = (function (IPython) {' | |||||
194 | // latest output was in the same stream, |
|
190 | // latest output was in the same stream, | |
195 | // so append directly into its pre tag |
|
191 | // so append directly into its pre tag | |
196 | // escape ANSI & HTML specials: |
|
192 | // escape ANSI & HTML specials: | |
197 | var text = utils.fixConsole(json.text); |
|
193 | pre = this.element.find('div.'+subclass).last().find('pre'); | |
198 | this.element.find('div.'+subclass).last().find('pre').append(text); |
|
194 | html = utils.fixCarriageReturn( | |
|
195 | pre.html() + utils.fixConsole(text)); | |||
|
196 | pre.html(html); | |||
199 | return; |
|
197 | return; | |
200 | } |
|
198 | } | |
201 | } |
|
199 | } | |
202 |
|
200 | |||
|
201 | if (!text.replace("\r", "")) { | |||
|
202 | // text is nothing (empty string, \r, etc.) | |||
|
203 | // so don't append any elements, which might add undesirable space | |||
|
204 | return; | |||
|
205 | } | |||
|
206 | ||||
203 | // If we got here, attach a new div |
|
207 | // If we got here, attach a new div | |
204 | var toinsert = this.create_output_area(); |
|
208 | var toinsert = this.create_output_area(); | |
205 |
this.append_text( |
|
209 | this.append_text(text, toinsert, "output_stream "+subclass); | |
206 | this.element.append(toinsert); |
|
210 | this.element.append(toinsert); | |
207 | }; |
|
211 | }; | |
208 |
|
212 | |||
@@ -260,6 +264,7 b' var IPython = (function (IPython) {' | |||||
260 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_text"); |
|
264 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_text"); | |
261 | // escape ANSI & HTML specials in plaintext: |
|
265 | // escape ANSI & HTML specials in plaintext: | |
262 | data = utils.fixConsole(data); |
|
266 | data = utils.fixConsole(data); | |
|
267 | data = utils.fixCarriageReturn(data); | |||
263 | if (extra_class){ |
|
268 | if (extra_class){ | |
264 | toinsert.addClass(extra_class); |
|
269 | toinsert.addClass(extra_class); | |
265 | } |
|
270 | } | |
@@ -328,7 +333,7 b' var IPython = (function (IPython) {' | |||||
328 |
|
333 | |||
329 | OutputArea.prototype.clear_output_callback = function (stdout, stderr, other) { |
|
334 | OutputArea.prototype.clear_output_callback = function (stdout, stderr, other) { | |
330 | var output_div = this.element; |
|
335 | var output_div = this.element; | |
331 |
|
336 | |||
332 | if (stdout && stderr && other){ |
|
337 | if (stdout && stderr && other){ | |
333 | // clear all, no need for logic |
|
338 | // clear all, no need for logic | |
334 | output_div.html(""); |
|
339 | output_div.html(""); | |
@@ -347,7 +352,7 b' var IPython = (function (IPython) {' | |||||
347 | if (other) { |
|
352 | if (other) { | |
348 | output_div.find("div.output_subarea").not("div.output_stderr").not("div.output_stdout").parent().remove(); |
|
353 | output_div.find("div.output_subarea").not("div.output_stderr").not("div.output_stdout").parent().remove(); | |
349 | } |
|
354 | } | |
350 |
|
355 | |||
351 | // remove cleared outputs from JSON list: |
|
356 | // remove cleared outputs from JSON list: | |
352 | for (var i = this.outputs.length - 1; i >= 0; i--) { |
|
357 | for (var i = this.outputs.length - 1; i >= 0; i--) { | |
353 | var out = this.outputs[i]; |
|
358 | var out = this.outputs[i]; |
@@ -117,7 +117,7 b' var IPython = (function (IPython) {' | |||||
117 |
|
117 | |||
118 | Pager.prototype.append_text = function (text) { |
|
118 | Pager.prototype.append_text = function (text) { | |
119 | var toinsert = $("<div/>").addClass("output_area output_stream"); |
|
119 | var toinsert = $("<div/>").addClass("output_area output_stream"); | |
120 | toinsert.append($('<pre/>').html(utils.fixConsole(text))); |
|
120 | toinsert.append($('<pre/>').html(utils.fixCarriageReturn(utils.fixConsole(text)))); | |
121 | this.pager_element.append(toinsert); |
|
121 | this.pager_element.append(toinsert); | |
122 | }; |
|
122 | }; | |
123 |
|
123 |
@@ -47,7 +47,7 b' IPython.utils = (function (IPython) {' | |||||
47 | "37":"ansigrey", "01":"ansibold" |
|
47 | "37":"ansigrey", "01":"ansibold" | |
48 | }; |
|
48 | }; | |
49 |
|
49 | |||
50 | // Transform ANI color escape codes into HTML <span> tags with css |
|
50 | // Transform ANSI color escape codes into HTML <span> tags with css | |
51 | // classes listed in the above ansi_colormap object. The actual color used |
|
51 | // classes listed in the above ansi_colormap object. The actual color used | |
52 | // are set in the css file. |
|
52 | // are set in the css file. | |
53 | function fixConsole(txt) { |
|
53 | function fixConsole(txt) { | |
@@ -58,7 +58,6 b' IPython.utils = (function (IPython) {' | |||||
58 | var opener = ""; |
|
58 | var opener = ""; | |
59 | var closer = ""; |
|
59 | var closer = ""; | |
60 | // \r does nothing, so shouldn't be included |
|
60 | // \r does nothing, so shouldn't be included | |
61 | txt = txt.replace('\r', ''); |
|
|||
62 | while (re.test(txt)) { |
|
61 | while (re.test(txt)) { | |
63 | var cmds = txt.match(re)[1].split(";"); |
|
62 | var cmds = txt.match(re)[1].split(";"); | |
64 | closer = opened?"</span>":""; |
|
63 | closer = opened?"</span>":""; | |
@@ -133,6 +132,7 b' IPython.utils = (function (IPython) {' | |||||
133 | fixConsole : fixConsole, |
|
132 | fixConsole : fixConsole, | |
134 | keycodes : keycodes, |
|
133 | keycodes : keycodes, | |
135 | grow : grow, |
|
134 | grow : grow, | |
|
135 | fixCarriageReturn : fixCarriageReturn | |||
136 | }; |
|
136 | }; | |
137 |
|
137 | |||
138 | }(IPython)); |
|
138 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now