Skip to content

Commit

Permalink
Merge pull request #4 from muesli/windows-console
Browse files Browse the repository at this point in the history
Improve support for Windows platforms
  • Loading branch information
Stephen Solka committed Oct 25, 2020
2 parents 02e7a2f + 71b3e45 commit c02531d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions console_windows.go
@@ -0,0 +1,23 @@
// +build windows

package main

import (
"os"

"golang.org/x/sys/windows"
)

// enableAnsiColors enables support for ANSI color sequences in Windows
// default console. Note that this only works with Windows 10.
func enableAnsiColors() {
stdout := windows.Handle(os.Stdout.Fd())
var originalMode uint32

windows.GetConsoleMode(stdout, &originalMode)
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
}

func init() {
enableAnsiColors()
}

0 comments on commit c02531d

Please sign in to comment.