Permalink
Browse files

Merge pull request #146 from fetus-hina/feature-ansi-escape

標準出力や標準エラー出力へのANSIエスケープコード付きの出力に対応
  • Loading branch information...
2 parents 0b2fdc7 + 11b0dab commit 33cf8cb317693cba8b422e71193cc99d4874ab44 @melpon committed Sep 24, 2015
Showing with 28 additions and 14 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 kennel2/src/root.tmpl
  3. +1 −0 kennel2/static/js/ansi_up.js
  4. +22 −14 kennel2/static/js/root.js
  5. +1 −0 submodules/ansi_up
View
@@ -7,3 +7,6 @@
[submodule "submodules/jquery-cookie"]
path = submodules/jquery-cookie
url = https://github.com/carhartl/jquery-cookie.git
+[submodule "submodules/ansi_up"]
+ path = submodules/ansi_up
+ url = https://github.com/drudru/ansi_up.git
@@ -68,6 +68,7 @@
<script src="//platform.twitter.com/widgets.js"></script>
<script src="<% url "static" %>/js/jquery.url.js"></script>
<script src="<% url "static" %>/js/jquery.cookie.js"></script>
+<script src="<% url "static" %>/js/ansi_up.js"></script>
<script src="<% url "static" %>/codemirror/lib/codemirror.js"></script>
<script src="<% url "static" %>/codemirror/addon/mode/simple.js"></script>
<script src="<% url "static" %>/codemirror/mode/clike/clike.js"></script>
@@ -994,7 +994,7 @@ ResultWindow.prototype.post_code = function(compiler, code, codes, stdin) {
src.close();
var outputs = self._output_window().find('pre').map(function(n,e) {
- return { 'type': $(e).attr('data-type'), 'output': $(e).text() };
+ return { 'type': $(e).attr('data-type'), 'output': $(e).attr('data-text') };
});
self.permlink(compiler_info, code, codes, stdin, outputs);
@@ -1013,18 +1013,22 @@ ResultWindow.prototype.post_code = function(compiler, code, codes, stdin) {
data.type == "StdOut" ||
data.type == "StdErr";
};
- if (is_message(data.type) &&
- preview_paragraph &&
- preview_paragraph.hasClass(data.type)) {
- var p = preview_paragraph;
- p.text(p.text() + data.message)
- } else {
- var p = $('<pre>').addClass(data.type)
- .attr('data-type', data.type)
- .text(data.message)
- .appendTo(output);
- preview_paragraph = p;
- }
+ var p =
+ (is_message(data.type) &&
+ preview_paragraph &&
+ preview_paragraph.hasClass(data.type))
+ ? preview_paragraph
+ : $('<pre>').addClass(data.type).attr('data-type', data.type).attr('data-text', '').appendTo(output);
+ p.attr('data-text', p.attr('data-text') + data.message);
+ p.html(
+ ansi_up.ansi_to_html(
+ ansi_up.escape_for_html(
+ p.attr('data-text')
+ )
+ )
+ );
+ preview_paragraph = p;
+
output[0].scrollTop = output[0].scrollHeight;
if (data.type == 'Control' && data.message == 'Finish') {
@@ -1046,7 +1050,11 @@ ResultWindow.prototype.set_code = function(compiler, code, codes, stdin, outputs
var output = e.output;
$('<pre>').addClass(type)
.attr('data-type', type)
- .text(output)
+ .html(
+ ansi_up.ansi_to_html(
+ ansi_up.escape_for_html(output)
+ )
+ )
.appendTo(self._output_window());
});
}
Submodule ansi_up added at 32a3c2

0 comments on commit 33cf8cb

Please sign in to comment.