summaryrefslogtreecommitdiff
path: root/src/source-error-handler.h
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-06-23 19:25:32 -0700
committerGitHub <noreply@github.com>2017-06-23 19:25:32 -0700
commitb2613e132d93372bd75c640dd4d7505a81f707f7 (patch)
treec5c529d46bc6439cdf4975aefcf186287a064054 /src/source-error-handler.h
parent29e8e9ee0068b0f90f30c69c4f6c0c3fd30bf96e (diff)
downloadwabt-b2613e132d93372bd75c640dd4d7505a81f707f7.tar.gz
wabt-b2613e132d93372bd75c640dd4d7505a81f707f7.tar.bz2
wabt-b2613e132d93372bd75c640dd4d7505a81f707f7.zip
Add color output in SourceErrorHandler (#517)
This is currently only supported where VT100 escape sequences work. We assume that if `isatty` is true then color will be supported. This logic will likely need to be improved, but this is a good start. This PR also adds support for passing an environment variable to a test via `ENV`. This is used to test the `FORCE_COLOR` environment variable.
Diffstat (limited to 'src/source-error-handler.h')
-rw-r--r--src/source-error-handler.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/source-error-handler.h b/src/source-error-handler.h
index 45e049b0..5e09dc26 100644
--- a/src/source-error-handler.h
+++ b/src/source-error-handler.h
@@ -19,6 +19,7 @@
#include <string>
+#include "color.h"
#include "common.h"
namespace wabt {
@@ -38,7 +39,8 @@ class SourceErrorHandler {
// OnError will be called with with source_line trimmed to this length.
virtual size_t source_line_max_length() const = 0;
- std::string DefaultErrorMessage(const Location*,
+ std::string DefaultErrorMessage(const Color&,
+ const Location*,
const std::string& error,
const std::string& source_line,
size_t source_line_column_offset,
@@ -93,6 +95,7 @@ class SourceErrorHandlerFile : public SourceErrorHandler {
std::string header_;
PrintHeader print_header_;
size_t source_line_max_length_;
+ Color color_;
};
class SourceErrorHandlerBuffer : public SourceErrorHandler {
@@ -114,6 +117,7 @@ class SourceErrorHandlerBuffer : public SourceErrorHandler {
private:
size_t source_line_max_length_;
std::string buffer_;
+ Color color_;
};
} // namespace wabt