Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color codes do not work in windows #143

Closed
unixfile opened this issue Nov 21, 2018 · 7 comments · Fixed by #188
Closed

Color codes do not work in windows #143

unixfile opened this issue Nov 21, 2018 · 7 comments · Fixed by #188

Comments

@unixfile
Copy link

Reading todo contents is more or less impossible when using 'xterm -bg lemonchiffon', or any bright background.

Is there a way to change or disable colors, without affecting the terminal?

@cvrn
Copy link

cvrn commented Dec 31, 2018

+1

@gammons gammons changed the title Disabling colors Color codes do not work in windows Mar 19, 2019
@robertpateii
Copy link

Here's how I disabled colors in case any window users are desperate:

diff --git a/ultralist/screen_printer.go b/ultralist/screen_printer.go
index 7a9c429..4fc459c 100644
--- a/ultralist/screen_printer.go
+++ b/ultralist/screen_printer.go
@@ -37,6 +37,7 @@ type ScreenPrinter struct {

 // NewScreenPrinter creates a new screeen printer.
 func NewScreenPrinter() *ScreenPrinter {
+       color.NoColor = true // disables colorized output
        w := new(tabwriter.Writer)
        w.Init(os.Stdout, 0, 8, 0, '\t', 0)
        formatter := &ScreenPrinter{Writer: w}

If you used go get to install this like I did, you'll find the source in ~\go\src\github.com\ultralist\ultralist. Modify that file, run a go build, then copy the new ultralist.exe to ~\go\bin, and then it should start working without colors immediately.

@bothzoli
Copy link

bothzoli commented Dec 16, 2019

i don't know the first thing about Go, but i managed to resolve this with the following changes:

diff --git a/ultralist/screen_printer.go b/ultralist/screen_printer.go
index 9e8f89c..acc03ff 100644
--- a/ultralist/screen_printer.go
+++ b/ultralist/screen_printer.go
@@ -7,6 +7,7 @@ import (
        "strconv"
        "strings"
        "time"
+       "text/tabwriter"

        "github.com/cheynewallace/tabby"
        "github.com/fatih/color"
@@ -48,7 +49,7 @@ func (f *ScreenPrinter) Print(groupedTodos *GroupedTodos, printNotes bool) {
        }
        sort.Strings(keys)

-       tabby := tabby.New()
+       tabby := tabby.NewCustom(tabwriter.NewWriter(color.Output, 0, 0, 2, ' ', 0))
        tabby.AddLine()
        for _, key := range keys {
                tabby.AddLine(cyan.Sprint(key))

maybe based on this you could solve this the idiomatic way.

i got this from these (https://github.com/fatih/color):

// Windows supported too! Just don't forget to change the output to color.Output
fmt.Fprintf(color.Output, "Windows support: %s", color.GreenString("PASS"))

for Tabby using the NewCustom method i can pass in a custom tabwriter, which uses colorOutput.

@gammons
Copy link
Owner

gammons commented Dec 16, 2019

@bothzoli I'll create a PR based upon this change and test it out.

@bothzoli
Copy link

thanks a lot.
i'm not sure how it'd affect other OS-s, and also i know almost nothing about Go that's why i didn't open a PR myself :)
but i hope you'll be able to resolve this issue with the above info.

@gammons
Copy link
Owner

gammons commented Dec 16, 2019

@bothzoli give that PR a review. if it looks good I'll merge it and build a release!

gammons added a commit that referenced this issue Dec 17, 2019
* Fix #143, windows color issue

* remove commented out line

* fix test failures

these were all related to year comparisons
@gammons
Copy link
Owner

gammons commented Dec 17, 2019

@00001 @cvrn @bothzoli @robertpateii just released 0.9.4 which includes this fix https://github.com/ultralist/ultralist/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants