Show More
@@ -623,7 +623,8 b' var IPython = (function (IPython) {' | |||||
623 | if (json.stream == undefined){ |
|
623 | if (json.stream == undefined){ | |
624 | json.stream = 'stdout'; |
|
624 | json.stream = 'stdout'; | |
625 | } |
|
625 | } | |
626 |
|
|
626 | var text = utils.fixConsole(json.text); | |
|
627 | if (!text){ | |||
627 | // fixConsole gives nothing (empty string, \r, etc.) |
|
628 | // fixConsole gives nothing (empty string, \r, etc.) | |
628 | // so don't append any elements, which might add undesirable space |
|
629 | // so don't append any elements, which might add undesirable space | |
629 | return; |
|
630 | return; | |
@@ -636,15 +637,16 b' var IPython = (function (IPython) {' | |||||
636 | // latest output was in the same stream, |
|
637 | // latest output was in the same stream, | |
637 | // so append directly into its pre tag |
|
638 | // so append directly into its pre tag | |
638 | // escape ANSI & HTML specials: |
|
639 | // escape ANSI & HTML specials: | |
639 | var text = utils.fixConsole(json.text); |
|
640 | pre = this.element.find('div.'+subclass).last().find('pre'); | |
640 | this.element.find('div.'+subclass).last().find('pre').append(text); |
|
641 | text = utils.fixCarriageReturn(pre.text() + text); | |
|
642 | pre.text(text); | |||
641 | return; |
|
643 | return; | |
642 | } |
|
644 | } | |
643 | } |
|
645 | } | |
644 |
|
646 | |||
645 | // If we got here, attach a new div |
|
647 | // If we got here, attach a new div | |
646 | var toinsert = this.create_output_area(); |
|
648 | var toinsert = this.create_output_area(); | |
647 |
this.append_text( |
|
649 | this.append_text(text, toinsert, "output_stream "+subclass); | |
648 | this.element.find('div.output').append(toinsert); |
|
650 | this.element.find('div.output').append(toinsert); | |
649 | }; |
|
651 | }; | |
650 |
|
652 | |||
@@ -702,6 +704,7 b' var IPython = (function (IPython) {' | |||||
702 | var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_text"); |
|
704 | var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_text"); | |
703 | // escape ANSI & HTML specials in plaintext: |
|
705 | // escape ANSI & HTML specials in plaintext: | |
704 | data = utils.fixConsole(data); |
|
706 | data = utils.fixConsole(data); | |
|
707 | data = utils.fixCarriageReturn(data); | |||
705 | if (extra_class){ |
|
708 | if (extra_class){ | |
706 | toinsert.addClass(extra_class); |
|
709 | toinsert.addClass(extra_class); | |
707 | } |
|
710 | } |
@@ -89,9 +89,9 b' var IPython = (function (IPython) {' | |||||
89 |
|
89 | |||
90 | Pager.prototype.append_text = function (text) { |
|
90 | Pager.prototype.append_text = function (text) { | |
91 | var toinsert = $("<div/>").addClass("output_area output_stream"); |
|
91 | var toinsert = $("<div/>").addClass("output_area output_stream"); | |
92 | toinsert.append($('<pre/>').html(utils.fixConsole(text))); |
|
92 | toinsert.append($('<pre/>').html(utils.fixCarriageReturn(utils.fixConsole(text)))); | |
93 | this.pager_element.append(toinsert); |
|
93 | this.pager_element.append(toinsert); | |
94 |
}; |
|
94 | }; | |
95 |
|
95 | |||
96 |
|
96 | |||
97 | IPython.Pager = Pager; |
|
97 | IPython.Pager = Pager; |
@@ -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>":""; | |
@@ -74,6 +73,16 b' IPython.utils = (function (IPython) {' | |||||
74 | return txt; |
|
73 | return txt; | |
75 | } |
|
74 | } | |
76 |
|
75 | |||
|
76 | // Remove chunks that should be overridden by the effect carriage | |||
|
77 | // return characters | |||
|
78 | function fixCarriageReturn(txt) { | |||
|
79 | tmp = txt; | |||
|
80 | do { | |||
|
81 | txt = tmp; | |||
|
82 | tmp = txt.replace(/^.*\r/gm, ''); | |||
|
83 | } while (tmp.length < txt.length); | |||
|
84 | return txt; | |||
|
85 | } | |||
77 |
|
86 | |||
78 | grow = function(element) { |
|
87 | grow = function(element) { | |
79 | // Grow the cell by hand. This is used upon reloading from JSON, when the |
|
88 | // Grow the cell by hand. This is used upon reloading from JSON, when the | |
@@ -95,7 +104,8 b' IPython.utils = (function (IPython) {' | |||||
95 | return { |
|
104 | return { | |
96 | uuid : uuid, |
|
105 | uuid : uuid, | |
97 | fixConsole : fixConsole, |
|
106 | fixConsole : fixConsole, | |
98 | grow : grow |
|
107 | grow : grow, | |
|
108 | fixCarriageReturn : fixCarriageReturn | |||
99 | }; |
|
109 | }; | |
100 |
|
110 | |||
101 | }(IPython)); |
|
111 | }(IPython)); |
General Comments 0
You need to be logged in to leave comments.
Login now