summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Despres <nicolas.despres@gmail.com>2011-10-12 16:33:08 (GMT)
committerNicolas Despres <nicolas.despres@gmail.com>2011-10-12 16:48:06 (GMT)
commit3b20df9f1c262bb54597631e7151b9194285c297 (patch)
tree144142d651767ff5a319ead40b2eb578c0b20b34 /src
parente54d2b6c8bbb78b238160c7f31ae8515c15183d9 (diff)
downloadNinja-3b20df9f1c262bb54597631e7151b9194285c297.zip
Ninja-3b20df9f1c262bb54597631e7151b9194285c297.tar.gz
Ninja-3b20df9f1c262bb54597631e7151b9194285c297.tar.bz2
Elide output in the middle when exceeding terminal width.
When building projects with long file paths, the rule name may disappear since the output is elided on the left side. So you no longer know whether you are compiling or linking. I think the user is interested in both the rule name and the file name. Eliding the output in the middle solves this problem.
Diffstat (limited to 'src')
-rw-r--r--src/build.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/build.cc b/src/build.cc
index 9adce8f..e72d9d7 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -156,9 +156,10 @@ void BuildStatus::PrintStatus(Edge* edge) {
if ((ioctl(0, TIOCGWINSZ, &size) == 0) && size.ws_col) {
const int kMargin = progress_chars + 3; // Space for [xx/yy] and "...".
if (to_print.size() + kMargin > size.ws_col) {
- int substr = std::min(to_print.size(),
- to_print.size() + kMargin - size.ws_col);
- to_print = "..." + to_print.substr(substr);
+ int elide_size = (size.ws_col - kMargin) / 2;
+ to_print = to_print.substr(0, elide_size)
+ + "..."
+ + to_print.substr(to_print.size() - elide_size, elide_size);
}
}
}