##// END OF EJS Templates
revert PR #1659...
MinRK -
Show More
@@ -623,8 +623,11 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 if (!utils.fixConsole(json.text)){
627 var text = utils.fixConsole(json.text);
627 // fixConsole gives nothing (empty string, \r, etc.)
628 // so don't append any elements, which might add undesirable space
629 return;
630 }
628 var subclass = "output_"+json.stream;
631 var subclass = "output_"+json.stream;
629 if (this.outputs.length > 0){
632 if (this.outputs.length > 0){
630 // have at least one output to consider
633 // have at least one output to consider
@@ -633,22 +636,15 b' var IPython = (function (IPython) {'
633 // latest output was in the same stream,
636 // latest output was in the same stream,
634 // so append directly into its pre tag
637 // so append directly into its pre tag
635 // escape ANSI & HTML specials:
638 // escape ANSI & HTML specials:
636 pre = this.element.find('div.'+subclass).last().find('pre');
639 var text = utils.fixConsole(json.text);
637 text = utils.fixCarriageReturn(pre.text() + text);
640 this.element.find('div.'+subclass).last().find('pre').append(text);
638 pre.text(text);
639 return;
641 return;
640 }
642 }
641 }
643 }
642
644
643 if (!text.replace("\r", "")) {
644 // text is nothing (empty string, \r, etc.)
645 // so don't append any elements, which might add undesirable space
646 return;
647 }
648
649 // If we got here, attach a new div
645 // If we got here, attach a new div
650 var toinsert = this.create_output_area();
646 var toinsert = this.create_output_area();
651 this.append_text(text, toinsert, "output_stream "+subclass);
647 this.append_text(json.text, toinsert, "output_stream "+subclass);
652 this.element.find('div.output').append(toinsert);
648 this.element.find('div.output').append(toinsert);
653 };
649 };
654
650
@@ -706,7 +702,6 b' var IPython = (function (IPython) {'
706 var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_text");
702 var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_text");
707 // escape ANSI & HTML specials in plaintext:
703 // escape ANSI & HTML specials in plaintext:
708 data = utils.fixConsole(data);
704 data = utils.fixConsole(data);
709 data = utils.fixCarriageReturn(data);
710 if (extra_class){
705 if (extra_class){
711 toinsert.addClass(extra_class);
706 toinsert.addClass(extra_class);
712 }
707 }
@@ -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.fixCarriageReturn(utils.fixConsole(text))));
92 toinsert.append($('<pre/>').html(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 ANSI color escape codes into HTML <span> tags with css
50 // Transform ANI 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) {
@@ -57,6 +57,8 b' IPython.utils = (function (IPython) {'
57 var cmds = [];
57 var cmds = [];
58 var opener = "";
58 var opener = "";
59 var closer = "";
59 var closer = "";
60 // \r does nothing, so shouldn't be included
61 txt = txt.replace('\r', '');
60 while (re.test(txt)) {
62 while (re.test(txt)) {
61 var cmds = txt.match(re)[1].split(";");
63 var cmds = txt.match(re)[1].split(";");
62 closer = opened?"</span>":"";
64 closer = opened?"</span>":"";
@@ -72,16 +74,6 b' IPython.utils = (function (IPython) {'
72 return txt;
74 return txt;
73 }
75 }
74
76
75 // Remove chunks that should be overridden by the effect of
76 // carriage return characters
77 function fixCarriageReturn(txt) {
78 tmp = txt;
79 do {
80 txt = tmp;
81 tmp = txt.replace(/^.*\r/gm, '');
82 } while (tmp.length < txt.length);
83 return txt;
84 }
85
77
86 grow = function(element) {
78 grow = function(element) {
87 // Grow the cell by hand. This is used upon reloading from JSON, when the
79 // Grow the cell by hand. This is used upon reloading from JSON, when the
@@ -103,8 +95,7 b' IPython.utils = (function (IPython) {'
103 return {
95 return {
104 uuid : uuid,
96 uuid : uuid,
105 fixConsole : fixConsole,
97 fixConsole : fixConsole,
106 grow : grow,
98 grow : grow
107 fixCarriageReturn : fixCarriageReturn
108 };
99 };
109
100
110 }(IPython));
101 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now