crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.28k stars 281 forks source link

MacOS terminal not displaying RGB colors correctly #819

Closed joshka closed 1 week ago

joshka commented 1 year ago

Describe the bug A Ratatui user (@nx10) using crossterm as a backend cut us an issue (https://github.com/ratatui-org/ratatui/issues/475) about macOS terminal rendering RGB colors incorrectly (with blinking). This seems to be an upstream problem rather than one in Ratatui.

I'm unsure whether this is a Terminal.app bug (and hence perhaps the remedy is to document it as an unsupported platform while submitting the issue to Apple for a fix) or a Crossterm bug.

My example code to repro this is in https://github.com/ratatui-org/ratatui/pull/476 (run cargo run --example colors and hit space) image Expected (iTerm2): image

I was able to repro something similar using the Crossterm interactive demo. Here's a screenshot of the blue screen:

image

To Reproduce Steps to reproduce the behavior:

  1. Open Mac terminal.app
  2. cd examples/interactive-demo
  3. cargo run
  4. Select colors, and hit space 5 times to get to the blue values demo (the red and green channels also render incorrectly, but don't blink)

Expected behavior The following is the blue screen rendered in iTerm2:

image

OS

Terminal/Console

joshka commented 1 year ago

Actually, this affects termion too (and termwiz seems to fallback to ansi colors), so it's just Terminal.app not supporting true color: https://discussions.apple.com/thread/250459018 https://discussions.apple.com/thread/250636611

So perhaps this can really just be handled with docs.

Interestingly the approach that Termwiz uses for this is to fallback to an ANSI color on non true color enabled terminals, which is neat.

joshka commented 1 week ago

Closing this out as the problem is that Terminal.app does not support RGB colors and it's not something that crossterm can reasonably fix. It's likely that apps need to detect support for RGB and then act accordingly.