|
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 (std::string to_print, LineType type) |
| Overprints the current line. More... | |
| void | PrintOnNewLine (const std::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... | |
| bool | supports_color () const |
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... | |
| std::string | line_buffer_ |
| Buffered current line while console is locked. More... | |
| LineType | line_type_ |
| Buffered line type while console is locked. More... | |
| std::string | output_buffer_ |
| Buffered console output while console is locked. More... | |
| bool | smart_terminal_ |
| Whether we can do fancy terminal control codes. More... | |
| bool | supports_color_ |
| Whether we can use ISO 6429 (ANSI) color sequences. More... | |
Prints lines of text, possibly overprinting previously printed lines if the terminal supports it.
Definition at line 23 of file line_printer.h.
| Enumerator | |
|---|---|
| FULL | |
| ELIDE | |
Definition at line 31 of file line_printer.h.
| LinePrinter::LinePrinter | ( | ) |
Definition at line 36 of file line_printer.cc.
References smart_terminal_, and supports_color_.
|
inline |
Definition at line 26 of file line_printer.h.
References smart_terminal_.
Referenced by StatusPrinter::BuildEdgeStarted().
| void LinePrinter::Print | ( | std::string | to_print, |
| LineType | type | ||
| ) |
Overprints the current line.
If type is ELIDE, elides to_print to fit on one line.
Definition at line 67 of file line_printer.cc.
References console_locked_, ELIDE, ElideMiddleInPlace(), have_blank_line_, line_buffer_, line_type_, smart_terminal_, and supports_color_.
Referenced by StatusPrinter::PrintStatus(), and SetConsoleLocked().
| void LinePrinter::PrintOnNewLine | ( | const std::string & | to_print | ) |
Prints a string on a new line, not overprinting previous output.
Definition at line 136 of file line_printer.cc.
References console_locked_, have_blank_line_, line_buffer_, output_buffer_, and PrintOrBuffer().
Referenced by StatusPrinter::BuildEdgeFinished(), StatusPrinter::BuildFinished(), StatusPrinter::PrintStatus(), and SetConsoleLocked().
|
private |
Print the given data to the console, or buffer it if it is locked.
Definition at line 126 of file line_printer.cc.
References console_locked_, and output_buffer_.
Referenced by PrintOnNewLine().
|
inline |
Definition at line 27 of file line_printer.h.
References smart_terminal_.
Referenced by StatusPrinter::StatusPrinter().
| 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 151 of file line_printer.cc.
References console_locked_, line_buffer_, line_type_, output_buffer_, Print(), and PrintOnNewLine().
Referenced by StatusPrinter::BuildEdgeFinished(), StatusPrinter::BuildEdgeStarted(), and StatusPrinter::BuildFinished().
|
inline |
Definition at line 29 of file line_printer.h.
References supports_color_.
Referenced by StatusPrinter::BuildEdgeFinished().
|
private |
Whether console is locked.
Definition at line 57 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 54 of file line_printer.h.
Referenced by Print(), and PrintOnNewLine().
|
private |
Buffered current line while console is locked.
Definition at line 60 of file line_printer.h.
Referenced by Print(), PrintOnNewLine(), and SetConsoleLocked().
|
private |
Buffered line type while console is locked.
Definition at line 63 of file line_printer.h.
Referenced by Print(), and SetConsoleLocked().
|
private |
Buffered console output while console is locked.
Definition at line 66 of file line_printer.h.
Referenced by PrintOnNewLine(), PrintOrBuffer(), and SetConsoleLocked().
|
private |
Whether we can do fancy terminal control codes.
Definition at line 48 of file line_printer.h.
Referenced by is_smart_terminal(), LinePrinter(), Print(), and set_smart_terminal().
|
private |
Whether we can use ISO 6429 (ANSI) color sequences.
Definition at line 51 of file line_printer.h.
Referenced by LinePrinter(), Print(), and supports_color().