Fixed bug and added more tests

This commit is contained in:
Faissal Elamraoui
2016-07-28 11:37:28 +02:00
parent 2b867f8152
commit d85293b7c0
4 changed files with 95 additions and 46 deletions

View File

@@ -25,7 +25,6 @@ import (
)
type (
outputMode int
csiState int
parseResult int
)
@@ -426,36 +425,4 @@ func (cw *ansiColorWriter) Write(p []byte) (int, error) {
}
return r, err
}
// DiscardNonColorEscSeq supports the divided color escape sequence.
// But non-color escape sequence is not output.
// Please use the OutputNonColorEscSeq If you want to output a non-color
// escape sequences such as ncurses. However, it does not support the divided
// color escape sequence.
const (
_ outputMode = iota
DiscardNonColorEscSeq
OutputNonColorEscSeq
)
// NewAnsiColorWriter creates and initializes a new ansiColorWriter
// using io.Writer w as its initial contents.
// In the console of Windows, which change the foreground and background
// colors of the text by the escape sequence.
// In the console of other systems, which writes to w all text.
func NewAnsiColorWriter(w io.Writer) io.Writer {
return NewModeAnsiColorWriter(w, DiscardNonColorEscSeq)
}
// NewModeAnsiColorWriter create and initializes a new ansiColorWriter
// by specifying the outputMode.
func NewModeAnsiColorWriter(w io.Writer, mode outputMode) io.Writer {
if _, ok := w.(*ansiColorWriter); !ok {
return &ansiColorWriter{
w: w,
mode: mode,
}
}
return w
}