[rust] palette256 -> ncpalette #1573

pull/1586/head
joseLuís 3 years ago
parent c8680255be
commit 97d8c91a1a

@ -758,14 +758,14 @@ pub use ffi::{
// already wrapped:
//
// // structs
// palette256,
// ncpalette,
#[doc(inline)]
pub use ffi::{
// functions
palette256_free,
palette256_new,
palette256_use,
ncpalette_free,
ncpalette_new,
ncpalette_use,
// constants
NCPALETTESIZE,

@ -5,30 +5,30 @@ use crate::{error, NcChannel, NcColor, NcPalette, NcPaletteIndex, NcResult, NcRg
impl NcPalette {
/// New NcPalette.
///
/// *C style function: [palette256_new()][crate::palette256_new].*
/// *C style function: [ncpalette_new()][crate::ncpalette_new].*
pub fn new<'a>(nc: &mut Notcurses) -> &'a mut Self {
unsafe { &mut *crate::palette256_new(nc) }
unsafe { &mut *crate::ncpalette_new(nc) }
}
/// Frees this NcPalette.
///
/// *C style function: [palette256_free()][crate::palette256_free].*
/// *C style function: [ncpalette_free()][crate::ncpalette_free].*
pub fn free(&mut self) {
unsafe {
crate::palette256_free(self);
crate::ncpalette_free(self);
}
}
/// Attempts to configure the terminal with this NcPalette.
///
/// *C style function: [palette256_use()][crate::palette256_use].*
/// *C style function: [ncpalette_use()][crate::ncpalette_use].*
pub fn r#use(&self, nc: &mut Notcurses) -> NcResult<()> {
error![unsafe { crate::palette256_use(nc, self) }]
error![unsafe { crate::ncpalette_use(nc, self) }]
}
/// Returns the [NcColor] RGB components from the [NcChannel] in this NcPalette.
///
/// *C style function: [palette256_get_rgb()][crate::palette256_get_rgb].*
/// *C style function: [ncpalette_get_rgb()][crate::ncpalette_get_rgb].*
pub fn get_rgb8(&self, index: NcPaletteIndex) -> (NcColor, NcColor, NcColor) {
let (mut r, mut g, mut b) = (0, 0, 0);
crate::channel_rgb8(self.chans[index as usize], &mut r, &mut g, &mut b);
@ -38,7 +38,7 @@ impl NcPalette {
/// Extracts the [NcColor] RGB components from an [NcChannel] entry inside
/// this NcPalette, and returns the NcChannel.
///
/// *C style function: [palette256_get_rgb()][crate::palette256_get_rgb].*
/// *C style function: [ncpalette_get_rgb()][crate::ncpalette_get_rgb].*
pub fn get_rgb(&self, index: NcPaletteIndex) -> NcChannel {
let (mut r, mut g, mut b) = (0, 0, 0);
crate::channel_rgb8(self.chans[index as usize], &mut r, &mut g, &mut b)
@ -47,7 +47,7 @@ impl NcPalette {
/// Sets the [NcRgb] value of the [NcChannel][crate::NcChannel] entry
/// inside this NcPalette.
///
/// *C style function: [palette256_set()][crate::palette256_set].*
/// *C style function: [ncpalette_set()][crate::ncpalette_set].*
pub fn set(&mut self, index: NcPaletteIndex, rgb: NcRgb) {
crate::channel_set(&mut self.chans[index as usize], rgb);
}

@ -9,9 +9,9 @@
// (#) test: 0
// (W) wrap: 3 / 0
// -----------------------------------------
//W palette256_free
//W palette256_new
//W palette256_use
//W ncpalette_free
//W ncpalette_new
//W ncpalette_use
//
// functions manually reimplemented: 3
// -----------------------------------------
@ -19,9 +19,9 @@
// (#) test: 0
// (W) wrap: 3 / 0
// -----------------------------------------
//W+ palette256_get_rgb
//W+ palette256_set
//W+ palette256_set_rgb
//W+ ncpalette_get_rgb
//W+ ncpalette_set
//W+ ncpalette_set_rgb
mod methods;
mod reimplemented;
@ -38,9 +38,9 @@ pub use reimplemented::*;
/// 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: ncpalette256 (struct)`
/// `type in C: ncncpalette (struct)`
///
pub type NcPalette = crate::bindings::ffi::palette256;
pub type NcPalette = crate::bindings::ffi::ncpalette;
/// 8-bit value used for indexing into a [`NcPalette`]
///

@ -1,4 +1,4 @@
//! `palette256_*` reimplemented functions.
//! `ncpalette_*` reimplemented functions.
use crate::{NcChannel, NcColor, NcPalette, NcPaletteIndex, NcRgb};
@ -8,7 +8,7 @@ use crate::{NcChannel, NcColor, NcPalette, NcPaletteIndex, NcRgb};
/// *Method: NcPalette.[get_rgb()][NcPalette#method.get_rgb].*
/// *Method: NcPalette.[get_rgb8()][NcPalette#method.get_rgb8].*
#[inline]
pub fn palette256_get_rgb(
pub fn ncpalette_get_rgb(
palette: &NcPalette,
index: NcPaletteIndex,
red: &mut NcColor,
@ -22,7 +22,7 @@ pub fn palette256_get_rgb(
///
/// *Method: NcPalette.[set()][NcPalette#method.set].*
#[inline]
pub fn palette256_set(palette: &mut NcPalette, index: NcPaletteIndex, rgb: NcRgb) {
pub fn ncpalette_set(palette: &mut NcPalette, index: NcPaletteIndex, rgb: NcRgb) {
crate::channel_set(&mut palette.chans[index as usize], rgb);
}
@ -30,7 +30,7 @@ pub fn palette256_set(palette: &mut NcPalette, index: NcPaletteIndex, rgb: NcRgb
///
/// *Method: NcPalette.[set_rgb()][NcPalette#method.set_rgb].*
#[inline]
pub fn palette256_set_rgb(
pub fn ncpalette_set_rgb(
palette: &mut NcPalette,
index: NcPaletteIndex,
red: NcColor,

Loading…
Cancel
Save