diff options
author | Nicolas Despres <nicolas.despres@gmail.com> | 2012-07-28 12:41:20 (GMT) |
---|---|---|
committer | Nicolas Despres <nicolas.despres@gmail.com> | 2012-07-31 07:24:52 (GMT) |
commit | 8b590881013a05fd5017aa94185a02f6b7d09758 (patch) | |
tree | e83647d4ae44cbaa6f7401b350980f74adb06034 /src/build.cc | |
parent | b26f978ac3d7c5fd91de675bba62f31f704e0e04 (diff) | |
download | Ninja-8b590881013a05fd5017aa94185a02f6b7d09758.zip Ninja-8b590881013a05fd5017aa94185a02f6b7d09758.tar.gz Ninja-8b590881013a05fd5017aa94185a02f6b7d09758.tar.bz2 |
Re-factor elide code and test it.
Diffstat (limited to 'src/build.cc')
-rw-r--r-- | src/build.cc | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/build.cc b/src/build.cc index 09d7f65..a1c94e4 100644 --- a/src/build.cc +++ b/src/build.cc @@ -236,28 +236,17 @@ void BuildStatus::PrintStatus(Edge* edge) { to_print = FormatProgressStatus(progress_status_format_) + to_print; if (smart_terminal_ && !force_full_command) { - const int kMargin = 3; // Space for "...". #ifndef _WIN32 // Limit output to width of the terminal if provided so we don't cause // line-wrapping. winsize size; if ((ioctl(0, TIOCGWINSZ, &size) == 0) && size.ws_col) { - if (to_print.size() + kMargin > size.ws_col) { - 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); - } + to_print = ElideMiddle(to_print, size.ws_col); } #else // Don't use the full width or console will move to next line. size_t width = static_cast<size_t>(csbi.dwSize.X) - 1; - if (to_print.size() + kMargin > width) { - int elide_size = (width - kMargin) / 2; - to_print = to_print.substr(0, elide_size) - + "..." - + to_print.substr(to_print.size() - elide_size, elide_size); - } + to_print = ElideMiddle(to_print, width); #endif } |