rust: rename NcDimension to NcDim; rustfmt

pull/1293/head
joseLuís 4 years ago
parent 1622375d41
commit da5f86cc8f

@ -48,12 +48,8 @@ impl NcCell {
/// ///
/// The styling of the cell is left untouched, but any resources are released. /// The styling of the cell is left untouched, but any resources are released.
/// *C style function: [cell_load()][crate::cell_load].* /// *C style function: [cell_load()][crate::cell_load].*
pub fn load( pub fn load(plane: &mut NcPlane, cell: &mut NcCell, egc: &str) -> NcResult<u32> {
plane: &mut NcPlane, let bytes = unsafe { crate::cell_load(plane, cell, cstring![egc]) };
cell: &mut NcCell,
egc: &str,
) -> NcResult<u32> {
let bytes = unsafe { crate::cell_load(plane, cell, cstring![egc])};
error![ error![
bytes, bytes,
&format!["NcCell.load(NcPlane, NcCell, {:?})", egc], &format!["NcCell.load(NcPlane, NcCell, {:?})", egc],

@ -1,6 +1,6 @@
//! Test `NcCell` methods and associated functions. //! Test `NcCell` methods and associated functions.
use crate::{NcCell, NcPlane, FullMode}; use crate::{FullMode, NcCell, NcPlane};
use serial_test::serial; use serial_test::serial;

@ -1,7 +1,7 @@
//! `NcDimension`, `NcOffset` //! `NcDim`, `NcOffset`
/// A dimension in rows or columns. Can't be negative. /// Represents a dimension in rows or columns. Can't be negative.
pub type NcDimension = u32; pub type NcDim = u32;
/// An offset in rows or columns. Can be negative. /// Represents an offset in rows or columns. Can be negative.
pub type NcOffset = i32; pub type NcOffset = i32;

@ -4,9 +4,9 @@ use core::ptr::{null, null_mut};
use crate::ffi::sigset_t; use crate::ffi::sigset_t;
use crate::{ use crate::{
cstring, error, error_ref_mut, NcAlign, NcBlitter, NcChannelPair, NcColor, NcDimension, cstring, error, error_ref_mut, NcAlign, NcBlitter, NcChannelPair, NcColor, NcDim, NcDirect,
NcDirect, NcDirectFlags, NcEgc, NcError, NcInput, NcPaletteIndex, NcPlane, NcResult, NcRgb, NcDirectFlags, NcEgc, NcError, NcInput, NcPaletteIndex, NcPlane, NcResult, NcRgb, NcScale,
NcScale, NcStyleMask, NcTime, NCRESULT_ERR, NcStyleMask, NcTime, NCRESULT_ERR,
}; };
/// # `NcDirect` constructors and destructors /// # `NcDirect` constructors and destructors
@ -306,7 +306,7 @@ impl NcDirect {
/// Moves the cursor down, `num` rows. /// Moves the cursor down, `num` rows.
/// ///
/// *C style function: [ncdirect_cursor_down()][crate::ncdirect_cursor_down].* /// *C style function: [ncdirect_cursor_down()][crate::ncdirect_cursor_down].*
pub fn cursor_down(&mut self, num: NcDimension) -> NcResult<()> { pub fn cursor_down(&mut self, num: NcDim) -> NcResult<()> {
error![ error![
unsafe { crate::ncdirect_cursor_down(self, num as i32) }, unsafe { crate::ncdirect_cursor_down(self, num as i32) },
&format!("NcDirect.cursor_down({})", num) &format!("NcDirect.cursor_down({})", num)
@ -316,7 +316,7 @@ impl NcDirect {
/// Moves the cursor left, `num` columns. /// Moves the cursor left, `num` columns.
/// ///
/// *C style function: [ncdirect_cursor_left()][crate::ncdirect_cursor_left].* /// *C style function: [ncdirect_cursor_left()][crate::ncdirect_cursor_left].*
pub fn cursor_left(&mut self, num: NcDimension) -> NcResult<()> { pub fn cursor_left(&mut self, num: NcDim) -> NcResult<()> {
error![ error![
unsafe { crate::ncdirect_cursor_left(self, num as i32) }, unsafe { crate::ncdirect_cursor_left(self, num as i32) },
&format!("NcDirect.cursor_left({})", num) &format!("NcDirect.cursor_left({})", num)
@ -326,7 +326,7 @@ impl NcDirect {
/// Moves the cursor right, `num` columns. /// Moves the cursor right, `num` columns.
/// ///
/// *C style function: [ncdirect_cursor_right()][crate::ncdirect_cursor_right].* /// *C style function: [ncdirect_cursor_right()][crate::ncdirect_cursor_right].*
pub fn cursor_right(&mut self, num: NcDimension) -> NcResult<()> { pub fn cursor_right(&mut self, num: NcDim) -> NcResult<()> {
error![ error![
unsafe { crate::ncdirect_cursor_right(self, num as i32) }, unsafe { crate::ncdirect_cursor_right(self, num as i32) },
&format!("NcDirect.cursor_right({})", num) &format!("NcDirect.cursor_right({})", num)
@ -336,7 +336,7 @@ impl NcDirect {
/// Moves the cursor up, `num` rows. /// Moves the cursor up, `num` rows.
/// ///
/// *C style function: [ncdirect_cursor_up()][crate::ncdirect_cursor_up].* /// *C style function: [ncdirect_cursor_up()][crate::ncdirect_cursor_up].*
pub fn cursor_up(&mut self, num: NcDimension) -> NcResult<()> { pub fn cursor_up(&mut self, num: NcDim) -> NcResult<()> {
error![ error![
unsafe { crate::ncdirect_cursor_up(self, num as i32) }, unsafe { crate::ncdirect_cursor_up(self, num as i32) },
&format!("NcDirect.cursor_up({})", num) &format!("NcDirect.cursor_up({})", num)
@ -346,21 +346,21 @@ impl NcDirect {
/// Moves the cursor in direct mode to the specified row, column. /// Moves the cursor in direct mode to the specified row, column.
/// ///
/// *C style function: [ncdirect_cursor_move_yx()][crate::ncdirect_cursor_move_yx].* /// *C style function: [ncdirect_cursor_move_yx()][crate::ncdirect_cursor_move_yx].*
pub fn cursor_move_yx(&mut self, y: NcDimension, x: NcDimension) -> NcResult<()> { pub fn cursor_move_yx(&mut self, y: NcDim, x: NcDim) -> NcResult<()> {
error![unsafe { crate::ncdirect_cursor_move_yx(self, y as i32, x as i32) }] error![unsafe { crate::ncdirect_cursor_move_yx(self, y as i32, x as i32) }]
} }
/// Moves the cursor in direct mode to the specified row. /// Moves the cursor in direct mode to the specified row.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_move_y(&mut self, y: NcDimension) -> NcResult<()> { pub fn cursor_move_y(&mut self, y: NcDim) -> NcResult<()> {
error![unsafe { crate::ncdirect_cursor_move_yx(self, y as i32, -1) }] error![unsafe { crate::ncdirect_cursor_move_yx(self, y as i32, -1) }]
} }
/// Moves the cursor in direct mode to the specified column. /// Moves the cursor in direct mode to the specified column.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_move_x(&mut self, x: NcDimension) -> NcResult<()> { pub fn cursor_move_x(&mut self, x: NcDim) -> NcResult<()> {
error![unsafe { crate::ncdirect_cursor_move_yx(self, -1, x as i32) }] error![unsafe { crate::ncdirect_cursor_move_yx(self, -1, x as i32) }]
} }
@ -371,12 +371,12 @@ impl NcDirect {
/// the results might be detrimental. /// the results might be detrimental.
/// ///
/// *C style function: [ncdirect_cursor_yx()][crate::ncdirect_cursor_yx].* /// *C style function: [ncdirect_cursor_yx()][crate::ncdirect_cursor_yx].*
pub fn cursor_yx(&mut self) -> NcResult<(NcDimension, NcDimension)> { pub fn cursor_yx(&mut self) -> NcResult<(NcDim, NcDim)> {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
error![ error![
unsafe { crate::ncdirect_cursor_yx(self, &mut y, &mut x) }, unsafe { crate::ncdirect_cursor_yx(self, &mut y, &mut x) },
"", "",
(y as NcDimension, x as NcDimension) (y as NcDim, x as NcDim)
] ]
} }
@ -401,23 +401,23 @@ impl NcDirect {
/// Gets the current number of rows. /// Gets the current number of rows.
/// ///
/// *C style function: [ncdirect_dim_y()][crate::ncdirect_dim_y].* /// *C style function: [ncdirect_dim_y()][crate::ncdirect_dim_y].*
pub fn dim_y(&self) -> NcDimension { pub fn dim_y(&self) -> NcDim {
unsafe { crate::ncdirect_dim_y(self) as NcDimension } unsafe { crate::ncdirect_dim_y(self) as NcDim }
} }
/// Gets the current number of columns. /// Gets the current number of columns.
/// ///
/// *C style function: [ncdirect_dim_x()][crate::ncdirect_dim_x].* /// *C style function: [ncdirect_dim_x()][crate::ncdirect_dim_x].*
pub fn dim_x(&self) -> NcDimension { pub fn dim_x(&self) -> NcDim {
unsafe { crate::ncdirect_dim_x(self) as NcDimension } unsafe { crate::ncdirect_dim_x(self) as NcDim }
} }
/// Gets the current number of rows and columns. /// Gets the current number of rows and columns.
/// ///
/// *C style function: [ncdirect_dim_y()][crate::ncdirect_dim_y].* /// *C style function: [ncdirect_dim_y()][crate::ncdirect_dim_y].*
pub fn dim_yx(&self) -> (NcDimension, NcDimension) { pub fn dim_yx(&self) -> (NcDim, NcDim) {
let y = unsafe { crate::ncdirect_dim_y(self) as NcDimension }; let y = unsafe { crate::ncdirect_dim_y(self) as NcDim };
let x = unsafe { crate::ncdirect_dim_x(self) as NcDimension }; let x = unsafe { crate::ncdirect_dim_x(self) as NcDim };
(y, x) (y, x)
} }
} }
@ -534,8 +534,8 @@ impl NcDirect {
ll: NcChannelPair, ll: NcChannelPair,
lr: NcChannelPair, lr: NcChannelPair,
wchars: &[char; 6], wchars: &[char; 6],
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
ctlword: u32, ctlword: u32,
) -> NcResult<()> { ) -> NcResult<()> {
error![ error![
@ -569,8 +569,8 @@ impl NcDirect {
ur: NcChannelPair, ur: NcChannelPair,
ll: NcChannelPair, ll: NcChannelPair,
lr: NcChannelPair, lr: NcChannelPair,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
ctlword: u32, ctlword: u32,
) -> NcResult<()> { ) -> NcResult<()> {
error![unsafe { error![unsafe {
@ -587,8 +587,8 @@ impl NcDirect {
ur: NcChannelPair, ur: NcChannelPair,
ll: NcChannelPair, ll: NcChannelPair,
lr: NcChannelPair, lr: NcChannelPair,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
ctlword: u32, ctlword: u32,
) -> NcResult<()> { ) -> NcResult<()> {
error![unsafe { error![unsafe {
@ -610,7 +610,7 @@ impl NcDirect {
pub fn hline_interp( pub fn hline_interp(
&mut self, &mut self,
egc: &NcEgc, egc: &NcEgc,
len: NcDimension, len: NcDim,
h1: NcChannelPair, h1: NcChannelPair,
h2: NcChannelPair, h2: NcChannelPair,
) -> NcResult<()> { ) -> NcResult<()> {
@ -632,7 +632,7 @@ impl NcDirect {
pub fn vline_interp( pub fn vline_interp(
&mut self, &mut self,
egc: &NcEgc, egc: &NcEgc,
len: NcDimension, len: NcDim,
h1: NcChannelPair, h1: NcChannelPair,
h2: NcChannelPair, h2: NcChannelPair,
) -> NcResult<()> { ) -> NcResult<()> {

@ -2,9 +2,7 @@
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use crate::{ use crate::{raw_wrap, NcDirect, NcResult};
raw_wrap, NcDirect, NcResult
};
/// Safe wrapper around [NcDirect], minimal notcurses instance for styling text. /// Safe wrapper around [NcDirect], minimal notcurses instance for styling text.
pub struct DirectMode<'a> { pub struct DirectMode<'a> {

@ -11,7 +11,7 @@
use std::ffi::c_void; use std::ffi::c_void;
use crate::{NcIntResult, Notcurses, NcPlane, NcTime}; use crate::{NcIntResult, NcPlane, NcTime, Notcurses};
/// Called for each fade iteration on the NcPlane. /// Called for each fade iteration on the NcPlane.
/// ///

@ -9,7 +9,7 @@
// + nckey_mouse_p // + nckey_mouse_p
// + nckey_supppuab_p // + nckey_supppuab_p
use crate::NcDimension; use crate::NcDim;
mod keycodes; mod keycodes;
pub use keycodes::*; pub use keycodes::*;
@ -88,8 +88,8 @@ impl NcInput {
/// New NcInput, expecting all the arguments. /// New NcInput, expecting all the arguments.
pub const fn with_all_args( pub const fn with_all_args(
id: char, id: char,
x: Option<NcDimension>, x: Option<NcDim>,
y: Option<NcDimension>, y: Option<NcDim>,
alt: bool, alt: bool,
shift: bool, shift: bool,
ctrl: bool, ctrl: bool,

@ -5,7 +5,7 @@
#[allow(unused_imports)] #[allow(unused_imports)]
// enjoy briefer doc comments // enjoy briefer doc comments
use crate::{NcDirect, NcError, Notcurses, NcResult, NCRESULT_ERR, NCRESULT_OK}; use crate::{NcDirect, NcError, NcResult, Notcurses, NCRESULT_ERR, NCRESULT_OK};
// Sleep, Render & Flush Macros ------------------------------------------------ // Sleep, Render & Flush Macros ------------------------------------------------

@ -4,9 +4,9 @@ use core::ptr::{null, null_mut};
use crate::{ use crate::{
cstring, error, error_ref_mut, notcurses_init, rstring, NcAlign, NcBlitter, NcChannelPair, cstring, error, error_ref_mut, notcurses_init, rstring, NcAlign, NcBlitter, NcChannelPair,
NcDimension, NcEgc, NcError, NcFile, NcInput, NcLogLevel, Notcurses, NotcursesOptions, NcDim, NcEgc, NcError, NcFile, NcInput, NcLogLevel, NcPlane, NcResult, NcScale, NcSignalSet,
NcPlane, NcResult, NcScale, NcSignalSet, NcStats, NcStyleMask, NcTime, NcStats, NcStyleMask, NcTime, Notcurses, NotcursesOptions, NCOPTION_NO_ALTERNATE_SCREEN,
NCOPTION_NO_ALTERNATE_SCREEN, NCOPTION_SUPPRESS_BANNERS, NCRESULT_ERR, NCOPTION_SUPPRESS_BANNERS, NCRESULT_ERR,
}; };
/// # `NotcursesOptions` Constructors /// # `NotcursesOptions` Constructors
@ -17,12 +17,7 @@ impl NotcursesOptions {
} }
/// New NotcursesOptions, with margins. /// New NotcursesOptions, with margins.
pub const fn with_margins( pub const fn with_margins(top: NcDim, right: NcDim, bottom: NcDim, left: NcDim) -> Self {
top: NcDimension,
right: NcDimension,
bottom: NcDimension,
left: NcDimension,
) -> Self {
Self::with_all_options(0, top, right, bottom, left, 0) Self::with_all_options(0, top, right, bottom, left, 0)
} }
@ -64,10 +59,10 @@ impl NotcursesOptions {
/// ///
pub const fn with_all_options( pub const fn with_all_options(
loglevel: NcLogLevel, loglevel: NcLogLevel,
margin_t: NcDimension, margin_t: NcDim,
margin_r: NcDimension, margin_r: NcDim,
margin_b: NcDimension, margin_b: NcDim,
margin_l: NcDimension, margin_l: NcDim,
flags: u64, flags: u64,
) -> Self { ) -> Self {
Self { Self {
@ -132,7 +127,7 @@ impl Notcurses {
/// *C style function: [notcurses_align()][crate::notcurses_align].* /// *C style function: [notcurses_align()][crate::notcurses_align].*
// //
// TODO: handle error rightfully. // TODO: handle error rightfully.
pub fn align(availcols: NcDimension, align: NcAlign, cols: NcDimension) -> NcResult<()> { pub fn align(availcols: NcDim, align: NcAlign, cols: NcDim) -> NcResult<()> {
error![crate::notcurses_align(availcols, align, cols)] error![crate::notcurses_align(availcols, align, cols)]
} }
@ -145,8 +140,8 @@ impl Notcurses {
/// *C style function: [notcurses_at_yx()][crate::notcurses_at_yx].* /// *C style function: [notcurses_at_yx()][crate::notcurses_at_yx].*
pub fn at_yx( pub fn at_yx(
&mut self, &mut self,
y: NcDimension, y: NcDim,
x: NcDimension, x: NcDim,
stylemask: &mut NcStyleMask, stylemask: &mut NcStyleMask,
channels: &mut NcChannelPair, channels: &mut NcChannelPair,
) -> Option<NcEgc> { ) -> Option<NcEgc> {
@ -249,7 +244,7 @@ impl Notcurses {
/// It is an error if `y`, `x` lies outside the standard plane. /// It is an error if `y`, `x` lies outside the standard plane.
/// ///
/// *C style function: [notcurses_cursor_enable()][crate::notcurses_cursor_enable].* /// *C style function: [notcurses_cursor_enable()][crate::notcurses_cursor_enable].*
pub fn cursor_enable(&mut self, y: NcDimension, x: NcDimension) -> NcResult<()> { pub fn cursor_enable(&mut self, y: NcDim, x: NcDim) -> NcResult<()> {
error![unsafe { crate::notcurses_cursor_enable(self, y as i32, x as i32) }] error![unsafe { crate::notcurses_cursor_enable(self, y as i32, x as i32) }]
} }
@ -463,12 +458,12 @@ impl Notcurses {
/// ///
/// *C style function: [notcurses_refresh()][crate::notcurses_refresh].* /// *C style function: [notcurses_refresh()][crate::notcurses_refresh].*
// //
pub fn refresh(&mut self) -> NcResult<(NcDimension, NcDimension)> { pub fn refresh(&mut self) -> NcResult<(NcDim, NcDim)> {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
error![ error![
unsafe { crate::notcurses_refresh(self, &mut y, &mut x) }, unsafe { crate::notcurses_refresh(self, &mut y, &mut x) },
"", "",
(y as NcDimension, x as NcDimension) (y as NcDim, x as NcDim)
] ]
} }
@ -547,8 +542,8 @@ impl Notcurses {
// #[inline] // #[inline]
// pub fn stddim_yx<'a>( // pub fn stddim_yx<'a>(
// &'a mut self, // &'a mut self,
// y: &mut NcDimension, // y: &mut NcDim,
// x: &mut NcDimension, // x: &mut NcDim,
// ) -> NcResult<&'a mut NcPlane> { // ) -> NcResult<&'a mut NcPlane> {
// crate::notcurses_stddim_yx(self, y, x) // crate::notcurses_stddim_yx(self, y, x)
// } // }
@ -560,8 +555,8 @@ impl Notcurses {
// #[inline] // #[inline]
// pub fn stddim_yx_const<'a>( // pub fn stddim_yx_const<'a>(
// &'a self, // &'a self,
// y: &mut NcDimension, // y: &mut NcDim,
// x: &mut NcDimension, // x: &mut NcDim,
// ) -> NcResult<&'a NcPlane> { // ) -> NcResult<&'a NcPlane> {
// crate::notcurses_stddim_yx_const(self, y, x) // crate::notcurses_stddim_yx_const(self, y, x)
// } // }
@ -573,7 +568,7 @@ impl Notcurses {
/// ///
/// *C style function: [notcurses_stdplane()][crate::notcurses_stdplane].* /// *C style function: [notcurses_stdplane()][crate::notcurses_stdplane].*
pub fn stdplane<'a>(&mut self) -> &'a mut NcPlane { pub fn stdplane<'a>(&mut self) -> &'a mut NcPlane {
unsafe { &mut *crate::notcurses_stdplane(self) } unsafe { &mut *crate::notcurses_stdplane(self) }
} }
/// Returns a reference to the standard [NcPlane] for this terminal. /// Returns a reference to the standard [NcPlane] for this terminal.
@ -622,7 +617,7 @@ impl Notcurses {
/// Returns our current idea of the terminal dimensions in rows and cols. /// Returns our current idea of the terminal dimensions in rows and cols.
/// ///
/// *C style function: [notcurses_supported_styles()][crate::notcurses_supported_styles].* /// *C style function: [notcurses_supported_styles()][crate::notcurses_supported_styles].*
pub fn term_dim_yx(&self) -> (NcDimension, NcDimension) { pub fn term_dim_yx(&self) -> (NcDim, NcDim) {
crate::notcurses_term_dim_yx(self) crate::notcurses_term_dim_yx(self)
} }

@ -3,8 +3,8 @@
use core::ptr::{null, null_mut}; use core::ptr::{null, null_mut};
use crate::{ use crate::{
NcAlign, NcDimension, NcError, NcInput, Notcurses, NcOffset, NcPlane, NcResult, NcSignalSet, NcAlign, NcDim, NcError, NcInput, NcOffset, NcPlane, NcResult, NcSignalSet, NcTime, Notcurses,
NcTime, NCALIGN_CENTER, NCALIGN_LEFT, NCALIGN_RIGHT, NCRESULT_ERR, NCRESULT_MAX, NCALIGN_CENTER, NCALIGN_LEFT, NCALIGN_RIGHT, NCRESULT_ERR, NCRESULT_MAX,
}; };
/// Returns the offset into `availcols` at which `cols` ought be output given /// Returns the offset into `availcols` at which `cols` ought be output given
@ -15,7 +15,7 @@ use crate::{
/// ///
/// *Method: Notcurses.[align()][Notcurses#method.align].* /// *Method: Notcurses.[align()][Notcurses#method.align].*
#[inline] #[inline]
pub fn notcurses_align(availcols: NcDimension, align: NcAlign, cols: NcDimension) -> NcOffset { pub fn notcurses_align(availcols: NcDim, align: NcAlign, cols: NcDim) -> NcOffset {
if align == NCALIGN_LEFT { if align == NCALIGN_LEFT {
return 0; return 0;
} }
@ -79,8 +79,8 @@ pub fn notcurses_getc_blocking(nc: &mut Notcurses, input: Option<&mut NcInput>)
#[inline] #[inline]
pub fn notcurses_stddim_yx<'a>( pub fn notcurses_stddim_yx<'a>(
nc: &'a mut Notcurses, nc: &'a mut Notcurses,
y: &mut NcDimension, y: &mut NcDim,
x: &mut NcDimension, x: &mut NcDim,
) -> NcResult<&'a mut NcPlane> { ) -> NcResult<&'a mut NcPlane> {
unsafe { unsafe {
let sp = crate::notcurses_stdplane(nc); let sp = crate::notcurses_stdplane(nc);
@ -99,8 +99,8 @@ pub fn notcurses_stddim_yx<'a>(
#[inline] #[inline]
pub fn notcurses_stddim_yx_const<'a>( pub fn notcurses_stddim_yx_const<'a>(
nc: &'a Notcurses, nc: &'a Notcurses,
y: &mut NcDimension, y: &mut NcDim,
x: &mut NcDimension, x: &mut NcDim,
) -> NcResult<&'a NcPlane> { ) -> NcResult<&'a NcPlane> {
unsafe { unsafe {
let sp = crate::notcurses_stdplane_const(nc); let sp = crate::notcurses_stdplane_const(nc);
@ -116,10 +116,10 @@ pub fn notcurses_stddim_yx_const<'a>(
/// ///
/// *Method: Notcurses.[getc_term_yx()][Notcurses#method.term_yx].* /// *Method: Notcurses.[getc_term_yx()][Notcurses#method.term_yx].*
#[inline] #[inline]
pub fn notcurses_term_dim_yx(nc: &Notcurses) -> (NcDimension, NcDimension) { pub fn notcurses_term_dim_yx(nc: &Notcurses) -> (NcDim, NcDim) {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
unsafe { unsafe {
crate::ncplane_dim_yx(crate::notcurses_stdplane_const(nc), &mut y, &mut x); crate::ncplane_dim_yx(crate::notcurses_stdplane_const(nc), &mut y, &mut x);
} }
(y as NcDimension, x as NcDimension) (y as NcDim, x as NcDim)
} }

@ -3,8 +3,7 @@
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use crate::{ use crate::{
raw_wrap, NcAlign, NcBlitter, NcDimension, NcLogLevel, Notcurses, NotcursesOptions, raw_wrap, NcAlign, NcBlitter, NcDim, NcLogLevel, NcResult, NcScale, Notcurses, NotcursesOptions,
NcResult, NcScale,
}; };
/// Safe wrapper around [Notcurses], the main struct of the TUI library. /// Safe wrapper around [Notcurses], the main struct of the TUI library.
@ -91,7 +90,7 @@ impl<'a> FullMode<'a> {
/// Returns the offset into `availcols` at which `cols` ought be output given /// Returns the offset into `availcols` at which `cols` ought be output given
/// the requirements of `align`. /// the requirements of `align`.
pub fn align(availcols: NcDimension, align: NcAlign, cols: NcDimension) -> NcResult<()> { pub fn align(availcols: NcDim, align: NcAlign, cols: NcDim) -> NcResult<()> {
Notcurses::align(availcols, align, cols) Notcurses::align(availcols, align, cols)
} }

@ -1,6 +1,6 @@
//! `NcPalette` methods and associated functions. //! `NcPalette` methods and associated functions.
use crate::{error, NcChannel, NcColor, Notcurses, NcPalette, NcPaletteIndex, NcResult, NcRgb}; use crate::{error, NcChannel, NcColor, NcPalette, NcPaletteIndex, NcResult, NcRgb, Notcurses};
impl NcPalette { impl NcPalette {
/// New NcPalette. /// New NcPalette.

@ -1,4 +1,4 @@
use crate::{NcDimension, Notcurses, NcOffset, NcPlane, NcPlaneOptions}; use crate::{NcDim, NcOffset, NcPlane, NcPlaneOptions, Notcurses};
/// Helper function for a new NcPlane on C style tests. /// Helper function for a new NcPlane on C style tests.
#[allow(dead_code)] #[allow(dead_code)]
@ -6,8 +6,8 @@ pub(crate) unsafe fn ncplane_new_test<'a>(
nc: &mut Notcurses, nc: &mut Notcurses,
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDim,
cols: NcDimension, cols: NcDim,
) -> &'a mut NcPlane { ) -> &'a mut NcPlane {
&mut *crate::ncpile_create(nc, &NcPlaneOptions::new(y, x, rows, cols)) &mut *crate::ncpile_create(nc, &NcPlaneOptions::new(y, x, rows, cols))
} }
@ -18,8 +18,8 @@ pub(crate) unsafe fn ncplane_new_bound_test<'a>(
plane: &mut NcPlane, plane: &mut NcPlane,
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDim,
cols: NcDimension, cols: NcDim,
) -> &'a mut NcPlane { ) -> &'a mut NcPlane {
&mut *crate::ncplane_create(plane, &NcPlaneOptions::new(y, x, rows, cols)) &mut *crate::ncplane_create(plane, &NcPlaneOptions::new(y, x, rows, cols))
} }

@ -4,20 +4,20 @@ use core::ptr::{null, null_mut};
use crate::{ use crate::{
cstring, error, error_ref, error_ref_mut, rstring, NcAlign, NcAlphaBits, NcBoxMask, NcCell, cstring, error, error_ref, error_ref_mut, rstring, NcAlign, NcAlphaBits, NcBoxMask, NcCell,
NcChannel, NcChannelPair, NcColor, NcDimension, NcEgc, NcError, NcFadeCb, Notcurses, NcChannel, NcChannelPair, NcColor, NcDim, NcEgc, NcError, NcFadeCb, NcOffset, NcPaletteIndex,
NcOffset, NcPaletteIndex, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb, NcStyleMask, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb, NcStyleMask, NcTime, Notcurses,
NcTime, NCRESULT_ERR, NCRESULT_ERR,
}; };
/// # NcPlaneOptions Constructors /// # NcPlaneOptions Constructors
impl NcPlaneOptions { impl NcPlaneOptions {
/// New NcPlaneOptions using the horizontal x. /// New NcPlaneOptions using the horizontal x.
pub fn new(y: NcOffset, x: NcOffset, rows: NcDimension, cols: NcDimension) -> Self { pub fn new(y: NcOffset, x: NcOffset, rows: NcDim, cols: NcDim) -> Self {
Self::with_flags(y, x, rows, cols, None, 0) Self::with_flags(y, x, rows, cols, None, 0)
} }
/// New NcPlaneOptions with horizontal alignment. /// New NcPlaneOptions with horizontal alignment.
pub fn new_aligned(y: NcOffset, align: NcAlign, rows: NcDimension, cols: NcDimension) -> Self { pub fn new_aligned(y: NcOffset, align: NcAlign, rows: NcDim, cols: NcDim) -> Self {
Self::with_flags_aligned(y, align, rows, cols, None, crate::NCPLANE_OPTION_HORALIGNED) Self::with_flags_aligned(y, align, rows, cols, None, crate::NCPLANE_OPTION_HORALIGNED)
} }
@ -25,8 +25,8 @@ impl NcPlaneOptions {
pub fn with_flags( pub fn with_flags(
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDim,
cols: NcDimension, cols: NcDim,
resizecb: Option<NcResizeCb>, resizecb: Option<NcResizeCb>,
flags: u64, flags: u64,
) -> Self { ) -> Self {
@ -49,8 +49,8 @@ impl NcPlaneOptions {
pub fn with_flags_aligned( pub fn with_flags_aligned(
y: NcOffset, y: NcOffset,
align: NcAlign, align: NcAlign,
rows: NcDimension, rows: NcDim,
cols: NcDimension, cols: NcDim,
resizecb: Option<NcResizeCb>, resizecb: Option<NcResizeCb>,
flags: u64, flags: u64,
) -> Self { ) -> Self {
@ -79,8 +79,8 @@ impl NcPlane {
nc: &mut Notcurses, nc: &mut Notcurses,
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDim,
cols: NcDimension, cols: NcDim,
) -> NcResult<&'a mut NcPlane> { ) -> NcResult<&'a mut NcPlane> {
Self::with_options(nc, NcPlaneOptions::new(y, x, rows, cols)) Self::with_options(nc, NcPlaneOptions::new(y, x, rows, cols))
} }
@ -107,8 +107,8 @@ impl NcPlane {
bound_to: &mut NcPlane, bound_to: &mut NcPlane,
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDim,
cols: NcDimension, cols: NcDim,
) -> NcResult<&'a mut NcPlane> { ) -> NcResult<&'a mut NcPlane> {
Self::with_options_bound(bound_to, NcPlaneOptions::new(y, x, rows, cols)) Self::with_options_bound(bound_to, NcPlaneOptions::new(y, x, rows, cols))
} }
@ -136,7 +136,7 @@ impl NcPlane {
assert![(trows > 0) & (tcols > 0)]; assert![(trows > 0) & (tcols > 0)];
Self::with_options( Self::with_options(
nc, nc,
NcPlaneOptions::new(0, 0, trows as NcDimension, tcols as NcDimension), NcPlaneOptions::new(0, 0, trows as NcDim, tcols as NcDim),
) )
} }
@ -248,8 +248,8 @@ impl NcPlane {
/// *C style function: [ncplane_stain()][crate::ncplane_stain].* /// *C style function: [ncplane_stain()][crate::ncplane_stain].*
pub fn stain( pub fn stain(
&mut self, &mut self,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
ul: NcChannelPair, ul: NcChannelPair,
ur: NcChannelPair, ur: NcChannelPair,
ll: NcChannelPair, ll: NcChannelPair,
@ -419,10 +419,10 @@ impl NcPlane {
/// *C style function: [ncplane_format()][crate::ncplane_format].* /// *C style function: [ncplane_format()][crate::ncplane_format].*
pub fn format( pub fn format(
&mut self, &mut self,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
stylemask: NcStyleMask, stylemask: NcStyleMask,
) -> NcResult<NcDimension> { ) -> NcResult<NcDim> {
let res = let res =
unsafe { crate::ncplane_format(self, y_stop as i32, x_stop as i32, stylemask as u32) }; unsafe { crate::ncplane_format(self, y_stop as i32, x_stop as i32, stylemask as u32) };
error![ error![
@ -540,8 +540,8 @@ impl NcPlane {
/// *C style function: [ncplane_at_yx()][crate::ncplane_at_yx].* /// *C style function: [ncplane_at_yx()][crate::ncplane_at_yx].*
pub fn at_yx( pub fn at_yx(
&mut self, &mut self,
y: NcDimension, y: NcDim,
x: NcDimension, x: NcDim,
stylemask: &mut NcStyleMask, stylemask: &mut NcStyleMask,
channels: &mut NcChannelPair, channels: &mut NcChannelPair,
) -> NcResult<NcEgc> { ) -> NcResult<NcEgc> {
@ -566,12 +566,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_at_yx_cell()][crate::ncplane_at_yx_cell].* /// *C style function: [ncplane_at_yx_cell()][crate::ncplane_at_yx_cell].*
#[inline] #[inline]
pub fn ncplane_at_yx_cell( pub fn ncplane_at_yx_cell(&mut self, y: NcDim, x: NcDim, cell: &mut NcCell) -> NcResult<u32> {
&mut self,
y: NcDimension,
x: NcDimension,
cell: &mut NcCell,
) -> NcResult<u32> {
let bytes = unsafe { crate::ncplane_at_yx_cell(self, y as i32, x as i32, cell) }; let bytes = unsafe { crate::ncplane_at_yx_cell(self, y as i32, x as i32, cell) };
error![ error![
bytes, bytes,
@ -651,10 +646,10 @@ impl NcPlane {
/// *C style function: [ncplane_contents()][crate::ncplane_contents].* /// *C style function: [ncplane_contents()][crate::ncplane_contents].*
pub fn contents( pub fn contents(
&self, &self,
beg_y: NcDimension, beg_y: NcDim,
beg_x: NcDimension, beg_x: NcDim,
len_y: NcDimension, len_y: NcDim,
len_x: NcDimension, len_x: NcDim,
through_y: bool, through_y: bool,
through_x: bool, through_x: bool,
) -> String { ) -> String {
@ -695,17 +690,12 @@ impl NcPlane {
/// On success, returns the number of columns the cursor was advanced. /// On success, returns the number of columns the cursor was advanced.
/// ///
/// *C style function: [ncplane_putc_yx()][crate::ncplane_putc_yx].* /// *C style function: [ncplane_putc_yx()][crate::ncplane_putc_yx].*
pub fn putc_yx( pub fn putc_yx(&mut self, y: NcDim, x: NcDim, cell: &NcCell) -> NcResult<NcDim> {
&mut self,
y: NcDimension,
x: NcDimension,
cell: &NcCell,
) -> NcResult<NcDimension> {
let res = unsafe { crate::ncplane_putc_yx(self, y as i32, x as i32, cell) }; let res = unsafe { crate::ncplane_putc_yx(self, y as i32, x as i32, cell) };
error![ error![
res, res,
&format!("NcPlane.putc_yx({}, {}, {:?})", y, x, cell), &format!("NcPlane.putc_yx({}, {}, {:?})", y, x, cell),
res as NcDimension res as NcDim
] ]
} }
@ -716,13 +706,9 @@ impl NcPlane {
/// On success, returns the number of columns the cursor was advanced. /// On success, returns the number of columns the cursor was advanced.
/// ///
/// *C style function: [ncplane_putc()][crate::ncplane_putc].* /// *C style function: [ncplane_putc()][crate::ncplane_putc].*
pub fn putc(&mut self, cell: &NcCell) -> NcResult<NcDimension> { pub fn putc(&mut self, cell: &NcCell) -> NcResult<NcDim> {
let res = crate::ncplane_putc(self, cell); let res = crate::ncplane_putc(self, cell);
error![ error![res, &format!("NcPlane.putc({:?})", cell), res as NcDim]
res,
&format!("NcPlane.putc({:?})", cell),
res as NcDimension
]
} }
/// Calls [putchar_yx][NcPlane#method.putchar_yx] at the current cursor location. /// Calls [putchar_yx][NcPlane#method.putchar_yx] at the current cursor location.
@ -730,20 +716,16 @@ impl NcPlane {
/// On success, returns the number of columns the cursor was advanced. /// On success, returns the number of columns the cursor was advanced.
/// ///
/// *C style function: [ncplane_putchar()][crate::ncplane_putchar].* /// *C style function: [ncplane_putchar()][crate::ncplane_putchar].*
pub fn putchar(&mut self, ch: char) -> NcResult<NcDimension> { pub fn putchar(&mut self, ch: char) -> NcResult<NcDim> {
let res = crate::ncplane_putchar(self, ch); let res = crate::ncplane_putchar(self, ch);
error![ error![res, &format!("NcPlane.putchar({:?})", ch), res as NcDim]
res,
&format!("NcPlane.putchar({:?})", ch),
res as NcDimension
]
} }
// TODO: call put_egc // TODO: call put_egc
// /// Replaces the [NcEgc][crate::NcEgc] to the current location, but retain // /// Replaces the [NcEgc][crate::NcEgc] to the current location, but retain
// /// the styling. The current styling of the plane will not be changed. // /// the styling. The current styling of the plane will not be changed.
// pub fn putchar_stained(&mut self, y: NcDimension, x: NcDimension, ch: char) -> // pub fn putchar_stained(&mut self, y: NcDim, x: NcDim, ch: char) ->
// NcResult<NcDimension> { // NcResult<NcDim> {
// error![crate::ncplane_putchar_stained(self, ch)] // error![crate::ncplane_putchar_stained(self, ch)]
// } // }
@ -753,17 +735,12 @@ impl NcPlane {
/// On success, returns the number of columns the cursor was advanced. /// On success, returns the number of columns the cursor was advanced.
/// ///
/// *C style function: [ncplane_putchar_yx()][crate::ncplane_putchar_yx].* /// *C style function: [ncplane_putchar_yx()][crate::ncplane_putchar_yx].*
pub fn putchar_yx( pub fn putchar_yx(&mut self, y: NcDim, x: NcDim, ch: char) -> NcResult<NcDim> {
&mut self,
y: NcDimension,
x: NcDimension,
ch: char,
) -> NcResult<NcDimension> {
let res = crate::ncplane_putchar_yx(self, y, x, ch); let res = crate::ncplane_putchar_yx(self, y, x, ch);
error![ error![
res, res,
&format!("NcPlane.putchar_yx({}, {}, {:?})", y, x, ch), &format!("NcPlane.putchar_yx({}, {}, {:?})", y, x, ch),
res as NcDimension res as NcDim
] ]
} }
@ -779,13 +756,9 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_putstr()][crate::ncplane_putstr].* /// *C style function: [ncplane_putstr()][crate::ncplane_putstr].*
#[inline] #[inline]
pub fn putstr(&mut self, string: &str) -> NcResult<NcDimension> { pub fn putstr(&mut self, string: &str) -> NcResult<NcDim> {
let res = crate::ncplane_putstr(self, string); let res = crate::ncplane_putstr(self, string);
error![ error![res, &format!("NcPlane.putstr({:?})", string), res as NcDim]
res,
&format!("NcPlane.putstr({:?})", string),
res as NcDimension
]
} }
/// Same as [putstr][NcPlane#method.putstr], but it also tries to move the /// Same as [putstr][NcPlane#method.putstr], but it also tries to move the
@ -798,7 +771,7 @@ impl NcPlane {
/// columns which were written before the error. /// columns which were written before the error.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn putstrln(&mut self, string: &str) -> NcResult<NcDimension> { pub fn putstrln(&mut self, string: &str) -> NcResult<NcDim> {
let cols = self.putstr(string)?; let cols = self.putstr(string)?;
let (y, _x) = self.cursor_yx(); let (y, _x) = self.cursor_yx();
self.cursor_move_yx(y + 1, 0)?; self.cursor_move_yx(y + 1, 0)?;
@ -808,17 +781,12 @@ impl NcPlane {
/// Same as [putstr_yx()][NcPlane#method.putstr_yx] but [NcAlign]ed on x. /// Same as [putstr_yx()][NcPlane#method.putstr_yx] but [NcAlign]ed on x.
/// ///
/// *C style function: [ncplane_putstr_aligned()][crate::ncplane_putstr_aligned].* /// *C style function: [ncplane_putstr_aligned()][crate::ncplane_putstr_aligned].*
pub fn putstr_aligned( pub fn putstr_aligned(&mut self, y: NcDim, align: NcAlign, string: &str) -> NcResult<NcDim> {
&mut self,
y: NcDimension,
align: NcAlign,
string: &str,
) -> NcResult<NcDimension> {
let res = unsafe { crate::ncplane_putstr_aligned(self, y as i32, align, cstring![string]) }; let res = unsafe { crate::ncplane_putstr_aligned(self, y as i32, align, cstring![string]) };
error![ error![
res, res,
&format!("NcPlane.putstr_aligned({}, {}, {:?})", y, align, string), &format!("NcPlane.putstr_aligned({}, {}, {:?})", y, align, string),
res as NcDimension res as NcDim
] ]
} }
@ -833,12 +801,12 @@ impl NcPlane {
/// columns which were written before the error. /// columns which were written before the error.
/// ///
/// *C style function: [ncplane_putstr_stained()][crate::ncplane_putstr_stained].* /// *C style function: [ncplane_putstr_stained()][crate::ncplane_putstr_stained].*
pub fn putstr_stained(&mut self, string: &str) -> NcResult<NcDimension> { pub fn putstr_stained(&mut self, string: &str) -> NcResult<NcDim> {
let res = unsafe { crate::ncplane_putstr_stained(self, cstring![string]) }; let res = unsafe { crate::ncplane_putstr_stained(self, cstring![string]) };
error![ error![
res, res,
&format!("NcPlane.putstr_stained({:?})", string), &format!("NcPlane.putstr_stained({:?})", string),
res as NcDimension res as NcDim
] ]
} }
@ -854,17 +822,12 @@ impl NcPlane {
/// columns which were written before the error. /// columns which were written before the error.
/// ///
/// *C style function: [ncplane_putstr_yx()][crate::ncplane_putstr_yx].* /// *C style function: [ncplane_putstr_yx()][crate::ncplane_putstr_yx].*
pub fn putstr_yx( pub fn putstr_yx(&mut self, y: NcDim, x: NcDim, string: &str) -> NcResult<NcDim> {
&mut self,
y: NcDimension,
x: NcDimension,
string: &str,
) -> NcResult<NcDimension> {
let res = unsafe { crate::ncplane_putstr_yx(self, y as i32, x as i32, cstring![string]) }; let res = unsafe { crate::ncplane_putstr_yx(self, y as i32, x as i32, cstring![string]) };
error![ error![
res, res,
&format!("NcPlane.putstr_yx({}, {}, {:?})", y, x, string), &format!("NcPlane.putstr_yx({}, {}, {:?})", y, x, string),
res as NcDimension res as NcDim
] ]
} }
} }
@ -991,12 +954,12 @@ impl NcPlane {
pub fn mergedown( pub fn mergedown(
&mut self, &mut self,
source: &NcPlane, source: &NcPlane,
source_y: NcDimension, source_y: NcDim,
source_x: NcDimension, source_x: NcDim,
len_y: NcDimension, len_y: NcDim,
len_x: NcDimension, len_x: NcDim,
target_y: NcDimension, target_y: NcDim,
target_x: NcDimension, target_x: NcDim,
) -> NcResult<()> { ) -> NcResult<()> {
error![ error![
unsafe { unsafe {
@ -1154,23 +1117,23 @@ impl NcPlane {
// //
// NOTE: y and/or x may be NULL. // NOTE: y and/or x may be NULL.
// check for null and return NcResult // check for null and return NcResult
pub fn cursor_yx(&self) -> (NcDimension, NcDimension) { pub fn cursor_yx(&self) -> (NcDim, NcDim) {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
unsafe { crate::ncplane_cursor_yx(self, &mut y, &mut x) }; unsafe { crate::ncplane_cursor_yx(self, &mut y, &mut x) };
(y as NcDimension, x as NcDimension) (y as NcDim, x as NcDim)
} }
/// Returns the current row of the cursor within this NcPlane. /// Returns the current row of the cursor within this NcPlane.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_y(&self) -> NcDimension { pub fn cursor_y(&self) -> NcDim {
self.cursor_yx().0 self.cursor_yx().0
} }
/// Returns the current column of the cursor within this NcPlane. /// Returns the current column of the cursor within this NcPlane.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_x(&self) -> NcDimension { pub fn cursor_x(&self) -> NcDim {
self.cursor_yx().1 self.cursor_yx().1
} }
@ -1182,7 +1145,7 @@ impl NcPlane {
/// and the cursor position will remain unchanged. /// and the cursor position will remain unchanged.
/// ///
/// *C style function: [ncplane_cursor_move_yx()][crate::ncplane_cursor_move_yx].* /// *C style function: [ncplane_cursor_move_yx()][crate::ncplane_cursor_move_yx].*
pub fn cursor_move_yx(&mut self, y: NcDimension, x: NcDimension) -> NcResult<()> { pub fn cursor_move_yx(&mut self, y: NcDim, x: NcDim) -> NcResult<()> {
error![ error![
unsafe { crate::ncplane_cursor_move_yx(self, y as i32, x as i32) }, unsafe { crate::ncplane_cursor_move_yx(self, y as i32, x as i32) },
&format!("NcPlane.move_yx({}, {})", y, x) &format!("NcPlane.move_yx({}, {})", y, x)
@ -1192,7 +1155,7 @@ impl NcPlane {
/// Moves the cursor to the specified row within this NcPlane. /// Moves the cursor to the specified row within this NcPlane.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_move_y(&mut self, y: NcDimension) -> NcResult<()> { pub fn cursor_move_y(&mut self, y: NcDim) -> NcResult<()> {
let x = self.cursor_x(); let x = self.cursor_x();
error![ error![
unsafe { crate::ncplane_cursor_move_yx(self, y as i32, x as i32) }, unsafe { crate::ncplane_cursor_move_yx(self, y as i32, x as i32) },
@ -1203,7 +1166,7 @@ impl NcPlane {
/// Moves the cursor to the specified column within this NcPlane. /// Moves the cursor to the specified column within this NcPlane.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_move_x(&mut self, x: NcDimension) -> NcResult<()> { pub fn cursor_move_x(&mut self, x: NcDim) -> NcResult<()> {
let y = self.cursor_y(); let y = self.cursor_y();
error![ error![
unsafe { crate::ncplane_cursor_move_yx(self, y as i32, x as i32) }, unsafe { crate::ncplane_cursor_move_yx(self, y as i32, x as i32) },
@ -1218,7 +1181,7 @@ impl NcPlane {
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_move_rows(&mut self, rows: NcOffset) -> NcResult<()> { pub fn cursor_move_rows(&mut self, rows: NcOffset) -> NcResult<()> {
let (y, x) = self.cursor_yx(); let (y, x) = self.cursor_yx();
self.cursor_move_yx((y as NcOffset + rows) as NcDimension, x) self.cursor_move_yx((y as NcOffset + rows) as NcDim, x)
} }
/// Moves the cursor the number of columns specified (forward or backwards). /// Moves the cursor the number of columns specified (forward or backwards).
@ -1228,7 +1191,7 @@ impl NcPlane {
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn cursor_move_cols(&mut self, cols: NcOffset) -> NcResult<()> { pub fn cursor_move_cols(&mut self, cols: NcOffset) -> NcResult<()> {
let (y, x) = self.cursor_yx(); let (y, x) = self.cursor_yx();
self.cursor_move_yx(y, (x as NcOffset + cols) as NcDimension) self.cursor_move_yx(y, (x as NcOffset + cols) as NcDim)
} }
} }
@ -1243,7 +1206,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_align()][crate::ncplane_align].* /// *C style function: [ncplane_align()][crate::ncplane_align].*
#[inline] #[inline]
pub fn align(&mut self, align: NcAlign, cols: NcDimension) -> NcResult<()> { pub fn align(&mut self, align: NcAlign, cols: NcDim) -> NcResult<()> {
error![ error![
crate::ncplane_align(self, align, cols), crate::ncplane_align(self, align, cols),
&format!("NcPlane.align({:?}, {})", align, cols) &format!("NcPlane.align({:?}, {})", align, cols)
@ -1255,7 +1218,7 @@ impl NcPlane {
/// *C style function: [ncplane_center_abs()][crate::ncplane_center_abs].* /// *C style function: [ncplane_center_abs()][crate::ncplane_center_abs].*
// //
// TODO: doc. // TODO: doc.
pub fn center_abs(&self, y: &mut NcDimension, x: &mut NcDimension) { pub fn center_abs(&self, y: &mut NcDim, x: &mut NcDim) {
unsafe { unsafe {
crate::ncplane_center_abs(self, &mut (*y as i32), &mut (*x as i32)); crate::ncplane_center_abs(self, &mut (*y as i32), &mut (*x as i32));
} }
@ -1264,17 +1227,17 @@ impl NcPlane {
/// Returns the dimensions of this NcPlane. /// Returns the dimensions of this NcPlane.
/// ///
/// *C style function: [ncplane_dim_yx()][crate::ncplane_dim_yx].* /// *C style function: [ncplane_dim_yx()][crate::ncplane_dim_yx].*
pub fn dim_yx(&self) -> (NcDimension, NcDimension) { pub fn dim_yx(&self) -> (NcDim, NcDim) {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
unsafe { crate::ncplane_dim_yx(self, &mut y, &mut x) }; unsafe { crate::ncplane_dim_yx(self, &mut y, &mut x) };
(y as NcDimension, x as NcDimension) (y as NcDim, x as NcDim)
} }
/// Return the rows of this NcPlane. /// Return the rows of this NcPlane.
/// ///
/// *C style function: [ncplane_dim_y()][crate::ncplane_dim_y].* /// *C style function: [ncplane_dim_y()][crate::ncplane_dim_y].*
#[inline] #[inline]
pub fn dim_y(&self) -> NcDimension { pub fn dim_y(&self) -> NcDim {
self.dim_yx().0 self.dim_yx().0
} }
@ -1282,7 +1245,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_dim_x()][crate::ncplane_dim_x].* /// *C style function: [ncplane_dim_x()][crate::ncplane_dim_x].*
#[inline] #[inline]
pub fn dim_x(&self) -> NcDimension { pub fn dim_x(&self) -> NcDim {
self.dim_yx().1 self.dim_yx().1
} }
@ -1292,7 +1255,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_dim_y()][crate::ncplane_dim_y].* /// *C style function: [ncplane_dim_y()][crate::ncplane_dim_y].*
#[inline] #[inline]
pub fn rows(&self) -> NcDimension { pub fn rows(&self) -> NcDim {
self.dim_yx().0 self.dim_yx().0
} }
@ -1302,7 +1265,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_dim_x()][crate::ncplane_dim_x].* /// *C style function: [ncplane_dim_x()][crate::ncplane_dim_x].*
#[inline] #[inline]
pub fn cols(&self) -> NcDimension { pub fn cols(&self) -> NcDim {
self.dim_yx().1 self.dim_yx().1
} }
@ -1328,14 +1291,14 @@ impl NcPlane {
/// *C style function: [ncplane_resize()][crate::ncplane_resize].* /// *C style function: [ncplane_resize()][crate::ncplane_resize].*
pub fn resize( pub fn resize(
&mut self, &mut self,
keep_y: NcDimension, keep_y: NcDim,
keep_x: NcDimension, keep_x: NcDim,
keep_len_y: NcDimension, keep_len_y: NcDim,
keep_len_x: NcDimension, keep_len_x: NcDim,
y_off: NcOffset, y_off: NcOffset,
x_off: NcOffset, x_off: NcOffset,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
) -> NcResult<()> { ) -> NcResult<()> {
error![ error![
unsafe { unsafe {
@ -1375,7 +1338,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncplane_resize_simple()][crate::ncplane_resize_simple].* /// *C style function: [ncplane_resize_simple()][crate::ncplane_resize_simple].*
#[inline] #[inline]
pub fn resize_simple(&mut self, y_len: NcDimension, x_len: NcDimension) -> NcResult<()> { pub fn resize_simple(&mut self, y_len: NcDim, x_len: NcDim) -> NcResult<()> {
error![crate::ncplane_resize_simple( error![crate::ncplane_resize_simple(
self, self,
y_len as u32, y_len as u32,
@ -1432,7 +1395,7 @@ impl NcPlane {
/// *C style function: [ncplane_translate()][crate::ncplane_translate].* /// *C style function: [ncplane_translate()][crate::ncplane_translate].*
// //
// TODO: API change, return the coordinates as a tuple instead of being &mut // TODO: API change, return the coordinates as a tuple instead of being &mut
pub fn translate(&self, target: &NcPlane, y: &mut NcDimension, x: &mut NcDimension) { pub fn translate(&self, target: &NcPlane, y: &mut NcDim, x: &mut NcDim) {
unsafe { crate::ncplane_translate(self, target, &mut (*y as i32), &mut (*x as i32)) } unsafe { crate::ncplane_translate(self, target, &mut (*y as i32), &mut (*x as i32)) }
} }
@ -1444,7 +1407,7 @@ impl NcPlane {
/// *C style function: [ncplane_translate_abs()][crate::ncplane_translate_abs].* /// *C style function: [ncplane_translate_abs()][crate::ncplane_translate_abs].*
// //
// TODO: API change, return a tuple (y,x,bool) // TODO: API change, return a tuple (y,x,bool)
pub fn translate_abs(&self, y: &mut NcDimension, x: &mut NcDimension) -> bool { pub fn translate_abs(&self, y: &mut NcDim, x: &mut NcDim) -> bool {
unsafe { crate::ncplane_translate_abs(self, &mut (*y as i32), &mut (*x as i32)) } unsafe { crate::ncplane_translate_abs(self, &mut (*y as i32), &mut (*x as i32)) }
} }
@ -1520,8 +1483,8 @@ impl NcPlane {
lr: &NcCell, lr: &NcCell,
hline: &NcCell, hline: &NcCell,
vline: &NcCell, vline: &NcCell,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcResult<()> { ) -> NcResult<()> {
error![unsafe { error![unsafe {
@ -1556,8 +1519,8 @@ impl NcPlane {
lr: &NcCell, lr: &NcCell,
hline: &NcCell, hline: &NcCell,
vline: &NcCell, vline: &NcCell,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcResult<()> { ) -> NcResult<()> {
error![crate::ncplane_box_sized( error![crate::ncplane_box_sized(
@ -1573,8 +1536,8 @@ impl NcPlane {
&mut self, &mut self,
stylemask: NcStyleMask, stylemask: NcStyleMask,
channels: NcChannelPair, channels: NcChannelPair,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcResult<()> { ) -> NcResult<()> {
error![crate::ncplane_double_box( error![crate::ncplane_double_box(
@ -1590,8 +1553,8 @@ impl NcPlane {
&mut self, &mut self,
stylemask: NcStyleMask, stylemask: NcStyleMask,
channels: NcChannelPair, channels: NcChannelPair,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcResult<()> { ) -> NcResult<()> {
error![crate::ncplane_double_box( error![crate::ncplane_double_box(
@ -1748,9 +1711,9 @@ impl NcPlane {
ur: NcChannelPair, ur: NcChannelPair,
ll: NcChannelPair, ll: NcChannelPair,
lr: NcChannelPair, lr: NcChannelPair,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
) -> NcResult<NcDimension> { ) -> NcResult<NcDim> {
let res = unsafe { let res = unsafe {
crate::ncplane_gradient( crate::ncplane_gradient(
self, self,
@ -1764,7 +1727,7 @@ impl NcPlane {
x_stop as i32, x_stop as i32,
) )
}; };
error![res, "", res as NcDimension] error![res, "", res as NcDim]
} }
/// Draw a gradient with its upper-left corner at the current cursor position, /// Draw a gradient with its upper-left corner at the current cursor position,
@ -1782,11 +1745,11 @@ impl NcPlane {
ur: NcChannel, ur: NcChannel,
ll: NcChannel, ll: NcChannel,
lr: NcChannel, lr: NcChannel,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
) -> NcResult<NcDimension> { ) -> NcResult<NcDim> {
let res = crate::ncplane_gradient_sized(self, egc, stylemask, ul, ur, ll, lr, y_len, x_len); let res = crate::ncplane_gradient_sized(self, egc, stylemask, ul, ur, ll, lr, y_len, x_len);
error![res, "", res as NcDimension] error![res, "", res as NcDim]
} }
/// Draws a high-resolution gradient using upper blocks and synced backgrounds. /// Draws a high-resolution gradient using upper blocks and synced backgrounds.
@ -1804,13 +1767,13 @@ impl NcPlane {
ur: NcChannel, ur: NcChannel,
ll: NcChannel, ll: NcChannel,
lr: NcChannel, lr: NcChannel,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
) -> NcResult<NcDimension> { ) -> NcResult<NcDim> {
let res = unsafe { let res = unsafe {
crate::ncplane_highgradient(self, ul, ur, ll, lr, y_stop as i32, x_stop as i32) crate::ncplane_highgradient(self, ul, ur, ll, lr, y_stop as i32, x_stop as i32)
}; };
error![res, "", res as NcDimension] error![res, "", res as NcDim]
} }
/// [`gradient_sized`][NcPlane#method.gradient_sized] /// [`gradient_sized`][NcPlane#method.gradient_sized]
@ -1823,13 +1786,13 @@ impl NcPlane {
ur: NcChannel, ur: NcChannel,
ll: NcChannel, ll: NcChannel,
lr: NcChannel, lr: NcChannel,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
) -> NcResult<NcDimension> { ) -> NcResult<NcDim> {
let res = unsafe { let res = unsafe {
crate::ncplane_highgradient_sized(self, ul, ur, ll, lr, y_stop as i32, x_stop as i32) crate::ncplane_highgradient_sized(self, ul, ur, ll, lr, y_stop as i32, x_stop as i32)
}; };
error![res, "", res as NcDimension] error![res, "", res as NcDim]
} }
/// Converts this NcPlane's content to greyscale. /// Converts this NcPlane's content to greyscale.

@ -5,8 +5,8 @@ use core::ptr::null_mut;
use crate::ffi::__va_list_tag; use crate::ffi::__va_list_tag;
use crate::{ use crate::{
cell_release, cstring, ncplane_channels, NcAlign, NcAlphaBits, NcBoxMask, NcCell, NcChannel, cell_release, cstring, ncplane_channels, NcAlign, NcAlphaBits, NcBoxMask, NcCell, NcChannel,
NcChannelPair, NcColor, NcDimension, NcEgc, NcIntResult, NcPlane, NcRgb, NcStyleMask, NcChannelPair, NcColor, NcDim, NcEgc, NcIntResult, NcPlane, NcRgb, NcStyleMask, NCRESULT_ERR,
NCRESULT_ERR, NCRESULT_OK, NCRESULT_OK,
}; };
// Alpha ----------------------------------------------------------------------- // Alpha -----------------------------------------------------------------------
@ -137,12 +137,7 @@ pub fn ncplane_putchar(plane: &mut NcPlane, ch: char) -> NcIntResult {
/// ///
/// *Method: NcPlane.[putchar_yx()][NcPlane#method.putchar_yx].* /// *Method: NcPlane.[putchar_yx()][NcPlane#method.putchar_yx].*
#[inline] #[inline]
pub fn ncplane_putchar_yx( pub fn ncplane_putchar_yx(plane: &mut NcPlane, y: NcDim, x: NcDim, ch: char) -> NcIntResult {
plane: &mut NcPlane,
y: NcDimension,
x: NcDimension,
ch: char,
) -> NcIntResult {
unsafe { unsafe {
let cell = NcCell::with_char(ch, plane); let cell = NcCell::with_char(ch, plane);
crate::ncplane_putc_yx(plane, y as i32, x as i32, &cell) crate::ncplane_putc_yx(plane, y as i32, x as i32, &cell)
@ -186,11 +181,11 @@ pub fn ncplane_vprintf(plane: &mut NcPlane, format: &str, ap: &mut __va_list_tag
/// ///
/// *Method: NcPlane.[dim_x()][NcPlane#method.dim_x].* /// *Method: NcPlane.[dim_x()][NcPlane#method.dim_x].*
#[inline] #[inline]
pub fn ncplane_dim_x(plane: &NcPlane) -> NcDimension { pub fn ncplane_dim_x(plane: &NcPlane) -> NcDim {
unsafe { unsafe {
let mut x = 0; let mut x = 0;
crate::ncplane_dim_yx(plane, null_mut(), &mut x); crate::ncplane_dim_yx(plane, null_mut(), &mut x);
x as NcDimension x as NcDim
} }
} }
@ -199,11 +194,11 @@ pub fn ncplane_dim_x(plane: &NcPlane) -> NcDimension {
/// *Method: NcPlane.[dim_y()][NcPlane#method.dim_y].* /// *Method: NcPlane.[dim_y()][NcPlane#method.dim_y].*
#[inline] #[inline]
#[inline] #[inline]
pub fn ncplane_dim_y(plane: &NcPlane) -> NcDimension { pub fn ncplane_dim_y(plane: &NcPlane) -> NcDim {
unsafe { unsafe {
let mut y = 0; let mut y = 0;
crate::ncplane_dim_yx(plane, &mut y, null_mut()); crate::ncplane_dim_yx(plane, &mut y, null_mut());
y as NcDimension y as NcDim
} }
} }
@ -212,11 +207,7 @@ pub fn ncplane_dim_y(plane: &NcPlane) -> NcDimension {
/// ///
/// *Method: NcPlane.[resize_simple()][NcPlane#method.resize_simple].* /// *Method: NcPlane.[resize_simple()][NcPlane#method.resize_simple].*
#[inline] #[inline]
pub fn ncplane_resize_simple( pub fn ncplane_resize_simple(plane: &mut NcPlane, y_len: NcDim, x_len: NcDim) -> NcIntResult {
plane: &mut NcPlane,
y_len: NcDimension,
x_len: NcDimension,
) -> NcIntResult {
let (mut old_y, mut old_x) = (0, 0); let (mut old_y, mut old_x) = (0, 0);
unsafe { unsafe {
crate::ncplane_dim_yx(plane, &mut old_y, &mut old_x); crate::ncplane_dim_yx(plane, &mut old_y, &mut old_x);
@ -258,7 +249,7 @@ pub fn ncplane_resize_simple(
/// ///
/// *Method: NcPlane.[align()][NcPlane#method.align].* /// *Method: NcPlane.[align()][NcPlane#method.align].*
#[inline] #[inline]
pub fn ncplane_align(plane: &NcPlane, align: NcAlign, cols: NcDimension) -> NcIntResult { pub fn ncplane_align(plane: &NcPlane, align: NcAlign, cols: NcDim) -> NcIntResult {
crate::notcurses_align(ncplane_dim_x(plane), align, cols) crate::notcurses_align(ncplane_dim_x(plane), align, cols)
} }
@ -275,7 +266,7 @@ pub fn ncplane_align(plane: &NcPlane, align: NcAlign, cols: NcDimension) -> NcIn
/// ///
/// *Method: NcPlane.[hline()][NcPlane#method.hline].* /// *Method: NcPlane.[hline()][NcPlane#method.hline].*
#[inline] #[inline]
pub fn ncplane_hline(plane: &mut NcPlane, cell: &NcCell, len: NcDimension) -> NcIntResult { pub fn ncplane_hline(plane: &mut NcPlane, cell: &NcCell, len: NcDim) -> NcIntResult {
unsafe { crate::ncplane_hline_interp(plane, cell, len as i32, cell.channels, cell.channels) } unsafe { crate::ncplane_hline_interp(plane, cell, len as i32, cell.channels, cell.channels) }
} }
@ -290,7 +281,7 @@ pub fn ncplane_hline(plane: &mut NcPlane, cell: &NcCell, len: NcDimension) -> Nc
/// ///
/// *Method: NcPlane.[vline()][NcPlane#method.vline].* /// *Method: NcPlane.[vline()][NcPlane#method.vline].*
#[inline] #[inline]
pub fn ncplane_vline(plane: &mut NcPlane, cell: &NcCell, len: NcDimension) -> NcIntResult { pub fn ncplane_vline(plane: &mut NcPlane, cell: &NcCell, len: NcDim) -> NcIntResult {
unsafe { crate::ncplane_vline_interp(plane, cell, len as i32, cell.channels, cell.channels) } unsafe { crate::ncplane_vline_interp(plane, cell, len as i32, cell.channels, cell.channels) }
} }
@ -322,8 +313,8 @@ pub fn ncplane_perimeter(
lr, lr,
hline, hline,
vline, vline,
dimy as NcDimension, dimy as NcDim,
dimx as NcDimension, dimx as NcDim,
boxmask, boxmask,
) )
} }
@ -376,8 +367,8 @@ pub fn ncplane_perimeter_double(
&lr, &lr,
&hl, &hl,
&vl, &vl,
dimy as NcDimension, dimy as NcDim,
dimx as NcDimension, dimx as NcDim,
boxmask, boxmask,
); );
unsafe { unsafe {
@ -438,8 +429,8 @@ pub fn ncplane_perimeter_rounded(
&lr, &lr,
&hl, &hl,
&vl, &vl,
dimy as NcDimension, dimy as NcDim,
dimx as NcDimension, dimx as NcDim,
boxmask, boxmask,
); );
unsafe { unsafe {
@ -472,8 +463,8 @@ pub fn ncplane_box_sized(
lr: &NcCell, lr: &NcCell,
hline: &NcCell, hline: &NcCell,
vline: &NcCell, vline: &NcCell,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcIntResult { ) -> NcIntResult {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
@ -502,8 +493,8 @@ pub fn ncplane_double_box(
plane: &mut NcPlane, plane: &mut NcPlane,
stylemask: NcStyleMask, stylemask: NcStyleMask,
channels: NcChannelPair, channels: NcChannelPair,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcIntResult { ) -> NcIntResult {
#[allow(unused_assignments)] #[allow(unused_assignments)]
@ -561,8 +552,8 @@ pub fn ncplane_double_box_sized(
plane: &mut NcPlane, plane: &mut NcPlane,
stylemask: NcStyleMask, stylemask: NcStyleMask,
channels: NcChannelPair, channels: NcChannelPair,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcIntResult { ) -> NcIntResult {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
@ -573,8 +564,8 @@ pub fn ncplane_double_box_sized(
plane, plane,
stylemask, stylemask,
channels, channels,
y as NcDimension + y_len - 1, y as NcDim + y_len - 1,
x as NcDimension + x_len - 1, x as NcDim + x_len - 1,
boxmask, boxmask,
) )
} }
@ -587,8 +578,8 @@ pub fn ncplane_rounded_box(
plane: &mut NcPlane, plane: &mut NcPlane,
stylemask: NcStyleMask, stylemask: NcStyleMask,
channels: NcChannelPair, channels: NcChannelPair,
y_stop: NcDimension, y_stop: NcDim,
x_stop: NcDimension, x_stop: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcIntResult { ) -> NcIntResult {
#[allow(unused_assignments)] #[allow(unused_assignments)]
@ -645,8 +636,8 @@ pub fn ncplane_rounded_box_sized(
plane: &mut NcPlane, plane: &mut NcPlane,
stylemask: NcStyleMask, stylemask: NcStyleMask,
channels: NcChannelPair, channels: NcChannelPair,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
boxmask: NcBoxMask, boxmask: NcBoxMask,
) -> NcIntResult { ) -> NcIntResult {
let (mut y, mut x) = (0, 0); let (mut y, mut x) = (0, 0);
@ -657,8 +648,8 @@ pub fn ncplane_rounded_box_sized(
plane, plane,
stylemask, stylemask,
channels, channels,
y as NcDimension + y_len - 1, y as NcDim + y_len - 1,
x as NcDimension + x_len - 1, x as NcDim + x_len - 1,
boxmask, boxmask,
) )
} }
@ -680,8 +671,8 @@ pub fn ncplane_gradient_sized(
ur: NcChannel, ur: NcChannel,
ll: NcChannel, ll: NcChannel,
lr: NcChannel, lr: NcChannel,
y_len: NcDimension, y_len: NcDim,
x_len: NcDimension, x_len: NcDim,
) -> NcIntResult { ) -> NcIntResult {
if y_len < 1 || x_len < 1 { if y_len < 1 || x_len < 1 {
return NCRESULT_ERR; return NCRESULT_ERR;

Loading…
Cancel
Save