Permalink
Browse files

Make LinePrinter members private, add comments.

  • Loading branch information...
1 parent f872a91 commit a95b0819703aefc6a4f74004d6639f2cebd1e5d2 @nico nico committed Apr 9, 2013
Showing with 13 additions and 4 deletions.
  1. +3 −3 src/build.cc
  2. +10 −1 src/line_printer.h
View
@@ -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;
View
@@ -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_;
};

0 comments on commit a95b081

Please sign in to comment.