LLVM  3.7.0
SyntaxHighlighting.cpp
Go to the documentation of this file.
1 //===-- SyntaxHighlighting.cpp ----------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "SyntaxHighlighting.h"
12 using namespace llvm;
13 using namespace dwarf;
14 using namespace syntax;
15 
17  UseColor("color",
18  cl::desc("use colored syntax highlighting (default=autodetect)"),
20 
22  // Detect color from terminal type unless the user passed the --color option.
24  switch (Type) {
27  case Tag: OS.changeColor(llvm::raw_ostream::BLUE); break;
30  }
31  }
32 }
33 
36  OS.resetColor();
37 }
virtual bool has_colors() const
This function determines if this stream is displayed and supports colors.
Definition: raw_ostream.h:258
virtual raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false)
Changes the foreground color of text that will be output from this point forward. ...
Definition: raw_ostream.h:236
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:325
static cl::opt< cl::boolOrDefault > UseColor("color", cl::desc("use colored syntax highlighting (default=autodetect)"), cl::init(cl::BOU_UNSET))
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
virtual raw_ostream & resetColor()
Resets the colors to terminal defaults.
Definition: raw_ostream.h:247
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
WithColor(llvm::raw_ostream &OS, enum HighlightColor Type)
To be used like this: WithColor(OS, syntax::String) << "text";.