mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Improvements to ANSI emulation in conemu
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
7d13f2fb7d
commit
506722bf9f
2 changed files with 38 additions and 2 deletions
|
@ -40,8 +40,8 @@ var usingNativeConsole bool
|
|||
func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||
switch {
|
||||
case os.Getenv("ConEmuANSI") == "ON":
|
||||
// The ConEmu shell emulates ANSI well by default.
|
||||
return os.Stdin, os.Stdout, os.Stderr
|
||||
// The ConEmu terminal emulates ANSI on output streams well.
|
||||
return windows.ConEmuStreams()
|
||||
case os.Getenv("MSYSTEM") != "":
|
||||
// MSYS (mingw) does not emulate ANSI well.
|
||||
return windows.ConsoleStreams()
|
||||
|
|
|
@ -8,8 +8,44 @@ import (
|
|||
"syscall"
|
||||
|
||||
"github.com/Azure/go-ansiterm/winterm"
|
||||
|
||||
ansiterm "github.com/Azure/go-ansiterm"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// ConEmuStreams returns prepared versions of console streams,
|
||||
// for proper use in ConEmu terminal.
|
||||
// The ConEmu terminal emulates ANSI on output streams well by default.
|
||||
func ConEmuStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||
if IsConsole(os.Stdin.Fd()) {
|
||||
stdIn = newAnsiReader(syscall.STD_INPUT_HANDLE)
|
||||
} else {
|
||||
stdIn = os.Stdin
|
||||
}
|
||||
|
||||
stdOut = os.Stdout
|
||||
stdErr = os.Stderr
|
||||
|
||||
// WARNING (BEGIN): sourced from newAnsiWriter
|
||||
|
||||
logFile := ioutil.Discard
|
||||
|
||||
if isDebugEnv := os.Getenv(ansiterm.LogEnv); isDebugEnv == "1" {
|
||||
logFile, _ = os.Create("ansiReaderWriter.log")
|
||||
}
|
||||
|
||||
logger = &logrus.Logger{
|
||||
Out: logFile,
|
||||
Formatter: new(logrus.TextFormatter),
|
||||
Level: logrus.DebugLevel,
|
||||
}
|
||||
|
||||
// WARNING (END): sourced from newAnsiWriter
|
||||
|
||||
return stdIn, stdOut, stdErr
|
||||
}
|
||||
|
||||
// ConsoleStreams returns a wrapped version for each standard stream referencing a console,
|
||||
// that handles ANSI character sequences.
|
||||
func ConsoleStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
|
||||
|
|
Loading…
Reference in a new issue