mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
roll back wayward sed on rust
This commit is contained in:
parent
309d211cde
commit
ca4a1c7fd8
@ -227,7 +227,7 @@ impl NcCell {
|
||||
/// Sets the background [NcPaletteIndex].
|
||||
///
|
||||
/// Also sets [NCCELL_BG_PALETTE][crate::NCCELL_BG_PALETTE] and
|
||||
/// [NCNCALPHA_OPAQUE][crate::NCNCALPHA_OPAQUE], and clears out
|
||||
/// [NCCELL_OPAQUE][crate::NCCELL_OPAQUE], and clears out
|
||||
/// [NCCELL_BGDEFAULT_MASK][crate::NCCELL_BGDEFAULT_MASK].
|
||||
///
|
||||
/// *C style function: [nccell_set_bg_palindex()][crate::nccell_set_bg_palindex].*
|
||||
@ -267,7 +267,7 @@ impl NcCell {
|
||||
/// Sets the foreground [NcPaletteIndex].
|
||||
///
|
||||
/// Also sets [NCCELL_FG_PALETTE][crate::NCCELL_FG_PALETTE] and
|
||||
/// [NCNCALPHA_OPAQUE][crate::NCNCALPHA_OPAQUE], and clears out
|
||||
/// [NCCELL_OPAQUE][crate::NCCELL_OPAQUE], and clears out
|
||||
/// [NCCELL_BGDEFAULT_MASK][crate::NCCELL_BGDEFAULT_MASK].
|
||||
///
|
||||
/// *C style function: [nccell_set_fg_palindex()][crate::nccell_set_fg_palindex].*
|
||||
|
@ -161,19 +161,19 @@ pub use reimplemented::*;
|
||||
/// have two bits of inverted alpha. The actual grapheme written to a cell is
|
||||
/// the topmost non-zero grapheme.
|
||||
///
|
||||
/// - If its alpha is 00 ([`NCNCALPHA_OPAQUE`]) its foreground color is used unchanged.
|
||||
/// - If its alpha is 00 ([`NCCELL_OPAQUE`]) its foreground color is used unchanged.
|
||||
///
|
||||
/// - If its alpha is 10 ([`NCNCALPHA_TRANSPARENT`]) its foreground color is derived
|
||||
/// - If its alpha is 10 ([`NCCELL_TRANSPARENT`]) its foreground color is derived
|
||||
/// entirely from cells underneath it.
|
||||
///
|
||||
/// - If its alpha is 01 ([`NCNCALPHA_BLEND`]) the result will be a composite.
|
||||
/// - If its alpha is 01 ([`NCCELL_BLEND`]) the result will be a composite.
|
||||
///
|
||||
/// Likewise for the background. If the bottom of a coordinate's zbuffer is
|
||||
/// reached with a cumulative alpha of zero, the default is used. In this way,
|
||||
/// a terminal configured with transparent background can be supported through
|
||||
/// multiple occluding ncplanes.
|
||||
///
|
||||
/// A foreground alpha of 11 ([`NCNCALPHA_HIGHCONTRAST`]) requests high-contrast
|
||||
/// A foreground alpha of 11 ([`NCCELL_HIGHCONTRAST`]) requests high-contrast
|
||||
/// text (relative to the computed background).
|
||||
/// A background alpha of 11 is currently forbidden.
|
||||
///
|
||||
@ -206,21 +206,21 @@ use crate::{NcAlphaBits, NcChannel, NcPlane};
|
||||
/// [`NcAlphaBits`] bits indicating
|
||||
/// [`NcCell`]'s foreground or background color will be a composite between
|
||||
/// its color and the `NcCell`s' corresponding colors underneath it
|
||||
pub const NCNCALPHA_BLEND: u32 = crate::bindings::ffi::NCALPHA_BLEND;
|
||||
pub const NCCELL_BLEND: u32 = crate::bindings::ffi::NCALPHA_BLEND;
|
||||
|
||||
/// [`NcAlphaBits`] bits indicating
|
||||
/// [`NcCell`]'s foreground color will be high-contrast (relative to the
|
||||
/// computed background). Background cannot be highcontrast
|
||||
pub const NCNCALPHA_HIGHCONTRAST: u32 = crate::bindings::ffi::NCALPHA_HIGHCONTRAST;
|
||||
pub const NCCELL_HIGHCONTRAST: u32 = crate::bindings::ffi::NCALPHA_HIGHCONTRAST;
|
||||
|
||||
/// [`NcAlphaBits`] bits indicating
|
||||
/// [`NcCell`]'s foreground or background color is used unchanged
|
||||
pub const NCNCALPHA_OPAQUE: u32 = crate::bindings::ffi::NCALPHA_OPAQUE;
|
||||
pub const NCCELL_OPAQUE: u32 = crate::bindings::ffi::NCALPHA_OPAQUE;
|
||||
|
||||
/// [`NcAlphaBits`] bits indicating
|
||||
/// [`NcCell`]'s foreground or background color is derived entirely from the
|
||||
/// `NcCell`s underneath it
|
||||
pub const NCNCALPHA_TRANSPARENT: u32 = crate::bindings::ffi::NCALPHA_TRANSPARENT;
|
||||
pub const NCCELL_TRANSPARENT: u32 = crate::bindings::ffi::NCALPHA_TRANSPARENT;
|
||||
|
||||
/// If this bit is set, we are *not* using the default background color
|
||||
///
|
||||
|
@ -4,7 +4,7 @@ use libc::strcmp;
|
||||
|
||||
use crate::{
|
||||
cstring, nccell_release, NcAlphaBits, NcCell, NcChannel, NcChannelPair, NcColor, NcEgc,
|
||||
NcIntResult, NcPaletteIndex, NcPlane, NcRgb, NcStyleMask, NCNCALPHA_OPAQUE,
|
||||
NcIntResult, NcPaletteIndex, NcPlane, NcRgb, NcStyleMask, NCCELL_OPAQUE,
|
||||
NCCELL_BGDEFAULT_MASK, NCCELL_BG_PALETTE, NCCELL_FGDEFAULT_MASK, NCCELL_FG_PALETTE,
|
||||
NCRESULT_ERR, NCRESULT_OK, NCSTYLE_MASK,
|
||||
};
|
||||
@ -208,7 +208,7 @@ pub const fn nccell_bg_palindex(cell: &NcCell) -> NcPaletteIndex {
|
||||
|
||||
/// Sets an [NcCell]'s foreground [NcPaletteIndex].
|
||||
///
|
||||
/// Also sets [NCCELL_FG_PALETTE] and [NCNCALPHA_OPAQUE],
|
||||
/// Also sets [NCCELL_FG_PALETTE] and [NCCELL_OPAQUE],
|
||||
/// and clears out [NCCELL_FGDEFAULT_MASK].
|
||||
///
|
||||
/// *Method: NcCell.[set_fg_palindex()][NcCell#method.set_fg_palindex].*
|
||||
@ -219,14 +219,14 @@ pub const fn nccell_bg_palindex(cell: &NcCell) -> NcPaletteIndex {
|
||||
pub fn nccell_set_fg_palindex(cell: &mut NcCell, index: NcPaletteIndex) {
|
||||
cell.channels |= NCCELL_FGDEFAULT_MASK;
|
||||
cell.channels |= NCCELL_FG_PALETTE;
|
||||
nccell_set_fg_alpha(cell, NCNCALPHA_OPAQUE);
|
||||
nccell_set_fg_alpha(cell, NCCELL_OPAQUE);
|
||||
cell.channels &= 0xff000000ffffffff as NcChannelPair;
|
||||
cell.channels |= (index as NcChannelPair) << 32;
|
||||
}
|
||||
|
||||
/// Sets an [NcCell]'s background [NcPaletteIndex].
|
||||
///
|
||||
/// Also sets [NCCELL_BG_PALETTE] and [NCNCALPHA_OPAQUE],
|
||||
/// Also sets [NCCELL_BG_PALETTE] and [NCCELL_OPAQUE],
|
||||
/// and clears out [NCCELL_BGDEFAULT_MASK].
|
||||
///
|
||||
/// *Method: NcCell.[set_bg_palindex()][NcCell#method.set_bg_palindex].*
|
||||
@ -236,7 +236,7 @@ pub fn nccell_set_fg_palindex(cell: &mut NcCell, index: NcPaletteIndex) {
|
||||
pub fn nccell_set_bg_palindex(cell: &mut NcCell, index: NcPaletteIndex) {
|
||||
cell.channels |= NCCELL_BGDEFAULT_MASK as NcChannelPair;
|
||||
cell.channels |= NCCELL_BG_PALETTE as NcChannelPair;
|
||||
nccell_set_bg_alpha(cell, NCNCALPHA_OPAQUE);
|
||||
nccell_set_bg_alpha(cell, NCCELL_OPAQUE);
|
||||
cell.channels &= 0xffffffffff000000;
|
||||
cell.channels |= index as NcChannelPair;
|
||||
}
|
||||
|
@ -41,11 +41,11 @@ fn alpha() {
|
||||
assert_eq![0, crate::nccell_fg_alpha(&c1)];
|
||||
assert_eq![0, crate::nccell_bg_alpha(&c1)];
|
||||
|
||||
crate::nccell_set_fg_alpha(&mut c1, crate::NCNCALPHA_TRANSPARENT);
|
||||
assert_eq![crate::NCNCALPHA_TRANSPARENT, crate::nccell_fg_alpha(&c1)];
|
||||
crate::nccell_set_fg_alpha(&mut c1, crate::NCCELL_TRANSPARENT);
|
||||
assert_eq![crate::NCCELL_TRANSPARENT, crate::nccell_fg_alpha(&c1)];
|
||||
|
||||
crate::nccell_set_bg_alpha(&mut c1, crate::NCNCALPHA_BLEND);
|
||||
assert_eq![crate::NCNCALPHA_BLEND, crate::nccell_bg_alpha(&c1)];
|
||||
crate::nccell_set_bg_alpha(&mut c1, crate::NCCELL_BLEND);
|
||||
assert_eq![crate::NCCELL_BLEND, crate::nccell_bg_alpha(&c1)];
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::{
|
||||
NcAlphaBits, NcChannel, NcChannelPair, NcColor, NcPaletteIndex, NcRgb,
|
||||
NCNCALPHA_HIGHCONTRAST, NCNCALPHA_OPAQUE, NCCELL_BGDEFAULT_MASK, NCCELL_BG_PALETTE,
|
||||
NCCELL_HIGHCONTRAST, NCCELL_OPAQUE, NCCELL_BGDEFAULT_MASK, NCCELL_BG_PALETTE,
|
||||
NCCELL_BG_RGB_MASK, NCCELL_FGDEFAULT_MASK, NCCELL_FG_PALETTE, NCCHANNEL_ALPHA_MASK,
|
||||
};
|
||||
|
||||
@ -24,7 +24,7 @@ pub fn ncchannel_set_alpha(channel: &mut NcChannel, alpha: NcAlphaBits) {
|
||||
let alpha_clean = alpha & NCCHANNEL_ALPHA_MASK;
|
||||
*channel = alpha_clean | (*channel & !NCCHANNEL_ALPHA_MASK);
|
||||
|
||||
if alpha != NCNCALPHA_OPAQUE {
|
||||
if alpha != NCCELL_OPAQUE {
|
||||
// indicate that we are *not* using the default background color
|
||||
*channel |= NCCELL_BGDEFAULT_MASK;
|
||||
}
|
||||
@ -62,9 +62,9 @@ pub fn ncchannels_set_fg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits)
|
||||
#[inline]
|
||||
pub fn ncchannels_set_bg_alpha(channels: &mut NcChannelPair, alpha: NcAlphaBits) {
|
||||
let mut alpha_clean = alpha;
|
||||
if alpha == NCNCALPHA_HIGHCONTRAST {
|
||||
if alpha == NCCELL_HIGHCONTRAST {
|
||||
// forbidden for background alpha, so makes it opaque
|
||||
alpha_clean = NCNCALPHA_OPAQUE;
|
||||
alpha_clean = NCCELL_OPAQUE;
|
||||
}
|
||||
let mut channel = ncchannels_bchannel(*channels);
|
||||
ncchannel_set_alpha(&mut channel, alpha_clean);
|
||||
@ -345,7 +345,7 @@ pub const fn ncchannel_default_p(channel: NcChannel) -> bool {
|
||||
/// *Method: NcChannel.[set_default()][NcChannel#method.set_default]*
|
||||
#[inline]
|
||||
pub fn ncchannel_set_default(channel: &mut NcChannel) -> NcChannel {
|
||||
*channel &= !(NCCELL_BGDEFAULT_MASK | NCNCALPHA_HIGHCONTRAST);
|
||||
*channel &= !(NCCELL_BGDEFAULT_MASK | NCCELL_HIGHCONTRAST);
|
||||
*channel
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ pub fn ncchannels_bg_palindex_p(channels: NcChannelPair) -> bool {
|
||||
pub fn ncchannels_set_fg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
||||
*channels |= NCCELL_FGDEFAULT_MASK;
|
||||
*channels |= NCCELL_FG_PALETTE as NcChannelPair;
|
||||
ncchannels_set_fg_alpha(channels, NCNCALPHA_OPAQUE);
|
||||
ncchannels_set_fg_alpha(channels, NCCELL_OPAQUE);
|
||||
*channels &= 0xff000000ffffffff as NcChannelPair;
|
||||
*channels |= (index as NcChannelPair) << 32;
|
||||
}
|
||||
@ -504,7 +504,7 @@ pub fn ncchannels_set_fg_palindex(channels: &mut NcChannelPair, index: NcPalette
|
||||
pub fn ncchannels_set_bg_palindex(channels: &mut NcChannelPair, index: NcPaletteIndex) {
|
||||
*channels |= NCCELL_BGDEFAULT_MASK as NcChannelPair;
|
||||
*channels |= NCCELL_BG_PALETTE as NcChannelPair;
|
||||
ncchannels_set_bg_alpha(channels, NCNCALPHA_OPAQUE);
|
||||
ncchannels_set_bg_alpha(channels, NCCELL_OPAQUE);
|
||||
*channels &= 0xffffffffff000000;
|
||||
*channels |= index as NcChannelPair;
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
use serial_test::serial;
|
||||
|
||||
use crate::{
|
||||
NcChannel, NcChannelPair, NCNCALPHA_BLEND, NCNCALPHA_HIGHCONTRAST, NCNCALPHA_OPAQUE,
|
||||
NCNCALPHA_TRANSPARENT,
|
||||
NcChannel, NcChannelPair, NCCELL_BLEND, NCCELL_HIGHCONTRAST, NCCELL_OPAQUE,
|
||||
NCCELL_TRANSPARENT,
|
||||
};
|
||||
|
||||
// NcChannel tests -------------------------------------------------------------
|
||||
@ -89,10 +89,10 @@ fn channel_set() {
|
||||
#[serial]
|
||||
fn channel_alpha() {
|
||||
let c: NcChannel = 0x112233;
|
||||
assert_ne!(crate::ncchannel_alpha(c), NCNCALPHA_TRANSPARENT);
|
||||
assert_ne!(crate::ncchannel_alpha(c), NCCELL_TRANSPARENT);
|
||||
|
||||
let c: NcChannel = 0x112233 | NCNCALPHA_TRANSPARENT;
|
||||
assert_eq!(crate::ncchannel_alpha(c), NCNCALPHA_TRANSPARENT);
|
||||
let c: NcChannel = 0x112233 | NCCELL_TRANSPARENT;
|
||||
assert_eq!(crate::ncchannel_alpha(c), NCCELL_TRANSPARENT);
|
||||
}
|
||||
|
||||
/// sets the alpha component
|
||||
@ -100,17 +100,17 @@ fn channel_alpha() {
|
||||
#[serial]
|
||||
fn channel_set_alpha() {
|
||||
let mut c: NcChannel = 0x112233;
|
||||
crate::ncchannel_set_alpha(&mut c, NCNCALPHA_HIGHCONTRAST);
|
||||
assert_eq!(NCNCALPHA_HIGHCONTRAST, crate::ncchannel_alpha(c));
|
||||
crate::ncchannel_set_alpha(&mut c, NCCELL_HIGHCONTRAST);
|
||||
assert_eq!(NCCELL_HIGHCONTRAST, crate::ncchannel_alpha(c));
|
||||
|
||||
crate::ncchannel_set_alpha(&mut c, NCNCALPHA_TRANSPARENT);
|
||||
assert_eq!(NCNCALPHA_TRANSPARENT, crate::ncchannel_alpha(c));
|
||||
crate::ncchannel_set_alpha(&mut c, NCCELL_TRANSPARENT);
|
||||
assert_eq!(NCCELL_TRANSPARENT, crate::ncchannel_alpha(c));
|
||||
|
||||
crate::ncchannel_set_alpha(&mut c, NCNCALPHA_BLEND);
|
||||
assert_eq!(NCNCALPHA_BLEND, crate::ncchannel_alpha(c));
|
||||
crate::ncchannel_set_alpha(&mut c, NCCELL_BLEND);
|
||||
assert_eq!(NCCELL_BLEND, crate::ncchannel_alpha(c));
|
||||
|
||||
crate::ncchannel_set_alpha(&mut c, NCNCALPHA_OPAQUE);
|
||||
assert_eq!(NCNCALPHA_OPAQUE, crate::ncchannel_alpha(c));
|
||||
crate::ncchannel_set_alpha(&mut c, NCCELL_OPAQUE);
|
||||
assert_eq!(NCCELL_OPAQUE, crate::ncchannel_alpha(c));
|
||||
// TODO: CHECK for NCCELL_BGDEFAULT_MASK
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ fn channel_set_default() {
|
||||
assert_eq!(true, crate::ncchannel_default_p(channel));
|
||||
|
||||
// If we change it from being opaque...
|
||||
let mut channel_transp = channel | NCNCALPHA_TRANSPARENT;
|
||||
let mut channel_transp = channel | NCCELL_TRANSPARENT;
|
||||
assert_eq!(0x_20_112233, channel_transp); // the transparent bit is now set
|
||||
|
||||
crate::ncchannel_set_not_default(&mut channel_transp);
|
||||
@ -162,7 +162,7 @@ fn channel_default_p() {
|
||||
let mut c: NcChannel = 0x112233;
|
||||
assert_eq!(true, crate::ncchannel_default_p(c));
|
||||
|
||||
let _ = crate::ncchannel_set_alpha(&mut c, NCNCALPHA_OPAQUE);
|
||||
let _ = crate::ncchannel_set_alpha(&mut c, NCCELL_OPAQUE);
|
||||
assert_eq!(true, crate::ncchannel_default_p(c));
|
||||
|
||||
crate::ncchannel_set(&mut c, 0x112233);
|
||||
|
@ -134,7 +134,7 @@ pub type NcRgba = u32;
|
||||
/// Treats as transparent the color specified in the `transcolor` field.
|
||||
pub const NCVISUAL_OPTION_ADDALPHA: u32 = crate::bindings::ffi::NCVISUAL_OPTION_ADDALPHA;
|
||||
|
||||
/// Uses [`NCNCALPHA_BLEND`][crate::NCNCALPHA_BLEND] with visual.
|
||||
/// Uses [`NCCELL_BLEND`][crate::NCCELL_BLEND] with visual.
|
||||
pub const NCVISUAL_OPTION_BLEND: u32 = crate::bindings::ffi::NCVISUAL_OPTION_BLEND;
|
||||
|
||||
/// allows you to indicate that the n field of ncvisual_options refers not to
|
||||
|
Loading…
x
Reference in New Issue
Block a user