Skip to content

Commit

Permalink
fix: enable ANSI color support on Windows
Browse files Browse the repository at this point in the history
resolves #5
  • Loading branch information
JanDeDobbeleer committed Sep 20, 2020
1 parent f73a308 commit 11e4e98
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
20 changes: 10 additions & 10 deletions Gopkg.lock

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

5 changes: 3 additions & 2 deletions Gopkg.toml
Expand Up @@ -25,8 +25,9 @@
# unused-packages = true

[[constraint]]
name = "gopkg.in/gookit/color.v1"
source = "gopkg.in/gookit/color.v1"
version = "1.3.0"
name = "github.com/gookit/color"
source = "github.com/gookit/color"

[[constraint]]
version = "v0.3.3"
Expand Down
2 changes: 1 addition & 1 deletion color_writer.go
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"strings"

"gopkg.in/gookit/color.v1"
"github.com/gookit/color"
)

//ColorWriter writes colorized strings
Expand Down
15 changes: 3 additions & 12 deletions color_writer_test.go
Expand Up @@ -13,8 +13,8 @@ func TestWriteAndRemoveText(t *testing.T) {
}
inputText := "This is white, <#ff5733>this is orange</>, white again"
text := writer.writeAndRemoveText("#193549", "#fff", "This is white, ", "This is white, ", inputText)
assert.Equal(t, "This is white, ", writer.string())
assert.Equal(t, "<#ff5733>this is orange</>, white again", text)
assert.NotContains(t, writer.string(), "<#ff5733>")
}

func TestWriteAndRemoveTextColored(t *testing.T) {
Expand All @@ -23,17 +23,8 @@ func TestWriteAndRemoveTextColored(t *testing.T) {
}
inputText := "This is white, <#ff5733>this is orange</>, white again"
text := writer.writeAndRemoveText("#193549", "#ff5733", "this is orange", "<#ff5733>this is orange</>", inputText)
assert.Equal(t, "this is orange", writer.string())
assert.Equal(t, "This is white, , white again", text)
}

func TestWritePlain(t *testing.T) {
writer := &ColorWriter{
Buffer: new(bytes.Buffer),
}
text := "This is white, this is orange, white again"
writer.write("#193549", "#ff5733", text)
assert.Equal(t, "This is white, this is orange, white again", writer.string())
assert.NotContains(t, writer.string(), "<#ff5733>")
}

func TestWriteColorOverride(t *testing.T) {
Expand All @@ -42,5 +33,5 @@ func TestWriteColorOverride(t *testing.T) {
}
text := "This is white, <#ff5733>this is orange</>, white again"
writer.write("#193549", "#ff5733", text)
assert.Equal(t, "This is white, this is orange, white again", writer.string())
assert.NotContains(t, writer.string(), "<#ff5733>")
}
4 changes: 4 additions & 0 deletions packages/powershell/go-my-posh/go-my-posh.psm1
Expand Up @@ -23,6 +23,10 @@ if (!$IsWindows) {
$executable = Get-PoshCommand
Invoke-Expression -Command "chmod +x $executable"
}
if ($IsWindows) {
# WHen this is not set, outputted fonts aren't rendered correctly in some terminals for the prompt function
[console]::OutputEncoding = New-Object System.Text.UTF8Encoding
}

function Set-PoshPrompt {
param(
Expand Down

0 comments on commit 11e4e98

Please sign in to comment.