Code Monkey home page Code Monkey logo

Comments (12)

jbnicolai avatar jbnicolai commented on May 21, 2024

Interesting, thank you for the suggestion. I'll have a look at this πŸ˜„

from chalk.

jbnicolai avatar jbnicolai commented on May 21, 2024

So after some testing, it seems that KDE's konsole is the only terminal currently supporting 24-bit this. Worse, other terminals interpret these codes incorrectly, making the output unpredictable.

I'll still have a look at 8-bit though, all though as you said that doesn't seem to be widely supported either.

from chalk.

jbnicolai avatar jbnicolai commented on May 21, 2024

Seems like 8 bit color codes are indeed better supported! I've created the ansi-8-bit package wrapping these codes, and will think about a good way to wrap these in chalk.

@sindresorhus any ideas what the best api would be? The ansi-8-bit module works fairly similar to ansi-styles, so I'm thinking of simply adding a Chalk.rgb(int, int int) doing the same as the other chalk functions.

from chalk.

jbnicolai avatar jbnicolai commented on May 21, 2024

Actually, that API wouldn't work - as there's both a foreground and a background rgb styling function.

How about simply exporting the functions

chalk.foreground = function (r, g, b, str) { return ansi8bit.fg.getRgb(r,g,b) + str + ansi8bit.reset; };
chalk.background = function (r, g, b, str) { return ansi8bit.bg.getRgb(r,g,b) + str + ansi8bit.reset; };

from chalk.

sindresorhus avatar sindresorhus commented on May 21, 2024

What is the terminal support for 8-bit colors? I'm resistant to add something that most won't use because of lack of widespread support. I've considered it multiple times in the past, but have never come up with a situation where I would personally use it. What's the use-case?

from chalk.

jbnicolai avatar jbnicolai commented on May 21, 2024

Support is pretty widespread, any terminal with xterm support - which is any terminal I've ever used on OS X (terminal.app and iTerm) and linux. On windows I wouldn't know ;-)

The use case is not that common I suppose. On the other hand, there are clearly people asking for it, the effect is pretty nice, and the overhead is almost zero:

du -hs node_modules/ansi-8-bit/
  12K

screen shot 2014-07-14 at 00 31 43

from chalk.

sindresorhus avatar sindresorhus commented on May 21, 2024

Ya, I'm just hesitant of adding things most people wouldn't use as that would probably be better fit as a separate package. Might be better to just recommend a module of yours in the readme instead. As I would most likely recommend against using it in the readme for reusable things anyways.

Let me mull it over :)

from chalk.

jbnicolai avatar jbnicolai commented on May 21, 2024

Fair enough πŸ‘ let me know :)

from chalk.

sindresorhus avatar sindresorhus commented on May 21, 2024

I've thought this over for a while and I still don't think it makes sense to add this to Chalk. I want to keep Chalk focused on reusable modules and targeting the 90% use-case. Every new method adds overhead for users. More things to learn and having to care about. Some users might want more colors, but for reusable modules it doesn't really make much sense.

Can you instead add a section called 256-colors or something to the bottom of the readme linking to your module and saying when it makes sense to use and when not (reusable modules)?

from chalk.

sindresorhus avatar sindresorhus commented on May 21, 2024

@jbnicolai ⬆️

from chalk.

jbnicolai avatar jbnicolai commented on May 21, 2024

Woops, completely lost sight of this one. Will do it later today πŸ˜„

from chalk.

rektide avatar rektide commented on May 21, 2024

#73 had some further work on this topic.

from chalk.

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.