| 1 | //! Terminfo capability values reported via XTGETTCAP (`DCS + q <name> ST`). |
| 2 | |
| 3 | /// Look up a terminfo capability beer reports via XTGETTCAP, by its terminfo |
| 4 | /// name. `None` means the capability is unknown (the reply is then a negative |
| 5 | /// `DCS 0 + r`). |
| 6 | pub fn cap_value(name: &[u8]) -> Option<&'static str> { |
| 7 | match name { |
| 8 | b"TN" => Some("beer"), |
| 9 | b"Co" | b"colors" => Some("256"), |
| 10 | b"RGB" => Some("8/8/8"), |
| 11 | _ => None, |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | #[cfg(test)] |
| 16 | mod tests { |
| 17 | use super::*; |
| 18 | |
| 19 | #[test] |
| 20 | fn known_and_unknown_caps() { |
| 21 | assert_eq!(cap_value(b"TN"), Some("beer")); |
| 22 | assert_eq!(cap_value(b"colors"), Some("256")); |
| 23 | assert_eq!(cap_value(b"nope"), None); |
| 24 | } |
| 25 | } |