Merge branch 'master' of github.com:dankamongmen/notcurses

This commit is contained in:
nick black 2021-04-10 09:11:09 -04:00
commit 94a2badc06
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
7 changed files with 95 additions and 23 deletions

View File

@ -24,6 +24,9 @@ Palette size: {6:?}
nc.palette_size(), nc.palette_size(),
); );
let pixelgeom = nc.stdplane().pixelgeom();
println!("{:#?}", pixelgeom);
rsleep![&mut nc, 1]; rsleep![&mut nc, 1];
Ok(()) Ok(())
} }

View File

@ -332,6 +332,7 @@ pub use ffi::{
ncplane_abs_x, ncplane_abs_x,
ncplane_abs_y, ncplane_abs_y,
ncplane_abs_yx, ncplane_abs_yx,
ncplane_as_rgba,
ncplane_at_cursor, ncplane_at_cursor,
ncplane_at_cursor_cell, ncplane_at_cursor_cell,
ncplane_at_yx, ncplane_at_yx,
@ -373,6 +374,7 @@ pub use ffi::{
ncplane_on_styles, ncplane_on_styles,
ncplane_parent, ncplane_parent,
ncplane_parent_const, ncplane_parent_const,
ncplane_pixelgeom,
ncplane_polyfill_yx, ncplane_polyfill_yx,
ncplane_pulse, ncplane_pulse,
ncplane_putc_yx, ncplane_putc_yx,
@ -395,7 +397,6 @@ pub use ffi::{
ncplane_resize_maximize, ncplane_resize_maximize,
ncplane_resize_realign, ncplane_resize_realign,
ncplane_resizecb, ncplane_resizecb,
ncplane_as_rgba,
ncplane_rotate_ccw, ncplane_rotate_ccw,
ncplane_rotate_cw, ncplane_rotate_cw,
ncplane_set_base, ncplane_set_base,
@ -662,6 +663,7 @@ pub use ffi::{
pub use ffi::{ pub use ffi::{
// functions // functions
ncvisual_at_yx, ncvisual_at_yx,
ncvisual_blitter_geom,
ncvisual_decode, ncvisual_decode,
ncvisual_decode_loop, ncvisual_decode_loop,
ncvisual_destroy, ncvisual_destroy,
@ -669,7 +671,6 @@ pub use ffi::{
ncvisual_from_file, ncvisual_from_file,
ncvisual_from_plane, ncvisual_from_plane,
ncvisual_from_rgba, ncvisual_from_rgba,
ncvisual_blitter_geom,
ncvisual_media_defblitter, ncvisual_media_defblitter,
ncvisual_polyfill_yx, ncvisual_polyfill_yx,
ncvisual_render, ncvisual_render,

View File

@ -154,10 +154,10 @@ macro_rules! error_ref {
} }
}; };
($ptr:expr, $msg:expr) => { ($ptr:expr, $msg:expr) => {
error_ref![$ptr, $msg, &*$ptr ]; error_ref![$ptr, $msg, &*$ptr];
}; };
($ptr:expr) => { ($ptr:expr) => {
error_ref![$ptr, "", &*$ptr ]; error_ref![$ptr, "", &*$ptr];
}; };
} }
@ -180,10 +180,10 @@ macro_rules! error_ref_mut {
} }
}; };
($ptr:expr, $msg:expr) => { ($ptr:expr, $msg:expr) => {
error_ref_mut![$ptr, $msg, &mut *$ptr ]; error_ref_mut![$ptr, $msg, &mut *$ptr];
}; };
($ptr:expr) => { ($ptr:expr) => {
error_ref_mut![$ptr, "", &mut *$ptr ]; error_ref_mut![$ptr, "", &mut *$ptr];
}; };
} }

View File

@ -8,8 +8,8 @@ use core::{
use crate::{ use crate::{
cstring, error, error_ref, error_ref_mut, rstring, NcAlign, NcAlphaBits, NcBlitter, NcBoxMask, cstring, error, error_ref, error_ref_mut, rstring, NcAlign, NcAlphaBits, NcBlitter, NcBoxMask,
NcCell, NcChannel, NcChannelPair, NcColor, NcDim, NcEgc, NcError, NcFadeCb, NcOffset, NcCell, NcChannel, NcChannelPair, NcColor, NcDim, NcEgc, NcError, NcFadeCb, NcOffset,
NcPaletteIndex, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb, NcStyleMask, NcTime, NcPaletteIndex, NcPixelGeometry, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb,
Notcurses, NCRESULT_ERR, NcStyleMask, NcTime, Notcurses, NCRESULT_ERR,
}; };
/// # NcPlaneOptions Constructors /// # NcPlaneOptions Constructors
@ -1445,16 +1445,63 @@ impl NcPlane {
let mut pxdimx = 0; let mut pxdimx = 0;
let res_array = unsafe { let res_array = unsafe {
crate::ncplane_as_rgba(self, blitter, beg_y as i32, beg_x as i32, len_y2, len_x2, &mut pxdimy, &mut pxdimx) crate::ncplane_as_rgba(
self,
blitter,
beg_y as i32,
beg_x as i32,
len_y2,
len_x2,
&mut pxdimy,
&mut pxdimx,
)
}; };
error_ref_mut![ error_ref_mut![
res_array, res_array,
&format!["NcPlane.rgba({}, {}, {}, {:?}, {:?})", blitter, beg_y, beg_x, len_y, len_x], &format![
"NcPlane.rgba({}, {}, {}, {:?}, {:?})",
blitter, beg_y, beg_x, len_y, len_x
],
from_raw_parts_mut(res_array, (pxdimy * pxdimx) as usize) from_raw_parts_mut(res_array, (pxdimy * pxdimx) as usize)
] ]
} }
/// Returns an [NcPixelGeometry] structure filled with pixel geometry for
/// the display region, each cell, and the maximum displayable bitmap.
///
/// This function calls [notcurses_check_pixel_support], possibly leading to
/// an interrogation of the terminal.
///
/// *C style function: [ncplane_pixelgeom()][crate::ncplane_pixelgeom].*
pub fn pixelgeom(&mut self) -> NcPixelGeometry {
let mut pxy = 0;
let mut pxx = 0;
let mut celldimy = 0;
let mut celldimx = 0;
let mut maxbmapy = 0;
let mut maxbmapx = 0;
unsafe {
crate::ncplane_pixelgeom(
self,
&mut pxy,
&mut pxx,
&mut celldimy,
&mut celldimx,
&mut maxbmapy,
&mut maxbmapx,
);
}
NcPixelGeometry {
display_y: pxy as NcDim,
display_x: pxx as NcDim,
cell_y: celldimy as NcDim,
cell_x: celldimx as NcDim,
max_bitmap_y: maxbmapy as NcDim,
max_bitmap_x: maxbmapx as NcDim,
}
}
/// Realigns this NcPlane against its parent, using the alignment specified /// Realigns this NcPlane against its parent, using the alignment specified
/// at creation time. /// at creation time.
/// ///

View File

@ -1,11 +1,11 @@
//! `NcPlane` //! `NcPlane`
// functions already exported by bindgen : 112 // functions already exported by bindgen : 113
// ------------------------------------------- // -------------------------------------------
// (X) wont: 6 // (X) wont: 6
// (D) depr: 4 // (D) depr: 4
// (#) test: 13 // (#) test: 13
// (W) wrap: 82 of 102 (112 - 6 - 4) // (W) wrap: 83 of 102 (112 - 6 - 4)
// ------------------------------------------- // -------------------------------------------
//W ncpile_bottom //W ncpile_bottom
//W# ncpile_create //W# ncpile_create
@ -58,6 +58,7 @@
//W ncplane_on_styles //W ncplane_on_styles
//W ncplane_parent //W ncplane_parent
//W ncplane_parent_const //W ncplane_parent_const
//W ncplane_pixelgeom
// ncplane_polyfill_yx // ncplane_polyfill_yx
//W ncplane_pulse //W ncplane_pulse
// ncplane_putchar_stained // ncplane_putchar_stained
@ -182,6 +183,8 @@ mod reimplemented;
pub(crate) use helpers::*; pub(crate) use helpers::*;
pub use reimplemented::*; pub use reimplemented::*;
use crate::NcDim;
// NcPlane // NcPlane
/// Fundamental drawing surface. /// Fundamental drawing surface.
/// ///
@ -323,3 +326,18 @@ pub const NCBLIT_DEFAULT: NcBlitter = crate::bindings::ffi::ncblitter_e_NCBLIT_D
/// ///
/// See [Sixel in Wikipedia](https://en.wikipedia.org/wiki/Sixel). /// See [Sixel in Wikipedia](https://en.wikipedia.org/wiki/Sixel).
pub const NCBLIT_PIXEL: NcBlitter = crate::bindings::ffi::ncblitter_e_NCBLIT_PIXEL; pub const NCBLIT_PIXEL: NcBlitter = crate::bindings::ffi::ncblitter_e_NCBLIT_PIXEL;
/// Contains the pixel geometry information as returned by the
/// NcPlane.[pixelgeom()][NcPlane#method.pixelgeom] method.
///
/// If bitmaps are not supported, the fields max_bitmap_[yx] will be 0.
#[derive(Clone, Debug)]
pub struct NcPixelGeometry {
/// Geometry of the display region
pub display_y: NcDim,
pub display_x: NcDim,
pub cell_y: NcDim,
pub cell_x: NcDim,
pub max_bitmap_y: NcDim,
pub max_bitmap_x: NcDim,
}

View File

@ -13,7 +13,7 @@
//W ncvisual_from_file //W ncvisual_from_file
//W ncvisual_from_plane //W ncvisual_from_plane
//W ncvisual_from_rgba //W ncvisual_from_rgba
//W ncvisual_geom //W ncvisual_blitter_geom
//W ncvisual_media_defblitter //W ncvisual_media_defblitter
//W ncvisual_polyfill_yx //W ncvisual_polyfill_yx
//W ncvisual_render //W ncvisual_render
@ -321,7 +321,7 @@ impl NcVisual {
/// ///
/// Errors on invalid blitter in `options`. Scaling is taken into consideration. /// Errors on invalid blitter in `options`. Scaling is taken into consideration.
/// ///
/// *C style function: [ncvisual_geom()][crate::ncvisual_geom].* /// *C style function: [ncvisual_blitter_geom()][crate::ncvisual_blitter_geom].*
pub fn geom( pub fn geom(
&self, &self,
nc: &Notcurses, nc: &Notcurses,
@ -333,7 +333,16 @@ impl NcVisual {
let mut to_x = 0; let mut to_x = 0;
let res = unsafe { let res = unsafe {
crate::ncvisual_blitter_geom(nc, self, options, &mut y, &mut x, &mut to_y, &mut to_x, null_mut()) crate::ncvisual_blitter_geom(
nc,
self,
options,
&mut y,
&mut x,
&mut to_y,
&mut to_x,
null_mut(),
)
}; };
error![ error![
res, res,

View File

@ -7,15 +7,9 @@ PENDING changes
bindgen add: bindgen add:
- [ ] ncdirect_stream - [ ] ncdirect_stream
- [x] ncplane_as_rgba - [x] ncplane_as_rgba
- [ ] nclane_pixelgeom - [x] ncplane_pixelgeom
- [ ] ncvisual_blitter_geom - [x] ncvisual_blitter_geom
- [ ] ncvisual_geom
bindgen del bindgen del
- [x] ncplane_rgba - [x] ncplane_rgba
static add:
- [ ] ncplane_rgba
- [ ] ncvisual_geom
static del:
## ... ## ...