diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-04-09 04:19:27 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-04-09 04:19:27 (GMT) |
commit | a95b0819703aefc6a4f74004d6639f2cebd1e5d2 (patch) | |
tree | 2e3aba171219da51db1ec822013cbb54a51035e4 /src | |
parent | f872a912c57879767a7715094790aa4380badce2 (diff) | |
download | Ninja-a95b0819703aefc6a4f74004d6639f2cebd1e5d2.zip Ninja-a95b0819703aefc6a4f74004d6639f2cebd1e5d2.tar.gz Ninja-a95b0819703aefc6a4f74004d6639f2cebd1e5d2.tar.bz2 |
Make LinePrinter members private, add comments.
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 6 | ||||
-rw-r--r-- | src/line_printer.h | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/build.cc b/src/build.cc index 4ed586f..340a3d9 100644 --- a/src/build.cc +++ b/src/build.cc @@ -77,7 +77,7 @@ BuildStatus::BuildStatus(const BuildConfig& config) // Don't do anything fancy in verbose mode. if (config_.verbosity != BuildConfig::NORMAL) - printer_.smart_terminal_ = false; + printer_.set_smart_terminal(false); progress_status_format_ = getenv("NINJA_STATUS"); if (!progress_status_format_) @@ -112,7 +112,7 @@ void BuildStatus::BuildEdgeFinished(Edge* edge, if (config_.verbosity == BuildConfig::QUIET) return; - if (printer_.smart_terminal_) + if (printer_.is_smart_terminal()) PrintStatus(edge); // Print the command that is spewing before printing its output. @@ -133,7 +133,7 @@ void BuildStatus::BuildEdgeFinished(Edge* edge, // thousands of parallel compile commands.) // TODO: There should be a flag to disable escape code stripping. string final_output; - if (!printer_.smart_terminal_) + if (!printer_.is_smart_terminal()) final_output = StripAnsiEscapeCodes(output); else final_output = output; diff --git a/src/line_printer.h b/src/line_printer.h index b3cb163..78510ea 100644 --- a/src/line_printer.h +++ b/src/line_printer.h @@ -17,22 +17,31 @@ #include <string> +/// Prints lines of text, possibly overprinting previously printed lines +/// if the terminal supports it. class LinePrinter { public: LinePrinter(); + bool is_smart_terminal() const { return smart_terminal_; } + void set_smart_terminal(bool smart) { smart_terminal_ = smart; } + enum LineType { FULL, SHORT }; + /// Overprints the current line. If type is SHORT, elides to_print to fit on + /// one line. void Print(std::string to_print, LineType type); + /// Prints a string on a new line, not overprinting previous output. void PrintOnNewLine(const std::string& to_print); - //private: + private: /// Whether we can do fancy terminal control codes. bool smart_terminal_; + /// Whether the caret is at the beginning of a blank line. bool have_blank_line_; }; |