Author: NicolasPierron Date: Mon Apr 25 22:20:39 2011 New Revision: 26975 URL: https://svn.nixos.org/websvn/nix/?rev=26975&sc=1
Log: nixos-gui: Improve pretty-print: - Handle int & derivations. - Change the new-line policy. Modified: nixos/trunk/gui/chrome/content/nixos.js Modified: nixos/trunk/gui/chrome/content/nixos.js ============================================================================== --- nixos/trunk/gui/chrome/content/nixos.js Mon Apr 25 22:20:30 2011 (r26974) +++ nixos/trunk/gui/chrome/content/nixos.js Mon Apr 25 22:20:39 2011 (r26975) @@ -142,41 +142,47 @@ var xml2nix_pptable = { attrs: function (node, depth, pp) { - var out = ""; - out += "{"; var children = node.children().not( function () { var name = $(this).attr("name"); return name.charAt(0) == "_"; } ); - if (children.lenght != 0) - { - depth += 1; - children.each( - function (idx) { out += pp.dispatch($(this), depth, pp); } - ); - depth -= 1; - out += this.indent(depth) + ""; - } + var c = 0; + var out = ""; + out += "{"; + depth += 1; + children.each( + function (idx) { + c += 1; + out += pp.indent(depth); + out += pp.dispatch($(this), depth, pp); + } + ); + depth -= 1; + if (c > 0) + out += this.indent(depth); else out += " "; out += "}"; return out; }, list: function (node, depth, pp) { + var children = node.children(); + var c = 0; var out = ""; out += "["; - var children = node.children(); - if (children.lenght != 0) - { - depth += 1; - children.each( - function (idx) { out += pp.dispatch($(this), depth, pp); } - ); - depth -= 1; + depth += 1; + children.each( + function (idx) { + c += 1; + out += pp.indent(depth); + out += pp.dispatch($(this), depth, pp); + } + ); + depth -= 1; + if (c > 0) out += this.indent(depth); - } else out += " "; out += "]"; @@ -186,13 +192,10 @@ var name = node.attr("name"); var out = ""; var val = ""; - out += this.indent(depth); out += name + " = "; depth += 1; val = pp.dispatch(node.children().first(), depth, pp); out += val; - if (val.indexOf("\n") != -1) - out += this.indent(depth);; depth -= 1; out += ";"; return out; @@ -206,9 +209,15 @@ bool: function (node, depth, pp) { return node.attr("value"); }, + "int": function (node, depth, pp) { + return node.attr("value"); + }, null: function (node, depth, pp) { return "null"; }, + derivation: function (node, depth, pp) { + return "<derivation>"; + }, function: function (node, depth, pp) { return "<function>"; }, _______________________________________________ nix-commits mailing list nix-comm...@cs.uu.nl http://mail.cs.uu.nl/mailman/listinfo/nix-commits