Code Monkey home page Code Monkey logo

Comments (3)

montanaflynn avatar montanaflynn commented on September 27, 2024

Just ran into the same thing, did you end up solving it?

I tried both color.RedString and color.New(color.FgRed).SprintFunc() with no luck...

Before using color:

Screenshot 2023-02-05 at 9 01 19 PM

After:

Screenshot 2023-02-05 at 9 00 42 PM

Edit: I think this is actually a text/tabwriter problem because the same issue when just using color codes directly:

		colorReset := "\033[0m"
		colorRed := "\033[31m"
		colorGreen := "\033[32m"
		colorYellow := "\033[33m"

from color.

rmsrob avatar rmsrob commented on September 27, 2024

for me this fix works

w.Init(os.Stdout, 0, 8, 4, ' ', 0)

from color.

FollowTheProcess avatar FollowTheProcess commented on September 27, 2024

It's an issue with tabwriter because the escape sequences aren't always the same length, they get used as part of the cell width calculations so some cells appear wider than they are really and don't render correctly

See https://stackoverflow.com/questions/35398497/how-do-i-get-colors-to-work-with-golang-tabwriter

color could pad the escape sequences to ensure they are all the same length as per the answer in the SO thread above but I suspect it's much trickier and more nuanced than that in practice and there will be a bunch of edge cases that need to be handled

from color.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.