tastty-core 0.1.0

Sans-IO core of the tastty terminal session library: VT parser, screen buffer, and byte encoders.
1
2
3
4
5
6
7
8
9
10
11
/// Expand an 8-bit color component to 16-bit X11 range (0xFF -> 0xFFFF).
///
/// X11 color queries ([OSC 4/10/11/12][xterm-osc]) report channels in
/// 16-bit hex form such as `rgb:ffff/0000/0000`. Multiplying by 257
/// (`0x101`) replicates the 8-bit value into both bytes so that 0xFF
/// maps cleanly to 0xFFFF rather than 0xFF00.
///
/// [xterm-osc]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
pub(crate) fn u8_to_x11(v: u8) -> u16 {
    u16::from(v) * 257
}