1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! `NcPalette*`

// -----------------------------------------------------------------------------
// Now none of these functions can't fail and therefore don't return errors.
// -----------------------------------------------------------------------------
//
// functions already exported by bindgen : 3
// -----------------------------------------
// (#) test: 0
// (W) wrap: 3 / 0
// -----------------------------------------
//W  ncpalette_free
//W  ncpalette_new
//W  ncpalette_use
//
// functions manually reimplemented: 5
// -----------------------------------------
// (+) done: 3 / 0
// (#) test: 0
// (W) wrap: 3 / 0
// -----------------------------------------
//W+ ncpalette_get_rgb
//   ncpalette_get_rgb8
//W+ ncpalette_set
//W+ ncpalette_set_rgb
//   ncpalette_set_rgb8

mod methods;
pub(crate) mod reimplemented;
pub use methods::*;

/// An array of 256 [`NcChannel`][crate::NcChannel]s.
///
/// See also [`NcPaletteIndex`].
///
/// Some terminals only support 256 colors, but allow the full
/// palette to be specified with arbitrary RGB colors. In all cases, it's more
/// performant to use indexed colors, since it's much less data to write to the
/// terminal. If you can limit yourself to 256 colors, that's probably best.
///
/// `type in C: ncncpalette (struct)`
pub type NcPalette = crate::bindings::ffi::ncpalette;

/// Used for indexing into a [`NcPalette`] (alias of `u8`).
pub type NcPaletteIndex = u8;

impl NcPalette {
    /// The supported palette-indexed colors number is up to 8 bits.
    pub const SIZE: u32 = constants::NCPALETTE_SIZE;
}

pub(crate) mod constants {
    /// The supported palette-indexed colors number is up to 8 bits.
    pub const NCPALETTE_SIZE: u32 = crate::bindings::ffi::NCPALETTESIZE;
}