diff --git a/include/ncpp/Cell.hh b/include/ncpp/Cell.hh index 457dcd297..d280f5663 100644 --- a/include/ncpp/Cell.hh +++ b/include/ncpp/Cell.hh @@ -102,12 +102,12 @@ namespace ncpp unsigned get_fg_rgb () const noexcept { - return cell_fg_rgb (&_cell); + return nccell_fg_rgb (&_cell); } unsigned get_bg_rgb () const noexcept { - return cell_bg_rgb (&_cell); + return nccell_bg_rgb (&_cell); } unsigned get_fg_alpha () const noexcept @@ -168,7 +168,7 @@ namespace ncpp bool set_bg_rgb8 (int r, int g, int b, bool clipped = false) noexcept { if (clipped) { - cell_set_bg_rgb8_clipped (&_cell, r, g, b); + nccell_set_bg_rgb8_clipped (&_cell, r, g, b); return true; } diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 0e6f7a3b4..8f5f3ee69 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -2086,16 +2086,26 @@ API void ncplane_erase(struct ncplane* n); // Extract 24 bits of foreground RGB from 'cl', shifted to LSBs. static inline uint32_t -cell_fg_rgb(const nccell* cl){ +nccell_fg_rgb(const nccell* cl){ return channels_fg_rgb(cl->channels); } +__attribute__ ((deprecated)) static inline uint32_t +cell_fg_rgb(const nccell* cl){ + return nccell_fg_rgb(cl); +} + // Extract 24 bits of background RGB from 'cl', shifted to LSBs. static inline uint32_t -cell_bg_rgb(const nccell* cl){ +nccell_bg_rgb(const nccell* cl){ return channels_bg_rgb(cl->channels); } +__attribute__ ((deprecated)) static inline uint32_t +cell_bg_rgb(const nccell* cl){ + return nccell_bg_rgb(cl); +} + // Extract 2 bits of foreground alpha from 'cl', shifted to LSBs. static inline uint32_t nccell_fg_alpha(const nccell* cl){ @@ -2211,10 +2221,15 @@ cell_set_bg_rgb8(nccell* cl, int r, int g, int b){ // Same, but clipped to [0..255]. static inline void -cell_set_bg_rgb8_clipped(nccell* cl, int r, int g, int b){ +nccell_set_bg_rgb8_clipped(nccell* cl, int r, int g, int b){ channels_set_bg_rgb8_clipped(&cl->channels, r, g, b); } +__attribute__ ((deprecated)) static inline void +cell_set_bg_rgb8_clipped(nccell* cl, int r, int g, int b){ + nccell_set_bg_rgb8_clipped(cl, r, g, b); +} + // Same, but with an assembled 24-bit RGB value. A value over 0xffffff // will be rejected, with a non-zero return value. static inline int diff --git a/rust/src/cells/test/reimplemented.rs b/rust/src/cells/test/reimplemented.rs index 246095ac6..8d489da7f 100644 --- a/rust/src/cells/test/reimplemented.rs +++ b/rust/src/cells/test/reimplemented.rs @@ -10,13 +10,13 @@ fn rgb() { // rgb let mut c1 = NcCell::new(); - assert_eq![0, crate::cell_fg_rgb(&c1)]; - assert_eq![0, crate::cell_bg_rgb(&c1)]; + assert_eq![0, crate::nccell_fg_rgb(&c1)]; + assert_eq![0, crate::nccell_bg_rgb(&c1)]; crate::cell_set_fg_rgb(&mut c1, 0x99112233); - assert_eq![0x112233, crate::cell_fg_rgb(&c1)]; + assert_eq![0x112233, crate::nccell_fg_rgb(&c1)]; crate::cell_set_bg_rgb(&mut c1, 0x99445566); - assert_eq![0x445566, crate::cell_bg_rgb(&c1)]; + assert_eq![0x445566, crate::nccell_bg_rgb(&c1)]; // rgb8 @@ -24,12 +24,12 @@ fn rgb() { let (mut r, mut g, mut b) = (0, 0, 0); crate::cell_set_fg_rgb8(&mut c2, 0x11, 0x22, 0x33); - let fchannel = crate::cell_fg_rgb8(&c2, &mut r, &mut g, &mut b); + let fchannel = crate::nccell_fg_rgb8(&c2, &mut r, &mut g, &mut b); assert_eq!((0x11, 0x22, 0x33), (r, g, b)); assert_eq![0x112233, fchannel & !crate::NCCELL_BGDEFAULT_MASK]; crate::cell_set_bg_rgb8(&mut c2, 0x44, 0x55, 0x66); - let bchannel = crate::cell_bg_rgb8(&c2, &mut r, &mut g, &mut b); + let bchannel = crate::nccell_bg_rgb8(&c2, &mut r, &mut g, &mut b); assert_eq!((0x44, 0x55, 0x66), (r, g, b)); assert_eq![0x445566, bchannel & !crate::NCCELL_BGDEFAULT_MASK]; } @@ -41,63 +41,63 @@ fn alpha() { assert_eq![0, crate::cell_fg_alpha(&c1)]; assert_eq![0, crate::cell_bg_alpha(&c1)]; - crate::cell_set_fg_alpha(&mut c1, crate::NCCELL_ALPHA_TRANSPARENT); - assert_eq![crate::NCCELL_ALPHA_TRANSPARENT, crate::cell_fg_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::cell_set_bg_alpha(&mut c1, crate::NCCELL_ALPHA_BLEND); - assert_eq![crate::NCCELL_ALPHA_BLEND, crate::cell_bg_alpha(&c1)]; + crate::nccell_set_bg_alpha(&mut c1, crate::NCCELL_ALPHA_BLEND); + assert_eq![crate::NCCELL_ALPHA_BLEND, crate::nccell_bg_alpha(&c1)]; } #[test] #[serial] fn default() { let mut c1 = NcCell::new(); - assert_eq![true, crate::cell_fg_default_p(&c1)]; - assert_eq![true, crate::cell_bg_default_p(&c1)]; + assert_eq![true, crate::nccell_fg_default_p(&c1)]; + assert_eq![true, crate::nccell_bg_default_p(&c1)]; // rgb crate::cell_set_fg_rgb(&mut c1, 0x112233); crate::cell_set_bg_rgb(&mut c1, 0x445566); - assert_eq![false, crate::cell_fg_default_p(&c1)]; - assert_eq![false, crate::cell_bg_default_p(&c1)]; + assert_eq![false, crate::nccell_fg_default_p(&c1)]; + assert_eq![false, crate::nccell_bg_default_p(&c1)]; // reset crate::cell_set_fg_default(&mut c1); crate::cell_set_bg_default(&mut c1); - assert_eq![true, crate::cell_fg_default_p(&c1)]; - assert_eq![true, crate::cell_bg_default_p(&c1)]; + assert_eq![true, crate::nccell_fg_default_p(&c1)]; + assert_eq![true, crate::nccell_bg_default_p(&c1)]; // rgb8 crate::cell_set_fg_rgb8(&mut c1, 0x11, 0x22, 0x33); crate::cell_set_bg_rgb8(&mut c1, 0x44, 0x55, 0x66); - assert_eq![false, crate::cell_fg_default_p(&c1)]; - assert_eq![false, crate::cell_bg_default_p(&c1)]; + assert_eq![false, crate::nccell_fg_default_p(&c1)]; + assert_eq![false, crate::nccell_bg_default_p(&c1)]; // reset - crate::cell_set_fg_default(&mut c1); - crate::cell_set_bg_default(&mut c1); + crate::nccell_set_fg_default(&mut c1); + crate::nccell_set_bg_default(&mut c1); // palette - crate::cell_set_fg_palindex(&mut c1, 5); - crate::cell_set_bg_palindex(&mut c1, 6); - assert_eq![false, crate::cell_fg_default_p(&c1)]; - assert_eq![false, crate::cell_bg_default_p(&c1)]; + crate::nccell_set_fg_palindex(&mut c1, 5); + crate::nccell_set_bg_palindex(&mut c1, 6); + assert_eq![false, crate::nccell_fg_default_p(&c1)]; + assert_eq![false, crate::nccell_bg_default_p(&c1)]; } #[test] #[serial] fn palette() { let mut c1 = NcCell::new(); - assert_eq![false, crate::cell_fg_palindex_p(&c1)]; - assert_eq![false, crate::cell_bg_palindex_p(&c1)]; - assert_eq![0, crate::cell_fg_palindex(&c1)]; - assert_eq![0, crate::cell_bg_palindex(&c1)]; - - crate::cell_set_fg_palindex(&mut c1, 5); - crate::cell_set_bg_palindex(&mut c1, 6); - assert_eq![true, crate::cell_fg_palindex_p(&c1)]; - assert_eq![true, crate::cell_bg_palindex_p(&c1)]; - - assert_eq![5, crate::cell_fg_palindex(&c1)]; - assert_eq![6, crate::cell_bg_palindex(&c1)]; + assert_eq![false, crate::nccell_fg_palindex_p(&c1)]; + assert_eq![false, crate::nccell_bg_palindex_p(&c1)]; + assert_eq![0, crate::nccell_fg_palindex(&c1)]; + assert_eq![0, crate::nccell_bg_palindex(&c1)]; + + crate::nccell_set_fg_palindex(&mut c1, 5); + crate::nccell_set_bg_palindex(&mut c1, 6); + assert_eq![true, crate::nccell_fg_palindex_p(&c1)]; + assert_eq![true, crate::nccell_bg_palindex_p(&c1)]; + + assert_eq![5, crate::nccell_fg_palindex(&c1)]; + assert_eq![6, crate::nccell_bg_palindex(&c1)]; } diff --git a/src/demo/hud.c b/src/demo/hud.c index c4e65efc8..63f4f876d 100644 --- a/src/demo/hud.c +++ b/src/demo/hud.c @@ -370,7 +370,7 @@ hud_print_finished(elem* list){ if(hud){ nccell c = CELL_TRIVIAL_INITIALIZER; ncplane_base(hud, &c); - ncplane_set_bg_rgb(hud, cell_bg_rgb(&c)); + ncplane_set_bg_rgb(hud, nccell_bg_rgb(&c)); ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND); ncplane_set_fg_rgb(hud, 0xffffff); ncplane_set_fg_alpha(hud, CELL_ALPHA_OPAQUE); @@ -585,7 +585,7 @@ int demo_render(struct notcurses* nc){ ++elems->frames; nccell c = CELL_TRIVIAL_INITIALIZER; ncplane_base(hud, &c); - ncplane_set_bg_rgb(hud, cell_bg_rgb(&c)); + ncplane_set_bg_rgb(hud, nccell_bg_rgb(&c)); ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND); ncplane_set_fg_rgb(hud, 0x80d0ff); ncplane_set_fg_alpha(hud, CELL_ALPHA_OPAQUE); diff --git a/src/tests/fills.cpp b/src/tests/fills.cpp index d4d20a027..bffb91bf0 100644 --- a/src/tests/fills.cpp +++ b/src/tests/fills.cpp @@ -255,7 +255,7 @@ TEST_CASE("Fills") { nccell d = CELL_TRIVIAL_INITIALIZER; CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &d)); CHECK(d.stylemask == c.stylemask); - CHECK(0x444444 == cell_fg_rgb(&d)); + CHECK(0x444444 == nccell_fg_rgb(&d)); } SUBCASE("Ncplane_Stain") {