|
7 | 7 | //!
|
8 | 8 | //! ## Features
|
9 | 9 | //! * Background and foreground color detection.
|
10 |
| -//! * Uses a timeout (for situations with high latency such as an SSH connection). |
| 10 | +//! * Uses a fast and reliable heuristic to detect if the terminal supports color querying. |
11 | 11 | //! * *Correct* perceived lightness calculation.
|
12 |
| -//! * Works even if all of stderr, stdout and stdin are redirected. |
| 12 | +//! * Works on Windows (*soon*). |
13 | 13 | //! * Safely restores the terminal from raw mode even if the library errors or panicks.
|
14 | 14 | //! * Does not send any escape sequences if `TERM=dumb`.
|
15 |
| -//! * Works on Windows (*soon*). |
| 15 | +//! * Works even if all of stderr, stdout and stdin are redirected. |
| 16 | +//! * Supports a timeout (for situations with high latency such as an SSH connection). |
| 17 | +//! |
| 18 | +//! ## Terminal Support |
| 19 | +//! `terminal-colorsaurus` works with most modern terminals and has been [tested extensively](`terminal_survey`). |
| 20 | +//! It's also really good at [detecting](`feature_detection`) when querying for the terminal's colors is not supported. |
16 | 21 | //!
|
17 | 22 | //! ## Example 1: Test If the Terminal Uses a Dark Background
|
18 | 23 | //! ```no_run
|
|
22 | 27 | //! dbg!(color_scheme == ColorScheme::Dark);
|
23 | 28 | //! ```
|
24 | 29 | //!
|
25 |
| -//! ## Example 2: Query for the Terminal's Foreground Color |
| 30 | +//! ## Example 2: Get the Terminal's Foreground Color |
26 | 31 | //! ```no_run
|
27 | 32 | //! use terminal_colorsaurus::foreground_color;
|
28 | 33 | //!
|
29 | 34 | //! let fg = foreground_color().unwrap();
|
30 | 35 | //! println!("rgb({}, {}, {})", fg.r, fg.g, fg.b);
|
31 | 36 | //! ```
|
32 | 37 | //!
|
33 |
| -//! ## Terminals |
34 |
| -//! The following terminals have known support or non-support for |
35 |
| -//! querying for the background/foreground colors. |
36 |
| -//! |
37 |
| -//! Note that terminals that support the relevant terminal |
38 |
| -//! sequences automatically work with this library even if they |
39 |
| -//! are not explicitly listed below. |
40 |
| -//! |
41 |
| -//! <details> |
42 |
| -//! <summary><strong>Supported</strong></summary> |
43 |
| -//! |
44 |
| -//! * Alacritty |
45 |
| -//! * Contour |
46 |
| -//! * foot |
47 |
| -//! * GNOME Terminal, (GNOME) Console, MATE Terminal, XFCE Terminal, (elementary) Terminal, LXTerminal |
48 |
| -//! * Hyper |
49 |
| -//! * The builtin terminal of JetBrains IDEs (i.e. IntelliJ IDEA, …) |
50 |
| -//! * iTerm2 |
51 |
| -//! * kitty |
52 |
| -//! * Konsole |
53 |
| -//! * macOS Terminal |
54 |
| -//! * Rio |
55 |
| -//! * st |
56 |
| -//! * Terminology |
57 |
| -//! * Termux |
58 |
| -//! * tmux (next-3.4) |
59 |
| -//! * urxvt (rxvt-unicode) |
60 |
| -//! * VSCode (xterm.js) |
61 |
| -//! * WezTerm |
62 |
| -//! * Windows Terminal (in an upcoming version) |
63 |
| -//! * xterm |
64 |
| -//! * [Zed](https://zed.dev) |
65 |
| -//! |
66 |
| -//! </details> |
67 |
| -//! |
68 |
| -//! <details> |
69 |
| -//! <summary><strong>Unsupported</strong></summary> |
70 |
| -//! |
71 |
| -//! * linux |
72 |
| -//! * Jetbrains Fleet |
73 |
| -//! * iSH |
74 |
| -//! * GNU Screen |
75 |
| -//! |
76 |
| -//! </details> |
77 |
| -//! |
78 | 38 | //! ## Optional Dependencies
|
79 | 39 | //! * [`rgb`] — Enable this feature to convert between [`Color`] and [`rgb::RGB16`] / [`rgb::RGB8`].
|
80 | 40 | //! * [`anstyle`] — Enable this feature to convert [`Color`] to [`anstyle::RgbColor`].
|
81 |
| -//! |
82 |
| -//! ## Comparison with Other Crates |
83 |
| -//! ### [termbg] |
84 |
| -//! * Is hardcoded to use stdin/stderr for communicating with the terminal. \ |
85 |
| -//! This means that it does not work if some or all of these streams are redirected. |
86 |
| -//! * Pulls in an async runtime for the timeout. |
87 |
| -//! * Does not calculate the perceived lightness, but another metric. |
88 |
| -//! |
89 |
| -//! ### [terminal-light] |
90 |
| -//! * Is hardcoded to use stdin/stdout for communicating with the terminal. |
91 |
| -//! * Does not report the colors, only the color's luma. |
92 |
| -//! * Does not calculate the perceived lightness, but another metric. |
93 |
| -//! |
94 |
| -//! [termbg]: https://docs.rs/termbg |
95 |
| -//! [terminal-light]: https://docs.rs/terminal-light |
96 | 41 |
|
97 | 42 | use cfg_if::cfg_if;
|
98 | 43 | use std::time::Duration;
|
@@ -128,6 +73,10 @@ cfg_if! {
|
128 | 73 | #[doc(cfg(docsrs))]
|
129 | 74 | #[doc = include_str!("../doc/feature-detection.md")]
|
130 | 75 | pub mod feature_detection {}
|
| 76 | + |
| 77 | + #[doc(cfg(docsrs))] |
| 78 | + #[doc = include_str!("../doc/comparison.md")] |
| 79 | + pub mod comparison {} |
131 | 80 | }
|
132 | 81 | }
|
133 | 82 |
|
|
0 commit comments