Skip to content

Commit

Permalink
Merge 7eb6dc1 into 830641e
Browse files Browse the repository at this point in the history
  • Loading branch information
jedib0t committed Aug 18, 2018
2 parents 830641e + 7eb6dc1 commit dc894cd
Show file tree
Hide file tree
Showing 30 changed files with 6,885 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions cmd/demo/demo.go
@@ -0,0 +1,14 @@
package main

import (
"fmt"
"github.com/jedib0t/go-pretty/text"
"github.com/jedib0t/go-pretty/util"
)

func main() {
fmt.Printf("%#v\n", text.FgRed.Sprint("Red"))
fmt.Printf("%s\n", text.FgRed.Sprint("Red"))
fmt.Printf("%c[31mRed%c[0m\n", util.EscapeStartRune, util.EscapeStartRune)
fmt.Printf("Red\n")
}
4 changes: 4 additions & 0 deletions text/ansi.go
@@ -0,0 +1,4 @@
package text

// ANSISupported will be true on consoles where ANSI Sequences are supported.
var ANSISupported = isANSISupported()
2 changes: 1 addition & 1 deletion text/color.go
Expand Up @@ -142,7 +142,7 @@ func (c Colors) Sprintf(format string, a ...interface{}) string {
}

func colorize(s string, escapeSeq string) string {
if escapeSeq == "" {
if !ANSISupported || escapeSeq == "" {
return s
}

Expand Down
7 changes: 7 additions & 0 deletions text/color_unix.go
@@ -0,0 +1,7 @@
// +build !windows

package text

func isANSISupported() bool {
return true
}
23 changes: 23 additions & 0 deletions text/color_windows.go
@@ -0,0 +1,23 @@
// +build windows

package text

import (
"os"

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

func isANSISupported() bool {
outHandle := windows.Handle(os.Stdout.Fd())
var outMode uint32
if err := windows.GetConsoleMode(outHandle, &outMode); err == nil {
if outMode&windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0 {
return true
}
if err := windows.SetConsoleMode(outHandle, outMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING); err == nil {
return true
}
}
return false
}
3 changes: 3 additions & 0 deletions vendor/golang.org/x/sys/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/golang.org/x/sys/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/golang.org/x/sys/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/sys/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/golang.org/x/sys/windows/aliases.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/golang.org/x/sys/windows/asm_windows_386.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/golang.org/x/sys/windows/asm_windows_amd64.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc894cd

Please sign in to comment.