|
|
@ -10,21 +10,22 @@ namespace Cxxi |
|
|
|
private const uint MaxIndent = 80; |
|
|
|
private const uint MaxIndent = 80; |
|
|
|
|
|
|
|
|
|
|
|
private readonly StringBuilder sb; |
|
|
|
private readonly StringBuilder sb; |
|
|
|
private readonly Stack<uint> currentIndent; |
|
|
|
|
|
|
|
private bool isStartOfLine; |
|
|
|
private bool isStartOfLine; |
|
|
|
private bool needsNewLine; |
|
|
|
private bool needsNewLine; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected readonly Stack<uint> CurrentIndent; |
|
|
|
|
|
|
|
|
|
|
|
public TextGenerator() |
|
|
|
public TextGenerator() |
|
|
|
{ |
|
|
|
{ |
|
|
|
sb = new StringBuilder(); |
|
|
|
sb = new StringBuilder(); |
|
|
|
currentIndent = new Stack<uint>(); |
|
|
|
|
|
|
|
isStartOfLine = false; |
|
|
|
isStartOfLine = false; |
|
|
|
|
|
|
|
CurrentIndent = new Stack<uint>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Write(string msg, params object[] args) |
|
|
|
public void Write(string msg, params object[] args) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (isStartOfLine) |
|
|
|
if (isStartOfLine) |
|
|
|
sb.Append(new string(' ', (int)currentIndent.Sum(u => u))); |
|
|
|
sb.Append(new string(' ', (int)CurrentIndent.Sum(u => u))); |
|
|
|
|
|
|
|
|
|
|
|
if (args.Length > 0) |
|
|
|
if (args.Length > 0) |
|
|
|
msg = string.Format(msg, args); |
|
|
|
msg = string.Format(msg, args); |
|
|
@ -69,12 +70,12 @@ namespace Cxxi |
|
|
|
|
|
|
|
|
|
|
|
public void PushIndent(uint indent = DefaultIndent) |
|
|
|
public void PushIndent(uint indent = DefaultIndent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
currentIndent.Push(indent); |
|
|
|
CurrentIndent.Push(indent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void PopIndent() |
|
|
|
public void PopIndent() |
|
|
|
{ |
|
|
|
{ |
|
|
|
currentIndent.Pop(); |
|
|
|
CurrentIndent.Pop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void WriteStartBraceIndent() |
|
|
|
public void WriteStartBraceIndent() |
|
|
|