Ninja
|
Prints lines of text, possibly overprinting previously printed lines if the terminal supports it. More...
#include <line_printer.h>
Public Types | |
enum | LineType { FULL, ELIDE } |
Public Member Functions | |
bool | is_smart_terminal () const |
LinePrinter () | |
void | Print (string to_print, LineType type) |
Overprints the current line. More... | |
void | PrintOnNewLine (const string &to_print) |
Prints a string on a new line, not overprinting previous output. More... | |
void | set_smart_terminal (bool smart) |
void | SetConsoleLocked (bool locked) |
Lock or unlock the console. More... | |
Private Member Functions | |
void | PrintOrBuffer (const char *data, size_t size) |
Print the given data to the console, or buffer it if it is locked. More... | |
Private Attributes | |
bool | console_locked_ |
Whether console is locked. More... | |
bool | have_blank_line_ |
Whether the caret is at the beginning of a blank line. More... | |
string | line_buffer_ |
Buffered current line while console is locked. More... | |
LineType | line_type_ |
Buffered line type while console is locked. More... | |
string | output_buffer_ |
Buffered console output while console is locked. More... | |
bool | smart_terminal_ |
Whether we can do fancy terminal control codes. More... | |
Prints lines of text, possibly overprinting previously printed lines if the terminal supports it.
Definition at line 24 of file line_printer.h.
Enumerator | |
---|---|
FULL | |
ELIDE |
Definition at line 30 of file line_printer.h.
LinePrinter::LinePrinter | ( | ) |
Definition at line 29 of file line_printer.cc.
References smart_terminal_.
|
inline |
Definition at line 27 of file line_printer.h.
Referenced by BuildStatus::BuildEdgeFinished().
void LinePrinter::Print | ( | string | to_print, |
LineType | type | ||
) |
Overprints the current line.
If type is ELIDE, elides to_print to fit on one line.
Definition at line 45 of file line_printer.cc.
References console_locked_, ELIDE, ElideMiddle(), have_blank_line_, line_buffer_, line_type_, and smart_terminal_.
Referenced by LaconicPrinter::OnTestStart(), BuildStatus::PrintStatus(), and SetConsoleLocked().
void LinePrinter::PrintOnNewLine | ( | const string & | to_print | ) |
Prints a string on a new line, not overprinting previous output.
Definition at line 120 of file line_printer.cc.
References console_locked_, have_blank_line_, line_buffer_, output_buffer_, and PrintOrBuffer().
Referenced by BuildStatus::BuildEdgeFinished(), BuildStatus::BuildFinished(), LaconicPrinter::OnTestPartResult(), LaconicPrinter::OnTestProgramEnd(), and SetConsoleLocked().
|
private |
Print the given data to the console, or buffer it if it is locked.
Definition at line 110 of file line_printer.cc.
References console_locked_, and output_buffer_.
Referenced by PrintOnNewLine().
|
inline |
Definition at line 28 of file line_printer.h.
Referenced by BuildStatus::BuildStatus().
void LinePrinter::SetConsoleLocked | ( | bool | locked | ) |
Lock or unlock the console.
Any output sent to the LinePrinter while the console is locked will not be printed until it is unlocked.
Definition at line 135 of file line_printer.cc.
References console_locked_, line_buffer_, line_type_, output_buffer_, Print(), and PrintOnNewLine().
Referenced by BuildStatus::BuildEdgeFinished(), BuildStatus::BuildEdgeStarted(), and BuildStatus::BuildFinished().
|
private |
Whether console is locked.
Definition at line 53 of file line_printer.h.
Referenced by Print(), PrintOnNewLine(), PrintOrBuffer(), and SetConsoleLocked().
|
private |
Whether the caret is at the beginning of a blank line.
Definition at line 50 of file line_printer.h.
Referenced by Print(), and PrintOnNewLine().
|
private |
Buffered current line while console is locked.
Definition at line 56 of file line_printer.h.
Referenced by Print(), PrintOnNewLine(), and SetConsoleLocked().
|
private |
Buffered line type while console is locked.
Definition at line 59 of file line_printer.h.
Referenced by Print(), and SetConsoleLocked().
|
private |
Buffered console output while console is locked.
Definition at line 62 of file line_printer.h.
Referenced by PrintOnNewLine(), PrintOrBuffer(), and SetConsoleLocked().
|
private |
Whether we can do fancy terminal control codes.
Definition at line 47 of file line_printer.h.
Referenced by LinePrinter(), and Print().