diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 000000000..43ec86234 --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1 @@ +examples/*.c diff --git a/rust/build/build.rs b/rust/build/build.rs index 6484a3acf..0f65bca50 100644 --- a/rust/build/build.rs +++ b/rust/build/build.rs @@ -42,6 +42,13 @@ fn main() { .no_copy("ncuplot") .no_copy("ncvisual") .no_copy("notcurses") + // try to derive more traits + .derive_default(true) + .derive_hash(true) + .derive_partialord(true) + .derive_ord(true) + .derive_partialeq(true) + .derive_eq(true) // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks)); diff --git a/rust/examples/issue-1509.rs b/rust/examples/issue-1509.rs new file mode 100644 index 000000000..2be2c7bea --- /dev/null +++ b/rust/examples/issue-1509.rs @@ -0,0 +1,65 @@ +//! https://github.com/dankamongmen/notcurses/issues/1509 +//! strange color behaviour when moving planes +// +// TODO +// - +// + +use std::collections::BTreeMap; + +use libnotcurses_sys::*; + +fn main() { + let mut map = BTreeMap::::new(); + + let _res = notcurses(&mut map); + + for (k, v) in map { + //println!("{}: {:016X}", k, v.channels); + //println!("{}: {:064b}", k, v.channels); + println!("{}: {:?}", k, v); + } +} + +fn notcurses(map: &mut BTreeMap) -> NcResult<()> { + let mut nc = FullMode::new()?; + + let stdplane = nc.stdplane(); + map.insert("stdp_base0".into(), stdplane.base()?); + + let mut channels = NcChannelPair::with_rgb8(0, 0, 0, 0, 0x88, 0); + stdplane.set_base(" ", 0, channels)?; + map.insert("stdp_base1".into(), stdplane.base()?); + + // create one 1x1 blue plane on the top left corner + let blue = NcPlane::new_bound(stdplane, 0, 0, 1, 1)?; + map.insert("blue_base0".into(), blue.base()?); + blue.set_base(" ", 0, channels.set_bg_rgb8(0, 0, 0x88))?; + map.insert("blue_base1".into(), blue.base()?); + rsleep![&mut nc, 0, 500]; + + // create another 1x1 red plane, on top + let red = NcPlane::new_bound(stdplane, 0, 0, 1, 1)?; + map.insert(" red_base0".into(), red.base()?); + red.set_base(" ", 0, channels.set_bg_rgb8(0x88, 0, 0))?; + map.insert(" red_base1".into(), red.base()?); + rsleep![&mut nc, 0, 500]; + + // move the red plane to the bottom + // BUG: the underlying blue plane renders black + red.move_yx(1, 0)?; + map.insert("blue_base2".into(), blue.base()?); + map.insert(" red_base2".into(), red.base()?); + map.insert("stdp_base2".into(), stdplane.base()?); + rsleep![&mut nc, 1]; + + // move the blue plane to the right + // BUG: the underlying green stdplane plane renders black + blue.move_yx(0, 1)?; + map.insert("stdp_base3".into(), stdplane.base()?); // CHECK + map.insert(" red_base3".into(), red.base()?); + map.insert("blue_base3".into(), blue.base()?); + rsleep![&mut nc, 1]; + + Ok(()) +} diff --git a/rust/src/plane/methods.rs b/rust/src/plane/methods.rs index f2ec03406..f29e6b53d 100644 --- a/rust/src/plane/methods.rs +++ b/rust/src/plane/methods.rs @@ -575,7 +575,7 @@ impl NcPlane { /// /// *C style function: [ncplane_at_yx_cell()][crate::ncplane_at_yx_cell].* #[inline] - pub fn ncplane_at_yx_cell(&mut self, y: NcDim, x: NcDim, cell: &mut NcCell) -> NcResult { + pub fn at_yx_cell(&mut self, y: NcDim, x: NcDim, cell: &mut NcCell) -> NcResult { let bytes = unsafe { crate::ncplane_at_yx_cell(self, y as i32, x as i32, cell) }; error![ bytes, @@ -584,7 +584,7 @@ impl NcPlane { ] } - /// Extracts this NcPlane's base [NcCell] into `cell`. + /// Extracts this NcPlane's base [NcCell]. /// /// The reference is invalidated if this NcPlane is destroyed. ///