libnotcurses_sys/palette/
mod.rs

1//! `NcPalette*`
2
3// -----------------------------------------------------------------------------
4// Now none of these functions can't fail and therefore don't return errors.
5// -----------------------------------------------------------------------------
6//
7// functions already exported by bindgen : 3
8// -----------------------------------------
9// (#) test: 0
10// (W) wrap: 3 / 0
11// -----------------------------------------
12//W  ncpalette_free
13//W  ncpalette_new
14//W  ncpalette_use
15//
16// functions manually reimplemented: 4
17// -----------------------------------------
18// (+) done: 3 / 0
19// (#) test: 0
20// (W) wrap: 3 / 0
21// -----------------------------------------
22//W+ ncpalette_get
23//W  ncpalette_get_rgb
24// + ncpalette_get_rgb8   // unneeded method
25//W+ ncpalette_set
26//W  ncpalette_set_rgb
27// + ncpalette_set_rgb8   // unneeded method
28
29use crate::c_api::ffi;
30
31mod methods;
32pub(crate) mod reimplemented;
33pub use methods::*;
34
35/// An array of 256 [`NcChannel`][crate::NcChannel]s.
36///
37/// See also [`NcPaletteIndex`].
38///
39/// Some terminals only support 256 colors, but allow the full
40/// palette to be specified with arbitrary RGB colors. In all cases, it's more
41/// performant to use indexed colors, since it's much less data to write to the
42/// terminal. If you can limit yourself to 256 colors, that's probably best.
43///
44/// `type in C: ncncpalette (struct)`
45pub type NcPalette = ffi::ncpalette;
46
47/// Used for indexing into a [`NcPalette`] (alias of `u8`).
48pub type NcPaletteIndex = u8;
49
50impl NcPalette {
51    /// The supported palette-indexed colors number is up to 8 bits.
52    pub const SIZE: u32 = c_api::NCPALETTE_SIZE;
53}
54
55pub(crate) mod c_api {
56    use super::ffi;
57
58    /// The supported palette-indexed colors number is up to 8 bits.
59    pub const NCPALETTE_SIZE: u32 = ffi::NCPALETTESIZE;
60}