From cadd4aefee1fdd54a4fadb08389d4d830f3202b0 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 10 Jun 2021 03:02:30 -0400 Subject: [PATCH] s/CELL_ALPHA_/NCCELL_ALPHA_/g --- NEWS.md | 4 + USAGE.md | 14 +-- doc/HACKING.md | 2 +- doc/man/man3/notcurses_cell.3.md | 22 ++--- doc/man/man3/notcurses_render.3.md | 4 +- doc/man/man3/notcurses_visual.3.md | 2 +- include/notcurses/notcurses.h | 23 +++-- rust/src/bindings.rs | 8 +- rust/src/cells/methods.rs | 4 +- rust/src/cells/mod.rs | 16 +-- rust/src/cells/reimplemented.rs | 10 +- rust/src/cells/test/reimplemented.rs | 8 +- rust/src/channel/reimplemented.rs | 14 +-- rust/src/channel/test/reimplemented.rs | 30 +++--- rust/src/visual/mod.rs | 2 +- src/demo/boxdemo.c | 4 +- src/demo/chunli.c | 4 +- src/demo/eagle.c | 4 +- src/demo/highcon.c | 8 +- src/demo/hud.c | 52 +++++----- src/demo/keller.c | 4 +- src/demo/luigi.c | 8 +- src/demo/outro.c | 8 +- src/demo/reel.c | 4 +- src/demo/trans.c | 22 ++--- src/demo/unicodeblocks.c | 10 +- src/demo/view.c | 10 +- src/demo/whiteout.c | 8 +- src/demo/xray.c | 10 +- src/demo/yield.c | 6 +- src/demo/zoo.c | 12 +-- src/lib/blit.c | 44 ++++----- src/lib/debug.c | 16 ++- src/lib/direct.c | 7 +- src/lib/internal.h | 9 +- src/lib/menu.c | 4 +- src/lib/notcurses.c | 7 +- src/lib/render.c | 30 +++--- src/lib/selector.c | 8 +- src/lib/termdesc.c | 130 +++++++++++-------------- src/lib/termdesc.h | 2 - src/player/play.cpp | 12 +-- src/poc/multiselect.c | 4 +- src/poc/selector.c | 4 +- src/poc/textplay.c | 4 +- src/poc/wipebitmap.c | 4 +- src/tests/bitmap.cpp | 4 +- src/tests/cell.cpp | 46 ++++----- src/tests/channel.cpp | 12 +-- src/tests/notcurses.cpp | 18 ++-- src/tests/palette.cpp | 16 +-- src/tests/plot.cpp | 20 ++-- src/tests/reel.cpp | 2 +- src/tests/rotate.cpp | 4 +- src/tests/wide.cpp | 2 +- src/tetris/background.h | 10 +- src/tetris/newpiece.h | 6 +- 57 files changed, 369 insertions(+), 393 deletions(-) diff --git a/NEWS.md b/NEWS.md index cb65d2799..7442b02c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ This document attempts to list user-visible changes and any major internal rearrangements of Notcurses. +* 2.3.5 (not yet released) + * `CELL_ALPHA_*` macros are now `NCALPHA_*`. The former will remain + `#define`d until ABI3. + * 2.3.4 (2021-06-12) * Added the flag `NCVISUAL_OPTION_NOINTERPOLATE` to use non-interpolative scaling in `ncvisual_render()`. `ncvisual_render()` without a multimedia diff --git a/USAGE.md b/USAGE.md index 59d01ea98..8f39d227a 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1832,10 +1832,10 @@ typedef struct nccell { #define CELL_BG_PALETTE 0x0000000008000000ull #define CELL_FG_PALETTE (CELL_BG_PALETTE << 32u) #define NCCHANNEL_ALPHA_MASK 0x30000000ull -#define CELL_ALPHA_HIGHCONTRAST 0x30000000ull -#define CELL_ALPHA_TRANSPARENT 0x20000000ull -#define CELL_ALPHA_BLEND 0x10000000ull -#define CELL_ALPHA_OPAQUE 0x00000000ull +#define NCALPHA_HIGHCONTRAST 0x30000000ull +#define NCALPHA_TRANSPARENT 0x20000000ull +#define NCALPHA_BLEND 0x10000000ull +#define NCALPHA_OPAQUE 0x00000000ull ``` `nccell`s must be initialized with an initialization macro or `nccell_init()` @@ -2888,7 +2888,7 @@ channel_set_alpha(unsigned* channel, unsigned alpha){ return -1; } *channel = alpha | (*channel & ~CHANNEL_ALPHA_MASK); - if(alpha != CELL_ALPHA_OPAQUE){ + if(alpha != NCALPHA_OPAQUE){ *channel |= CELL_BGDEFAULT_MASK; } return 0; @@ -3013,7 +3013,7 @@ ncchannels_set_fg_alpha(uint64_t* channels, unsigned alpha){ // Set the 2-bit alpha component of the background channel. static inline int ncchannels_set_bg_alpha(uint64_t* channels, unsigned alpha){ - if(alpha == CELL_ALPHA_HIGHCONTRAST){ // forbidden for background alpha + if(alpha == NCALPHA_HIGHCONTRAST){ // forbidden for background alpha return -1; } unsigned channel = ncchannels_bchannel(*channels); @@ -3185,7 +3185,7 @@ int notcurses_lex_blitter(const char* op, ncblitter_e* blitter); const char* notcurses_str_blitter(ncblitter_e blitter); #define NCVISUAL_OPTION_NODEGRADE 0x0001ull // fail rather than degrade -#define NCVISUAL_OPTION_BLEND 0x0002ull // use CELL_ALPHA_BLEND +#define NCVISUAL_OPTION_BLEND 0x0002ull // use NCALPHA_BLEND #define NCVISUAL_OPTION_HORALIGNED 0x0004ull // x is an alignment, not abs #define NCVISUAL_OPTION_VERALIGNED 0x0008ull // y is an alignment, not abs #define NCVISUAL_OPTION_ADDALPHA 0x0010ull // transcolor is in effect diff --git a/doc/HACKING.md b/doc/HACKING.md index 1487036da..540e43167 100644 --- a/doc/HACKING.md +++ b/doc/HACKING.md @@ -193,7 +193,7 @@ there is no resize step between rasterizing and writing, writing deals with the same geometries as rasterization, so we ignore it. Rasterization can be split into two virtual phases: *postpaint* and *rastering*. -*postpaint* corrects for `CELL_ALPHA_HIGHCONTRAST`, performs damage detection, +*postpaint* corrects for `NCALPHA_HIGHCONTRAST`, performs damage detection, and copies any necessary EGCs from their source pools to the common pool (copying these EGCs is why a pile cannot be modified between rendering and rasterizing--such modifications might invalidate the EGC references). The diff --git a/doc/man/man3/notcurses_cell.3.md b/doc/man/man3/notcurses_cell.3.md index 131f4034f..e6efe4726 100644 --- a/doc/man/man3/notcurses_cell.3.md +++ b/doc/man/man3/notcurses_cell.3.md @@ -27,17 +27,17 @@ typedef struct nccell { #define CELL_INITIALIZER(c, s, chan) \ { .gcluster = (c), .stylemask = (s), .channels = (chan), } -#define CELL_BGDEFAULT_MASK 0x0000000040000000ull -#define CELL_FGDEFAULT_MASK (CELL_BGDEFAULT_MASK << 32u) -#define CELL_BG_RGB_MASK 0x0000000000ffffffull -#define CELL_FG_RGB_MASK (CELL_BG_MASK << 32u) -#define CELL_BG_PALETTE 0x0000000008000000ull -#define CELL_FG_PALETTE (CELL_BG_PALETTE << 32u) -#define CHANNEL_ALPHA_MASK 0x30000000ull -#define CELL_ALPHA_HIGHCONTRAST 0x30000000ull -#define CELL_ALPHA_TRANSPARENT 0x20000000ull -#define CELL_ALPHA_BLEND 0x10000000ull -#define CELL_ALPHA_OPAQUE 0x00000000ull +#define CELL_BGDEFAULT_MASK 0x0000000040000000ull +#define CELL_FGDEFAULT_MASK (CELL_BGDEFAULT_MASK << 32u) +#define CELL_BG_RGB_MASK 0x0000000000ffffffull +#define CELL_FG_RGB_MASK (CELL_BG_MASK << 32u) +#define CELL_BG_PALETTE 0x0000000008000000ull +#define CELL_FG_PALETTE (CELL_BG_PALETTE << 32u) +#define CHANNEL_ALPHA_MASK 0x30000000ull +#define NCALPHA_HIGHCONTRAST 0x30000000ull +#define NCALPHA_TRANSPARENT 0x20000000ull +#define NCALPHA_BLEND 0x10000000ull +#define NCALPHA_OPAQUE 0x00000000ull ``` **void nccell_init(nccell* ***c***);** diff --git a/doc/man/man3/notcurses_render.3.md b/doc/man/man3/notcurses_render.3.md index f7335c949..2c870fd3e 100644 --- a/doc/man/man3/notcurses_render.3.md +++ b/doc/man/man3/notcurses_render.3.md @@ -85,8 +85,8 @@ At each plane **P**, we consider a cell **C**. This cell is the intersecting cel unless that cell has no EGC. In that case, **C** is the plane's default cell. * If we have not yet determined an EGC, and **C** has a non-zero EGC, use the EGC and style of **C**. -* If we have not yet locked in a foreground color, and **C** is not foreground-transparent, use the foreground color of **C** (see [BUGS][] below). If **C** is **CELL_ALPHA_OPAQUE**, lock the color in. -* If we have not yet locked in a background color, and **C** is not background-transparent, use the background color of **C** (see [BUGS][] below). If **C** is **CELL_ALPHA_OPAQUE**, lock the color in. +* If we have not yet locked in a foreground color, and **C** is not foreground-transparent, use the foreground color of **C** (see [BUGS][] below). If **C** is **NCALPHA_OPAQUE**, lock the color in. +* If we have not yet locked in a background color, and **C** is not background-transparent, use the background color of **C** (see [BUGS][] below). If **C** is **NCALPHA_OPAQUE**, lock the color in. If the algorithm concludes without an EGC, the cell is rendered with no glyph and a default background. If the algorithm concludes without a color locked in, diff --git a/doc/man/man3/notcurses_visual.3.md b/doc/man/man3/notcurses_visual.3.md index c3480a025..4a3dd72e3 100644 --- a/doc/man/man3/notcurses_visual.3.md +++ b/doc/man/man3/notcurses_visual.3.md @@ -150,7 +150,7 @@ subsection of the **ncvisual** to render, while ***leny***/***lenx*** specify th geometry of same. ***flags*** is a bitfield over: * **NCVISUAL_OPTION_NODEGRADE** If the specified blitter is not available, fail rather than degrading. -* **NCVISUAL_OPTION_BLEND**: Render with **CELL_ALPHA_BLEND**. Not available with +* **NCVISUAL_OPTION_BLEND**: Render with **NCALPHA_BLEND**. Not available with **NCBLIT_PIXEL** when using Sixel graphics. When used with **NCBLIT_PIXEL** when using Kitty graphics, the alpha channel is divided by 2 for each pixel. * **NCVISUAL_OPTION_HORALIGNED**: Interpret ***x*** as an **ncalign_e**. diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 70ef5571a..0161a2c7f 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -113,10 +113,10 @@ API int notcurses_ucs32_to_utf8(const char32_t* ucs32, unsigned ucs32count, unsigned char* resultbuf, size_t buflen); // background cannot be highcontrast, only foreground -#define CELL_ALPHA_HIGHCONTRAST 0x30000000ull -#define CELL_ALPHA_TRANSPARENT 0x20000000ull -#define CELL_ALPHA_BLEND 0x10000000ull -#define CELL_ALPHA_OPAQUE 0x00000000ull +#define NCALPHA_HIGHCONTRAST 0x30000000ull +#define NCALPHA_TRANSPARENT 0x20000000ull +#define NCALPHA_BLEND 0x10000000ull +#define NCALPHA_OPAQUE 0x00000000ull // if this bit is set, we are *not* using the default background color #define CELL_BGDEFAULT_MASK 0x0000000040000000ull @@ -248,7 +248,7 @@ ncchannel_set_alpha(unsigned* channel, unsigned alpha){ return -1; } *channel = alpha | (*channel & ~CELL_BG_ALPHA_MASK); - if(alpha != CELL_ALPHA_OPAQUE){ + if(alpha != NCALPHA_OPAQUE){ *channel |= CELL_BGDEFAULT_MASK; } return 0; @@ -261,7 +261,7 @@ ncchannel_set_palindex(uint32_t* channel, int idx){ } *channel |= CELL_BGDEFAULT_MASK; *channel |= CELL_BG_PALETTE; - ncchannel_set_alpha(channel, CELL_ALPHA_OPAQUE); + ncchannel_set_alpha(channel, NCALPHA_OPAQUE); *channel &= 0xff000000ull; *channel |= idx; return 0; @@ -282,7 +282,7 @@ ncchannel_palindex_p(unsigned channel){ // Mark the channel as using its default color, which also marks it opaque. static inline unsigned ncchannel_set_default(unsigned* channel){ - return *channel &= ~(CELL_BGDEFAULT_MASK | CELL_ALPHA_HIGHCONTRAST); + return *channel &= ~(CELL_BGDEFAULT_MASK | NCALPHA_HIGHCONTRAST); } // Extract the 32-bit background channel from a channel pair. @@ -438,7 +438,7 @@ ncchannels_set_bg_rgb8_clipped(uint64_t* channels, int r, int g, int b){ // Set the 2-bit alpha component of the background channel. static inline int ncchannels_set_bg_alpha(uint64_t* channels, unsigned alpha){ - if(alpha == CELL_ALPHA_HIGHCONTRAST){ // forbidden for background alpha + if(alpha == NCALPHA_HIGHCONTRAST){ // forbidden for background alpha return -1; } uint32_t channel = ncchannels_bchannel(*channels); @@ -2480,7 +2480,7 @@ API ALLOC struct ncvisual* ncvisual_from_plane(const struct ncplane* n, int leny, int lenx); #define NCVISUAL_OPTION_NODEGRADE 0x0001ull // fail rather than degrade -#define NCVISUAL_OPTION_BLEND 0x0002ull // use CELL_ALPHA_BLEND with visual +#define NCVISUAL_OPTION_BLEND 0x0002ull // use NCALPHA_BLEND with visual #define NCVISUAL_OPTION_HORALIGNED 0x0004ull // x is an alignment, not absolute #define NCVISUAL_OPTION_VERALIGNED 0x0008ull // y is an alignment, not absolute #define NCVISUAL_OPTION_ADDALPHA 0x0010ull // transcolor is in effect @@ -4316,6 +4316,11 @@ typedef ncpalette palette256; typedef nccell cell; // FIXME backwards-compat, remove in ABI3 +#define CELL_ALPHA_HIGHCONTRAST NCALPHA_HIGHCONTRAST +#define CELL_ALPHA_TRANSPARENT NCALPHA_TRANSPARENT +#define CELL_ALPHA_BLEND NCALPHA_BLEND +#define CELL_ALPHA_OPAQUE NCALPHA_OPAQUE + #undef ALLOC #undef API diff --git a/rust/src/bindings.rs b/rust/src/bindings.rs index 43b809fea..0f7895b7e 100644 --- a/rust/src/bindings.rs +++ b/rust/src/bindings.rs @@ -40,10 +40,10 @@ pub use ffi::{ // cell, // // // constants -// CELL_ALPHA_BLEND, -// CELL_ALPHA_HIGHCONTRAST, -// CELL_ALPHA_OPAQUE, -// CELL_ALPHA_TRANSPARENT, +// NCALPHA_BLEND, +// NCALPHA_HIGHCONTRAST, +// NCALPHA_OPAQUE, +// NCALPHA_TRANSPARENT, // CELL_BGDEFAULT_MASK, // CELL_BG_ALPHA_MASK, // CELL_BG_PALETTE, diff --git a/rust/src/cells/methods.rs b/rust/src/cells/methods.rs index 4652e84bf..8028eb2e4 100644 --- a/rust/src/cells/methods.rs +++ b/rust/src/cells/methods.rs @@ -227,7 +227,7 @@ impl NcCell { /// Sets the background [NcPaletteIndex]. /// /// Also sets [NCCELL_BG_PALETTE][crate::NCCELL_BG_PALETTE] and - /// [NCCELL_ALPHA_OPAQUE][crate::NCCELL_ALPHA_OPAQUE], and clears out + /// [NCNCALPHA_OPAQUE][crate::NCNCALPHA_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 - /// [NCCELL_ALPHA_OPAQUE][crate::NCCELL_ALPHA_OPAQUE], and clears out + /// [NCNCALPHA_OPAQUE][crate::NCNCALPHA_OPAQUE], and clears out /// [NCCELL_BGDEFAULT_MASK][crate::NCCELL_BGDEFAULT_MASK]. /// /// *C style function: [nccell_set_fg_palindex()][crate::nccell_set_fg_palindex].* diff --git a/rust/src/cells/mod.rs b/rust/src/cells/mod.rs index bc2cb703e..c85586fc3 100644 --- a/rust/src/cells/mod.rs +++ b/rust/src/cells/mod.rs @@ -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 ([`NCCELL_ALPHA_OPAQUE`]) its foreground color is used unchanged. +/// - If its alpha is 00 ([`NCNCALPHA_OPAQUE`]) its foreground color is used unchanged. /// -/// - If its alpha is 10 ([`NCCELL_ALPHA_TRANSPARENT`]) its foreground color is derived +/// - If its alpha is 10 ([`NCNCALPHA_TRANSPARENT`]) its foreground color is derived /// entirely from cells underneath it. /// -/// - If its alpha is 01 ([`NCCELL_ALPHA_BLEND`]) the result will be a composite. +/// - If its alpha is 01 ([`NCNCALPHA_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 ([`NCCELL_ALPHA_HIGHCONTRAST`]) requests high-contrast +/// A foreground alpha of 11 ([`NCNCALPHA_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 NCCELL_ALPHA_BLEND: u32 = crate::bindings::ffi::CELL_ALPHA_BLEND; +pub const NCNCALPHA_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 NCCELL_ALPHA_HIGHCONTRAST: u32 = crate::bindings::ffi::CELL_ALPHA_HIGHCONTRAST; +pub const NCNCALPHA_HIGHCONTRAST: u32 = crate::bindings::ffi::NCALPHA_HIGHCONTRAST; /// [`NcAlphaBits`] bits indicating /// [`NcCell`]'s foreground or background color is used unchanged -pub const NCCELL_ALPHA_OPAQUE: u32 = crate::bindings::ffi::CELL_ALPHA_OPAQUE; +pub const NCNCALPHA_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 NCCELL_ALPHA_TRANSPARENT: u32 = crate::bindings::ffi::CELL_ALPHA_TRANSPARENT; +pub const NCNCALPHA_TRANSPARENT: u32 = crate::bindings::ffi::NCALPHA_TRANSPARENT; /// If this bit is set, we are *not* using the default background color /// diff --git a/rust/src/cells/reimplemented.rs b/rust/src/cells/reimplemented.rs index cee5b34e8..32c91cb95 100644 --- a/rust/src/cells/reimplemented.rs +++ b/rust/src/cells/reimplemented.rs @@ -4,7 +4,7 @@ use libc::strcmp; use crate::{ cstring, nccell_release, NcAlphaBits, NcCell, NcChannel, NcChannelPair, NcColor, NcEgc, - NcIntResult, NcPaletteIndex, NcPlane, NcRgb, NcStyleMask, NCCELL_ALPHA_OPAQUE, + NcIntResult, NcPaletteIndex, NcPlane, NcRgb, NcStyleMask, NCNCALPHA_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 [NCCELL_ALPHA_OPAQUE], +/// Also sets [NCCELL_FG_PALETTE] and [NCNCALPHA_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, NCCELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(cell, NCNCALPHA_OPAQUE); cell.channels &= 0xff000000ffffffff as NcChannelPair; cell.channels |= (index as NcChannelPair) << 32; } /// Sets an [NcCell]'s background [NcPaletteIndex]. /// -/// Also sets [NCCELL_BG_PALETTE] and [NCCELL_ALPHA_OPAQUE], +/// Also sets [NCCELL_BG_PALETTE] and [NCNCALPHA_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, NCCELL_ALPHA_OPAQUE); + nccell_set_bg_alpha(cell, NCNCALPHA_OPAQUE); cell.channels &= 0xffffffffff000000; cell.channels |= index as NcChannelPair; } diff --git a/rust/src/cells/test/reimplemented.rs b/rust/src/cells/test/reimplemented.rs index b03da33ea..afd822cca 100644 --- a/rust/src/cells/test/reimplemented.rs +++ b/rust/src/cells/test/reimplemented.rs @@ -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::NCCELL_ALPHA_TRANSPARENT); - assert_eq![crate::NCCELL_ALPHA_TRANSPARENT, crate::nccell_fg_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_bg_alpha(&mut c1, crate::NCCELL_ALPHA_BLEND); - assert_eq![crate::NCCELL_ALPHA_BLEND, crate::nccell_bg_alpha(&c1)]; + crate::nccell_set_bg_alpha(&mut c1, crate::NCNCALPHA_BLEND); + assert_eq![crate::NCNCALPHA_BLEND, crate::nccell_bg_alpha(&c1)]; } #[test] diff --git a/rust/src/channel/reimplemented.rs b/rust/src/channel/reimplemented.rs index 535453a17..69f506c05 100644 --- a/rust/src/channel/reimplemented.rs +++ b/rust/src/channel/reimplemented.rs @@ -2,7 +2,7 @@ use crate::{ NcAlphaBits, NcChannel, NcChannelPair, NcColor, NcPaletteIndex, NcRgb, - NCCELL_ALPHA_HIGHCONTRAST, NCCELL_ALPHA_OPAQUE, NCCELL_BGDEFAULT_MASK, NCCELL_BG_PALETTE, + NCNCALPHA_HIGHCONTRAST, NCNCALPHA_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 != NCCELL_ALPHA_OPAQUE { + if alpha != NCNCALPHA_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 == NCCELL_ALPHA_HIGHCONTRAST { + if alpha == NCNCALPHA_HIGHCONTRAST { // forbidden for background alpha, so makes it opaque - alpha_clean = NCCELL_ALPHA_OPAQUE; + alpha_clean = NCNCALPHA_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 | NCCELL_ALPHA_HIGHCONTRAST); + *channel &= !(NCCELL_BGDEFAULT_MASK | NCNCALPHA_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, NCCELL_ALPHA_OPAQUE); + ncchannels_set_fg_alpha(channels, NCNCALPHA_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, NCCELL_ALPHA_OPAQUE); + ncchannels_set_bg_alpha(channels, NCNCALPHA_OPAQUE); *channels &= 0xffffffffff000000; *channels |= index as NcChannelPair; } diff --git a/rust/src/channel/test/reimplemented.rs b/rust/src/channel/test/reimplemented.rs index 10a58cb89..a9bcd2573 100644 --- a/rust/src/channel/test/reimplemented.rs +++ b/rust/src/channel/test/reimplemented.rs @@ -3,8 +3,8 @@ use serial_test::serial; use crate::{ - NcChannel, NcChannelPair, NCCELL_ALPHA_BLEND, NCCELL_ALPHA_HIGHCONTRAST, NCCELL_ALPHA_OPAQUE, - NCCELL_ALPHA_TRANSPARENT, + NcChannel, NcChannelPair, NCNCALPHA_BLEND, NCNCALPHA_HIGHCONTRAST, NCNCALPHA_OPAQUE, + NCNCALPHA_TRANSPARENT, }; // NcChannel tests ------------------------------------------------------------- @@ -89,10 +89,10 @@ fn channel_set() { #[serial] fn channel_alpha() { let c: NcChannel = 0x112233; - assert_ne!(crate::ncchannel_alpha(c), NCCELL_ALPHA_TRANSPARENT); + assert_ne!(crate::ncchannel_alpha(c), NCNCALPHA_TRANSPARENT); - let c: NcChannel = 0x112233 | NCCELL_ALPHA_TRANSPARENT; - assert_eq!(crate::ncchannel_alpha(c), NCCELL_ALPHA_TRANSPARENT); + let c: NcChannel = 0x112233 | NCNCALPHA_TRANSPARENT; + assert_eq!(crate::ncchannel_alpha(c), NCNCALPHA_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, NCCELL_ALPHA_HIGHCONTRAST); - assert_eq!(NCCELL_ALPHA_HIGHCONTRAST, crate::ncchannel_alpha(c)); + crate::ncchannel_set_alpha(&mut c, NCNCALPHA_HIGHCONTRAST); + assert_eq!(NCNCALPHA_HIGHCONTRAST, crate::ncchannel_alpha(c)); - crate::ncchannel_set_alpha(&mut c, NCCELL_ALPHA_TRANSPARENT); - assert_eq!(NCCELL_ALPHA_TRANSPARENT, 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_ALPHA_BLEND); - assert_eq!(NCCELL_ALPHA_BLEND, 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_ALPHA_OPAQUE); - assert_eq!(NCCELL_ALPHA_OPAQUE, crate::ncchannel_alpha(c)); + crate::ncchannel_set_alpha(&mut c, NCNCALPHA_OPAQUE); + assert_eq!(NCNCALPHA_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 | NCCELL_ALPHA_TRANSPARENT; + let mut channel_transp = channel | NCNCALPHA_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, NCCELL_ALPHA_OPAQUE); + let _ = crate::ncchannel_set_alpha(&mut c, NCNCALPHA_OPAQUE); assert_eq!(true, crate::ncchannel_default_p(c)); crate::ncchannel_set(&mut c, 0x112233); diff --git a/rust/src/visual/mod.rs b/rust/src/visual/mod.rs index 8e63f3f43..569f17ce5 100644 --- a/rust/src/visual/mod.rs +++ b/rust/src/visual/mod.rs @@ -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 [`NCCELL_ALPHA_BLEND`][crate::NCCELL_ALPHA_BLEND] with visual. +/// Uses [`NCNCALPHA_BLEND`][crate::NCNCALPHA_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 diff --git a/src/demo/boxdemo.c b/src/demo/boxdemo.c index 965190f12..f04463597 100644 --- a/src/demo/boxdemo.c +++ b/src/demo/boxdemo.c @@ -165,8 +165,8 @@ int box_demo(struct notcurses* nc){ struct ncplane* n = notcurses_stddim_yx(nc, &ylen, &xlen); ncplane_erase(n); uint64_t transchan = 0; - ncchannels_set_bg_alpha(&transchan, CELL_ALPHA_TRANSPARENT); - ncchannels_set_fg_alpha(&transchan, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&transchan, NCALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&transchan, NCALPHA_TRANSPARENT); ncplane_set_base(n, "", 0, transchan); nccell ul = CELL_TRIVIAL_INITIALIZER, ll = CELL_TRIVIAL_INITIALIZER; nccell lr = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER; diff --git a/src/demo/chunli.c b/src/demo/chunli.c index ec8f10a24..45125df30 100644 --- a/src/demo/chunli.c +++ b/src/demo/chunli.c @@ -52,8 +52,8 @@ int chunli_demo(struct notcurses* nc){ int ret, dimx, dimy; notcurses_refresh(nc, &dimy, &dimx); nccell b = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&b, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&b, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&b, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&b, NCALPHA_TRANSPARENT); if( (ret = chunli_draw(nc, "bmp", CHUNS, &b)) ){ return ret; } diff --git a/src/demo/eagle.c b/src/demo/eagle.c index a83f5b2d3..2dff3e355 100644 --- a/src/demo/eagle.c +++ b/src/demo/eagle.c @@ -116,8 +116,8 @@ zoom_map(struct notcurses* nc, const char* map, int* ret){ static int draw_eagle(struct ncplane* n, const char* sprite){ nccell bgc = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&bgc, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&bgc, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&bgc, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&bgc, NCALPHA_TRANSPARENT); ncplane_set_base_cell(n, &bgc); nccell_release(n, &bgc); size_t s; diff --git a/src/demo/highcon.c b/src/demo/highcon.c index 51ceace20..02da2038f 100644 --- a/src/demo/highcon.c +++ b/src/demo/highcon.c @@ -75,7 +75,7 @@ int highcontrast_demo(struct notcurses* nc){ } const char motto[] = " high contrast text is evaluated relative to the solved background"; nccell c = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST); + nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST); unsigned total = 0, r = 0, g = 0, b = 0; for(int out = 0 ; out < totcells ; ++out){ // build up the initial screen scrcolors[out] = generate_next_color(&total, &r, &g, &b, STEP); @@ -99,20 +99,20 @@ int highcontrast_demo(struct notcurses* nc){ uint64_t iterns = totalns / (totcells / 2); do{ if(offset){ - nccell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(&c, NCALPHA_OPAQUE); const int f = offset - 1 + dimx; const int l = totcells + dimx - offset; ncplane_at_yx_cell(n, f / dimx, f % dimx, &c); nccell_set_fg_rgb(&c, 0x004000 + (16 * offset)); nccell_set_bg_rgb(&c, 0); - nccell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(&c, NCALPHA_OPAQUE); if(ncplane_putc_yx(n, f / dimx, f % dimx, &c) < 0){ goto err; } ncplane_at_yx_cell(n, l / dimx, l % dimx, &c); nccell_set_fg_rgb(&c, 0x004000 + (16 * offset)); nccell_set_bg_rgb(&c, 0); - nccell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(&c, NCALPHA_OPAQUE); if(ncplane_putc_yx(n, l / dimx, l % dimx, &c) < 0){ goto err; } diff --git a/src/demo/hud.c b/src/demo/hud.c index a1352f620..b0b4e44e2 100644 --- a/src/demo/hud.c +++ b/src/demo/hud.c @@ -56,9 +56,9 @@ static struct ncplane* debug; // "debug info" modal popup static int hud_standard_bg_rgb(struct ncplane* n){ uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_fg_rgb8(&channels, 0x80, 0x80, 0x80); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_bg_rgb8(&channels, 0x80, 0x80, 0x80); if(ncplane_set_base(n, "", 0, channels) >= 0){ return -1; @@ -114,7 +114,7 @@ debug_toggle(struct notcurses* nc){ return; } uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); ncchannels_set_bg_rgb(&channels, 0xffffe5); ncplane_set_base(n, " ", 0, channels); ncplane_set_scrolling(n, true); @@ -127,8 +127,8 @@ debug_toggle(struct notcurses* nc){ } for(int y = 0 ; y < ncplane_dim_y(n) ; ++y){ nccell c = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT); ncplane_putc_yx(n, y, ncplane_dim_x(n) - 1, &c); nccell_release(n, &c); } @@ -159,14 +159,14 @@ about_toggle(struct notcurses* nc){ struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts); // let the glyphs below show through, but only dimly uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_fg_rgb8(&channels, 0x0, 0x0, 0x0); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_bg_rgb8(&channels, 0x0, 0x0, 0x0); if(ncplane_set_base(n, "", 0, channels) >= 0){ ncplane_set_fg_rgb(n, 0x11ffff); ncplane_set_bg_rgb(n, 0); - ncplane_set_bg_alpha(n, CELL_ALPHA_BLEND); + ncplane_set_bg_alpha(n, NCALPHA_BLEND); ncplane_printf_aligned(n, 1, NCALIGN_CENTER, "notcurses-demo %s", notcurses_version()); ncplane_printf_aligned(n, 3, NCALIGN_LEFT, " P toggle plot"); ncplane_printf_aligned(n, 3, NCALIGN_RIGHT, "toggle help Ctrl+U "); @@ -318,11 +318,11 @@ struct ncmenu* menu_create(struct notcurses* nc){ uint64_t sectionchannels = 0; ncchannels_set_fg_rgb(§ionchannels, 0xffffff); ncchannels_set_bg_rgb(§ionchannels, 0x000000); - ncchannels_set_fg_alpha(§ionchannels, CELL_ALPHA_HIGHCONTRAST); - ncchannels_set_bg_alpha(§ionchannels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(§ionchannels, NCALPHA_HIGHCONTRAST); + ncchannels_set_bg_alpha(§ionchannels, NCALPHA_BLEND); ncchannels_set_fg_rgb(&headerchannels, 0xffffff); ncchannels_set_bg_rgb(&headerchannels, 0x7f347f); - ncchannels_set_bg_alpha(&headerchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&headerchannels, NCALPHA_BLEND); const ncmenu_options mopts = { .sections = sections, .sectioncount = sizeof(sections) / sizeof(*sections), @@ -349,12 +349,12 @@ hud_refresh(struct ncplane* n){ lr.channels = CHANNELS_RGB_INITIALIZER(0xf0, 0xc0, 0xc0, 0, 0, 0); hl.channels = CHANNELS_RGB_INITIALIZER(0xf0, 0xc0, 0xc0, 0, 0, 0); vl.channels = CHANNELS_RGB_INITIALIZER(0xf0, 0xc0, 0xc0, 0, 0, 0); - nccell_set_bg_alpha(&ul, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&ur, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&ll, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&lr, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&hl, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&vl, CELL_ALPHA_BLEND); + nccell_set_bg_alpha(&ul, NCALPHA_BLEND); + nccell_set_bg_alpha(&ur, NCALPHA_BLEND); + nccell_set_bg_alpha(&ll, NCALPHA_BLEND); + nccell_set_bg_alpha(&lr, NCALPHA_BLEND); + nccell_set_bg_alpha(&hl, NCALPHA_BLEND); + nccell_set_bg_alpha(&vl, NCALPHA_BLEND); if(ncplane_perimeter(n, &ul, &ur, &ll, &lr, &hl, &vl, 0)){ nccell_release(n, &ul); nccell_release(n, &ur); nccell_release(n, &hl); nccell_release(n, &ll); nccell_release(n, &lr); nccell_release(n, &vl); @@ -385,9 +385,9 @@ hud_print_finished(elem* list){ nccell c = CELL_TRIVIAL_INITIALIZER; ncplane_base(hud, &c); ncplane_set_bg_rgb(hud, nccell_bg_rgb(&c)); - ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND); + ncplane_set_bg_alpha(hud, NCALPHA_BLEND); ncplane_set_fg_rgb(hud, 0xffffff); - ncplane_set_fg_alpha(hud, CELL_ALPHA_OPAQUE); + ncplane_set_fg_alpha(hud, NCALPHA_OPAQUE); nccell_release(hud, &c); if(ncplane_printf_yx(hud, line, 1, "%d", e->frames) < 0){ return -1; @@ -430,7 +430,7 @@ struct ncplane* hud_create(struct notcurses* nc){ hud_refresh(n); ncplane_set_fg_rgb(n, 0xffffff); ncplane_set_bg_rgb(n, 0); - ncplane_set_bg_alpha(n, CELL_ALPHA_BLEND); + ncplane_set_bg_alpha(n, NCALPHA_BLEND); if(hud_hidden){ ncplane_reparent(n, n); } @@ -598,9 +598,9 @@ int demo_render(struct notcurses* nc){ nccell c = CELL_TRIVIAL_INITIALIZER; ncplane_base(hud, &c); ncplane_set_bg_rgb(hud, nccell_bg_rgb(&c)); - ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND); + ncplane_set_bg_alpha(hud, NCALPHA_BLEND); ncplane_set_fg_rgb(hud, 0x80d0ff); - ncplane_set_fg_alpha(hud, CELL_ALPHA_OPAQUE); + ncplane_set_fg_alpha(hud, NCALPHA_OPAQUE); nccell_release(hud, &c); ncplane_on_styles(hud, NCSTYLE_BOLD); if(ncplane_printf_yx(hud, 1, 1, "%d", elems->frames) < 0){ @@ -648,9 +648,9 @@ int fpsgraph_init(struct notcurses* nc){ } uint32_t style = 0; uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_fg_rgb(&channels, 0x201020); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_bg_rgb(&channels, 0x201020); ncplane_set_base(newp, "", style, channels); ncplot_options opts; @@ -663,10 +663,10 @@ int fpsgraph_init(struct notcurses* nc){ opts.title = "frames per semisecond"; ncchannels_set_fg_rgb8(&opts.minchannels, 0x80, 0x80, 0xff); ncchannels_set_bg_rgb(&opts.minchannels, 0x201020); - ncchannels_set_bg_alpha(&opts.minchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&opts.minchannels, NCALPHA_BLEND); ncchannels_set_fg_rgb8(&opts.maxchannels, 0x80, 0xff, 0x80); ncchannels_set_bg_rgb(&opts.maxchannels, 0x201020); - ncchannels_set_bg_alpha(&opts.maxchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&opts.maxchannels, NCALPHA_BLEND); // takes ownership of newp on all paths struct ncuplot* fpsplot = ncuplot_create(newp, &opts, 0, 0); if(!fpsplot){ diff --git a/src/demo/keller.c b/src/demo/keller.c index b8dc8f177..9b7e4364a 100644 --- a/src/demo/keller.c +++ b/src/demo/keller.c @@ -18,8 +18,8 @@ visualize(struct notcurses* nc, struct ncvisual* ncv){ ncplane_set_bg_rgb(stdn, 0); ncplane_set_styles(stdn, NCSTYLE_BOLD); uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(stdn, "", 0, channels); for(size_t i = 0 ; i < sizeof(bs) / sizeof(*bs) ; ++i){ struct ncvisual_options vopts = { diff --git a/src/demo/luigi.c b/src/demo/luigi.c index cea3213e5..457e41cea 100644 --- a/src/demo/luigi.c +++ b/src/demo/luigi.c @@ -112,8 +112,8 @@ static const char* luigis[] = { static int draw_luigi(struct ncplane* n, const char* sprite){ uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(n, "", 0, channels); size_t s; int sbytes; @@ -197,8 +197,8 @@ int luigi_demo(struct notcurses* nc){ return -1; } uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); struct ncplane* wmplane = ncvisual_render(nc, wmncv, NULL); if(wmplane == NULL){ ncvisual_destroy(wmncv); diff --git a/src/demo/outro.c b/src/demo/outro.c index e79a50666..5b67918da 100644 --- a/src/demo/outro.c +++ b/src/demo/outro.c @@ -95,8 +95,8 @@ videothread(void* vnc){ return PTHREAD_CANCELED; } uint64_t trans_channel = 0; - ncchannels_set_bg_alpha(&trans_channel, CELL_ALPHA_TRANSPARENT); - ncchannels_set_fg_alpha(&trans_channel, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&trans_channel, NCALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&trans_channel, NCALPHA_TRANSPARENT); ncplane_set_base(apiap, "", 0, trans_channel); ncplane_set_fg_rgb8(apiap, 0xc0, 0x40, 0x80); ncplane_set_bg_rgb8(apiap, 0, 0, 0); @@ -138,7 +138,7 @@ outro_message(struct notcurses* nc, int* rows, int* cols){ ncplane_dim_yx(non, rows, cols); int ybase = 0; // bevel the upper corners - if(ncplane_set_bg_alpha(non, CELL_ALPHA_TRANSPARENT)){ + if(ncplane_set_bg_alpha(non, NCALPHA_TRANSPARENT)){ return NULL; } if(ncplane_putchar_yx(non, ybase, 0, ' ') < 0 || ncplane_putchar(non, ' ') < 0){ @@ -160,7 +160,7 @@ outro_message(struct notcurses* nc, int* rows, int* cols){ if(ncplane_set_bg_rgb8(non, 0, 180, 180)){ return NULL; } - if(ncplane_set_bg_alpha(non, CELL_ALPHA_BLEND)){ + if(ncplane_set_bg_alpha(non, NCALPHA_BLEND)){ return NULL; } ncplane_on_styles(non, NCSTYLE_BOLD); diff --git a/src/demo/reel.c b/src/demo/reel.c index 3b00d864d..59b2725bc 100644 --- a/src/demo/reel.c +++ b/src/demo/reel.c @@ -219,11 +219,11 @@ ncreel_demo_core(struct notcurses* nc){ ncchannels_set_fg_rgb8(&popts.borderchan, 136, 23, 152); ncchannels_set_bg_rgb8(&popts.borderchan, 0, 0, 0); uint64_t bgchannels = 0; - if(ncchannels_set_fg_alpha(&bgchannels, CELL_ALPHA_TRANSPARENT)){ + if(ncchannels_set_fg_alpha(&bgchannels, NCALPHA_TRANSPARENT)){ ncplane_destroy(n); return -1; } - if(ncchannels_set_bg_alpha(&bgchannels, CELL_ALPHA_TRANSPARENT)){ + if(ncchannels_set_bg_alpha(&bgchannels, NCALPHA_TRANSPARENT)){ ncplane_destroy(n); return -1; } diff --git a/src/demo/trans.c b/src/demo/trans.c index 0009a6f62..793857c41 100644 --- a/src/demo/trans.c +++ b/src/demo/trans.c @@ -41,8 +41,8 @@ legend(struct notcurses* nc, const char* msg){ } nccell c = CELL_TRIVIAL_INITIALIZER; nccell_set_fg_rgb8(&c, 0, 0, 0); // darken surrounding characters by half - nccell_set_fg_alpha(&c, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); // don't touch background + nccell_set_fg_alpha(&c, NCALPHA_BLEND); + nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT); // don't touch background if(ncplane_set_base_cell(n, &c)){ ncplane_destroy(n); return NULL; @@ -150,7 +150,7 @@ slidepanel(struct notcurses* nc, struct ncplane* stdn){ // Next, we set our foreground transparent, allowing characters underneath to // be seen in their natural colors. Our background remains opaque+default. - nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT); ncplane_set_base_cell(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); deadlinens = timespec_to_ns(&cur) + timespec_to_ns(&demodelay); @@ -165,7 +165,7 @@ slidepanel(struct notcurses* nc, struct ncplane* stdn){ // Set the foreground color, setting it to blend. We should get the underlying // glyphs in a blended color, with the default background color. nccell_set_fg_rgb(&c, 0x80c080); - nccell_set_fg_alpha(&c, CELL_ALPHA_BLEND); + nccell_set_fg_alpha(&c, NCALPHA_BLEND); ncplane_set_base_cell(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "default background, fg blended, no glyph"); @@ -180,7 +180,7 @@ slidepanel(struct notcurses* nc, struct ncplane* stdn){ // Opaque foreground color. This produces underlying glyphs in the specified, // fixed color, with the default background color. nccell_set_fg_rgb(&c, 0x80c080); - nccell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(&c, NCALPHA_OPAQUE); ncplane_set_base_cell(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "default background, fg colored opaque, no glyph"); @@ -196,8 +196,8 @@ slidepanel(struct notcurses* nc, struct ncplane* stdn){ // Our background color remains opaque default. nccell_load_char(n, &c, 'X'); nccell_set_fg_default(&c); - nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&c, NCALPHA_OPAQUE); ncplane_set_base_cell(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "default colors, fg transparent, print glyph"); @@ -211,8 +211,8 @@ slidepanel(struct notcurses* nc, struct ncplane* stdn){ // Now we replace the characters with X's, but draw the foreground and // background color from below us. - nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT); ncplane_set_base_cell(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "all transparent, print glyph"); @@ -226,8 +226,8 @@ slidepanel(struct notcurses* nc, struct ncplane* stdn){ // Finally, we populate the plane for the first time with non-transparent // characters. We blend, however, to show the underlying color in our glyphs. - nccell_set_fg_alpha(&c, CELL_ALPHA_BLEND); - nccell_set_bg_alpha(&c, CELL_ALPHA_BLEND); + nccell_set_fg_alpha(&c, NCALPHA_BLEND); + nccell_set_bg_alpha(&c, NCALPHA_BLEND); nccell_set_fg_rgb(&c, 0x80c080); nccell_set_bg_rgb(&c, 0x204080); ncplane_set_base_cell(n, &c); diff --git a/src/demo/unicodeblocks.c b/src/demo/unicodeblocks.c index 8ad5fd108..a73ed7808 100644 --- a/src/demo/unicodeblocks.c +++ b/src/demo/unicodeblocks.c @@ -72,10 +72,10 @@ draw_block(struct ncplane* nn, uint32_t blockstart){ nccell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER; nccell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER; nccells_rounded_box(nn, 0, 0, &ul, &ur, &ll, &lr, &hl, &vl); - nccell_set_bg_alpha(&ul, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&ur, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&ll, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&lr, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(&ul, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&ur, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&ll, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&lr, NCALPHA_TRANSPARENT); nccell_set_fg_rgb8(&ul, 0xea, 0xaa, 0x00); nccell_set_fg_rgb8(&ur, 0x00, 0x30, 0x57); nccell_set_fg_rgb8(&ll, 0x00, 0x30, 0x57); @@ -248,7 +248,7 @@ int unicodeblocks_demo(struct notcurses* nc){ return -1; } uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_fg_rgb(&channels, 0x004000); ncchannels_set_bg_rgb(&channels, 0x0); ncplane_set_base(header, "", 0, channels); diff --git a/src/demo/view.c b/src/demo/view.c index b2154c235..4d7379840 100644 --- a/src/demo/view.c +++ b/src/demo/view.c @@ -70,13 +70,13 @@ legend(struct ncplane* stdn, int dimy, int dimx){ .name = "lgd", }; struct ncplane* n = ncplane_create(stdn, &nopts); - ncplane_set_bg_alpha(n, CELL_ALPHA_TRANSPARENT); + ncplane_set_bg_alpha(n, NCALPHA_TRANSPARENT); uint64_t channels = 0; - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(n, " ", 0, channels); ncplane_set_styles(n, NCSTYLE_BOLD); ncplane_set_fg_rgb8(n, 0xff, 0xff, 0xff); - ncplane_set_fg_alpha(n, CELL_ALPHA_HIGHCONTRAST); + ncplane_set_fg_alpha(n, NCALPHA_HIGHCONTRAST); if(ncplane_putstr_aligned(n, 0, NCALIGN_CENTER, "target launch") <= 0){ ncplane_destroy(n); return NULL; @@ -136,8 +136,8 @@ view_images(struct notcurses* nc, struct ncplane* nstd, int dimy, int dimx){ return -1; } uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(dsplane, "", 0, channels); ncvisual_destroy(ncv2); demo_render(nc); diff --git a/src/demo/whiteout.c b/src/demo/whiteout.c index 28cc24c0f..e2397b6e3 100644 --- a/src/demo/whiteout.c +++ b/src/demo/whiteout.c @@ -27,8 +27,8 @@ mathplane(struct notcurses* nc){ struct ncplane* n = ncplane_create(stdn, &nopts); uint64_t channels = 0; ncchannels_set_fg_rgb(&channels, 0x2b50c8); // metallic gold, inverted - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(n, "", 0, channels); ncplane_set_fg_rgb(n, 0xd4af37); // metallic gold ncplane_set_bg_rgb(n, 0x0); @@ -168,8 +168,8 @@ static int message(struct ncplane* n, int maxy, int maxx, int num, int total, int bytes_out, int egs_out, int cols_out){ uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(n, "", 0, channels); ncplane_set_fg_rgb8(n, 255, 255, 255); ncplane_set_bg_rgb8(n, 32, 64, 32); diff --git a/src/demo/xray.c b/src/demo/xray.c index 67598a2cc..70ea1309b 100644 --- a/src/demo/xray.c +++ b/src/demo/xray.c @@ -31,14 +31,14 @@ make_slider(struct notcurses* nc, int dimx){ }; struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts); uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(n, " ", 0, channels); ncplane_set_scrolling(n, true); int r = 0x5f; int g = 0xaf; int b = 0x84; - ncplane_set_bg_alpha(n, CELL_ALPHA_TRANSPARENT); + ncplane_set_bg_alpha(n, NCALPHA_TRANSPARENT); for(int x = 0 ; x < REPS ; ++x){ for(size_t l = 0 ; l < sizeof(leg) / sizeof(*leg) ; ++l){ ncplane_set_fg_rgb8_clipped(n, r + 0x8 * l, g + 0x8 * l, b + 0x8 * l); @@ -169,8 +169,8 @@ int xray_demo(struct notcurses* nc){ return -1; } uint64_t stdc = 0; - ncchannels_set_fg_alpha(&stdc, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&stdc, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&stdc, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&stdc, NCALPHA_TRANSPARENT); ncplane_set_base(notcurses_stdplane(nc), "", 0, stdc); // returns non-zero if the selected blitter isn't available if(notcurses_check_pixel_support(nc) < 1){ diff --git a/src/demo/yield.c b/src/demo/yield.c index 9d49e533c..22f81078f 100644 --- a/src/demo/yield.c +++ b/src/demo/yield.c @@ -67,10 +67,10 @@ int yield_demo(struct notcurses* nc){ return -1; } uint64_t basechan = 0; - ncchannels_set_bg_alpha(&basechan, CELL_ALPHA_TRANSPARENT); - ncchannels_set_fg_alpha(&basechan, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&basechan, NCALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&basechan, NCALPHA_TRANSPARENT); ncplane_set_base(label, "", 0, basechan); - ncplane_set_bg_alpha(label, CELL_ALPHA_TRANSPARENT); + ncplane_set_bg_alpha(label, NCALPHA_TRANSPARENT); ncplane_set_fg_rgb8(label, 0xff, 0xff, 0xff); ncplane_set_styles(label, NCSTYLE_BOLD); ncplane_printf_aligned(label, 0, NCALIGN_CENTER, "Yield: %03.1f%%", ((double)tfilled * 100) / threshold_painted); diff --git a/src/demo/zoo.c b/src/demo/zoo.c index ce79f69d9..885dbed68 100644 --- a/src/demo/zoo.c +++ b/src/demo/zoo.c @@ -75,8 +75,8 @@ multiselector_demo(struct ncplane* n, struct ncplane* under, int y){ .titlechannels = CHANNELS_RGB_INITIALIZER(0x80, 0x80, 0xff, 0, 0, 0x20), }; uint64_t bgchannels = CHANNELS_RGB_INITIALIZER(0, 0x40, 0, 0, 0x40, 0); - ncchannels_set_fg_alpha(&bgchannels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(&bgchannels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&bgchannels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(&bgchannels, NCALPHA_BLEND); struct ncplane_options nopts = { .y = y, .x = 0, @@ -112,8 +112,8 @@ selector_demo(struct ncplane* n, struct ncplane* under, int dimx, int y){ .titlechannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0x80, 0, 0, 0x20), }; uint64_t bgchannels = CHANNELS_RGB_INITIALIZER(0, 0, 0x40, 0, 0, 0x40); - ncchannels_set_fg_alpha(&bgchannels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(&bgchannels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&bgchannels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(&bgchannels, NCALPHA_BLEND); struct ncplane_options nopts = { .y = y, .x = dimx, @@ -392,8 +392,8 @@ reader_demo(struct notcurses* nc){ } ncplane_set_fg_rgb8(rp, 0x20, 0xe0, 0xe0); uint64_t echannels = 0; - ncchannels_set_fg_alpha(&echannels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(&echannels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&echannels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(&echannels, NCALPHA_BLEND); ncplane_set_base(rp, "", 0, echannels); ncplane_set_scrolling(rp, true); // Bring the selector left across the top, while raising the exposition diff --git a/src/lib/blit.c b/src/lib/blit.c index e7160e726..076357103 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -71,12 +71,12 @@ tria_blit_ascii(ncplane* nc, int linesize, const void* data, c->channels = 0; c->stylemask = 0; if(blendcolors){ - nccell_set_bg_alpha(c, CELL_ALPHA_BLEND); - nccell_set_fg_alpha(c, CELL_ALPHA_BLEND); + nccell_set_bg_alpha(c, NCALPHA_BLEND); + nccell_set_fg_alpha(c, NCALPHA_BLEND); } if(rgba_trans_q(rgbbase_up, bargs->transcolor)){ - nccell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); - nccell_set_fg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); + nccell_set_fg_alpha(c, NCALPHA_TRANSPARENT); cell_set_blitquadrants(c, 0, 0, 0, 0); }else{ nccell_set_fg_rgb8(c, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2]); @@ -130,13 +130,13 @@ tria_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, c->channels = 0; c->stylemask = 0; if(blendcolors){ - nccell_set_bg_alpha(c, CELL_ALPHA_BLEND); - nccell_set_fg_alpha(c, CELL_ALPHA_BLEND); + nccell_set_bg_alpha(c, NCALPHA_BLEND); + nccell_set_fg_alpha(c, NCALPHA_BLEND); } if(rgba_trans_q(rgbbase_up, transcolor) || rgba_trans_q(rgbbase_down, transcolor)){ - nccell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); if(rgba_trans_q(rgbbase_up, transcolor) && rgba_trans_q(rgbbase_down, transcolor)){ - nccell_set_fg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(c, NCALPHA_TRANSPARENT); }else if(rgba_trans_q(rgbbase_up, transcolor)){ // down has the color if(pool_blit_direct(&nc->pool, c, "\u2584", strlen("\u2584"), 1) <= 0){ return -1; @@ -412,11 +412,11 @@ qtrans_check(nccell* c, unsigned blendcolors, } } assert(egc); - nccell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); if(*egc == '\0'){ - nccell_set_fg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(c, NCALPHA_TRANSPARENT); }else if(blendcolors){ - nccell_set_fg_alpha(c, CELL_ALPHA_BLEND); + nccell_set_fg_alpha(c, NCALPHA_BLEND); } //fprintf(stderr, "QBQ: 0x%x\n", cell_blittedquadrants(c)); return egc; @@ -479,8 +479,8 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, cell_set_fchannel(c, fg); cell_set_bchannel(c, bg); if(blendcolors){ - nccell_set_bg_alpha(c, CELL_ALPHA_BLEND); - nccell_set_fg_alpha(c, CELL_ALPHA_BLEND); + nccell_set_bg_alpha(c, NCALPHA_BLEND); + nccell_set_fg_alpha(c, NCALPHA_BLEND); } cell_set_blitquadrants(c, 1, 1, 1, 1); } @@ -590,8 +590,8 @@ sex_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors){ //fprintf(stderr, "solved for best: %d (%u)\n", best, mindiff); assert(best >= 0 && best < 32); if(blendcolors){ - ncchannels_set_fg_alpha(channels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(channels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(channels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(channels, NCALPHA_BLEND); } return sex[best]; } @@ -629,20 +629,20 @@ sex_trans_check(cell* c, const uint32_t rgbas[6], unsigned blendcolors, if(transstring == 0){ // there was no transparency return NULL; } - nccell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); // there were some transparent pixels. since they get priority, the foreground // is just a general lerp across non-transparent pixels. const char* egc = sex[transstring]; - nccell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); //fprintf(stderr, "transtring: %u egc: %s\n", transtring, egc); if(*egc == ' '){ // entirely transparent - nccell_set_fg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(c, NCALPHA_TRANSPARENT); return ""; }else{ // partially transparent, thus div >= 1 //fprintf(stderr, "div: %u r: %u g: %u b: %u\n", div, r, g, b); cell_set_fchannel(c, generalerp(r, g, b, div)); if(blendcolors){ - nccell_set_fg_alpha(c, CELL_ALPHA_BLEND); + nccell_set_fg_alpha(c, NCALPHA_BLEND); } cell_set_blitquadrants(c, !(transstring & 5u), !(transstring & 10u), !(transstring & 20u), !(transstring & 40u)); @@ -821,14 +821,14 @@ braille_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, c->channels = 0; c->stylemask = 0; if(blendcolors){ - nccell_set_fg_alpha(c, CELL_ALPHA_BLEND); + nccell_set_fg_alpha(c, NCALPHA_BLEND); } // FIXME for now, we just sample, color-wise, and always draw crap. // more complicated to do optimally than quadrants, for sure. ideally, // we only get one color in an area. - nccell_set_bg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); if(!egcidx){ - nccell_set_fg_alpha(c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(c, NCALPHA_TRANSPARENT); // FIXME else look for pairs of transparency! }else{ if(blends){ diff --git a/src/lib/debug.c b/src/lib/debug.c index 8a71c9cdf..295a46bb3 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -26,17 +26,13 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols, capyn(get_escape(ti, ESCAPE_BGOP))); fprintf(debugfp, "%srows: %u cols: %u rpx: %u cpx: %u (%dx%d)\n", indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx); - if(!ti->pixel_query_done){ - fprintf(debugfp, "%sno bitmap graphics information yet\n", indent); + if(!ti->bitmap_supported){ + fprintf(debugfp, "%sdidn't detect bitmap graphics support\n", indent); + }else if(ti->sixel_maxy || ti->color_registers){ + fprintf(debugfp, "%smax sixel size: %dx%d colorregs: %u\n", + indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers); }else{ - if(!ti->bitmap_supported){ - fprintf(debugfp, "%sdidn't detect bitmap graphics support\n", indent); - }else if(ti->sixel_maxy || ti->color_registers){ - fprintf(debugfp, "%smax sixel size: %dx%d colorregs: %u\n", - indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers); - }else{ - fprintf(debugfp, "%sRGBA pixel graphics supported\n", indent); - } + fprintf(debugfp, "%sRGBA pixel graphics supported\n", indent); } fprintf(debugfp, "%sUTF8: %c quad: %c sex: %c braille: %c images: %c videos: %c\n", indent, capbool(ti->utf8), capbool(ti->quadrants), diff --git a/src/lib/direct.c b/src/lib/direct.c index 6fab2df14..154dab8dc 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -495,12 +495,12 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ if(egc == NULL){ return -1; } - if(ncchannels_fg_alpha(channels) == CELL_ALPHA_TRANSPARENT){ + if(ncchannels_fg_alpha(channels) == NCALPHA_TRANSPARENT){ ncdirect_set_fg_default(n); }else{ ncdirect_set_fg_rgb(n, ncchannels_fg_rgb(channels)); } - if(ncchannels_bg_alpha(channels) == CELL_ALPHA_TRANSPARENT){ + if(ncchannels_bg_alpha(channels) == NCALPHA_TRANSPARENT){ ncdirect_set_bg_default(n); }else{ ncdirect_set_bg_rgb(n, ncchannels_bg_rgb(channels)); @@ -1278,9 +1278,6 @@ int ncdirect_flush(const ncdirect* nc){ } int ncdirect_check_pixel_support(ncdirect* n){ - if(query_term(&n->tcache, n->ctermfd)){ - return -1; - } if(n->tcache.bitmap_supported){ return 1; } diff --git a/src/lib/internal.h b/src/lib/internal.h index ca4abbf45..a0fa6bd55 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -436,7 +436,7 @@ struct crender { // take this into account when solving the background color. unsigned blittedquads: 4; unsigned damaged: 1; // only used in rasterization - // if CELL_ALPHA_HIGHCONTRAST is in play, we apply the HSV flip once the + // if NCALPHA_HIGHCONTRAST is in play, we apply the HSV flip once the // background is locked in. set highcontrast to indicate this. unsigned highcontrast: 1; unsigned fgblends: 8; @@ -606,11 +606,6 @@ int reset_term_attributes(const tinfo* ti, FILE* fp); void free_terminfo_cache(tinfo* ti); -// perform queries that require writing to the terminal, and reading a -// response, rather than simply reading the terminfo database. can result -// in a lengthy delay or even block if the terminal doesn't respond. -int query_term(tinfo* ti, int fd); - // if there were missing elements we wanted from terminfo, bitch about them here void warn_terminfo(const notcurses* nc, const tinfo* ti); @@ -1337,7 +1332,7 @@ cell_set_fchannel(nccell* cl, uint32_t channel){ // Palette-indexed colors do not blend. Do not pass me palette-indexed channels! static inline unsigned channels_blend(unsigned c1, unsigned c2, unsigned* blends){ - if(ncchannel_alpha(c2) == CELL_ALPHA_TRANSPARENT){ + if(ncchannel_alpha(c2) == NCALPHA_TRANSPARENT){ return c1; // do *not* increment *blends } bool c2default = ncchannel_default_p(c2); diff --git a/src/lib/menu.c b/src/lib/menu.c index 750b7891a..a2a12aba3 100644 --- a/src/lib/menu.c +++ b/src/lib/menu.c @@ -383,8 +383,8 @@ ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){ ret->disablechannels = ret->sectionchannels; ncchannels_set_fg_rgb(&ret->disablechannels, 0xdddddd); nccell c = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT); ncplane_set_base_cell(ret->ncp, &c); nccell_release(ret->ncp, &c); if(write_header(ret) == 0){ diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 8b9309561..21b40ac18 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -983,9 +983,6 @@ recursive_lock_init(pthread_mutex_t *lock){ } int notcurses_check_pixel_support(notcurses* nc){ - if(query_term(&nc->tcache, nc->ttyfd)){ - return -1; - } if(nc->tcache.bitmap_supported){ return 1; } @@ -1311,7 +1308,7 @@ int ncplane_set_fg_palindex(ncplane* n, int idx){ } n->channels |= CELL_FGDEFAULT_MASK; n->channels |= CELL_FG_PALETTE; - ncchannels_set_fg_alpha(&n->channels, CELL_ALPHA_OPAQUE); + ncchannels_set_fg_alpha(&n->channels, NCALPHA_OPAQUE); n->stylemask &= 0xffff00ff; n->stylemask |= (idx << 8u); return 0; @@ -1323,7 +1320,7 @@ int ncplane_set_bg_palindex(ncplane* n, int idx){ } n->channels |= CELL_BGDEFAULT_MASK; n->channels |= CELL_BG_PALETTE; - ncchannels_set_bg_alpha(&n->channels, CELL_ALPHA_OPAQUE); + ncchannels_set_bg_alpha(&n->channels, NCALPHA_OPAQUE); n->stylemask &= 0xffffff00; n->stylemask |= idx; return 0; diff --git a/src/lib/render.c b/src/lib/render.c index fc391f238..3be45f68d 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -242,17 +242,17 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx, } const nccell* vis = &p->fb[nfbcellidx(p, y, x)]; - if(nccell_fg_alpha(targc) > CELL_ALPHA_OPAQUE){ + if(nccell_fg_alpha(targc) > NCALPHA_OPAQUE){ vis = &p->fb[nfbcellidx(p, y, x)]; if(nccell_fg_default_p(vis)){ vis = &p->basecell; } if(nccell_fg_palindex_p(vis)){ - if(nccell_fg_alpha(targc) == CELL_ALPHA_TRANSPARENT){ + if(nccell_fg_alpha(targc) == NCALPHA_TRANSPARENT){ nccell_set_fg_palindex(targc, nccell_fg_palindex(vis)); } }else{ - if(nccell_fg_alpha(vis) == CELL_ALPHA_HIGHCONTRAST){ + if(nccell_fg_alpha(vis) == NCALPHA_HIGHCONTRAST){ crender->s.highcontrast = true; crender->s.hcfgblends = crender->s.fgblends; crender->hcfg = cell_fchannel(targc); @@ -262,9 +262,9 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx, crender->s.fgblends = fgblends; // crender->highcontrast can only be true if we just set it, since we're // about to set targc opaque based on crender->highcontrast (and this - // entire stanza is conditional on targc not being CELL_ALPHA_OPAQUE). + // entire stanza is conditional on targc not being NCALPHA_OPAQUE). if(crender->s.highcontrast){ - nccell_set_fg_alpha(targc, CELL_ALPHA_OPAQUE); + nccell_set_fg_alpha(targc, NCALPHA_OPAQUE); } } } @@ -274,7 +274,7 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx, // If it's transparent, it has no effect. Otherwise, update the // background channel and balpha. // Evaluate the background first, in case we have HIGHCONTRAST fg text. - if(nccell_bg_alpha(targc) > CELL_ALPHA_OPAQUE){ + if(nccell_bg_alpha(targc) > NCALPHA_OPAQUE){ vis = &p->fb[nfbcellidx(p, y, x)]; // to be on the blitter stacking path, we need // 1) crender->s.blittedquads to be non-zero (we're below semigraphics) @@ -285,7 +285,7 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx, vis = &p->basecell; } if(nccell_bg_palindex_p(vis)){ - if(nccell_bg_alpha(targc) == CELL_ALPHA_TRANSPARENT){ + if(nccell_bg_alpha(targc) == NCALPHA_TRANSPARENT){ nccell_set_bg_palindex(targc, nccell_bg_palindex(vis)); } }else{ @@ -298,7 +298,7 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx, vis = &p->basecell; } if(nccell_fg_palindex_p(vis)){ - if(nccell_bg_alpha(targc) == CELL_ALPHA_TRANSPARENT){ + if(nccell_bg_alpha(targc) == NCALPHA_TRANSPARENT){ nccell_set_bg_palindex(targc, nccell_fg_palindex(vis)); } }else{ @@ -360,13 +360,13 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx, } } -// it's not a pure memset(), because CELL_ALPHA_OPAQUE is the zero value, and -// we need CELL_ALPHA_TRANSPARENT +// it's not a pure memset(), because NCALPHA_OPAQUE is the zero value, and +// we need NCALPHA_TRANSPARENT static inline void init_rvec(struct crender* rvec, int totalcells){ struct crender c = {}; - nccell_set_fg_alpha(&c.c, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&c.c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&c.c, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&c.c, NCALPHA_TRANSPARENT); for(int t = 0 ; t < totalcells ; ++t){ memcpy(&rvec[t], &c, sizeof(c)); } @@ -377,10 +377,10 @@ init_rvec(struct crender* rvec, int totalcells){ // against the real background. static inline void lock_in_highcontrast(nccell* targc, struct crender* crender){ - if(nccell_fg_alpha(targc) == CELL_ALPHA_TRANSPARENT){ + if(nccell_fg_alpha(targc) == NCALPHA_TRANSPARENT){ nccell_set_fg_default(targc); } - if(nccell_bg_alpha(targc) == CELL_ALPHA_TRANSPARENT){ + if(nccell_bg_alpha(targc) == NCALPHA_TRANSPARENT){ nccell_set_bg_default(targc); } if(crender->s.highcontrast){ @@ -443,7 +443,7 @@ postpaint_cell(nccell* lastframe, int dimx, struct crender* crender, // iterate over the rendered frame, adjusting the foreground colors for any -// cells marked CELL_ALPHA_HIGHCONTRAST, and clearing any cell covered by a +// cells marked NCALPHA_HIGHCONTRAST, and clearing any cell covered by a // wide glyph to its left. // // FIXME this cannot be performed at render time (we don't yet know the diff --git a/src/lib/selector.c b/src/lib/selector.c index b9d11949c..079d1093d 100644 --- a/src/lib/selector.c +++ b/src/lib/selector.c @@ -70,8 +70,8 @@ static int ncselector_draw(ncselector* n){ ncplane_erase(n->ncp); nccell transchar = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&transchar, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&transchar, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&transchar, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&transchar, NCALPHA_TRANSPARENT); // if we have a title, we'll draw a riser. the riser is two rows tall, and // exactly four columns longer than the title, and aligned to the right. we // draw a rounded box. the body will blow part or all of the bottom away. @@ -564,8 +564,8 @@ static int ncmultiselector_draw(ncmultiselector* n){ ncplane_erase(n->ncp); nccell transchar = CELL_TRIVIAL_INITIALIZER; - nccell_set_fg_alpha(&transchar, CELL_ALPHA_TRANSPARENT); - nccell_set_bg_alpha(&transchar, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&transchar, NCALPHA_TRANSPARENT); + nccell_set_bg_alpha(&transchar, NCALPHA_TRANSPARENT); // if we have a title, we'll draw a riser. the riser is two rows tall, and // exactly four columns longer than the title, and aligned to the right. we // draw a rounded box. the body will blow part or all of the bottom away. diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index af359dcfd..55deb874b 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -93,7 +93,6 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd){ ti->bg_collides_default = 0x1000000; ti->sextants = true; // work since bugfix in 0.19.3 ti->quadrants = true; - ti->pixel_query_done = true; ti->RGBflag = true; setup_kitty_bitmaps(ti, fd); }else if(strstr(termname, "alacritty")){ @@ -156,7 +155,6 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd){ } void free_terminfo_cache(tinfo* ti){ - pthread_mutex_destroy(&ti->pixel_query); free(ti->esctable); } @@ -201,9 +199,59 @@ init_terminfo_esc(tinfo* ti, const char* name, escape_e idx, return 0; } +// Device Attributes; replies with (depending on decTerminalID resource): +// ⇒ CSI ? 1 ; 2 c ("VT100 with Advanced Video Option") +// ⇒ CSI ? 1 ; 0 c ("VT101 with No Options") +// ⇒ CSI ? 4 ; 6 c ("VT132 with Advanced Video and Graphics") +// ⇒ CSI ? 6 c ("VT102") +// ⇒ CSI ? 7 c ("VT131") +// ⇒ CSI ? 1 2 ; Ps c ("VT125") +// ⇒ CSI ? 6 2 ; Ps c ("VT220") +// ⇒ CSI ? 6 3 ; Ps c ("VT320") +// ⇒ CSI ? 6 4 ; Ps c ("VT420") +#define ESC_DA "\e[c" + +/* +// query for Sixel details including the number of color registers and, one day +// perhaps, maximum geometry. xterm binds its return by the current geometry, +// making it useless for a one-time query. +static int +query_sixel_details(tinfo* ti, int fd){ + if(query_xtsmgraphics(fd, "\x1b[?2;1;0S" ESC_DA, &ti->sixel_maxx, &ti->sixel_maxy)){ + return -1; + } + if(query_xtsmgraphics(fd, "\x1b[?1;1;0S" ESC_DA, &ti->color_registers, NULL)){ + return -1; + } +//fprintf(stderr, "Sixel ColorRegs: %d Max_x: %d Max_y: %d\n", ti->color_registers, ti->sixel_maxx, ti->sixel_maxy); + if(ti->color_registers < 64){ // FIXME try to drive it higher + return -1; + } + return 0; +} +*/ + +// we send an XTSMGRAPHICS to set up 256 color registers (the most we can +// currently take advantage of; we need at least 64 to use sixel at all. +// maybe that works, maybe it doesn't. then query both color registers +// and geometry. +static int +send_initial_queries(int fd){ + const char queries[] = "\x1b[?1;3;256S\x1b[?2;1;0S\x1b[?1;1;0S" ESC_DA; + if(blocking_write(fd, queries, strlen(queries))){ + return -1; + } + return 0; +} + // termname is just the TERM environment variable. some details are not // exposed via terminfo, and we must make heuristic decisions based on // the detected terminal type, yuck :/. +// the first thing we do is fire off any queries we have (XTSMGRAPHICS, etc.) +// with a trailing Device Attributes. all known terminals will reply to a +// Device Attributes, allowing us to get a negative response if our queries +// aren't supported by the terminal. we fire it off early because we have a +// full round trip before getting the reply, which is likely to pace init. int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8, unsigned noaltscreen, unsigned nocbreak){ memset(ti, 0, sizeof(*ti)); @@ -213,6 +261,10 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8, fprintf(stderr, "Couldn't preserve terminal state for %d (%s)\n", fd, strerror(errno)); return -1; } + if(send_initial_queries(fd)){ + fprintf(stderr, "Error issuing terminal queries on %d\n", fd); + return -1; + } } if(ncinputlayer_init(&ti->input, stdin)){ return -1; @@ -371,10 +423,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8, goto err; } } - pthread_mutex_init(&ti->pixel_query, NULL); - ti->pixel_query_done = false; if(apply_term_heuristics(ti, termname, fd)){ - pthread_mutex_destroy(&ti->pixel_query); goto err; } return 0; @@ -384,6 +433,7 @@ err: return -1; } +/* // FIXME need unit tests on this // FIXME can read a character not intended for it // we'll get a trailing Device Attributes response, because we write @@ -490,36 +540,6 @@ query_xtsmgraphics(int fd, const char* seq, int* val, int* val2){ return 0; } -// Device Attributes; replies with (depending on decTerminalID resource): -// ⇒ CSI ? 1 ; 2 c ("VT100 with Advanced Video Option") -// ⇒ CSI ? 1 ; 0 c ("VT101 with No Options") -// ⇒ CSI ? 4 ; 6 c ("VT132 with Advanced Video and Graphics") -// ⇒ CSI ? 6 c ("VT102") -// ⇒ CSI ? 7 c ("VT131") -// ⇒ CSI ? 1 2 ; Ps c ("VT125") -// ⇒ CSI ? 6 2 ; Ps c ("VT220") -// ⇒ CSI ? 6 3 ; Ps c ("VT320") -// ⇒ CSI ? 6 4 ; Ps c ("VT420") -#define ESC_DA "\e[c" - -// query for Sixel details including the number of color registers and, one day -// perhaps, maximum geometry. xterm binds its return by the current geometry, -// making it useless for a one-time query. -static int -query_sixel_details(tinfo* ti, int fd){ - if(query_xtsmgraphics(fd, "\x1b[?2;1;0S" ESC_DA, &ti->sixel_maxx, &ti->sixel_maxy)){ - return -1; - } - if(query_xtsmgraphics(fd, "\x1b[?1;1;0S" ESC_DA, &ti->color_registers, NULL)){ - return -1; - } -//fprintf(stderr, "Sixel ColorRegs: %d Max_x: %d Max_y: %d\n", ti->color_registers, ti->sixel_maxx, ti->sixel_maxy); - if(ti->color_registers < 64){ // FIXME try to drive it higher - return -1; - } - return 0; -} - // query for Sixel support static int query_sixel(tinfo* ti, int fd){ @@ -597,46 +617,10 @@ query_sixel(tinfo* ti, int fd){ } } if(ti->bitmap_supported){ - if(query_sixel_details(ti, fd)){ + if(ti->color_registers < 64){ ti->bitmap_supported = false; } } return 0; } - -// fd must be a real terminal. uses the query lock of |ti| to only act once. -// we ought already have performed a TIOCGWINSZ ioctl() to verify that the -// terminal reports cell area in pixels, as that's necessary for our use of -// sixel (or any other bitmap protocol). -int query_term(tinfo* ti, int fd){ - if(fd < 0){ - return -1; - } - int flags = fcntl(fd, F_GETFL, 0); - if(flags < 0){ - return -1; - } - int ret = 0; - pthread_mutex_lock(&ti->pixel_query); - if(!ti->pixel_query_done){ - // if the terminal reported 0 pixels for cell dimensions, bypass any - // interrogation, and assume no bitmap support. - if(!ti->cellpixx || !ti->cellpixy){ - ti->pixel_query_done = true; - }else{ - if(flags & O_NONBLOCK){ - fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - } - ret = query_sixel(ti, fd); - ti->pixel_query_done = true; - if(ti->bitmap_supported){ - ti->pixel_init(fd); - } - if(flags & O_NONBLOCK){ - fcntl(fd, F_SETFL, flags); - } - } - } - pthread_mutex_unlock(&ti->pixel_query); - return ret; -} +*/ diff --git a/src/lib/termdesc.h b/src/lib/termdesc.h index 0de0f5471..5110b2df2 100644 --- a/src/lib/termdesc.h +++ b/src/lib/termdesc.h @@ -102,7 +102,6 @@ typedef struct tinfo { // which we support sixel and kitty. the kitty protocol is used based // on TERM heuristics. otherwise, we attempt to detect sixel support, and // query the details of the implementation. - pthread_mutex_t pixel_query; // only query for pixel support once int color_registers; // sixel color registers (post pixel_query_done) int sixel_maxx, sixel_maxy; // sixel size maxima (post pixel_query_done) int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s); @@ -123,7 +122,6 @@ typedef struct tinfo { ncinputlayer input; // input layer bool bitmap_supported; // do we support bitmaps (post pixel_query_done)? bool bitmap_lowest_line; // can we render pixels to the bottom row? - bool pixel_query_done; // have we yet performed pixel query? bool RGBflag; // "RGB" flag for 24bpc truecolor bool CCCflag; // "CCC" flag for palette set capability bool BCEflag; // "BCE" flag for erases with background color diff --git a/src/player/play.cpp b/src/player/play.cpp index 023f97a8e..8db882d8d 100644 --- a/src/player/play.cpp +++ b/src/player/play.cpp @@ -62,12 +62,12 @@ auto handle_subtitle(char* subtitle, struct marshal* marsh, }; marsh->subtitle_plane = ncplane_create(vopts->n, &nopts); uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(marsh->subtitle_plane, "", 0, channels); ncplane_set_fg_rgb(marsh->subtitle_plane, 0x00ffff); - ncplane_set_fg_alpha(marsh->subtitle_plane, CELL_ALPHA_HIGHCONTRAST); - ncplane_set_bg_alpha(marsh->subtitle_plane, CELL_ALPHA_TRANSPARENT); + ncplane_set_fg_alpha(marsh->subtitle_plane, NCALPHA_HIGHCONTRAST); + ncplane_set_bg_alpha(marsh->subtitle_plane, NCALPHA_TRANSPARENT); }else{ ncplane_erase(marsh->subtitle_plane); } @@ -378,8 +378,8 @@ int rendered_mode_player_inner(NotCurses& nc, int argc, char** argv, int dimy, dimx; std::unique_ptr stdn(nc.get_stdplane(&dimy, &dimx)); uint64_t transchan = 0; - ncchannels_set_fg_alpha(&transchan, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&transchan, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&transchan, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&transchan, NCALPHA_TRANSPARENT); stdn->set_base("", 0, transchan); struct ncplane_options nopts{}; nopts.name = "play"; diff --git a/src/poc/multiselect.c b/src/poc/multiselect.c index 2c82f88b9..13862e9c4 100644 --- a/src/poc/multiselect.c +++ b/src/poc/multiselect.c @@ -86,8 +86,8 @@ int main(void){ sopts.footchannels = CHANNELS_RGB_INITIALIZER(0xe0, 0, 0x40, 0x20, 0x20, 0); sopts.titlechannels = CHANNELS_RGB_INITIALIZER(0x20, 0xff, 0xff, 0, 0, 0x20); uint64_t bgchannels = CHANNELS_RGB_INITIALIZER(0, 0x20, 0, 0, 0x20, 0); - ncchannels_set_fg_alpha(&bgchannels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(&bgchannels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&bgchannels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(&bgchannels, NCALPHA_BLEND); struct ncplane* n = notcurses_stdplane(nc); if(notcurses_canopen_images(nc)){ diff --git a/src/poc/selector.c b/src/poc/selector.c index 647d83677..bfc5fd16b 100644 --- a/src/poc/selector.c +++ b/src/poc/selector.c @@ -77,8 +77,8 @@ int main(void){ sopts.footchannels = CHANNELS_RGB_INITIALIZER(0xe0, 0, 0x40, 0x20, 0, 0); sopts.titlechannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0x80, 0, 0, 0x20); uint64_t bgchannels = CHANNELS_RGB_INITIALIZER(0, 0x20, 0, 0, 0x20, 0); - ncchannels_set_fg_alpha(&bgchannels, CELL_ALPHA_BLEND); - ncchannels_set_bg_alpha(&bgchannels, CELL_ALPHA_BLEND); + ncchannels_set_fg_alpha(&bgchannels, NCALPHA_BLEND); + ncchannels_set_bg_alpha(&bgchannels, NCALPHA_BLEND); struct ncplane* n = notcurses_stdplane(nc); if(notcurses_canopen_images(nc)){ diff --git a/src/poc/textplay.c b/src/poc/textplay.c index 1132cc533..cad6a1333 100644 --- a/src/poc/textplay.c +++ b/src/poc/textplay.c @@ -192,8 +192,8 @@ textplane(struct notcurses* nc){ }; struct ncplane* n = ncplane_create(stdn, &nopts); uint64_t channels = CHANNELS_RGB_INITIALIZER(0, 0, 0, 0x22, 0x22, 0x22); - /*ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);*/ + /*ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT);*/ if(n){ ncplane_set_base(n, "", 0, channels); } diff --git a/src/poc/wipebitmap.c b/src/poc/wipebitmap.c index 53f1c1f7a..b80d531d4 100644 --- a/src/poc/wipebitmap.c +++ b/src/poc/wipebitmap.c @@ -44,8 +44,8 @@ wipebitmap(struct notcurses* nc){ } } uint64_t channels = 0; - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); ncplane_set_base(notcurses_stdplane(nc), "", 0, channels); ncplane_move_top(notcurses_stdplane(nc)); emit(notcurses_stdplane(nc), "Ought see 16 *s"); diff --git a/src/tests/bitmap.cpp b/src/tests/bitmap.cpp index 4f61e7b98..95f78c16c 100644 --- a/src/tests/bitmap.cpp +++ b/src/tests/bitmap.cpp @@ -636,8 +636,8 @@ TEST_CASE("Bitmaps") { #ifdef NOTCURSES_USE_MULTIMEDIA SUBCASE("PixelWipeImage") { uint64_t channels = 0; - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); CHECK(0 == ncplane_set_base(n_, "", 0, channels)); auto ncv = ncvisual_from_file(find_data("worldmap.png").get()); REQUIRE(ncv); diff --git a/src/tests/cell.cpp b/src/tests/cell.cpp index 351505e13..a4a579e69 100644 --- a/src/tests/cell.cpp +++ b/src/tests/cell.cpp @@ -125,12 +125,12 @@ TEST_CASE("Cell") { nccell c = CELL_TRIVIAL_INITIALIZER; CHECK(0 > nccell_set_fg_alpha(&c, -1)); CHECK(0 > nccell_set_fg_alpha(&c, 4)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_OPAQUE)); CHECK(nccell_fg_default_p(&c)); CHECK(nccell_bg_default_p(&c)); - CHECK(CELL_ALPHA_OPAQUE == nccell_fg_alpha(&c)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); - CHECK(CELL_ALPHA_HIGHCONTRAST == nccell_fg_alpha(&c)); + CHECK(NCALPHA_OPAQUE == nccell_fg_alpha(&c)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST)); + CHECK(NCALPHA_HIGHCONTRAST == nccell_fg_alpha(&c)); CHECK(!nccell_fg_default_p(&c)); CHECK(nccell_bg_default_p(&c)); } @@ -139,11 +139,11 @@ TEST_CASE("Cell") { nccell c = CELL_TRIVIAL_INITIALIZER; CHECK(0 > nccell_set_bg_alpha(&c, -1)); CHECK(0 > nccell_set_bg_alpha(&c, 4)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE)); - CHECK(CELL_ALPHA_OPAQUE == nccell_bg_alpha(&c)); - CHECK(0 != nccell_set_bg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT)); - CHECK(CELL_ALPHA_TRANSPARENT == nccell_bg_alpha(&c)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_OPAQUE)); + CHECK(NCALPHA_OPAQUE == nccell_bg_alpha(&c)); + CHECK(0 != nccell_set_bg_alpha(&c, NCALPHA_HIGHCONTRAST)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT)); + CHECK(NCALPHA_TRANSPARENT == nccell_bg_alpha(&c)); CHECK(nccell_fg_default_p(&c)); CHECK(!nccell_bg_default_p(&c)); } @@ -152,8 +152,8 @@ TEST_CASE("Cell") { SUBCASE("HighContrastWhiteOnBlackBackground"){ nccell c = CELL_CHAR_INITIALIZER('+'); CHECK(0 == nccell_set_fg_rgb8(&c, 0xff, 0xff, 0xff)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT)); struct ncplane_options nopts = { .y = 0, .x = 0, @@ -170,7 +170,7 @@ TEST_CASE("Cell") { CHECK(1 == ncplane_putc(np, &c)); nccell_load_char(np, &c, '*'); CHECK(0 == nccell_set_bg_rgb8(&c, 0x0, 0x0, 0x0)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_OPAQUE)); CHECK(1 == ncplane_putc(n_, &c)); CHECK(0 == notcurses_render(nc_)); uint64_t channels, underchannels, overchannels; @@ -192,8 +192,8 @@ TEST_CASE("Cell") { SUBCASE("HighContrastWhiteOnWhiteBackground"){ nccell c = CELL_CHAR_INITIALIZER('+'); CHECK(0 == nccell_set_fg_rgb8(&c, 0xff, 0xff, 0xff)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT)); struct ncplane_options nopts = { .y = 0, .x = 0, @@ -210,7 +210,7 @@ TEST_CASE("Cell") { CHECK(1 == ncplane_putc(np, &c)); nccell_load_char(np, &c, '*'); CHECK(0 == nccell_set_bg_rgb8(&c, 0xff, 0xff, 0xff)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_OPAQUE)); CHECK(1 == ncplane_putc(n_, &c)); CHECK(0 == notcurses_render(nc_)); uint64_t channels, underchannels, overchannels; @@ -232,8 +232,8 @@ TEST_CASE("Cell") { SUBCASE("HighContrastBlackOnBlackBackground"){ nccell c = CELL_CHAR_INITIALIZER('+'); CHECK(0 == nccell_set_fg_rgb8(&c, 0x0, 0x0, 0x0)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT)); struct ncplane_options nopts = { .y = 0, .x = 0, @@ -250,7 +250,7 @@ TEST_CASE("Cell") { CHECK(1 == ncplane_putc(np, &c)); nccell_load_char(np, &c, '*'); CHECK(0 == nccell_set_bg_rgb8(&c, 0x0, 0x0, 0x0)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_OPAQUE)); CHECK(1 == ncplane_putc(n_, &c)); CHECK(0 == notcurses_render(nc_)); uint64_t channels, underchannels, overchannels; @@ -272,8 +272,8 @@ TEST_CASE("Cell") { SUBCASE("HighContrastBlackOnWhiteBackground"){ nccell c = CELL_CHAR_INITIALIZER('+'); CHECK(0 == nccell_set_fg_rgb8(&c, 0x0, 0x0, 0x0)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT)); struct ncplane_options nopts = { .y = 0, .x = 0, @@ -290,7 +290,7 @@ TEST_CASE("Cell") { CHECK(1 == ncplane_putc(np, &c)); nccell_load_char(np, &c, '*'); CHECK(0 == nccell_set_bg_rgb8(&c, 0xff, 0xff, 0xff)); - CHECK(0 == nccell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE)); + CHECK(0 == nccell_set_bg_alpha(&c, NCALPHA_OPAQUE)); CHECK(1 == ncplane_putc(n_, &c)); CHECK(0 == notcurses_render(nc_)); uint64_t channels, underchannels, overchannels; @@ -314,7 +314,7 @@ TEST_CASE("Cell") { nccell c = CELL_TRIVIAL_INITIALIZER; // top has a background of white CHECK(0 == nccell_set_bg_rgb8(&c, 0xff, 0xff, 0xff)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT)); struct ncplane_options nopts = { .y = 0, .x = 0, @@ -332,7 +332,7 @@ TEST_CASE("Cell") { nccell_load_char(n_, &c, '*'); // bottom has white foreground + HIGHCONTRAST, should remain white CHECK(0 == nccell_set_fg_rgb8(&c, 0xff, 0x0, 0xff)); - CHECK(0 == nccell_set_fg_alpha(&c, CELL_ALPHA_HIGHCONTRAST)); + CHECK(0 == nccell_set_fg_alpha(&c, NCALPHA_HIGHCONTRAST)); nccell_set_bg_default(&c); CHECK(1 == ncplane_putc(n_, &c)); CHECK(0 == notcurses_render(nc_)); diff --git a/src/tests/channel.cpp b/src/tests/channel.cpp index f950d4001..a44c4f87c 100644 --- a/src/tests/channel.cpp +++ b/src/tests/channel.cpp @@ -27,12 +27,12 @@ TEST_CASE("ChannelGetAlpha") { uint32_t channel; int a; } test[] = { - { .channel = 0x00000000, .a = CELL_ALPHA_OPAQUE, }, - { .channel = 0x10808080, .a = CELL_ALPHA_BLEND, }, - { .channel = 0x20080808, .a = CELL_ALPHA_TRANSPARENT, }, - { .channel = 0xe0080808, .a = CELL_ALPHA_TRANSPARENT, }, - { .channel = 0x3fffffff, .a = CELL_ALPHA_HIGHCONTRAST, }, - { .channel = 0xffffffff, .a = CELL_ALPHA_HIGHCONTRAST, }, + { .channel = 0x00000000, .a = NCALPHA_OPAQUE, }, + { .channel = 0x10808080, .a = NCALPHA_BLEND, }, + { .channel = 0x20080808, .a = NCALPHA_TRANSPARENT, }, + { .channel = 0xe0080808, .a = NCALPHA_TRANSPARENT, }, + { .channel = 0x3fffffff, .a = NCALPHA_HIGHCONTRAST, }, + { .channel = 0xffffffff, .a = NCALPHA_HIGHCONTRAST, }, }; for(auto i = 0u ; i < sizeof(test) / sizeof(*test) ; ++i){ CHECK(test[i].a == ncchannel_alpha(test[i].channel)); diff --git a/src/tests/notcurses.cpp b/src/tests/notcurses.cpp index 33d04bc71..07a642ec5 100644 --- a/src/tests/notcurses.cpp +++ b/src/tests/notcurses.cpp @@ -105,12 +105,12 @@ TEST_CASE("NotcursesBase") { uint64_t channel = 0; CHECK(0 > ncchannels_set_fg_alpha(&channel, -1)); CHECK(0 > ncchannels_set_fg_alpha(&channel, 4)); - CHECK(0 == ncchannels_set_fg_alpha(&channel, CELL_ALPHA_OPAQUE)); - CHECK(CELL_ALPHA_OPAQUE == ncchannels_fg_alpha(channel)); + CHECK(0 == ncchannels_set_fg_alpha(&channel, NCALPHA_OPAQUE)); + CHECK(NCALPHA_OPAQUE == ncchannels_fg_alpha(channel)); CHECK(ncchannels_fg_default_p(channel)); CHECK(ncchannels_bg_default_p(channel)); - CHECK(0 == ncchannels_set_fg_alpha(&channel, CELL_ALPHA_HIGHCONTRAST)); - CHECK(CELL_ALPHA_HIGHCONTRAST == ncchannels_fg_alpha(channel)); + CHECK(0 == ncchannels_set_fg_alpha(&channel, NCALPHA_HIGHCONTRAST)); + CHECK(NCALPHA_HIGHCONTRAST == ncchannels_fg_alpha(channel)); CHECK(!ncchannels_fg_default_p(channel)); CHECK(ncchannels_bg_default_p(channel)); } @@ -119,11 +119,11 @@ TEST_CASE("NotcursesBase") { uint64_t channel = 0; CHECK(0 > ncchannels_set_bg_alpha(&channel, -1)); CHECK(0 > ncchannels_set_bg_alpha(&channel, 4)); - CHECK(0 == ncchannels_set_bg_alpha(&channel, CELL_ALPHA_OPAQUE)); - CHECK(CELL_ALPHA_OPAQUE == ncchannels_bg_alpha(channel)); - CHECK(0 == ncchannels_set_bg_alpha(&channel, CELL_ALPHA_TRANSPARENT)); - CHECK(0 > ncchannels_set_bg_alpha(&channel, CELL_ALPHA_HIGHCONTRAST)); - CHECK(CELL_ALPHA_TRANSPARENT == ncchannels_bg_alpha(channel)); + CHECK(0 == ncchannels_set_bg_alpha(&channel, NCALPHA_OPAQUE)); + CHECK(NCALPHA_OPAQUE == ncchannels_bg_alpha(channel)); + CHECK(0 == ncchannels_set_bg_alpha(&channel, NCALPHA_TRANSPARENT)); + CHECK(0 > ncchannels_set_bg_alpha(&channel, NCALPHA_HIGHCONTRAST)); + CHECK(NCALPHA_TRANSPARENT == ncchannels_bg_alpha(channel)); CHECK(ncchannels_fg_default_p(channel)); CHECK(!ncchannels_bg_default_p(channel)); } diff --git a/src/tests/palette.cpp b/src/tests/palette.cpp index f11abd879..9b673f066 100644 --- a/src/tests/palette.cpp +++ b/src/tests/palette.cpp @@ -42,22 +42,22 @@ TEST_CASE("Palette256") { SUBCASE("FAttributes") { nccell c = CELL_TRIVIAL_INITIALIZER; CHECK(nccell_fg_default_p(&c)); - nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); + nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT); CHECK(0 == nccell_set_fg_palindex(&c, 0x20)); CHECK(!nccell_fg_default_p(&c)); CHECK(nccell_fg_palindex_p(&c)); - CHECK(CELL_ALPHA_OPAQUE == nccell_fg_alpha(&c)); + CHECK(NCALPHA_OPAQUE == nccell_fg_alpha(&c)); CHECK(0x20 == nccell_fg_palindex(&c)); } SUBCASE("BAttributes") { nccell c = CELL_TRIVIAL_INITIALIZER; CHECK(nccell_bg_default_p(&c)); - nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); + nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT); CHECK(0 == nccell_set_bg_palindex(&c, 0x20)); CHECK(!nccell_bg_default_p(&c)); CHECK(nccell_bg_palindex_p(&c)); - CHECK(CELL_ALPHA_OPAQUE == nccell_bg_alpha(&c)); + CHECK(NCALPHA_OPAQUE == nccell_bg_alpha(&c)); CHECK(0x20 == nccell_bg_palindex(&c)); } @@ -73,8 +73,8 @@ TEST_CASE("Palette256") { CHECK(0 < ncplane_at_yx_cell(n_, 0, 0, &r)); CHECK(nccell_fg_palindex_p(&r)); CHECK(nccell_bg_palindex_p(&r)); - CHECK(CELL_ALPHA_OPAQUE == nccell_fg_alpha(&r)); - CHECK(CELL_ALPHA_OPAQUE == nccell_bg_alpha(&r)); + CHECK(NCALPHA_OPAQUE == nccell_fg_alpha(&r)); + CHECK(NCALPHA_OPAQUE == nccell_bg_alpha(&r)); CHECK(0x20 == nccell_fg_palindex(&r)); CHECK(0x40 == nccell_bg_palindex(&r)); nccell_release(n_, &r); @@ -94,8 +94,8 @@ TEST_CASE("Palette256") { CHECK(nullptr != notcurses_at_yx(nc_, 0, 0, &r.stylemask, &r.channels)); CHECK(nccell_fg_palindex_p(&r)); CHECK(nccell_bg_palindex_p(&r)); - CHECK(CELL_ALPHA_OPAQUE == nccell_fg_alpha(&r)); - CHECK(CELL_ALPHA_OPAQUE == nccell_bg_alpha(&r)); + CHECK(NCALPHA_OPAQUE == nccell_fg_alpha(&r)); + CHECK(NCALPHA_OPAQUE == nccell_bg_alpha(&r)); CHECK(0x20 == nccell_fg_palindex(&r)); CHECK(0x40 == nccell_bg_palindex(&r)); nccell_release(n_, &r); diff --git a/src/tests/plot.cpp b/src/tests/plot.cpp index 8d0c1890a..6e95966f7 100644 --- a/src/tests/plot.cpp +++ b/src/tests/plot.cpp @@ -158,8 +158,8 @@ TEST_CASE("Plot") { memset(&popts, 0, sizeof(popts)); popts.maxchannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0); popts.minchannels = CHANNELS_RGB_INITIALIZER(0, 0xff, 0, 0, 0, 0); - ncchannels_set_bg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); - ncchannels_set_fg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&popts.minchannels, NCALPHA_BLEND); + ncchannels_set_fg_alpha(&popts.minchannels, NCALPHA_BLEND); popts.gridtype = NCBLIT_BRAILLE; auto p = ncuplot_create(ncp, &popts, 0, 0); REQUIRE(p); @@ -189,8 +189,8 @@ TEST_CASE("Plot") { memset(&popts, 0, sizeof(popts)); popts.maxchannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0); popts.minchannels = CHANNELS_RGB_INITIALIZER(0, 0xff, 0, 0, 0, 0); - ncchannels_set_bg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); - ncchannels_set_fg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&popts.minchannels, NCALPHA_BLEND); + ncchannels_set_fg_alpha(&popts.minchannels, NCALPHA_BLEND); popts.gridtype = NCBLIT_2x2; auto p = ncuplot_create(ncp, &popts, 0, 0); REQUIRE(p); @@ -216,8 +216,8 @@ TEST_CASE("Plot") { memset(&popts, 0, sizeof(popts)); popts.maxchannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0); popts.minchannels = CHANNELS_RGB_INITIALIZER(0, 0xff, 0, 0, 0, 0); - ncchannels_set_bg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); - ncchannels_set_fg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&popts.minchannels, NCALPHA_BLEND); + ncchannels_set_fg_alpha(&popts.minchannels, NCALPHA_BLEND); popts.gridtype = NCBLIT_8x1; auto p = ncuplot_create(ncp, &popts, 0, 0); REQUIRE(p); @@ -240,8 +240,8 @@ TEST_CASE("Plot") { memset(&popts, 0, sizeof(popts)); popts.maxchannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0); popts.minchannels = CHANNELS_RGB_INITIALIZER(0, 0xff, 0, 0, 0, 0); - ncchannels_set_bg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); - ncchannels_set_fg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&popts.minchannels, NCALPHA_BLEND); + ncchannels_set_fg_alpha(&popts.minchannels, NCALPHA_BLEND); popts.gridtype = NCBLIT_3x2; auto p = ncuplot_create(ncp, &popts, 0, 0); REQUIRE(p); @@ -267,8 +267,8 @@ TEST_CASE("Plot") { memset(&popts, 0, sizeof(popts)); popts.maxchannels = CHANNELS_RGB_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0); popts.minchannels = CHANNELS_RGB_INITIALIZER(0, 0xff, 0, 0, 0, 0); - ncchannels_set_bg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); - ncchannels_set_fg_alpha(&popts.minchannels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&popts.minchannels, NCALPHA_BLEND); + ncchannels_set_fg_alpha(&popts.minchannels, NCALPHA_BLEND); popts.gridtype = NCBLIT_BRAILLE; auto p = ncuplot_create(ncp, &popts, 0, 0); REQUIRE(p); diff --git a/src/tests/reel.cpp b/src/tests/reel.cpp index 45414be84..f8ef44d25 100644 --- a/src/tests/reel.cpp +++ b/src/tests/reel.cpp @@ -289,7 +289,7 @@ TEST_CASE("Reels") { int dimy, dimx; notcurses_term_dim_yx(nc_, &dimy, &dimx); uint64_t channels = 0; - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); struct ncplane_options nopts = { .y = 0, .x = 0, diff --git a/src/tests/rotate.cpp b/src/tests/rotate.cpp index 045df32c4..27d32ba3b 100644 --- a/src/tests/rotate.cpp +++ b/src/tests/rotate.cpp @@ -64,8 +64,8 @@ TEST_CASE("Rotate") { }; struct ncplane* testn = ncplane_create(n_, &nopts); uint64_t channels = 0; - CHECK(0 == ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT)); - CHECK(0 == ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT)); + CHECK(0 == ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT)); + CHECK(0 == ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT)); REQUIRE(0 >= ncplane_set_base(testn, "", 0, channels)); nccell tl = CELL_TRIVIAL_INITIALIZER, tr = CELL_TRIVIAL_INITIALIZER; nccell bl = CELL_TRIVIAL_INITIALIZER, br = CELL_TRIVIAL_INITIALIZER; diff --git a/src/tests/wide.cpp b/src/tests/wide.cpp index 1cb40d4ab..343d82102 100644 --- a/src/tests/wide.cpp +++ b/src/tests/wide.cpp @@ -416,7 +416,7 @@ TEST_CASE("Wide") { int sbytes; CHECK(2 == ncplane_putegc_yx(n_, 1, 1, "六", &sbytes)); uint64_t channels = 0; - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_BLEND); + ncchannels_set_bg_alpha(&channels, NCALPHA_BLEND); ncchannels_set_bg_rgb8(&channels, 0x80, 0xf0, 0x10); CHECK(1 == ncplane_set_base(p, " ", 0, channels)); CHECK(0 == notcurses_render(nc_)); diff --git a/src/tetris/background.h b/src/tetris/background.h index c8e753d02..298bb5929 100644 --- a/src/tetris/background.h +++ b/src/tetris/background.h @@ -19,16 +19,16 @@ void DrawBoard() { // draw all fixed components of the game board_top_y_, x / 2 - (BOARD_WIDTH + 1)); uint64_t channels = 0; ncchannels_set_fg_rgb(&channels, 0x00b040); - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); board_->double_box(0, channels, BOARD_HEIGHT - 1, BOARD_WIDTH * 2 - 1, NCBOXMASK_TOP); - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); board_->set_base("", 0, channels); scoreplane_ = std::make_unique(2, 30, y - BOARD_HEIGHT, 2, nullptr); uint64_t scorechan = 0; - ncchannels_set_bg_alpha(&scorechan, CELL_ALPHA_TRANSPARENT); - ncchannels_set_fg_alpha(&scorechan, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&scorechan, NCALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&scorechan, NCALPHA_TRANSPARENT); scoreplane_->set_base("", 0, scorechan); - scoreplane_->set_bg_alpha(CELL_ALPHA_TRANSPARENT); + scoreplane_->set_bg_alpha(NCALPHA_TRANSPARENT); scoreplane_->set_fg_rgb(0xd040d0); scoreplane_->printf(0, 1, "%s", getpwuid(geteuid())->pw_name); scoreplane_->set_fg_rgb(0x00d0a0); diff --git a/src/tetris/newpiece.h b/src/tetris/newpiece.h index fb1a891e8..d60686fd8 100644 --- a/src/tetris/newpiece.h +++ b/src/tetris/newpiece.h @@ -19,10 +19,10 @@ std::unique_ptr NewPiece() { std::unique_ptr n = std::make_unique(2, cols, board_top_y_ - 1, xoff, nullptr); if(n){ uint64_t channels = 0; - ncchannels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); - ncchannels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT); + ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT); + ncchannels_set_fg_alpha(&channels, NCALPHA_TRANSPARENT); n->set_fg_rgb(t->color); - n->set_bg_alpha(CELL_ALPHA_TRANSPARENT); + n->set_bg_alpha(NCALPHA_TRANSPARENT); n->set_base("", 0, channels); y = 0; x = 0; for(size_t i = 0 ; i < strlen(t->texture) ; ++i){