1 //===- LinePrinter.cpp ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "LinePrinter.h"
16 LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
17 : IndentSpaces(Indent), CurrentIndent(0), OS(Stream) {}
19 void LinePrinter::Indent() { CurrentIndent += IndentSpaces; }
21 void LinePrinter::Unindent() {
22 CurrentIndent = std::max(0, CurrentIndent - IndentSpaces);
25 void LinePrinter::NewLine() {
27 OS.indent(CurrentIndent);
30 WithColor::WithColor(LinePrinter &P, PDB_ColorItem C) : OS(P.OS) {
31 if (C == PDB_ColorItem::None)
34 raw_ostream::Colors Color;
36 translateColor(C, Color, Bold);
37 OS.changeColor(Color, Bold);
41 WithColor::~WithColor() { OS.resetColor(); }
43 void WithColor::translateColor(PDB_ColorItem C, raw_ostream::Colors &Color,
46 case PDB_ColorItem::Address:
47 Color = raw_ostream::YELLOW;
50 case PDB_ColorItem::Keyword:
51 Color = raw_ostream::MAGENTA;
54 case PDB_ColorItem::Offset:
55 Color = raw_ostream::YELLOW;
58 case PDB_ColorItem::Type:
59 Color = raw_ostream::CYAN;
62 case PDB_ColorItem::Identifier:
63 Color = raw_ostream::CYAN;
66 case PDB_ColorItem::Path:
67 Color = raw_ostream::CYAN;
70 case PDB_ColorItem::SectionHeader:
71 Color = raw_ostream::RED;
74 case PDB_ColorItem::LiteralValue:
75 Color = raw_ostream::GREEN;