mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
[rust] rename NcChannelPair
to NcChannels
- deprecate `NcChannelPair`
This commit is contained in:
parent
cf60ff5b94
commit
3e9b2c1fe4
@ -17,7 +17,7 @@ fn main() -> NcResult<()> {
|
||||
println!("terminal size (rows, cols): {}, {}", rows, cols);
|
||||
|
||||
let mut channels =
|
||||
NcChannelPair::combine(NcChannel::from_rgb(0xAA2244), NcChannel::from_rgb(0x112233));
|
||||
NcChannels::combine(NcChannel::from_rgb(0xAA2244), NcChannel::from_rgb(0x112233));
|
||||
dm.putstr(channels, "The current coordinates are")?;
|
||||
|
||||
for _n in 0..40 {
|
||||
|
@ -11,18 +11,18 @@ fn main() -> NcResult<()> {
|
||||
assert_eq![(t_rows, t_cols), stdplane.dim_yx()];
|
||||
|
||||
// set the standard plane's base cell's foreground and background colors
|
||||
let channels = NcChannelPair::from_rgb(0x88aa00, 0x222288);
|
||||
let channels = NcChannels::from_rgb(0x88aa00, 0x222288);
|
||||
stdplane.set_base("x", 0, channels)?;
|
||||
rsleep![&mut nc, 0, 500];
|
||||
|
||||
// add a green plane to the stdplane's pile
|
||||
let plane_green = NcPlane::new_bound(&mut stdplane, 0, 0, 16, 30)?;
|
||||
plane_green.set_base("·", 0, NcChannelPair::from_rgb(0x224411, 0x229922))?;
|
||||
plane_green.set_base("·", 0, NcChannels::from_rgb(0x224411, 0x229922))?;
|
||||
rsleep![&mut nc, 0, 800];
|
||||
|
||||
// add a smaller red plane, a bit displaced to the bottom right
|
||||
let plane_red = NcPlane::new_bound(&mut stdplane, 8, 12, 10, 20)?;
|
||||
plane_red.set_base("~", 0, NcChannelPair::from_rgb(0xaadd2b, 0x882222))?;
|
||||
plane_red.set_base("~", 0, NcChannels::from_rgb(0xaadd2b, 0x882222))?;
|
||||
rsleep![&mut nc, 0, 800];
|
||||
|
||||
// write something
|
||||
|
@ -44,7 +44,7 @@ fn main() -> NcResult<()> {
|
||||
menu_top.item_set_status("Schwarzgerät", "Disabled", false)?;
|
||||
menu_top.item_set_status("Schwarzgerät", "Restart", false)?;
|
||||
|
||||
stdplane.set_base("x", 0, NcChannelPair::from_rgb(0x88aa00, 0x000088))?;
|
||||
stdplane.set_base("x", 0, NcChannels::from_rgb(0x88aa00, 0x000088))?;
|
||||
|
||||
nc.render()?;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! `NcCell` methods and associated functions.
|
||||
|
||||
use crate::{
|
||||
cstring, error, nccell_load, NcAlphaBits, NcCell, NcChannelPair, NcComponent, NcEgc,
|
||||
cstring, error, nccell_load, NcAlphaBits, NcCell, NcChannels, NcComponent, NcEgc,
|
||||
NcEgcBackstop, NcPaletteIndex, NcPlane, NcResult, NcRgb, NcStyle, NCRESULT_ERR,
|
||||
};
|
||||
|
||||
@ -19,7 +19,7 @@ impl NcCell {
|
||||
gcluster_backstop: 0 as NcEgcBackstop,
|
||||
width: 0_u8,
|
||||
stylemask: 0 as NcStyle,
|
||||
channels: 0 as NcChannelPair,
|
||||
channels: 0 as NcChannels,
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ impl NcCell {
|
||||
cell: &mut NcCell,
|
||||
gcluster: &str,
|
||||
style: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
) -> NcResult<u32> {
|
||||
let bytes = crate::nccell_prime(plane, cell, gcluster, style, channels);
|
||||
error![bytes, "", bytes as u32]
|
||||
@ -111,10 +111,10 @@ impl NcCell {
|
||||
// -----------------------------------------------------------------------------
|
||||
/// ## NcCell methods: bg|fg `NcChannel`s manipulation.
|
||||
impl NcCell {
|
||||
/// Returns the [`NcChannelPair`] of this `NcCell`.
|
||||
/// Returns the [`NcChannels`] of this `NcCell`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
pub fn channels(&mut self, plane: &mut NcPlane) -> NcChannelPair {
|
||||
pub fn channels(&mut self, plane: &mut NcPlane) -> NcChannels {
|
||||
let (mut _styles, mut channels) = (0, 0);
|
||||
let _char = crate::nccell_extract(plane, self, &mut _styles, &mut channels);
|
||||
channels
|
||||
@ -304,7 +304,7 @@ impl NcCell {
|
||||
crate::nccellcmp(plane1, cell1, plane2, cell2)
|
||||
}
|
||||
|
||||
/// Saves the [`NcStyle`] and the [`NcChannelPair`], and returns the [`NcEgc`].
|
||||
/// Saves the [`NcStyle`] and the [`NcChannels`], and returns the [`NcEgc`].
|
||||
/// (These are the three elements of an NcCell).
|
||||
///
|
||||
/// *C style function: [nccell_fg_alpha()][crate::nccell_fg_alpha].*
|
||||
@ -312,7 +312,7 @@ impl NcCell {
|
||||
&mut self,
|
||||
plane: &mut NcPlane,
|
||||
styles: &mut NcStyle,
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
) -> NcEgc {
|
||||
crate::nccell_extract(plane, self, styles, channels)
|
||||
}
|
||||
@ -414,7 +414,7 @@ impl NcCell {
|
||||
pub fn load_box(
|
||||
plane: &mut NcPlane,
|
||||
style: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
ul: &mut NcCell,
|
||||
ur: &mut NcCell,
|
||||
ll: &mut NcCell,
|
||||
@ -434,7 +434,7 @@ impl NcCell {
|
||||
pub fn double_box(
|
||||
plane: &mut NcPlane,
|
||||
style: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
ul: &mut NcCell,
|
||||
ur: &mut NcCell,
|
||||
ll: &mut NcCell,
|
||||
@ -453,7 +453,7 @@ impl NcCell {
|
||||
pub fn rounded_box(
|
||||
plane: &mut NcPlane,
|
||||
style: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
ul: &mut NcCell,
|
||||
ur: &mut NcCell,
|
||||
ll: &mut NcCell,
|
||||
|
@ -116,7 +116,7 @@ use crate::{NcChannel, NcPlane};
|
||||
///
|
||||
/// GCLUSTER GCLUSTER GCLUSTER GCLUSTER 1. NcEgc
|
||||
/// 00000000 ~~~~~~~~ 11111111 11111111 2. NcEgcBackstop + 3. width + 4. NcStyle
|
||||
/// ~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB 5. NcChannelPair
|
||||
/// ~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB 5. NcChannels
|
||||
/// ~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB |
|
||||
///
|
||||
/// 1. (32b) Extended Grapheme Cluster, presented either as:
|
||||
@ -136,7 +136,7 @@ use crate::{NcChannel, NcPlane};
|
||||
/// 4. (16b) NcStyle
|
||||
/// 11111111 11111111
|
||||
///
|
||||
/// 5. (64b) NcChannelPair
|
||||
/// 5. (64b) NcChannels
|
||||
/// ~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB|~~AA~~~~ RRRRRRRR GGGGGGGG BBBBBBBB
|
||||
/// ```
|
||||
///
|
||||
|
@ -3,7 +3,7 @@
|
||||
use libc::strcmp;
|
||||
|
||||
use crate::{
|
||||
cstring, nccell_release, NcAlphaBits, NcCell, NcChannel, NcChannelPair, NcComponent, NcEgc,
|
||||
cstring, nccell_release, NcAlphaBits, NcCell, NcChannel, NcChannels, NcComponent, NcEgc,
|
||||
NcIntResult, NcPaletteIndex, NcPlane, NcRgb, NcStyle, NCALPHA_BGDEFAULT_MASK,
|
||||
NCALPHA_BG_PALETTE, NCALPHA_FGDEFAULT_MASK, NCALPHA_FG_PALETTE, NCALPHA_OPAQUE, NCRESULT_ERR,
|
||||
NCRESULT_OK, NCSTYLE_MASK,
|
||||
@ -204,7 +204,7 @@ pub fn nccell_bg_palindex_p(cell: &NcCell) -> bool {
|
||||
#[inline]
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
pub const fn nccell_fg_palindex(cell: &NcCell) -> NcPaletteIndex {
|
||||
((cell.channels & 0xff00000000 as NcChannelPair) >> 32) as NcPaletteIndex
|
||||
((cell.channels & 0xff00000000 as NcChannels) >> 32) as NcPaletteIndex
|
||||
}
|
||||
|
||||
/// Gets the [`NcPaletteIndex`] of the background [`NcChannel`] of the [`NcCell`].
|
||||
@ -230,8 +230,8 @@ pub fn nccell_set_fg_palindex(cell: &mut NcCell, index: NcPaletteIndex) {
|
||||
cell.channels |= NCALPHA_FGDEFAULT_MASK;
|
||||
cell.channels |= NCALPHA_FG_PALETTE;
|
||||
nccell_set_fg_alpha(cell, NCALPHA_OPAQUE);
|
||||
cell.channels &= 0xff000000ffffffff as NcChannelPair;
|
||||
cell.channels |= (index as NcChannelPair) << 32;
|
||||
cell.channels &= 0xff000000ffffffff as NcChannels;
|
||||
cell.channels |= (index as NcChannels) << 32;
|
||||
}
|
||||
|
||||
/// Sets an [`NcCell`]'s background [`NcPaletteIndex`].
|
||||
@ -244,11 +244,11 @@ pub fn nccell_set_fg_palindex(cell: &mut NcCell, index: NcPaletteIndex) {
|
||||
// NOTE: unlike the original C function, this one can't fail
|
||||
#[inline]
|
||||
pub fn nccell_set_bg_palindex(cell: &mut NcCell, index: NcPaletteIndex) {
|
||||
cell.channels |= NCALPHA_BGDEFAULT_MASK as NcChannelPair;
|
||||
cell.channels |= NCALPHA_BG_PALETTE as NcChannelPair;
|
||||
cell.channels |= NCALPHA_BGDEFAULT_MASK as NcChannels;
|
||||
cell.channels |= NCALPHA_BG_PALETTE as NcChannels;
|
||||
nccell_set_bg_alpha(cell, NCALPHA_OPAQUE);
|
||||
cell.channels &= 0xffffffffff000000;
|
||||
cell.channels |= index as NcChannelPair;
|
||||
cell.channels |= index as NcChannels;
|
||||
}
|
||||
|
||||
// Styles ----------------------------------------------------------------------
|
||||
@ -375,7 +375,7 @@ pub fn nccell_strdup(plane: &NcPlane, cell: &NcCell) -> NcEgc {
|
||||
|
||||
// Misc. -----------------------------------------------------------------------
|
||||
|
||||
/// Saves the [`NcStyle`] and the [`NcChannelPair`],
|
||||
/// Saves the [`NcStyle`] and the [`NcChannels`],
|
||||
/// and returns the [`NcEgc`], of an [`NcCell`].
|
||||
///
|
||||
/// *Method: NcCell.[extract()][NcCell#method.extract].*
|
||||
@ -384,7 +384,7 @@ pub fn nccell_extract(
|
||||
plane: &NcPlane,
|
||||
cell: &NcCell,
|
||||
stylemask: &mut NcStyle,
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
) -> NcEgc {
|
||||
if *stylemask != 0 {
|
||||
*stylemask = cell.stylemask;
|
||||
@ -441,7 +441,7 @@ pub fn nccell_prime(
|
||||
cell: &mut NcCell,
|
||||
gcluster: &str,
|
||||
style: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
) -> NcIntResult {
|
||||
cell.stylemask = style;
|
||||
cell.channels = channels;
|
||||
@ -459,7 +459,7 @@ pub fn nccell_prime(
|
||||
pub fn nccells_load_box(
|
||||
plane: &mut NcPlane,
|
||||
style: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
ul: &mut NcCell,
|
||||
ur: &mut NcCell,
|
||||
ll: &mut NcCell,
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! `NcChannel*` methods and associated functions.
|
||||
#![allow(clippy::unnecessary_cast)]
|
||||
|
||||
use crate::{NcAlphaBits, NcChannel, NcChannelPair, NcComponent, NcPaletteIndex, NcRgb};
|
||||
use crate::{NcAlphaBits, NcChannel, NcChannels, NcComponent, NcPaletteIndex, NcRgb};
|
||||
|
||||
/// Enables the [`NcChannel`] methods.
|
||||
pub trait NcChannelMethods {
|
||||
@ -14,8 +14,8 @@ pub trait NcChannelMethods {
|
||||
fn from_rgb8_alpha(r: NcComponent, g: NcComponent, b: NcComponent, alpha: NcAlphaBits) -> Self;
|
||||
|
||||
// methods
|
||||
fn fcombine(&self, bchannel: NcChannel) -> NcChannelPair;
|
||||
fn bcombine(&self, fchannel: NcChannel) -> NcChannelPair;
|
||||
fn fcombine(&self, bchannel: NcChannel) -> NcChannels;
|
||||
fn bcombine(&self, fchannel: NcChannel) -> NcChannels;
|
||||
|
||||
fn alpha(&self) -> NcAlphaBits;
|
||||
fn set_alpha(&mut self, alpha: NcAlphaBits) -> Self;
|
||||
@ -41,8 +41,8 @@ pub trait NcChannelMethods {
|
||||
fn palindex_p(&self) -> bool;
|
||||
}
|
||||
|
||||
/// Enables the [`NcChannelPair`] methods.
|
||||
pub trait NcChannelPairMethods {
|
||||
/// Enables the [`NcChannels`] methods.
|
||||
pub trait NcChannelsMethods {
|
||||
// constructors
|
||||
fn new() -> Self;
|
||||
fn with_default() -> Self;
|
||||
@ -137,32 +137,32 @@ pub trait NcChannelPairMethods {
|
||||
impl NcChannelMethods for NcChannel {
|
||||
// Constructors
|
||||
|
||||
/// New NcChannel, set to black and NOT using the "default color".
|
||||
/// New `NcChannel`, set to black and NOT using the "default color".
|
||||
fn new() -> Self {
|
||||
0 as NcChannel | crate::NCALPHA_BGDEFAULT_MASK
|
||||
}
|
||||
|
||||
/// New NcChannel, set to black but using the "default color".
|
||||
/// New `NcChannel`, set to black but using the "default color".
|
||||
fn with_default() -> Self {
|
||||
0 as NcChannel
|
||||
}
|
||||
|
||||
/// New NcChannel, expects [`NcRgb`].
|
||||
/// New `NcChannel`, expects [`NcRgb`].
|
||||
fn from_rgb(rgb: NcRgb) -> Self {
|
||||
Self::new().set(rgb)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects [`NcRgb`] & [`NcAlphaBits`].
|
||||
/// New `NcChannel`, expects [`NcRgb`] & [`NcAlphaBits`].
|
||||
fn from_rgb_alpha(rgb: NcRgb, alpha: NcAlphaBits) -> Self {
|
||||
Self::new().set(rgb).set_alpha(alpha)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects three RGB [`NcComponent`] components.
|
||||
/// New `NcChannel`, expects three RGB [`NcComponent`] components.
|
||||
fn from_rgb8(r: NcComponent, g: NcComponent, b: NcComponent) -> Self {
|
||||
Self::new().set_rgb8(r, g, b)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects three RGB [`NcComponent`] components & [`NcAlphaBits`].
|
||||
/// New `NcChannel`, expects three RGB [`NcComponent`] components & [`NcAlphaBits`].
|
||||
fn from_rgb8_alpha(r: NcComponent, g: NcComponent, b: NcComponent, alpha: NcAlphaBits) -> Self {
|
||||
Self::new().set_rgb8(r, g, b).set_alpha(alpha)
|
||||
}
|
||||
@ -170,22 +170,22 @@ impl NcChannelMethods for NcChannel {
|
||||
// Combine
|
||||
|
||||
/// Combines this [`NcChannel`] as foreground, with another as background
|
||||
/// into an [`NcChannelPair`].
|
||||
/// into an [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_combine()][crate::ncchannels_combine].*
|
||||
//
|
||||
// Not in the C API
|
||||
fn fcombine(&self, bchannel: NcChannel) -> NcChannelPair {
|
||||
fn fcombine(&self, bchannel: NcChannel) -> NcChannels {
|
||||
crate::ncchannels_combine(*self, bchannel)
|
||||
}
|
||||
|
||||
/// Combines this [`NcChannel`] as background, with another as foreground
|
||||
/// into an [`NcChannelPair`].
|
||||
/// into an [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_combine()][crate::ncchannels_combine].*
|
||||
//
|
||||
// Not in the C API
|
||||
fn bcombine(&self, fchannel: NcChannel) -> NcChannelPair {
|
||||
fn bcombine(&self, fchannel: NcChannel) -> NcChannels {
|
||||
crate::ncchannels_combine(fchannel, *self)
|
||||
}
|
||||
|
||||
@ -346,13 +346,13 @@ impl NcChannelMethods for NcChannel {
|
||||
}
|
||||
}
|
||||
|
||||
// NcChannelPair ---------------------------------------------------------------
|
||||
// NcChannels ---------------------------------------------------------------
|
||||
|
||||
/// # NcChannelPair Methods
|
||||
impl NcChannelPairMethods for NcChannelPair {
|
||||
/// # NcChannels Methods
|
||||
impl NcChannelsMethods for NcChannels {
|
||||
// Constructors
|
||||
|
||||
/// New NcChannelPair, set to black and NOT using the "default color".
|
||||
/// New `NcChannels`, set to black and NOT using the "default color".
|
||||
fn new() -> Self {
|
||||
Self::combine(
|
||||
0 as NcChannel | crate::NCALPHA_BGDEFAULT_MASK,
|
||||
@ -360,25 +360,25 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
)
|
||||
}
|
||||
|
||||
/// New NcChannelPair, set to black but using the "default color".
|
||||
/// New `NcChannels`, set to black but using the "default color".
|
||||
fn with_default() -> Self {
|
||||
Self::combine(0 as NcChannel, 0 as NcChannel)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects two separate [`NcRgb`]s for the foreground
|
||||
/// New `NcChannels`, expects two separate [`NcRgb`]s for the foreground
|
||||
/// and background channels.
|
||||
fn from_rgb(fg_rgb: NcRgb, bg_rgb: NcRgb) -> Self {
|
||||
Self::combine(NcChannel::from_rgb(fg_rgb), NcChannel::from_rgb(bg_rgb))
|
||||
}
|
||||
|
||||
/// New NcChannelPair, expects a single [`NcRgb`] for both foreground
|
||||
/// New `NcChannels`, expects a single [`NcRgb`] for both foreground
|
||||
/// and background channels.
|
||||
fn from_rgb_both(rgb: NcRgb) -> Self {
|
||||
let channel = NcChannel::new().set(rgb);
|
||||
Self::combine(channel, channel)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects two separate [`NcRgb`] & [`NcAlphaBits`] for the
|
||||
/// New `NcChannels`, expects two separate [`NcRgb`] & [`NcAlphaBits`] for the
|
||||
/// foreground and background channels.
|
||||
fn from_rgb_alpha(
|
||||
fg_rgb: NcRgb,
|
||||
@ -392,13 +392,15 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects [`NcRgb`] & [`NcAlphaBits`] for both channels.
|
||||
/// New `NcChannels`, expects [`NcRgb`] & [`NcAlphaBits`] for both
|
||||
/// channels.
|
||||
fn from_rgb_alpha_both(rgb: NcRgb, alpha: NcAlphaBits) -> Self {
|
||||
let channel = NcChannel::new().set(rgb).set_alpha(alpha);
|
||||
Self::combine(channel, channel)
|
||||
}
|
||||
|
||||
/// New NcChannelPair, expects three RGB [`NcComponent`] components for each channel.
|
||||
/// New `NcChannels`, expects three RGB [`NcComponent`] components
|
||||
/// for each channel.
|
||||
fn from_rgb8(
|
||||
fg_r: NcComponent,
|
||||
fg_g: NcComponent,
|
||||
@ -413,15 +415,15 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
)
|
||||
}
|
||||
|
||||
/// New NcChannelPair, expects three RGB [`NcComponent`] components for both
|
||||
/// the foreground and background channels.
|
||||
/// New `NcChannels`, expects three RGB [`NcComponent`] components for
|
||||
/// both the foreground and background channels.
|
||||
fn from_rgb8_both(r: NcComponent, g: NcComponent, b: NcComponent) -> Self {
|
||||
let channel = NcChannel::new().set_rgb8(r, g, b);
|
||||
Self::combine(channel, channel)
|
||||
}
|
||||
|
||||
/// New NcChannelPair, expects three RGB [`NcComponent`] components & [`NcAlphaBits`]
|
||||
/// for both foreground and background channels.
|
||||
/// New `NcChannels`, expects three RGB [`NcComponent`]s and
|
||||
/// [`NcAlphaBits`], for both the foreground and background channels.
|
||||
fn from_rgb8_alpha(
|
||||
fg_r: NcComponent,
|
||||
fg_g: NcComponent,
|
||||
@ -438,7 +440,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
)
|
||||
}
|
||||
|
||||
/// New NcChannel, expects three RGB [`NcComponent`] components.
|
||||
/// New `NcChannel`, expects three RGB [`NcComponent`]s.
|
||||
fn from_rgb8_alpha_both(
|
||||
r: NcComponent,
|
||||
g: NcComponent,
|
||||
@ -451,7 +453,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
|
||||
// Combine
|
||||
|
||||
/// Combines two [`NcChannel`]s into an [`NcChannelPair`].
|
||||
/// Combines two [`NcChannel`]s into an [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_combine()][crate::ncchannels_combine].*
|
||||
fn combine(fchannel: NcChannel, bchannel: NcChannel) -> Self {
|
||||
@ -552,7 +554,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
|
||||
// NcComponent
|
||||
|
||||
/// Gets the three foreground [`NcComponent`]s (r, g, b).
|
||||
/// Gets the three foreground RGB [`NcComponent`]s (r, g, b).
|
||||
///
|
||||
/// *C style function: [channels_fg_rgb8()][crate::ncchannels_fg_rgb8].*
|
||||
fn fg_rgb8(&self) -> (NcComponent, NcComponent, NcComponent) {
|
||||
@ -561,7 +563,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
(r, g, b)
|
||||
}
|
||||
|
||||
/// Gets the three background [`NcComponent`]s (r, g, b).
|
||||
/// Gets the three background RGB [`NcComponent`]s (r, g, b).
|
||||
///
|
||||
/// *C style function: [channels_bg_rgb8()][crate::ncchannels_bg_rgb8].*
|
||||
fn bg_rgb8(&self) -> (NcComponent, NcComponent, NcComponent) {
|
||||
@ -570,7 +572,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
(r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the three foreground [`NcComponent`]s (r, g, b), and
|
||||
/// Sets the three foreground RGB [`NcComponent`]s (r, g, b), and
|
||||
/// marks the foreground [`NcChannel`] as not using the "default color".
|
||||
///
|
||||
/// *C style function: [channels_set_fg_rgb8()][crate::ncchannels_set_fg_rgb8].*
|
||||
@ -578,7 +580,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_set_fg_rgb8(self, r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the three background [`NcComponent`]s (r, g, b), and
|
||||
/// Sets the three background RGB [`NcComponent`]s (r, g, b), and
|
||||
/// marks the background [`NcChannel`] as not using the "default color".
|
||||
///
|
||||
/// *C style function: [channels_set_bg_rgb8()][crate::ncchannels_set_bg_rgb8].*
|
||||
@ -628,7 +630,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannel_b(crate::ncchannels_bchannel(*self))
|
||||
}
|
||||
|
||||
/// Sets the foreground red [`NcComponent`], and returns the new `NcChannelPair`.
|
||||
/// Sets the foreground red [`NcComponent`], and returns the new `NcChannels`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
fn fg_set_r(&mut self, r: NcComponent) -> Self {
|
||||
@ -636,7 +638,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_set_fg_rgb8(self, r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the foreground green [`NcComponent`], and returns the new `NcChannelPair`.
|
||||
/// Sets the foreground green [`NcComponent`], and returns the new `NcChannels`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
fn fg_set_g(&mut self, g: NcComponent) -> Self {
|
||||
@ -644,7 +646,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_set_fg_rgb8(self, r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the foreground blue [`NcComponent`], and returns the new `NcChannelPair`.
|
||||
/// Sets the foreground blue [`NcComponent`], and returns the new `NcChannels`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
fn fg_set_b(&mut self, b: NcComponent) -> Self {
|
||||
@ -652,7 +654,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_set_fg_rgb8(self, r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the background red [`NcComponent`], and returns the new `NcChannelPair`.
|
||||
/// Sets the background red [`NcComponent`], and returns the new `NcChannels`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
fn bg_set_r(&mut self, r: NcComponent) -> Self {
|
||||
@ -660,7 +662,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_set_bg_rgb8(self, r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the background green [`NcComponent`], and returns the new `NcChannelPair`.
|
||||
/// Sets the background green [`NcComponent`], and returns the new `NcChannels`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
fn bg_set_g(&mut self, g: NcComponent) -> Self {
|
||||
@ -668,7 +670,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_set_bg_rgb8(self, r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the background blue [`NcComponent`], and returns the new `NcChannelPair`.
|
||||
/// Sets the background blue [`NcComponent`], and returns the new `NcChannels`.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
fn bg_set_b(&mut self, b: NcComponent) -> Self {
|
||||
@ -696,7 +698,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
}
|
||||
|
||||
/// Marks the foreground as using its "default color", and
|
||||
/// returns the new [`NcChannelPair`].
|
||||
/// returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_set_fg_default()][crate::ncchannels_set_fg_default].*
|
||||
fn set_fg_default(&mut self) -> Self {
|
||||
@ -704,7 +706,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
}
|
||||
|
||||
/// Marks the background as using its "default color", and
|
||||
/// returns the new [`NcChannelPair`].
|
||||
/// returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_set_bg_default()][crate::ncchannels_set_bg_default].*
|
||||
fn set_bg_default(&mut self) -> Self {
|
||||
@ -712,7 +714,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
}
|
||||
|
||||
/// Marks the foreground as NOT using its "default color", and
|
||||
/// returns the new [`NcChannelPair`].
|
||||
/// returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_set_fg_default()][crate::ncchannels_set_fg_default].*
|
||||
//
|
||||
@ -722,7 +724,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
}
|
||||
|
||||
/// Marks the background as NOT using its "default color", and
|
||||
/// returns the new [`NcChannelPair`].
|
||||
/// returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [channels_set_bg_not_default()][crate::ncchannels_set_bg_not_default].*
|
||||
//
|
||||
@ -732,7 +734,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background as using its "default color", and
|
||||
/// returns the new [`NcChannelPair`].
|
||||
/// returns the new [`NcChannels`].
|
||||
///
|
||||
//
|
||||
// Not in the C API
|
||||
@ -741,7 +743,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background as NOT using its "default color",
|
||||
/// and returns the new [`NcChannelPair`].
|
||||
/// and returns the new [`NcChannels`].
|
||||
///
|
||||
//
|
||||
// Not in the C API
|
||||
@ -767,7 +769,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
crate::ncchannels_bg_palindex_p(*self)
|
||||
}
|
||||
|
||||
/// Sets the foreground of an [`NcChannelPair`] as using an
|
||||
/// Sets the foreground of an [`NcChannels`] as using an
|
||||
/// [indexed][NcPaletteIndex] [NcPalette][crate::NcPalette] color.
|
||||
///
|
||||
/// *C style function: [channels_set_fg_palindex()][crate::ncchannels_set_fg_palindex].*
|
||||
@ -776,7 +778,7 @@ impl NcChannelPairMethods for NcChannelPair {
|
||||
*self
|
||||
}
|
||||
|
||||
/// Sets the background of an [`NcChannelPair`] as using an
|
||||
/// Sets the background of an [`NcChannels`] as using an
|
||||
/// [indexed][NcPaletteIndex] [NcPalette][crate::NcPalette] color.
|
||||
///
|
||||
/// *C style function: [channels_set_bg_palindex()][crate::ncchannels_set_bg_palindex].*
|
||||
|
@ -73,7 +73,7 @@ mod test;
|
||||
|
||||
mod methods;
|
||||
mod reimplemented;
|
||||
pub use methods::{NcChannelMethods, NcChannelPairMethods};
|
||||
pub use methods::{NcChannelMethods, NcChannelsMethods};
|
||||
pub use reimplemented::*;
|
||||
|
||||
// NcChannel
|
||||
@ -87,7 +87,7 @@ pub use reimplemented::*;
|
||||
/// - 2 bits of [`NcAlphaBits`]
|
||||
/// - 6 bits of context-dependent info
|
||||
///
|
||||
/// The context details are documented in [`NcChannelPair`]
|
||||
/// The context details are documented in [`NcChannels`]
|
||||
///
|
||||
/// ## Diagram
|
||||
///
|
||||
@ -137,7 +137,7 @@ pub const NCALPHA_TRANSPARENT: u32 = crate::bindings::ffi::NCALPHA_TRANSPARENT;
|
||||
|
||||
/// If this bit is set, we are *not* using the default background color
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: This can also be used against a single [`NcChannel`]
|
||||
pub const NCALPHA_BGDEFAULT_MASK: u32 = crate::bindings::ffi::CELL_BGDEFAULT_MASK;
|
||||
@ -145,7 +145,7 @@ pub const NCALPHA_BGDEFAULT_MASK: u32 = crate::bindings::ffi::CELL_BGDEFAULT_MAS
|
||||
/// Extract these bits to get the background alpha mask
|
||||
/// ([`NcAlphaBits`])
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: This can also be used against a single [`NcChannel`]
|
||||
pub const NCALPHA_BG_ALPHA_MASK: u32 = crate::bindings::ffi::CELL_BG_ALPHA_MASK;
|
||||
@ -153,21 +153,21 @@ pub const NCALPHA_BG_ALPHA_MASK: u32 = crate::bindings::ffi::CELL_BG_ALPHA_MASK;
|
||||
/// If this bit *and* [`NCALPHA_BGDEFAULT_MASK`] are set, we're using a
|
||||
/// palette-indexed background color
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: This can also be used against a single [`NcChannel`]
|
||||
pub const NCALPHA_BG_PALETTE: u32 = crate::bindings::ffi::CELL_BG_PALETTE;
|
||||
|
||||
/// Extract these bits to get the background [`NcRgb`][crate::NcRgb] value
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: This can also be used against a single [`NcChannel`]
|
||||
pub const NCALPHA_BG_RGB_MASK: u32 = crate::bindings::ffi::CELL_BG_RGB_MASK;
|
||||
|
||||
/// If this bit is set, we are *not* using the default foreground color
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: When working with a single [`NcChannel`] use [`NCALPHA_BGDEFAULT_MASK`];
|
||||
pub const NCALPHA_FGDEFAULT_MASK: u64 = crate::bindings::ffi::CELL_FGDEFAULT_MASK;
|
||||
@ -175,7 +175,7 @@ pub const NCALPHA_FGDEFAULT_MASK: u64 = crate::bindings::ffi::CELL_FGDEFAULT_MAS
|
||||
/// Extract these bits to get the foreground alpha mask
|
||||
/// ([`NcAlphaBits`])
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: When working with a single [`NcChannel`] use [`NCALPHA_BG_ALPHA_MASK`];
|
||||
pub const NCALPHA_FG_ALPHA_MASK: u64 = crate::bindings::ffi::CELL_FG_ALPHA_MASK;
|
||||
@ -183,19 +183,19 @@ pub const NCALPHA_FG_ALPHA_MASK: u64 = crate::bindings::ffi::CELL_FG_ALPHA_MASK;
|
||||
/// If this bit *and* [`NCALPHA_FGDEFAULT_MASK`] are set, we're using a
|
||||
/// palette-indexed background color
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: When working with a single [`NcChannel`] use [`NCALPHA_BG_PALETTE`];
|
||||
pub const NCALPHA_FG_PALETTE: u64 = crate::bindings::ffi::CELL_FG_PALETTE;
|
||||
|
||||
/// Extract these bits to get the foreground [`NcRgb`][crate::NcRgb] value
|
||||
///
|
||||
/// See the detailed diagram at [`NcChannelPair`][crate::NcChannelPair]
|
||||
/// See the detailed diagram at [`NcChannels`][crate::NcChannels]
|
||||
///
|
||||
/// Note: When working with a single [`NcChannel`] use [`NCALPHA_BG_RGB_MASK`];
|
||||
pub const NCALPHA_FG_RGB_MASK: u64 = crate::bindings::ffi::CELL_FG_RGB_MASK;
|
||||
|
||||
// NcChannelPair
|
||||
// NcChannels
|
||||
//
|
||||
/// 64 bits containing a foreground and background [`NcChannel`]
|
||||
///
|
||||
@ -279,7 +279,10 @@ pub const NCALPHA_FG_RGB_MASK: u64 = crate::bindings::ffi::CELL_FG_RGB_MASK;
|
||||
/// - [`NCALPHA_FG_PALETTE`][crate::NCALPHA_FG_PALETTE]
|
||||
/// - [`NCALPHA_FG_RGB_MASK`][crate::NCALPHA_FG_RGB_MASK]
|
||||
///
|
||||
pub type NcChannelPair = u64;
|
||||
pub type NcChannels = u64;
|
||||
|
||||
#[deprecated]
|
||||
pub type NcChannelPair = NcChannels;
|
||||
|
||||
// NcRgb
|
||||
//
|
||||
|
@ -1,9 +1,9 @@
|
||||
//! `channel*_*` reimplemented functions.
|
||||
|
||||
use crate::{
|
||||
NcAlphaBits, NcChannel, NcChannelPair, NcComponent, NcPaletteIndex, NcRgb,
|
||||
NCALPHA_BGDEFAULT_MASK, NCALPHA_BG_PALETTE, NCALPHA_BG_RGB_MASK, NCALPHA_FGDEFAULT_MASK,
|
||||
NCALPHA_FG_PALETTE, NCALPHA_HIGHCONTRAST, NCALPHA_OPAQUE, NCCHANNEL_ALPHA_MASK,
|
||||
NcAlphaBits, NcChannel, NcChannels, NcComponent, NcPaletteIndex, NcRgb, NCALPHA_BGDEFAULT_MASK,
|
||||
NCALPHA_BG_PALETTE, NCALPHA_BG_RGB_MASK, NCALPHA_FGDEFAULT_MASK, NCALPHA_FG_PALETTE,
|
||||
NCALPHA_HIGHCONTRAST, NCALPHA_OPAQUE, NCCHANNEL_ALPHA_MASK,
|
||||
};
|
||||
|
||||
// Alpha -----------------------------------------------------------------------
|
||||
@ -30,37 +30,37 @@ pub fn ncchannel_set_alpha(channel: &mut NcChannel, alpha: NcAlphaBits) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the foreground [`NcAlphaBits`] from an [`NcChannelPair`], shifted to LSBs.
|
||||
/// Gets the foreground [`NcAlphaBits`] from an [`NcChannels`], shifted to LSBs.
|
||||
///
|
||||
/// *Method: NcChannelPair.[fg_alpha()][NcChannelPair#method.fg_alpha]*
|
||||
/// *Method: NcChannels.[fg_alpha()][NcChannels#method.fg_alpha]*
|
||||
#[inline]
|
||||
pub const fn ncchannels_fg_alpha(channels: NcChannelPair) -> NcAlphaBits {
|
||||
pub const fn ncchannels_fg_alpha(channels: NcChannels) -> NcAlphaBits {
|
||||
ncchannel_alpha(ncchannels_fchannel(channels))
|
||||
}
|
||||
|
||||
/// Gets the background [`NcAlphaBits`] from an [`NcChannelPair`], shifted to LSBs.
|
||||
/// Gets the background [`NcAlphaBits`] from an [`NcChannels`], shifted to LSBs.
|
||||
///
|
||||
/// *Method: NcChannelPair.[bg_alpha()][NcChannelPair#method.bg_alpha]*
|
||||
/// *Method: NcChannels.[bg_alpha()][NcChannels#method.bg_alpha]*
|
||||
#[inline]
|
||||
pub const fn ncchannels_bg_alpha(channels: NcChannelPair) -> NcAlphaBits {
|
||||
pub const fn ncchannels_bg_alpha(channels: NcChannels) -> NcAlphaBits {
|
||||
ncchannel_alpha(ncchannels_bchannel(channels))
|
||||
}
|
||||
|
||||
/// Sets the [`NcAlphaBits`] of the foreground [`NcChannel`] of an [`NcChannelPair`].
|
||||
/// Sets the [`NcAlphaBits`] of the foreground [`NcChannel`] of an [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fg_alpha()][NcChannelPair#method.set_fg_alpha]*
|
||||
/// *Method: NcChannels.[set_fg_alpha()][NcChannels#method.set_fg_alpha]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_fg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits) {
|
||||
pub fn ncchannels_set_fg_alpha(channels: &mut NcChannels, alpha: NcAlphaBits) {
|
||||
let mut channel = ncchannels_fchannel(*channels);
|
||||
ncchannel_set_alpha(&mut channel, alpha);
|
||||
*channels = (channel as NcChannelPair) << 32 | *channels & 0xffffffff_u64;
|
||||
*channels = (channel as NcChannels) << 32 | *channels & 0xffffffff_u64;
|
||||
}
|
||||
|
||||
/// Sets the [`NcAlphaBits`] of the background [`NcChannel`] of an [`NcChannelPair`].
|
||||
/// Sets the [`NcAlphaBits`] of the background [`NcChannel`] of an [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bg_alpha()][NcChannelPair#method.set_bg_alpha]*
|
||||
/// *Method: NcChannels.[set_bg_alpha()][NcChannels#method.set_bg_alpha]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits) {
|
||||
pub fn ncchannels_set_bg_alpha(channels: &mut NcChannels, alpha: NcAlphaBits) {
|
||||
let mut alpha_clean = alpha;
|
||||
if alpha == NCALPHA_HIGHCONTRAST {
|
||||
// forbidden for background alpha, so makes it opaque
|
||||
@ -73,46 +73,46 @@ pub fn ncchannels_set_bg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits)
|
||||
|
||||
// Channels --------------------------------------------------------------------
|
||||
|
||||
/// Extracts the background [`NcChannel`] from a [`NcChannelPair`].
|
||||
/// Extracts the background [`NcChannel`] from a [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[bchannel()][NcChannelPair#method.bchannel]*
|
||||
/// *Method: NcChannels.[bchannel()][NcChannels#method.bchannel]*
|
||||
#[inline]
|
||||
pub const fn ncchannels_bchannel(channels: NcChannelPair) -> NcChannel {
|
||||
pub const fn ncchannels_bchannel(channels: NcChannels) -> NcChannel {
|
||||
(channels & 0xffffffff_u64) as NcChannel
|
||||
}
|
||||
|
||||
/// Extracts the foreground [`NcChannel`] from an [`NcChannelPair`].
|
||||
/// Extracts the foreground [`NcChannel`] from an [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[fchannel()][NcChannelPair#method.fchannel]*
|
||||
/// *Method: NcChannels.[fchannel()][NcChannels#method.fchannel]*
|
||||
#[inline]
|
||||
pub const fn ncchannels_fchannel(channels: NcChannelPair) -> NcChannel {
|
||||
pub const fn ncchannels_fchannel(channels: NcChannels) -> NcChannel {
|
||||
ncchannels_bchannel(channels >> 32)
|
||||
}
|
||||
|
||||
/// Sets the background [`NcChannel`] of an [`NcChannelPair`].
|
||||
/// Sets the background [`NcChannel`] of an [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bchannel()][NcChannelPair#method.set_bchannel]*
|
||||
/// *Method: NcChannels.[set_bchannel()][NcChannels#method.set_bchannel]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bchannel(channels: &mut NcChannelPair, bchannel: NcChannel) -> NcChannelPair {
|
||||
pub fn ncchannels_set_bchannel(channels: &mut NcChannels, bchannel: NcChannel) -> NcChannels {
|
||||
*channels = (*channels & 0xffffffff00000000_u64) | bchannel as u64;
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Sets the foreground [`NcChannel`] of an [`NcChannelPair`].
|
||||
/// Sets the foreground [`NcChannel`] of an [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fchannel()][NcChannelPair#method.set_fchannel]*
|
||||
/// *Method: NcChannels.[set_fchannel()][NcChannels#method.set_fchannel]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_fchannel(channels: &mut NcChannelPair, fchannel: NcChannel) -> NcChannelPair {
|
||||
pub fn ncchannels_set_fchannel(channels: &mut NcChannels, fchannel: NcChannel) -> NcChannels {
|
||||
*channels = (*channels & 0xffffffff_u64) | (fchannel as u64) << 32;
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Combines two [`NcChannel`]s into an [`NcChannelPair`].
|
||||
/// Combines two [`NcChannel`]s into an [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[combine()][NcChannelPair#method.combine]*
|
||||
/// *Method: NcChannels.[combine()][NcChannels#method.combine]*
|
||||
#[inline]
|
||||
pub fn ncchannels_combine(fchannel: NcChannel, bchannel: NcChannel) -> NcChannelPair {
|
||||
let mut channels: NcChannelPair = 0;
|
||||
pub fn ncchannels_combine(fchannel: NcChannel, bchannel: NcChannel) -> NcChannels {
|
||||
let mut channels: NcChannels = 0;
|
||||
ncchannels_set_fchannel(&mut channels, fchannel);
|
||||
ncchannels_set_bchannel(&mut channels, bchannel);
|
||||
channels
|
||||
@ -203,13 +203,13 @@ pub fn ncchannel_set_rgb8(channel: &mut NcChannel, r: NcComponent, g: NcComponen
|
||||
*channel = (*channel & !NCALPHA_BG_RGB_MASK) | NCALPHA_BGDEFAULT_MASK | rgb;
|
||||
}
|
||||
|
||||
/// Gets the three foreground RGB [`NcComponent`]s from an [`NcChannelPair`], and
|
||||
/// Gets the three foreground RGB [`NcComponent`]s from an [`NcChannels`], and
|
||||
/// returns the foreground [`NcChannel`] (which can have some extra bits set).
|
||||
///
|
||||
/// *Method: NcChannelPair.[fg_rgb8()][NcChannelPair#method.fg_rgb8]*
|
||||
/// *Method: NcChannels.[fg_rgb8()][NcChannels#method.fg_rgb8]*
|
||||
#[inline]
|
||||
pub fn ncchannels_fg_rgb8(
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
r: &mut NcComponent,
|
||||
g: &mut NcComponent,
|
||||
b: &mut NcComponent,
|
||||
@ -217,13 +217,13 @@ pub fn ncchannels_fg_rgb8(
|
||||
ncchannel_rgb8(ncchannels_fchannel(channels), r, g, b)
|
||||
}
|
||||
|
||||
/// Gets the three background RGB [`NcComponent`]s from an [`NcChannelPair`], and
|
||||
/// Gets the three background RGB [`NcComponent`]s from an [`NcChannels`], and
|
||||
/// returns the background [`NcChannel`] (which can have some extra bits set).
|
||||
///
|
||||
/// *Method: NcChannelPair.[bg_rgb8()][NcChannelPair#method.bg_rgb8]*
|
||||
/// *Method: NcChannels.[bg_rgb8()][NcChannels#method.bg_rgb8]*
|
||||
#[inline]
|
||||
pub fn ncchannels_bg_rgb8(
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
r: &mut NcComponent,
|
||||
g: &mut NcComponent,
|
||||
b: &mut NcComponent,
|
||||
@ -231,38 +231,38 @@ pub fn ncchannels_bg_rgb8(
|
||||
ncchannel_rgb8(ncchannels_bchannel(channels), r, g, b)
|
||||
}
|
||||
|
||||
/// Sets the three foreground RGB [`NcComponent`]s of an [`NcChannelPair`], and
|
||||
/// Sets the three foreground RGB [`NcComponent`]s of an [`NcChannels`], and
|
||||
/// marks it as NOT using the "default color", retaining the other bits unchanged.
|
||||
///
|
||||
/// Unlike the original C API, it also returns the new NcChannelPair.
|
||||
/// Unlike the original C API, it also returns the new NcChannels.
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fg_rgb8()][NcChannelPair#method.set_fg_rgb8]*
|
||||
/// *Method: NcChannels.[set_fg_rgb8()][NcChannels#method.set_fg_rgb8]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_fg_rgb8(
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
r: NcComponent,
|
||||
g: NcComponent,
|
||||
b: NcComponent,
|
||||
) -> NcChannelPair {
|
||||
) -> NcChannels {
|
||||
let mut channel = ncchannels_fchannel(*channels);
|
||||
ncchannel_set_rgb8(&mut channel, r, g, b);
|
||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Sets the three background RGB [`NcComponent`]s of an [`NcChannelPair`], and
|
||||
/// Sets the three background RGB [`NcComponent`]s of an [`NcChannels`], and
|
||||
/// marks it as NOT using the "default color", retaining the other bits unchanged.
|
||||
///
|
||||
/// Unlike the original C API, it also returns the new NcChannelPair.
|
||||
/// Unlike the original C API, it also returns the new NcChannels.
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bg_rgb8()][NcChannelPair#method.set_bg_rgb8]*
|
||||
/// *Method: NcChannels.[set_bg_rgb8()][NcChannels#method.set_bg_rgb8]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_rgb8(
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
r: NcComponent,
|
||||
g: NcComponent,
|
||||
b: NcComponent,
|
||||
) -> NcChannelPair {
|
||||
) -> NcChannels {
|
||||
let mut channel = ncchannels_bchannel(*channels);
|
||||
ncchannel_set_rgb8(&mut channel, r, g, b);
|
||||
ncchannels_set_bchannel(channels, channel);
|
||||
@ -271,19 +271,19 @@ pub fn ncchannels_set_bg_rgb8(
|
||||
|
||||
// NcRgb -----------------------------------------------------------------------
|
||||
|
||||
/// Gets the foreground [`NcRgb`] from an [`NcChannelPair`], shifted to LSBs.
|
||||
/// Gets the foreground [`NcRgb`] from an [`NcChannels`], shifted to LSBs.
|
||||
///
|
||||
/// *Method: NcChannelPair.[fg_rgb()][NcChannelPair#method.fg_rgb]*
|
||||
/// *Method: NcChannels.[fg_rgb()][NcChannels#method.fg_rgb]*
|
||||
#[inline]
|
||||
pub fn ncchannels_fg_rgb(channels: NcChannelPair) -> NcRgb {
|
||||
pub fn ncchannels_fg_rgb(channels: NcChannels) -> NcRgb {
|
||||
ncchannels_fchannel(channels) & NCALPHA_BG_RGB_MASK
|
||||
}
|
||||
|
||||
/// Gets the background [`NcRgb`] from an [`NcChannelPair`], shifted to LSBs.
|
||||
/// Gets the background [`NcRgb`] from an [`NcChannels`], shifted to LSBs.
|
||||
///
|
||||
/// *Method: NcChannelPair.[bg_rgb()][NcChannelPair#method.bg_rgb]*
|
||||
/// *Method: NcChannels.[bg_rgb()][NcChannels#method.bg_rgb]*
|
||||
#[inline]
|
||||
pub fn ncchannels_bg_rgb(channels: NcChannelPair) -> NcRgb {
|
||||
pub fn ncchannels_bg_rgb(channels: NcChannels) -> NcRgb {
|
||||
ncchannels_bchannel(channels) & NCALPHA_BG_RGB_MASK
|
||||
}
|
||||
|
||||
@ -308,23 +308,23 @@ pub fn ncchannel_set(channel: &mut NcChannel, rgb: NcRgb) {
|
||||
*channel = (*channel & !NCALPHA_BG_RGB_MASK) | NCALPHA_BGDEFAULT_MASK | (rgb & 0x00ffffff);
|
||||
}
|
||||
|
||||
/// Sets the foreground [`NcRgb`] of an [`NcChannelPair`], and marks it as NOT using
|
||||
/// Sets the foreground [`NcRgb`] of an [`NcChannels`], and marks it as NOT using
|
||||
/// the "default color", retaining the other bits unchanged.
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fg_rgb()][NcChannelPair#method.set_fg_rgb]*
|
||||
/// *Method: NcChannels.[set_fg_rgb()][NcChannels#method.set_fg_rgb]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_fg_rgb(channels: &mut NcChannelPair, rgb: NcRgb) {
|
||||
pub fn ncchannels_set_fg_rgb(channels: &mut NcChannels, rgb: NcRgb) {
|
||||
let mut channel = ncchannels_fchannel(*channels);
|
||||
ncchannel_set(&mut channel, rgb);
|
||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||
}
|
||||
|
||||
/// Sets the foreground [`NcRgb`] of an [`NcChannelPair`], and marks it as NOT using
|
||||
/// Sets the foreground [`NcRgb`] of an [`NcChannels`], and marks it as NOT using
|
||||
/// the "default color", retaining the other bits unchanged.
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bg_rgb()][NcChannelPair#method.set_bg_rgb]*
|
||||
/// *Method: NcChannels.[set_bg_rgb()][NcChannels#method.set_bg_rgb]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_rgb(channels: &mut NcChannelPair, rgb: NcRgb) {
|
||||
pub fn ncchannels_set_bg_rgb(channels: &mut NcChannels, rgb: NcRgb) {
|
||||
let mut channel = ncchannels_bchannel(*channels);
|
||||
ncchannel_set(&mut channel, rgb);
|
||||
ncchannels_set_bchannel(channels, channel);
|
||||
@ -361,11 +361,11 @@ pub fn ncchannel_set_not_default(channel: &mut NcChannel) -> NcChannel {
|
||||
*channel
|
||||
}
|
||||
|
||||
/// Is the foreground of an [`NcChannelPair`] using the "default foreground color"?
|
||||
/// Is the foreground of an [`NcChannels`] using the "default foreground color"?
|
||||
///
|
||||
/// *Method: NcChannelPair.[fg_default_p()][NcChannelPair#method.fg_default_p]*
|
||||
/// *Method: NcChannels.[fg_default_p()][NcChannels#method.fg_default_p]*
|
||||
#[inline]
|
||||
pub fn ncchannels_fg_default_p(channels: NcChannelPair) -> bool {
|
||||
pub fn ncchannels_fg_default_p(channels: NcChannels) -> bool {
|
||||
ncchannel_default_p(ncchannels_fchannel(channels))
|
||||
}
|
||||
|
||||
@ -374,83 +374,83 @@ pub fn ncchannels_fg_default_p(channels: NcChannelPair) -> bool {
|
||||
/// The "default background color" must generally be used to take advantage of
|
||||
/// terminal-effected transparency.
|
||||
///
|
||||
/// *Method: NcChannelPair.[bg_default_p()][NcChannelPair#method.bg_default_p]*
|
||||
/// *Method: NcChannels.[bg_default_p()][NcChannels#method.bg_default_p]*
|
||||
#[inline]
|
||||
pub fn ncchannels_bg_default_p(channels: NcChannelPair) -> bool {
|
||||
pub fn ncchannels_bg_default_p(channels: NcChannels) -> bool {
|
||||
ncchannel_default_p(ncchannels_bchannel(channels))
|
||||
}
|
||||
|
||||
/// Marks the foreground of an [`NcChannelPair`] as using its "default color",
|
||||
/// which also marks it opaque, and returns the new [`NcChannelPair`].
|
||||
/// Marks the foreground of an [`NcChannels`] as using its "default color",
|
||||
/// which also marks it opaque, and returns the new [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fg_default()][NcChannelPair#method.set_fg_default]*
|
||||
/// *Method: NcChannels.[set_fg_default()][NcChannels#method.set_fg_default]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_fg_default(channels: &mut NcChannelPair) -> NcChannelPair {
|
||||
pub fn ncchannels_set_fg_default(channels: &mut NcChannels) -> NcChannels {
|
||||
let mut channel = ncchannels_fchannel(*channels);
|
||||
ncchannel_set_default(&mut channel);
|
||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Marks the foreground of an [`NcChannelPair`] as NOT using its "default color",
|
||||
/// retaining the other bits unchanged, and returns the new [`NcChannelPair`].
|
||||
/// Marks the foreground of an [`NcChannels`] as NOT using its "default color",
|
||||
/// retaining the other bits unchanged, and returns the new [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fg_not_default()][NcChannelPair#method.set_fg_not_default]*
|
||||
/// *Method: NcChannels.[set_fg_not_default()][NcChannels#method.set_fg_not_default]*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn ncchannels_set_fg_not_default(channels: &mut NcChannelPair) -> NcChannelPair {
|
||||
pub fn ncchannels_set_fg_not_default(channels: &mut NcChannels) -> NcChannels {
|
||||
let mut channel = ncchannels_fchannel(*channels);
|
||||
ncchannel_set_not_default(&mut channel);
|
||||
*channels = (channel as u64) << 32 | *channels & 0xffffffff_u64;
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Marks the background of an [`NcChannelPair`] as using its "default color",
|
||||
/// which also marks it opaque, and returns the new [`NcChannelPair`].
|
||||
/// Marks the background of an [`NcChannels`] as using its "default color",
|
||||
/// which also marks it opaque, and returns the new [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bg_default()][NcChannelPair#method.set_bg_default]*
|
||||
/// *Method: NcChannels.[set_bg_default()][NcChannels#method.set_bg_default]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_default(channels: &mut NcChannelPair) -> NcChannelPair {
|
||||
pub fn ncchannels_set_bg_default(channels: &mut NcChannels) -> NcChannels {
|
||||
let mut channel = ncchannels_bchannel(*channels);
|
||||
ncchannel_set_default(&mut channel);
|
||||
ncchannels_set_bchannel(channels, channel);
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Marks the background of an [`NcChannelPair`] as NOT using its "default color",
|
||||
/// retaining the other bits unchanged, and returns the new [`NcChannelPair`].
|
||||
/// Marks the background of an [`NcChannels`] as NOT using its "default color",
|
||||
/// retaining the other bits unchanged, and returns the new [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bg_not_default()][NcChannelPair#method.set_bg_not_default]*
|
||||
/// *Method: NcChannels.[set_bg_not_default()][NcChannels#method.set_bg_not_default]*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_not_default(channels: &mut NcChannelPair) -> NcChannelPair {
|
||||
pub fn ncchannels_set_bg_not_default(channels: &mut NcChannels) -> NcChannels {
|
||||
let mut channel = ncchannels_bchannel(*channels);
|
||||
ncchannel_set_not_default(&mut channel);
|
||||
ncchannels_set_bchannel(channels, channel);
|
||||
*channels
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background of an [`NcChannelPair`] as using their
|
||||
/// "default color", which also marks them opaque, and returns the new [`NcChannelPair`].
|
||||
/// Marks both the foreground and background of an [`NcChannels`] as using their
|
||||
/// "default color", which also marks them opaque, and returns the new [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_default()][NcChannelPair#method.set_default]*
|
||||
/// *Method: NcChannels.[set_default()][NcChannels#method.set_default]*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn ncchannels_set_default(channels: &mut NcChannelPair) -> NcChannelPair {
|
||||
pub fn ncchannels_set_default(channels: &mut NcChannels) -> NcChannels {
|
||||
ncchannels_set_bg_default(&mut ncchannels_set_fg_default(channels))
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background of an [`NcChannelPair`] as NOT using their
|
||||
/// "default color", retaining the other bits unchanged, and returns the new [`NcChannelPair`].
|
||||
/// Marks both the foreground and background of an [`NcChannels`] as NOT using their
|
||||
/// "default color", retaining the other bits unchanged, and returns the new [`NcChannels`].
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_not_default()][NcChannelPair#method.set_not_default]*
|
||||
/// *Method: NcChannels.[set_not_default()][NcChannels#method.set_not_default]*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn ncchannels_set_not_default(channels: &mut NcChannelPair) -> NcChannelPair {
|
||||
pub fn ncchannels_set_not_default(channels: &mut NcChannels) -> NcChannels {
|
||||
ncchannels_set_bg_not_default(&mut ncchannels_set_fg_not_default(channels))
|
||||
}
|
||||
|
||||
@ -464,47 +464,47 @@ pub fn ncchannel_palindex_p(channel: NcChannel) -> bool {
|
||||
!(ncchannel_default_p(channel) && (channel & NCALPHA_BG_PALETTE) == 0)
|
||||
}
|
||||
|
||||
/// Is the foreground of an [`NcChannelPair`] using an [indexed][`NcPaletteIndex`]
|
||||
/// Is the foreground of an [`NcChannels`] using an [indexed][`NcPaletteIndex`]
|
||||
/// [`NcPalette`][crate::NcPalette] color?
|
||||
///
|
||||
/// *Method: NcChannelPair.[fg_palindex_p()][NcChannelPair#method.fg_palindex_p]*
|
||||
/// *Method: NcChannels.[fg_palindex_p()][NcChannels#method.fg_palindex_p]*
|
||||
#[inline]
|
||||
pub fn ncchannels_fg_palindex_p(channels: NcChannelPair) -> bool {
|
||||
pub fn ncchannels_fg_palindex_p(channels: NcChannels) -> bool {
|
||||
ncchannel_palindex_p(ncchannels_fchannel(channels))
|
||||
}
|
||||
|
||||
/// Is the background of an [`NcChannelPair`] using an [indexed][`NcPaletteIndex`]
|
||||
/// Is the background of an [`NcChannels`] using an [indexed][`NcPaletteIndex`]
|
||||
/// [`NcPalette`][crate::NcPalette] color?
|
||||
///
|
||||
/// *Method: NcChannelPair.[bg_palindex_p()][NcChannelPair#method.bg_palindex_p]*
|
||||
/// *Method: NcChannels.[bg_palindex_p()][NcChannels#method.bg_palindex_p]*
|
||||
#[inline]
|
||||
pub fn ncchannels_bg_palindex_p(channels: NcChannelPair) -> bool {
|
||||
pub fn ncchannels_bg_palindex_p(channels: NcChannels) -> bool {
|
||||
ncchannel_palindex_p(ncchannels_bchannel(channels))
|
||||
}
|
||||
|
||||
/// Sets the foreground of an [`NcChannelPair`] as using an
|
||||
/// Sets the foreground of an [`NcChannels`] as using an
|
||||
/// [indexed][`NcPaletteIndex`] [`NcPalette`][crate::NcPalette] color.
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_fg_palindex()][NcChannelPair#method.set_fg_palindex]*
|
||||
/// *Method: NcChannels.[set_fg_palindex()][NcChannels#method.set_fg_palindex]*
|
||||
#[inline]
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
pub fn ncchannels_set_fg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
||||
pub fn ncchannels_set_fg_palindex(channels: &mut NcChannels, index: NcPaletteIndex) {
|
||||
*channels |= NCALPHA_FGDEFAULT_MASK;
|
||||
*channels |= NCALPHA_FG_PALETTE as NcChannelPair;
|
||||
*channels |= NCALPHA_FG_PALETTE as NcChannels;
|
||||
ncchannels_set_fg_alpha(channels, NCALPHA_OPAQUE);
|
||||
*channels &= 0xff000000ffffffff as NcChannelPair;
|
||||
*channels |= (index as NcChannelPair) << 32;
|
||||
*channels &= 0xff000000ffffffff as NcChannels;
|
||||
*channels |= (index as NcChannels) << 32;
|
||||
}
|
||||
|
||||
/// Sets the background of an [`NcChannelPair`] as using an
|
||||
/// Sets the background of an [`NcChannels`] as using an
|
||||
/// [indexed][`NcPaletteIndex`] [`NcPalette`][crate::NcPalette] color.
|
||||
///
|
||||
/// *Method: NcChannelPair.[set_bg_palindex()][NcChannelPair#method.set_bg_palindex]*
|
||||
/// *Method: NcChannels.[set_bg_palindex()][NcChannels#method.set_bg_palindex]*
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
||||
*channels |= NCALPHA_BGDEFAULT_MASK as NcChannelPair;
|
||||
*channels |= NCALPHA_BG_PALETTE as NcChannelPair;
|
||||
pub fn ncchannels_set_bg_palindex(channels: &mut NcChannels, index: NcPaletteIndex) {
|
||||
*channels |= NCALPHA_BGDEFAULT_MASK as NcChannels;
|
||||
*channels |= NCALPHA_BG_PALETTE as NcChannels;
|
||||
ncchannels_set_bg_alpha(channels, NCALPHA_OPAQUE);
|
||||
*channels &= 0xffffffffff000000;
|
||||
*channels |= index as NcChannelPair;
|
||||
*channels |= index as NcChannels;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Test `NcChannel*` methods and associated functions.
|
||||
|
||||
// use crate::{NcChannel, NcChannelPair};
|
||||
// use crate::{NcChannel, NcChannels};
|
||||
//
|
||||
// use serial_test::serial;
|
||||
//
|
||||
|
@ -3,8 +3,7 @@
|
||||
use serial_test::serial;
|
||||
|
||||
use crate::{
|
||||
NcChannel, NcChannelPair, NCALPHA_BLEND, NCALPHA_HIGHCONTRAST, NCALPHA_OPAQUE,
|
||||
NCALPHA_TRANSPARENT,
|
||||
NcChannel, NcChannels, NCALPHA_BLEND, NCALPHA_HIGHCONTRAST, NCALPHA_OPAQUE, NCALPHA_TRANSPARENT,
|
||||
};
|
||||
|
||||
// NcChannel tests -------------------------------------------------------------
|
||||
@ -169,7 +168,7 @@ fn channel_default_p() {
|
||||
assert_eq!(false, crate::ncchannel_default_p(c));
|
||||
}
|
||||
|
||||
// NcChannelPair tests ---------------------------------------------------------
|
||||
// NcChannels tests ---------------------------------------------------------
|
||||
|
||||
///
|
||||
#[test]
|
||||
@ -177,7 +176,7 @@ fn channel_default_p() {
|
||||
#[allow(non_snake_case)]
|
||||
fn channels_set_fchannel__channels_fchannel() {
|
||||
let fc: NcChannel = 0x112233;
|
||||
let mut cp: NcChannelPair = 0;
|
||||
let mut cp: NcChannels = 0;
|
||||
crate::ncchannels_set_fchannel(&mut cp, fc);
|
||||
assert_eq!(crate::ncchannels_fchannel(cp), fc);
|
||||
}
|
||||
@ -188,7 +187,7 @@ fn channels_set_fchannel__channels_fchannel() {
|
||||
#[allow(non_snake_case)]
|
||||
fn channels_set_bchannel__channels_bchannel() {
|
||||
let bc: NcChannel = 0x112233;
|
||||
let mut cp: NcChannelPair = 0;
|
||||
let mut cp: NcChannels = 0;
|
||||
crate::ncchannels_set_bchannel(&mut cp, bc);
|
||||
assert_eq!(crate::ncchannels_bchannel(cp), bc);
|
||||
}
|
||||
@ -199,8 +198,8 @@ fn channels_set_bchannel__channels_bchannel() {
|
||||
fn channels_combine() {
|
||||
let bc: NcChannel = 0x112233;
|
||||
let fc: NcChannel = 0x445566;
|
||||
let mut cp1: NcChannelPair = 0;
|
||||
let mut _cp2: NcChannelPair = 0;
|
||||
let mut cp1: NcChannels = 0;
|
||||
let mut _cp2: NcChannels = 0;
|
||||
crate::ncchannels_set_bchannel(&mut cp1, bc);
|
||||
crate::ncchannels_set_fchannel(&mut cp1, fc);
|
||||
_cp2 = crate::ncchannels_combine(fc, bc);
|
||||
|
@ -4,7 +4,7 @@ use core::ptr::{null, null_mut};
|
||||
|
||||
use crate::ffi::sigset_t;
|
||||
use crate::{
|
||||
cstring, error, error_ref_mut, rstring, NcAlign, NcBlitter, NcChannelPair, NcComponent, NcDim,
|
||||
cstring, error, error_ref_mut, rstring, NcAlign, NcBlitter, NcChannels, NcComponent, NcDim,
|
||||
NcDirect, NcDirectFlags, NcDirectV, NcEgc, NcError, NcInput, NcPaletteIndex, NcResult, NcRgb,
|
||||
NcScale, NcStyle, NcTime, NCRESULT_ERR,
|
||||
};
|
||||
@ -550,7 +550,7 @@ impl NcDirect {
|
||||
/// are both marked as using the default color.
|
||||
///
|
||||
/// *C style function: [ncdirect_putstr()][crate::ncdirect_putstr].*
|
||||
pub fn putstr(&mut self, channels: NcChannelPair, string: &str) -> NcResult<()> {
|
||||
pub fn putstr(&mut self, channels: NcChannels, string: &str) -> NcResult<()> {
|
||||
error![
|
||||
unsafe { crate::ncdirect_putstr(self, channels, cstring![string]) },
|
||||
&format!("NcDirect.putstr({:0X}, {:?})", channels, string)
|
||||
@ -591,10 +591,10 @@ impl NcDirect {
|
||||
// TODO: CHECK, specially wchars.
|
||||
pub fn r#box(
|
||||
&mut self,
|
||||
ul: NcChannelPair,
|
||||
ur: NcChannelPair,
|
||||
ll: NcChannelPair,
|
||||
lr: NcChannelPair,
|
||||
ul: NcChannels,
|
||||
ur: NcChannels,
|
||||
ll: NcChannels,
|
||||
lr: NcChannels,
|
||||
wchars: &[char; 6],
|
||||
y_len: NcDim,
|
||||
x_len: NcDim,
|
||||
@ -627,10 +627,10 @@ impl NcDirect {
|
||||
/// *C style function: [ncdirect_double_box()][crate::ncdirect_double_box].*
|
||||
pub fn double_box(
|
||||
&mut self,
|
||||
ul: NcChannelPair,
|
||||
ur: NcChannelPair,
|
||||
ll: NcChannelPair,
|
||||
lr: NcChannelPair,
|
||||
ul: NcChannels,
|
||||
ur: NcChannels,
|
||||
ll: NcChannels,
|
||||
lr: NcChannels,
|
||||
y_len: NcDim,
|
||||
x_len: NcDim,
|
||||
ctlword: u32,
|
||||
@ -645,10 +645,10 @@ impl NcDirect {
|
||||
/// *C style function: [ncdirect_rounded_box()][crate::ncdirect_rounded_box].*
|
||||
pub fn rounded_box(
|
||||
&mut self,
|
||||
ul: NcChannelPair,
|
||||
ur: NcChannelPair,
|
||||
ll: NcChannelPair,
|
||||
lr: NcChannelPair,
|
||||
ul: NcChannels,
|
||||
ur: NcChannels,
|
||||
ll: NcChannels,
|
||||
lr: NcChannels,
|
||||
y_len: NcDim,
|
||||
x_len: NcDim,
|
||||
ctlword: u32,
|
||||
@ -657,7 +657,7 @@ impl NcDirect {
|
||||
crate::ncdirect_rounded_box(self, ul, ur, ll, lr, y_len as i32, x_len as i32, ctlword)
|
||||
}]
|
||||
}
|
||||
/// Draws horizontal lines using the specified [NcChannelPair]s, interpolating
|
||||
/// Draws horizontal lines using the specified [NcChannels]s, interpolating
|
||||
/// between them as we go.
|
||||
///
|
||||
/// All lines start at the current cursor position.
|
||||
@ -673,8 +673,8 @@ impl NcDirect {
|
||||
&mut self,
|
||||
egc: &NcEgc,
|
||||
len: NcDim,
|
||||
h1: NcChannelPair,
|
||||
h2: NcChannelPair,
|
||||
h1: NcChannels,
|
||||
h2: NcChannels,
|
||||
) -> NcResult<()> {
|
||||
// https://github.com/dankamongmen/notcurses/issues/1339
|
||||
#[cfg(any(target_arch = "x86_64", target_arch = "i686"))]
|
||||
@ -685,7 +685,7 @@ impl NcDirect {
|
||||
error![unsafe { crate::ncdirect_hline_interp(self, egc_ptr, len as i32, h1, h2) }]
|
||||
}
|
||||
|
||||
/// Draws horizontal lines using the specified [NcChannelPair]s, interpolating
|
||||
/// Draws horizontal lines using the specified [NcChannels]s, interpolating
|
||||
/// between them as we go.
|
||||
///
|
||||
/// All lines start at the current cursor position.
|
||||
@ -701,8 +701,8 @@ impl NcDirect {
|
||||
&mut self,
|
||||
egc: &NcEgc,
|
||||
len: NcDim,
|
||||
h1: NcChannelPair,
|
||||
h2: NcChannelPair,
|
||||
h1: NcChannels,
|
||||
h2: NcChannels,
|
||||
) -> NcResult<()> {
|
||||
// https://github.com/dankamongmen/notcurses/issues/1339
|
||||
#[cfg(any(target_arch = "x86_64", target_arch = "i686"))]
|
||||
|
@ -41,7 +41,7 @@
|
||||
//!
|
||||
//! For the types that don't allocate, most are based on primitives like `i32`,
|
||||
//! `u32`, `u64`… without a name in the C library. In Rust they are type aliased
|
||||
//! (e.g.: [`NcChannel`], [`NcChannelPair`], [`NcRgb`], [`NcComponent`]…), to
|
||||
//! (e.g.: [`NcChannel`], [`NcChannels`], [`NcRgb`], [`NcComponent`]…), to
|
||||
//! leverage type checking, and they implement methods through [traits](#traits)
|
||||
//! (e.g. [`NcChannelMethods`] must be in scope to use the `NcChannel` methods.
|
||||
//!
|
||||
|
@ -3,7 +3,7 @@
|
||||
use core::ptr::{null, null_mut};
|
||||
|
||||
use crate::{
|
||||
cstring, error, error_ref_mut, notcurses_init, rstring, Nc, NcAlign, NcBlitter, NcChannelPair,
|
||||
cstring, error, error_ref_mut, notcurses_init, rstring, Nc, NcAlign, NcBlitter, NcChannels,
|
||||
NcDim, NcEgc, NcError, NcFile, NcInput, NcLogLevel, NcOptions, NcPlane, NcResult, NcScale,
|
||||
NcSignalSet, NcStats, NcStyle, NcTime, NCOPTION_NO_ALTERNATE_SCREEN, NCOPTION_SUPPRESS_BANNERS,
|
||||
NCRESULT_ERR,
|
||||
@ -131,7 +131,7 @@ impl Nc {
|
||||
|
||||
/// Retrieves the current contents of the specified [NcCell][crate::NcCell]
|
||||
/// as last rendered, returning the [NcEgc] (or None on error) and writing
|
||||
/// out the [NcStyle] and the [NcChannelPair].
|
||||
/// out the [NcStyle] and the [NcChannels].
|
||||
///
|
||||
/// This NcEgc must be freed by the caller.
|
||||
///
|
||||
@ -141,7 +141,7 @@ impl Nc {
|
||||
y: NcDim,
|
||||
x: NcDim,
|
||||
stylemask: &mut NcStyle,
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
) -> Option<NcEgc> {
|
||||
let egc = unsafe { crate::notcurses_at_yx(self, x as i32, y as i32, stylemask, channels) };
|
||||
if egc.is_null() {
|
||||
|
@ -6,7 +6,7 @@ use core::{
|
||||
|
||||
use crate::{
|
||||
cstring, error, error_ref, error_ref_mut, rstring, Nc, NcAlign, NcAlphaBits, NcBlitter,
|
||||
NcBoxMask, NcCell, NcChannel, NcChannelPair, NcComponent, NcDim, NcEgc, NcError, NcFadeCb,
|
||||
NcBoxMask, NcCell, NcChannel, NcChannels, NcComponent, NcDim, NcEgc, NcError, NcFadeCb,
|
||||
NcOffset, NcPaletteIndex, NcPixelGeometry, NcPlane, NcPlaneOptions, NcResizeCb, NcResult,
|
||||
NcRgb, NcStyle, NcTime, NCRESULT_ERR,
|
||||
};
|
||||
@ -199,10 +199,10 @@ impl NcPlane {
|
||||
// -----------------------------------------------------------------------------
|
||||
/// ## NcPlane methods: `NcChannel`
|
||||
impl NcPlane {
|
||||
/// Gets the current [`NcChannelPair`] from this NcPlane.
|
||||
/// Gets the current [`NcChannels`] from this NcPlane.
|
||||
///
|
||||
/// *C style function: [ncplane_channels()][crate::ncplane_channels].*
|
||||
pub fn channels(&self) -> NcChannelPair {
|
||||
pub fn channels(&self) -> NcChannels {
|
||||
crate::ncplane_channels(self)
|
||||
}
|
||||
|
||||
@ -222,30 +222,30 @@ impl NcPlane {
|
||||
crate::ncchannels_bchannel(crate::ncplane_channels(self))
|
||||
}
|
||||
|
||||
/// Sets the current [`NcChannelPair`] for this NcPlane.
|
||||
/// Sets the current [`NcChannels`] for this NcPlane.
|
||||
///
|
||||
/// *C style function: [ncplane_set_channels()][crate::ncplane_set_channels].*
|
||||
pub fn set_channels(&mut self, channels: NcChannelPair) {
|
||||
pub fn set_channels(&mut self, channels: NcChannels) {
|
||||
crate::ncplane_set_channels(self, channels);
|
||||
}
|
||||
|
||||
/// Sets the current foreground [`NcChannel`] for this NcPlane.
|
||||
/// Returns the updated [`NcChannelPair`].
|
||||
/// Returns the updated [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [ncplane_set_fchannel()][crate::ncplane_set_fchannel].*
|
||||
pub fn set_fchannel(&mut self, channel: NcChannel) -> NcChannelPair {
|
||||
pub fn set_fchannel(&mut self, channel: NcChannel) -> NcChannels {
|
||||
crate::ncplane_set_fchannel(self, channel)
|
||||
}
|
||||
|
||||
/// Sets the current background [`NcChannel`] for this NcPlane.
|
||||
/// Returns the updated [`NcChannelPair`].
|
||||
/// Returns the updated [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [ncplane_set_bchannel()][crate::ncplane_set_bchannel].*
|
||||
pub fn set_bchannel(&mut self, channel: NcChannel) -> NcChannelPair {
|
||||
pub fn set_bchannel(&mut self, channel: NcChannel) -> NcChannels {
|
||||
crate::ncplane_set_bchannel(self, channel)
|
||||
}
|
||||
|
||||
/// Sets the given [`NcChannelPair`]s throughout the specified region,
|
||||
/// Sets the given [`NcChannels`]s throughout the specified region,
|
||||
/// keeping content and attributes unchanged.
|
||||
///
|
||||
/// Returns the number of cells set.
|
||||
@ -255,10 +255,10 @@ impl NcPlane {
|
||||
&mut self,
|
||||
y_stop: NcDim,
|
||||
x_stop: NcDim,
|
||||
ul: NcChannelPair,
|
||||
ur: NcChannelPair,
|
||||
ll: NcChannelPair,
|
||||
lr: NcChannelPair,
|
||||
ul: NcChannels,
|
||||
ur: NcChannels,
|
||||
ll: NcChannels,
|
||||
lr: NcChannels,
|
||||
) -> NcResult<u32> {
|
||||
let res =
|
||||
unsafe { crate::ncplane_stain(self, y_stop as i32, x_stop as i32, ul, ur, ll, lr) };
|
||||
@ -404,49 +404,49 @@ impl NcPlane {
|
||||
|
||||
/// Marks the foreground as NOT using the default color.
|
||||
///
|
||||
/// Returns the new [`NcChannelPair`].
|
||||
/// Returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [ncplane_set_fg_not_default()][crate::ncplane_set_fg_not_default].*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn set_fg_not_default(&mut self) -> NcChannelPair {
|
||||
pub fn set_fg_not_default(&mut self) -> NcChannels {
|
||||
crate::ncplane_set_fg_not_default(self)
|
||||
}
|
||||
|
||||
/// Marks the background as NOT using the default color.
|
||||
///
|
||||
/// Returns the new [`NcChannelPair`].
|
||||
/// Returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [ncplane_set_bg_not_default()][crate::ncplane_set_bg_not_default].*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn set_bg_not_default(&mut self) -> NcChannelPair {
|
||||
pub fn set_bg_not_default(&mut self) -> NcChannels {
|
||||
crate::ncplane_set_bg_not_default(self)
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background as using the default color.
|
||||
///
|
||||
/// Returns the new [`NcChannelPair`].
|
||||
/// Returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [ncplane_set_default()][crate::ncplane_set_default].*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn set_default(&mut self) -> NcChannelPair {
|
||||
pub fn set_default(&mut self) -> NcChannels {
|
||||
crate::ncplane_set_default(self)
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background as NOT using the default color.
|
||||
///
|
||||
/// Returns the new [`NcChannelPair`].
|
||||
/// Returns the new [`NcChannels`].
|
||||
///
|
||||
/// *C style function: [ncplane_set_not_default()][crate::ncplane_set_not_default].*
|
||||
//
|
||||
// Not in the C API
|
||||
#[inline]
|
||||
pub fn set_not_default(&mut self) -> NcChannelPair {
|
||||
pub fn set_not_default(&mut self) -> NcChannels {
|
||||
crate::ncplane_set_not_default(self)
|
||||
}
|
||||
}
|
||||
@ -533,7 +533,7 @@ impl NcPlane {
|
||||
/// ## NcPlane methods: `NcCell` & `NcEgc`
|
||||
impl NcPlane {
|
||||
/// Retrieves the current contents of the [`NcCell`] under the cursor,
|
||||
/// returning the [`NcEgc`] and writing out the [`NcStyle`] and the [`NcChannelPair`].
|
||||
/// returning the [`NcEgc`] and writing out the [`NcStyle`] and the [`NcChannels`].
|
||||
///
|
||||
/// This NcEgc must be freed by the caller.
|
||||
///
|
||||
@ -541,7 +541,7 @@ impl NcPlane {
|
||||
pub fn at_cursor(
|
||||
&mut self,
|
||||
stylemask: &mut NcStyle,
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
) -> NcResult<NcEgc> {
|
||||
let egc = unsafe { crate::ncplane_at_cursor(self, stylemask, channels) };
|
||||
if egc.is_null() {
|
||||
@ -571,7 +571,7 @@ impl NcPlane {
|
||||
}
|
||||
|
||||
/// Retrieves the current contents of the specified [`NcCell`], returning the
|
||||
/// [`NcEgc`] and writing out the [`NcStyle`] and the [`NcChannelPair`].
|
||||
/// [`NcEgc`] and writing out the [`NcStyle`] and the [`NcChannels`].
|
||||
///
|
||||
/// This NcEgc must be freed by the caller.
|
||||
///
|
||||
@ -581,7 +581,7 @@ impl NcPlane {
|
||||
y: NcDim,
|
||||
x: NcDim,
|
||||
stylemask: &mut NcStyle,
|
||||
channels: &mut NcChannelPair,
|
||||
channels: &mut NcChannels,
|
||||
) -> NcResult<NcEgc> {
|
||||
let egc = unsafe { crate::ncplane_at_yx(self, y as i32, x as i32, stylemask, channels) };
|
||||
if egc.is_null() {
|
||||
@ -645,7 +645,7 @@ impl NcPlane {
|
||||
&mut self,
|
||||
egc: &str,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
) -> NcResult<u32> {
|
||||
let res =
|
||||
unsafe { crate::ncplane_set_base(self, cstring![egc], stylemask as u32, channels) };
|
||||
@ -1761,7 +1761,7 @@ impl NcPlane {
|
||||
pub fn double_box(
|
||||
&mut self,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
y_stop: NcDim,
|
||||
x_stop: NcDim,
|
||||
boxmask: NcBoxMask,
|
||||
@ -1778,7 +1778,7 @@ impl NcPlane {
|
||||
pub fn double_box_sized(
|
||||
&mut self,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
y_len: NcDim,
|
||||
x_len: NcDim,
|
||||
boxmask: NcBoxMask,
|
||||
@ -1815,7 +1815,7 @@ impl NcPlane {
|
||||
pub fn perimeter_double(
|
||||
&mut self,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
boxmask: NcBoxMask,
|
||||
) -> NcResult<()> {
|
||||
error![crate::ncplane_perimeter_double(
|
||||
@ -1831,7 +1831,7 @@ impl NcPlane {
|
||||
pub fn perimeter_rounded(
|
||||
&mut self,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
boxmask: NcBoxMask,
|
||||
) -> NcResult<()> {
|
||||
error![crate::ncplane_perimeter_rounded(
|
||||
@ -1933,10 +1933,10 @@ impl NcPlane {
|
||||
&mut self,
|
||||
egc: &NcEgc,
|
||||
stylemask: NcStyle,
|
||||
ul: NcChannelPair,
|
||||
ur: NcChannelPair,
|
||||
ll: NcChannelPair,
|
||||
lr: NcChannelPair,
|
||||
ul: NcChannels,
|
||||
ur: NcChannels,
|
||||
ll: NcChannels,
|
||||
lr: NcChannels,
|
||||
y_stop: NcDim,
|
||||
x_stop: NcDim,
|
||||
) -> NcResult<NcDim> {
|
||||
|
@ -259,7 +259,7 @@ pub use reimplemented::*;
|
||||
///
|
||||
/// Methods:
|
||||
/// - [`NcAlphaBits`](#ncplane-methods-ncalphabits)
|
||||
/// - [`NcChannel` & `NcChannelPair`](#ncplane-methods-ncchannel)
|
||||
/// - [`NcChannel` & `NcChannels`](#ncplane-methods-ncchannel)
|
||||
/// - [`NcComponent`, `NcRgb` & default color](#ncplane-methods-nccomponent-ncrgb--default-color)
|
||||
/// - [`NcStyle` & `NcPaletteIndex`](#ncplane-methods-ncstylemask--paletteindex)
|
||||
/// - [`NcCell` & `NcEgc`](#ncplane-methods-nccell--ncegc)
|
||||
|
@ -3,7 +3,7 @@
|
||||
use core::ptr::null_mut;
|
||||
|
||||
use crate::{
|
||||
cstring, nccell_release, NcAlign, NcAlphaBits, NcBoxMask, NcCell, NcChannel, NcChannelPair,
|
||||
cstring, nccell_release, NcAlign, NcAlphaBits, NcBoxMask, NcCell, NcChannel, NcChannels,
|
||||
NcComponent, NcDim, NcEgc, NcIntResult, NcPlane, NcRgb, NcStyle, NCRESULT_ERR, NCRESULT_OK,
|
||||
};
|
||||
|
||||
@ -44,36 +44,36 @@ pub fn ncplane_bchannel(plane: &NcPlane) -> NcChannel {
|
||||
}
|
||||
|
||||
/// Sets the foreground [NcChannel] on an [NcPlane],
|
||||
/// and returns the new [NcChannelPair].
|
||||
/// and returns the new [NcChannels].
|
||||
///
|
||||
/// *Method: NcPlane.[set_fchannel()][NcPlane#method.set_fchannel].*
|
||||
#[inline]
|
||||
pub fn ncplane_set_fchannel(plane: &mut NcPlane, channel: NcChannel) -> NcChannelPair {
|
||||
pub fn ncplane_set_fchannel(plane: &mut NcPlane, channel: NcChannel) -> NcChannels {
|
||||
unsafe { crate::ffi::ncplane_set_fchannel(plane, channel) }
|
||||
}
|
||||
|
||||
/// Sets the background [NcChannel] on an [NcPlane],
|
||||
/// and returns the new [NcChannelPair].
|
||||
/// and returns the new [NcChannels].
|
||||
///
|
||||
/// *Method: NcPlane.[set_bchannel()][NcPlane#method.set_bchannel].*
|
||||
#[inline]
|
||||
pub fn ncplane_set_bchannel(plane: &mut NcPlane, channel: NcChannel) -> NcChannelPair {
|
||||
pub fn ncplane_set_bchannel(plane: &mut NcPlane, channel: NcChannel) -> NcChannels {
|
||||
unsafe { crate::ffi::ncplane_set_bchannel(plane, channel) }
|
||||
}
|
||||
|
||||
/// Gets the [NcChannelPair] of an [NcPlane].
|
||||
/// Gets the [NcChannels] of an [NcPlane].
|
||||
///
|
||||
/// *Method: NcPlane.[channels()][NcPlane#method.channels].*
|
||||
#[inline]
|
||||
pub fn ncplane_channels(plane: &NcPlane) -> NcChannelPair {
|
||||
pub fn ncplane_channels(plane: &NcPlane) -> NcChannels {
|
||||
unsafe { crate::ffi::ncplane_channels(plane) }
|
||||
}
|
||||
|
||||
/// Sets the [NcChannelPair] of an [NcPlane].
|
||||
/// Sets the [NcChannels] of an [NcPlane].
|
||||
///
|
||||
/// *Method: NcPlane.[set_channels()][NcPlane#method.set_channels].*
|
||||
#[inline]
|
||||
pub fn ncplane_set_channels(plane: &mut NcPlane, channels: NcChannelPair) {
|
||||
pub fn ncplane_set_channels(plane: &mut NcPlane, channels: NcChannels) {
|
||||
unsafe { crate::ffi::ncplane_set_channels(plane, channels) };
|
||||
}
|
||||
|
||||
@ -144,50 +144,50 @@ pub fn ncplane_bg_default_p(plane: &NcPlane) -> bool {
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background as using the "default color",
|
||||
/// and returns the new [NcChannelPair].
|
||||
/// and returns the new [NcChannels].
|
||||
///
|
||||
/// *Method: NcPlane.[set_default()][NcPlane#method.set_default].*
|
||||
//
|
||||
// Not in the C API.
|
||||
#[inline]
|
||||
pub fn ncplane_set_default(plane: &mut NcPlane) -> NcChannelPair {
|
||||
pub fn ncplane_set_default(plane: &mut NcPlane) -> NcChannels {
|
||||
let channels = crate::ncchannels_set_default(&mut ncplane_channels(plane));
|
||||
ncplane_set_channels(plane, channels);
|
||||
channels
|
||||
}
|
||||
|
||||
/// Marks both the foreground and background as NOT using the "default color",
|
||||
/// and returns the new [NcChannelPair].
|
||||
/// and returns the new [NcChannels].
|
||||
///
|
||||
/// *Method: NcPlane.[set_not_default()][NcPlane#method.set_not_default].*
|
||||
//
|
||||
// Not in the C API.
|
||||
#[inline]
|
||||
pub fn ncplane_set_not_default(plane: &mut NcPlane) -> NcChannelPair {
|
||||
pub fn ncplane_set_not_default(plane: &mut NcPlane) -> NcChannels {
|
||||
let channels = crate::ncchannels_set_not_default(&mut ncplane_channels(plane));
|
||||
crate::ncplane_set_channels(plane, channels);
|
||||
channels
|
||||
}
|
||||
|
||||
/// Marks the foreground as NOT using the "default color",
|
||||
/// and returns the new [NcChannelPair].
|
||||
/// and returns the new [NcChannels].
|
||||
///
|
||||
/// *Method: NcPlane.[set_fg_not_default()][NcPlane#method.set_fg_not_default].*
|
||||
//
|
||||
// Not in the C API.
|
||||
#[inline]
|
||||
pub fn ncplane_set_fg_not_default(plane: &NcPlane) -> NcChannelPair {
|
||||
pub fn ncplane_set_fg_not_default(plane: &NcPlane) -> NcChannels {
|
||||
crate::ncchannels_set_fg_not_default(&mut ncplane_channels(plane))
|
||||
}
|
||||
|
||||
/// Marks the background as NOT using the "default color",
|
||||
/// and returns the new [NcChannelPair].
|
||||
/// and returns the new [NcChannels].
|
||||
///
|
||||
/// *Method: NcPlane.[set_bg_not_default()][NcPlane#method.set_bg_not_default].*
|
||||
//
|
||||
// Not in the C API.
|
||||
#[inline]
|
||||
pub fn ncplane_set_bg_not_default(plane: &NcPlane) -> NcChannelPair {
|
||||
pub fn ncplane_set_bg_not_default(plane: &NcPlane) -> NcChannels {
|
||||
crate::ncchannels_set_bg_not_default(&mut ncplane_channels(plane))
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ pub fn ncplane_perimeter(
|
||||
pub fn ncplane_perimeter_double(
|
||||
plane: &mut NcPlane,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
boxmask: NcBoxMask,
|
||||
) -> NcIntResult {
|
||||
if unsafe { crate::ncplane_cursor_move_yx(plane, 0, 0) } != NCRESULT_OK {
|
||||
@ -473,7 +473,7 @@ pub fn ncplane_perimeter_double(
|
||||
pub fn ncplane_perimeter_rounded(
|
||||
plane: &mut NcPlane,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
boxmask: NcBoxMask,
|
||||
) -> NcIntResult {
|
||||
if unsafe { crate::ncplane_cursor_move_yx(plane, 0, 0) } != NCRESULT_OK {
|
||||
@ -576,7 +576,7 @@ pub fn ncplane_box_sized(
|
||||
pub fn ncplane_double_box(
|
||||
plane: &mut NcPlane,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
y_stop: NcDim,
|
||||
x_stop: NcDim,
|
||||
boxmask: NcBoxMask,
|
||||
@ -635,7 +635,7 @@ pub fn ncplane_double_box(
|
||||
pub fn ncplane_double_box_sized(
|
||||
plane: &mut NcPlane,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
y_len: NcDim,
|
||||
x_len: NcDim,
|
||||
boxmask: NcBoxMask,
|
||||
@ -661,7 +661,7 @@ pub fn ncplane_double_box_sized(
|
||||
pub fn ncplane_rounded_box(
|
||||
plane: &mut NcPlane,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
y_stop: NcDim,
|
||||
x_stop: NcDim,
|
||||
boxmask: NcBoxMask,
|
||||
@ -719,7 +719,7 @@ pub fn ncplane_rounded_box(
|
||||
pub fn ncplane_rounded_box_sized(
|
||||
plane: &mut NcPlane,
|
||||
stylemask: NcStyle,
|
||||
channels: NcChannelPair,
|
||||
channels: NcChannels,
|
||||
y_len: NcDim,
|
||||
x_len: NcDim,
|
||||
boxmask: NcBoxMask,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{NcChannelPair, NcMenuOptions, NcMenuSection};
|
||||
use crate::{NcChannels, NcMenuOptions, NcMenuSection};
|
||||
|
||||
/// # `NcMenuOptions` constructors
|
||||
impl NcMenuOptions {
|
||||
@ -14,8 +14,8 @@ impl NcMenuOptions {
|
||||
/// `sections` must contain at least 1 [NcMenuSection].
|
||||
pub fn with_all_args(
|
||||
sections: &mut [NcMenuSection],
|
||||
style_header: NcChannelPair,
|
||||
style_sections: NcChannelPair,
|
||||
style_header: NcChannels,
|
||||
style_sections: NcChannels,
|
||||
flags: u64,
|
||||
) -> Self {
|
||||
assert![!sections.is_empty()];
|
||||
@ -43,28 +43,28 @@ impl NcMenuOptions {
|
||||
/// Returns the styling for the header.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
pub const fn header_channels(&self) -> NcChannelPair {
|
||||
pub const fn header_channels(&self) -> NcChannels {
|
||||
self.headerchannels
|
||||
}
|
||||
|
||||
/// Returns a mutable reference of the styling for the sections.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
pub fn header_channels_mut(&mut self) -> &mut NcChannelPair {
|
||||
pub fn header_channels_mut(&mut self) -> &mut NcChannels {
|
||||
&mut self.headerchannels
|
||||
}
|
||||
|
||||
/// Returns the styling for the sections.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
pub const fn section_channels(&self) -> NcChannelPair {
|
||||
pub const fn section_channels(&self) -> NcChannels {
|
||||
self.sectionchannels
|
||||
}
|
||||
|
||||
/// Returns a mutable reference of the styling for the sections.
|
||||
///
|
||||
/// *(No equivalent C style function)*
|
||||
pub fn section_channels_mut(&mut self) -> &mut NcChannelPair {
|
||||
pub fn section_channels_mut(&mut self) -> &mut NcChannels {
|
||||
&mut self.sectionchannels
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user