mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
rust: add ncplane_abs_yx, ncplane_abs_y, ncplane_abs_x
- minor updates
This commit is contained in:
parent
29ac41440c
commit
aa9bf7a0e7
@ -1,4 +1,4 @@
|
||||
//! pixel example
|
||||
//! pixel-cell example
|
||||
//!
|
||||
//! Shows how to get the size of a cell in pixels
|
||||
//!
|
||||
@ -42,7 +42,7 @@ fn main() -> NcResult<()> {
|
||||
let range = Uniform::from(50..=180);
|
||||
let mut buffer = Vec::<u8>::with_capacity((cell_y * cell_x * 4) as usize);
|
||||
#[allow(unused_parens)]
|
||||
for _byte in (0..={ cell_x * cell_y }) {
|
||||
for _byte in (0..={ cell_y * cell_x }) {
|
||||
buffer.push(rng.sample(&range));
|
||||
buffer.push(rng.sample(&range));
|
||||
buffer.push(rng.sample(&range));
|
||||
|
@ -1,5 +1,7 @@
|
||||
//! based on the proof of concept at ../../src/poc/menu.c
|
||||
|
||||
// FIXME: has bugs, doesn't work well
|
||||
|
||||
use libnotcurses_sys::*;
|
||||
|
||||
fn main() -> NcResult<()> {
|
||||
|
@ -327,6 +327,9 @@ pub use ffi::{
|
||||
pub use ffi::{
|
||||
// functions
|
||||
ncplane_above,
|
||||
ncplane_abs_x,
|
||||
ncplane_abs_y,
|
||||
ncplane_abs_yx,
|
||||
ncplane_at_cursor,
|
||||
ncplane_at_cursor_cell,
|
||||
ncplane_at_yx,
|
||||
|
@ -370,7 +370,7 @@ impl NcPlane {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the backround [NcRgb] for this NcPlane.
|
||||
/// Sets the background [NcRgb] for this NcPlane.
|
||||
///
|
||||
/// *C style function: [ncplane_set_bg_rgb()][crate::ncplane_set_bg_rgb].*
|
||||
#[inline]
|
||||
@ -844,6 +844,32 @@ impl NcPlane {
|
||||
// -----------------------------------------------------------------------------
|
||||
/// ## NcPlane methods: `NcPlane` & `Notcurses`
|
||||
impl NcPlane {
|
||||
/// Gets the origin of this plane relative to its pile.
|
||||
///
|
||||
/// *C style function: [ncplane_abs_yx()][crate::ncplane_abs_yx].*
|
||||
pub fn abs_yx(&self) -> (NcDim, NcDim) {
|
||||
let mut y = 0;
|
||||
let mut x = 0;
|
||||
unsafe {
|
||||
crate::ncplane_abs_yx(self, &mut y, &mut x);
|
||||
}
|
||||
(y as NcDim, x as NcDim)
|
||||
}
|
||||
|
||||
/// Gets the origin of this plane relative to its pile, in the y axis.
|
||||
///
|
||||
/// *C style function: [ncplane_abs_y()][crate::ncplane_abs_y].*
|
||||
pub fn abs_y(&self) -> NcDim {
|
||||
unsafe { crate::ncplane_abs_y(self) as NcDim }
|
||||
}
|
||||
|
||||
/// Gets the origin of this plane relative to its pile, in the x axis.
|
||||
///
|
||||
/// *C style function: [ncplane_abs_x()][crate::ncplane_abs_x].*
|
||||
pub fn abs_x(&self) -> NcDim {
|
||||
unsafe { crate::ncplane_abs_x(self) as NcDim }
|
||||
}
|
||||
|
||||
/// Duplicates this NcPlane.
|
||||
///
|
||||
/// The new NcPlane will have the same geometry, the same rendering state,
|
||||
|
@ -5,7 +5,7 @@
|
||||
// (X) wont: 6
|
||||
// (D) depr: 4
|
||||
// (#) test: 13
|
||||
// (W) wrap: 81 of 98
|
||||
// (W) wrap: 81 of 101 (111 - 6 - 4)
|
||||
// -------------------------------------------
|
||||
//W ncpile_bottom
|
||||
//W# ncpile_create
|
||||
@ -13,6 +13,9 @@
|
||||
//W ncpile_render
|
||||
//W ncpile_top
|
||||
//W ncplane_above
|
||||
//W ncplane_abs_x
|
||||
//W ncplane_abs_y
|
||||
//W ncplane_abs_yx
|
||||
//W ncplane_at_cursor
|
||||
//W ncplane_at_cursor_cell
|
||||
//W ncplane_at_yx
|
||||
|
Loading…
Reference in New Issue
Block a user