mirror of
https://github.com/alecthomas/chroma.git
synced 2025-11-06 09:09:11 +02:00
support windows colors
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ import (
|
|||||||
"github.com/alecthomas/chroma/formatters/html"
|
"github.com/alecthomas/chroma/formatters/html"
|
||||||
"github.com/alecthomas/chroma/lexers"
|
"github.com/alecthomas/chroma/lexers"
|
||||||
"github.com/alecthomas/chroma/styles"
|
"github.com/alecthomas/chroma/styles"
|
||||||
|
"github.com/mattn/go-colorable"
|
||||||
|
"github.com/mattn/go-isatty"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -59,7 +62,11 @@ command, for Go.
|
|||||||
}()
|
}()
|
||||||
defer pprof.StopCPUProfile()
|
defer pprof.StopCPUProfile()
|
||||||
}
|
}
|
||||||
w := bufio.NewWriterSize(os.Stdout, 16384)
|
var out io.Writer = os.Stdout
|
||||||
|
if runtime.GOOS == "windows" && isatty.IsTerminal(os.Stdout.Fd()) {
|
||||||
|
out = colorable.NewColorableStdout()
|
||||||
|
}
|
||||||
|
w := bufio.NewWriterSize(out, 16384)
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
if *htmlFlag {
|
if *htmlFlag {
|
||||||
*formatterFlag = "html"
|
*formatterFlag = "html"
|
||||||
|
|||||||
Reference in New Issue
Block a user