r3bl-org/r3bl-open-core

[tui] use the new r3bl_ansi_color crate for detecting terminal color capabilities

Closed this issue · 1 comments

A bit of history is useful here. In the early days of the crate, I was using some 3rd party crates to do:

  • Terminal capability detection. The terminal capability detection crate never actually worked (fails totally on macOS Terminal.app, which is the default terminal that ships with macOS, and on Windows)
  • ANSI color output. This crate has a copyleft license so I had to replace it and rewrite it. I’ve had to rewrite so many crates so far (the latest one being simplelog, and include them in the r3bl_rs_utils repo workspace).

So currently the r3bl_tui crate does NOT use the r3bl_ansi_color crate detection capabilities. Instead it uses the broken old way using some existing crate. The task is to replace this deprecated functionality with the newer one (from r3bl_ansi_color crate). PLMK if this makes sense or if more information is needed, as I can add links to source files.


  • Currently the existing r3bl_tui crate does not do the right thing when detecting terminal capabilities. It currently does not work on Windows.
  • There is a better way to detect terminal color capabilities on mac, windows, linux in the r3bl_ansi_color crate which is what we should be using.

👎🏽 Here's the code for the old way:

https://github.com/r3bl-org/r3bl_rs_utils/blob/main/tui/src/tui/color_wheel/detect_color_support.rs#L37

👍🏽 Here's the code for the new way:

https://github.com/r3bl-org/r3bl_rs_utils/blob/main/ansi_color/src/detect_color_support.rs#L27

Both are similar.


In summary, the goals are:

  • Replace the old color detection capabilities with the new reliable ones from r3bl_ansi_color
  • Use the capabilities provided in ansi_color in the color_wheel folder in the r3bl_rs_utils repo
  • As a bonus, this might also get everything working correctly on Windows (which currently shows grayscale output due to the problematic terminal capability detection).

@Harshil-Jani I've added more clarification to this issue; apologies that it was so poorly worded and confusing. PLMK if this makes more sense. I can rewrite if needed and also provide links directly to the source code.