summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-24 14:24:19 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-01-24 14:24:19 +0100
commit2e8432a2fd10f4cf5519628c7ab6e7c6e270ca15 (patch)
tree1ca46f230e0efdc415fbec77f3adf74b15e34e0e /src
parent7e722fdd45496e6c8dd115faa7fab265e13b2e93 (diff)
Vastly improved terminal logger context output routine (code is still and will forever be a mess, but it is PREEEEETYYYY!)
Diffstat (limited to 'src')
-rw-r--r--src/core/frontend/TerminalLogger.cpp60
1 files changed, 43 insertions, 17 deletions
diff --git a/src/core/frontend/TerminalLogger.cpp b/src/core/frontend/TerminalLogger.cpp
index fdb7c8f..3bead06 100644
--- a/src/core/frontend/TerminalLogger.cpp
+++ b/src/core/frontend/TerminalLogger.cpp
@@ -93,18 +93,27 @@ void TerminalLogger::processMessage(const Message &msg)
// Indicate truncation and indent non-first lines
if (ctx.truncatedStart && firstLine) {
- os << "[...] ";
+ os << t.italic() << "[...] " << t.reset();
}
if (!firstLine) {
os << "\t";
}
- // Print the actual line
- os << lines[n];
+ // Print the actual line, replace tabs
+ for (char c: lines[n]) {
+ if (c == '\t') {
+ os << " ";
+ } else {
+ os << c;
+ }
+ }
+ if (!lastLine) {
+ os << t.color(Terminal::BLACK) << "¶" << t.reset();
+ }
// Indicate truncation
if (ctx.truncatedEnd && lastLine) {
- os << " [...]";
+ os << t.italic() << " [...]" << t.reset();
}
os << std::endl;
@@ -118,31 +127,48 @@ void TerminalLogger::processMessage(const Message &msg)
// Print the position indicators
lend = lastLine ? pend : lstart + lines[n].size();
- for (size_t i = lstart; i < lend; i++) {
+ bool inRegion = false;
+ for (size_t i = lstart; i < lend + 1; i++) {
if (i >= pstart && i < pend) {
- os << t.color(Terminal::GREEN);
- for (; i < std::min(lend, pend); i++) {
+ if (!inRegion) {
+ os << t.color(Terminal::GREEN);
+ inRegion = true;
+ }
+ } else {
+ if (inRegion) {
+ os << t.reset();
+ inRegion = false;
+ }
+ }
+ char c = i < ctx.text.size() ? ctx.text[i] : ' ';
+ if (c == '\t') {
+ if (inRegion) {
if (relLen == 1) {
- os << '^';
+ os << "^ ";
} else {
- os << '~';
- }
- if (i < ctx.text.size() && ctx.text[i] == '\t') {
- os << '\t';
+ os << "~~~~";
}
+ } else {
+ os << " ";
}
- os << t.reset();
} else {
- if (i < ctx.text.size() && ctx.text[i] == '\t') {
- os << '\t';
+ if (inRegion) {
+ if (relLen == 1) {
+ os << "^";
+ } else {
+ os << "~";
+ }
} else {
- os << ' ';
+ os << " ";
}
}
}
+ if (inRegion) {
+ os << t.reset();
+ }
os << std::endl;
- lstart = lend;
+ lstart = lend + 1; // skip newline
}
}
}