Go-ipfs: cli: Color on windows doesn't work

Created on 9 Aug 2016  路  5Comments  路  Source: ipfs/go-ipfs

Version/Platform/Processor information:
go-ipfs version: 0.4.3-rc2-
Repo version: 4
System version: amd64/windows
Golang version: go1.6.2

Type: bug
Area: commands/logging/cli
Priority: P1

Description:
The ipfs tool on windows doesn't display colors properly, even though the default cmd.exe supports ANSI escape codes with no problem.

Example daemon error message:

Windows colors demonstration:

help wanted kinbug topiwindows

Most helpful comment

Apparently, the windows terminal only accepts ANSI escape codes with a specific flag enabled:
"The following terminal sequences are intercepted by the console host when written into the output stream if the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is set on the screen buffer handle using the SetConsoleMode flag."
(https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx)
Example usage in Go: https://github.com/jfrazelle/binctr/blob/master/vendor/github.com/docker/docker/pkg/term/term_windows.go

All 5 comments

thanks for reporting, The output in the colored.txt matches what i get from ipfs on a linux box. Could you try doing ipfs daemon --debug 2> output.txt and show the hexdump of that?

Apparently, the windows terminal only accepts ANSI escape codes with a specific flag enabled:
"The following terminal sequences are intercepted by the console host when written into the output stream if the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is set on the screen buffer handle using the SetConsoleMode flag."
(https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx)
Example usage in Go: https://github.com/jfrazelle/binctr/blob/master/vendor/github.com/docker/docker/pkg/term/term_windows.go

Referencing old duplicate:
https://github.com/ipfs/go-ipfs/issues/2124

Since go-log is using a modified version of go-logging, maybe we can update the customized version with the changes in https://github.com/op/go-logging/issues/110 once the PR for it is merged.

edit: it looks like the op/go-logging repo may not be active, so maybe waiting for the changes to be merged upstream isn't a good option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djdv picture djdv  路  3Comments

jonchoi picture jonchoi  路  3Comments

funkyfuture picture funkyfuture  路  3Comments

daviddias picture daviddias  路  3Comments

slrslr picture slrslr  路  3Comments