* Added an extra escape code to signal "unimportant" messages. If a tree only has
unimportant messages, it is collapsed by the default. * Also added an optional integer argument to the escape code for opening a nesting level to indicate lack of importance. If set, the tree is collapsed by default.
This commit is contained in:
parent
84c617966b
commit
3f3c4cce5a
3 changed files with 46 additions and 9 deletions
|
@ -24,11 +24,25 @@
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="nest">
|
<xsl:template match="nest">
|
||||||
<script type='text/javascript'>showTreeToggle("show","hide")</script>
|
|
||||||
|
<!-- The tree should be collapsed by default if all children are
|
||||||
|
unimportant or if the header is unimportant. -->
|
||||||
|
<xsl:variable name="collapsed"
|
||||||
|
select="count(.//line[not(@priority = 3)]) = 0 or ./head[@priority = 3]" />
|
||||||
|
|
||||||
|
<xsl:variable name="style"><xsl:if test="$collapsed">display: none;</xsl:if></xsl:variable>
|
||||||
|
<xsl:variable name="arg"><xsl:choose><xsl:when test="$collapsed">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose></xsl:variable>
|
||||||
|
|
||||||
|
<script type='text/javascript'>showTreeToggle(<xsl:value-of select="$collapsed"/>)</script>
|
||||||
<xsl:apply-templates select='head'/>
|
<xsl:apply-templates select='head'/>
|
||||||
<ul class='nesting'>
|
|
||||||
|
<ul class='nesting' style="{$style}">
|
||||||
<xsl:for-each select='line|nest'>
|
<xsl:for-each select='line|nest'>
|
||||||
<xsl:param name="class"><xsl:choose><xsl:when test="position() != last()">line</xsl:when><xsl:otherwise>lastline</xsl:otherwise></xsl:choose></xsl:param>
|
|
||||||
|
<!-- Is this the last line? If so, mark it as such so that it
|
||||||
|
can be rendered differently. -->
|
||||||
|
<xsl:variable name="class"><xsl:choose><xsl:when test="position() != last()">line</xsl:when><xsl:otherwise>lastline</xsl:otherwise></xsl:choose></xsl:variable>
|
||||||
|
|
||||||
<li class='{$class}'>
|
<li class='{$class}'>
|
||||||
<span class='lineconn' />
|
<span class='lineconn' />
|
||||||
<span class='linebody'>
|
<span class='linebody'>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -11,6 +12,9 @@ struct Decoder
|
||||||
string line;
|
string line;
|
||||||
bool inHeader;
|
bool inHeader;
|
||||||
int level;
|
int level;
|
||||||
|
vector<int> args;
|
||||||
|
bool newNumber;
|
||||||
|
int priority;
|
||||||
|
|
||||||
Decoder()
|
Decoder()
|
||||||
{
|
{
|
||||||
|
@ -18,6 +22,7 @@ struct Decoder
|
||||||
line = "";
|
line = "";
|
||||||
inHeader = false;
|
inHeader = false;
|
||||||
level = 0;
|
level = 0;
|
||||||
|
priority = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushChar(char c);
|
void pushChar(char c);
|
||||||
|
@ -39,9 +44,11 @@ void Decoder::pushChar(char c)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case stEscape:
|
case stEscape:
|
||||||
if (c == '[')
|
if (c == '[') {
|
||||||
state = stCSI;
|
state = stCSI;
|
||||||
else
|
args.clear();
|
||||||
|
newNumber = true;
|
||||||
|
} else
|
||||||
state = stTop; /* !!! wrong */
|
state = stTop; /* !!! wrong */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -54,6 +61,7 @@ void Decoder::pushChar(char c)
|
||||||
level++;
|
level++;
|
||||||
inHeader = true;
|
inHeader = true;
|
||||||
cout << "<nest>" << endl;
|
cout << "<nest>" << endl;
|
||||||
|
priority = args.size() >= 1 ? args[0] : 1;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
if (line.size()) finishLine();
|
if (line.size()) finishLine();
|
||||||
|
@ -63,7 +71,19 @@ void Decoder::pushChar(char c)
|
||||||
} else
|
} else
|
||||||
cerr << "not enough nesting levels" << endl;
|
cerr << "not enough nesting levels" << endl;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
if (line.size()) finishLine();
|
||||||
|
priority = args.size() >= 1 ? args[0] : 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (c >= '0' && c <= '9') {
|
||||||
|
int n = 0;
|
||||||
|
if (!newNumber) {
|
||||||
|
n = args.back() * 10;
|
||||||
|
args.pop_back();
|
||||||
|
}
|
||||||
|
n += c - '0';
|
||||||
|
args.push_back(n);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -76,7 +96,9 @@ void Decoder::finishLine()
|
||||||
string storeDir = "/nix/store/";
|
string storeDir = "/nix/store/";
|
||||||
int sz = storeDir.size();
|
int sz = storeDir.size();
|
||||||
string tag = inHeader ? "head" : "line";
|
string tag = inHeader ? "head" : "line";
|
||||||
cout << "<" << tag << ">";
|
cout << "<" << tag;
|
||||||
|
if (priority != 1) cout << " priority='" << priority << "'";
|
||||||
|
cout << ">";
|
||||||
|
|
||||||
for (int i = 0; i < line.size(); i++) {
|
for (int i = 0; i < line.size(); i++) {
|
||||||
|
|
||||||
|
@ -113,6 +135,7 @@ void Decoder::finishLine()
|
||||||
cout << "</" << tag << ">" << endl;
|
cout << "</" << tag << ">" << endl;
|
||||||
line = "";
|
line = "";
|
||||||
inHeader = false;
|
inHeader = false;
|
||||||
|
priority = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
var idCounter = 0;
|
var idCounter = 0;
|
||||||
|
|
||||||
|
|
||||||
function showTreeToggle(show,hide) {
|
function showTreeToggle(isHidden) {
|
||||||
if (document.getElementById) {
|
if (document.getElementById) {
|
||||||
var id = "toggle_" + idCounter;
|
var id = "toggle_" + idCounter;
|
||||||
document.writeln(
|
document.writeln(
|
||||||
'<a href="javascript:toggleTree(\'' + id + '\')" class="toggle" id="' + id + '">' +
|
'<a href="javascript:toggleTree(\'' + id + '\')" class="toggle" id="' + id + '">' +
|
||||||
'<span class="showTree" style="display: none;">+</span>' +
|
'<span class="showTree" ' + (isHidden ? '' : 'style="display: none;"') + '>+</span>' +
|
||||||
'<span class="hideTree">-</span>' +
|
'<span class="hideTree" ' + (isHidden ? 'style="display: none;"' : '') + '>-</span>' +
|
||||||
'</a>');
|
'</a>');
|
||||||
idCounter = idCounter + 1;
|
idCounter = idCounter + 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue