summaryrefslogtreecommitdiffstats
path: root/src/line_printer.h
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2014-01-30 05:57:58 (GMT)
committerPeter Collingbourne <peter@pcc.me.uk>2014-02-03 05:20:01 (GMT)
commit2832613dc7c1a4a8ff3b9df729954715762a8381 (patch)
tree7f4be6edb18f26d73af002f977c2f4a901dfe2ea /src/line_printer.h
parent84986af6fdeae3f649f2bf884b20f644bc370e48 (diff)
downloadNinja-2832613dc7c1a4a8ff3b9df729954715762a8381.zip
Ninja-2832613dc7c1a4a8ff3b9df729954715762a8381.tar.gz
Ninja-2832613dc7c1a4a8ff3b9df729954715762a8381.tar.bz2
Introduce the "console" pool
This is a pre-defined pool with a depth of 1. It has the special property that any task in the pool has direct access to the console. This can be useful for interactive tasks or long-running tasks which produce status updates on the console (such as test suites).
Diffstat (limited to 'src/line_printer.h')
-rw-r--r--src/line_printer.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/line_printer.h b/src/line_printer.h
index aea2817..55225e5 100644
--- a/src/line_printer.h
+++ b/src/line_printer.h
@@ -15,6 +15,7 @@
#ifndef NINJA_LINE_PRINTER_H_
#define NINJA_LINE_PRINTER_H_
+#include <stddef.h>
#include <string>
using namespace std;
@@ -37,6 +38,10 @@ struct LinePrinter {
/// Prints a string on a new line, not overprinting previous output.
void PrintOnNewLine(const string& to_print);
+ /// Lock or unlock the console. Any output sent to the LinePrinter while the
+ /// console is locked will not be printed until it is unlocked.
+ void SetConsoleLocked(bool locked);
+
private:
/// Whether we can do fancy terminal control codes.
bool smart_terminal_;
@@ -44,9 +49,24 @@ struct LinePrinter {
/// Whether the caret is at the beginning of a blank line.
bool have_blank_line_;
+ /// Whether console is locked.
+ bool console_locked_;
+
+ /// Buffered current line while console is locked.
+ string line_buffer_;
+
+ /// Buffered line type while console is locked.
+ LineType line_type_;
+
+ /// Buffered console output while console is locked.
+ string output_buffer_;
+
#ifdef _WIN32
void* console_;
#endif
+
+ /// Print the given data to the console, or buffer it if it is locked.
+ void PrintOrBuffer(const char *data, size_t size);
};
#endif // NINJA_LINE_PRINTER_H_