Comments (12)
Interesting, thank you for the suggestion. I'll have a look at this π
from chalk.
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.
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.
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.
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.
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
from chalk.
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.
Fair enough π let me know :)
from chalk.
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.
@jbnicolai β¬οΈ
from chalk.
Woops, completely lost sight of this one. Will do it later today π
from chalk.
#73 had some further work on this topic.
from chalk.
Related Issues (20)
- Add more colors HOT 2
- Chalk is not working in Jenkins multibranch pipeline HOT 1
- Does chalk.js support squiggly lines? HOT 1
- Cannot find module 'chalk'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? HOT 2
- Can't show color in vscode integrated terminal HOT 1
- chalk not suppported?? HOT 1
- Tried to use with TS (NestJS Project) HOT 6
- is there r any way to mix background colors like gradient-string? HOT 1
- Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 6
- chalk 5.x fails with typescript HOT 3
- Is it possible to apply a style conditionally? HOT 5
- ReferenceError: navigator is not defined HOT 1
- Remove README.md from bundle HOT 2
- v4 property override error
- is support require('chalk')? HOT 3
- Chalk italic modifier is not applied in Windows Git Bash terminal. HOT 1
- $FORCE_COLOR works only as either level 0 or 3 HOT 1
- New Windows fluent emoji font - color is wrong HOT 1
- Unable to resolve module #ansi-styles HOT 2
- γsuggestionγsupport commonjs version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chalk.