rust: more changes and improvements

- raw field of new wrapping structs is now public just to the crate.
- NcNotcurses.stdplane method now doesn't return an NcResult since it can't fail.
- rename NcNotcurses to Notcurses and NcNotcursesOptions to NotcursesOptions.
- rename NcPlane::new_termsize constructor to with_termsize.
- bump MSV to 1.48 for the doc links.
- improve lib documentation.
- minor fixes.
pull/1279/head
joseLuís 4 years ago
parent 9dcbda54ef
commit 797ef4b0ae

@ -3,4 +3,4 @@
[![Crate](https://img.shields.io/crates/v/libnotcurses-sys.svg)](https://crates.io/crates/libnotcurses-sys) [![Crate](https://img.shields.io/crates/v/libnotcurses-sys.svg)](https://crates.io/crates/libnotcurses-sys)
[![API](https://docs.rs/libnotcurses-sys/badge.svg)](https://dankamongmen.github.io/notcurses/rustdoc/libnotcurses_sys/) [![API](https://docs.rs/libnotcurses-sys/badge.svg)](https://dankamongmen.github.io/notcurses/rustdoc/libnotcurses_sys/)
[![dependency status](https://deps.rs/crate/libnotcurses-sys/2.1.2/status.svg)](https://deps.rs/crate/libnotcurses-sys/2.1.2) [![dependency status](https://deps.rs/crate/libnotcurses-sys/2.1.2/status.svg)](https://deps.rs/crate/libnotcurses-sys/2.1.2)
[![MSRV: 1.47.0](https://flat.badgen.net/badge/MSRV/1.47.0/purple)](https://blog.rust-lang.org/2020/10/08/Rust-1.47.html) [![MSRV: 1.48.0](https://flat.badgen.net/badge/MSRV/1.48.0/purple)](https://blog.rust-lang.org/2020/11/19/Rust-1.48.html)

@ -2,7 +2,7 @@ use libnotcurses_sys::*;
fn main() -> NcResult<()> { fn main() -> NcResult<()> {
let mut nc = FullMode::new()?; let mut nc = FullMode::new()?;
let stdplane = nc.stdplane()?; let stdplane = nc.stdplane();
for ch in "Initializing cells...".chars() { for ch in "Initializing cells...".chars() {
let cell = NcCell::with_char7b(ch); let cell = NcCell::with_char7b(ch);

@ -4,7 +4,7 @@ use libnotcurses_sys::*;
fn main() -> NcResult<()> { fn main() -> NcResult<()> {
let mut nc = FullMode::new()?; let mut nc = FullMode::new()?;
let plane = nc.stdplane()?; let plane = nc.stdplane();
plane.set_scrolling(true); plane.set_scrolling(true);
let mut wc = '\u{4e00}'; // 一 let mut wc = '\u{4e00}'; // 一

@ -34,7 +34,7 @@ fn main() -> NcResult<()> {
mopts.section_channels_mut().set_fg_rgb(0xb0d700); mopts.section_channels_mut().set_fg_rgb(0xb0d700);
mopts.section_channels_mut().set_bg_rgb(0x002000); mopts.section_channels_mut().set_bg_rgb(0x002000);
let stdplane = nc.stdplane()?; let stdplane = nc.stdplane();
let (dim_y, _dim_x) = stdplane.dim_yx(); let (dim_y, _dim_x) = stdplane.dim_yx();
let menu_top = NcMenu::new(stdplane, mopts)?; let menu_top = NcMenu::new(stdplane, mopts)?;
@ -75,7 +75,7 @@ fn main() -> NcResult<()> {
fn run_menu(nc: &mut FullMode, menu: &mut NcMenu) -> NcResult<()> { fn run_menu(nc: &mut FullMode, menu: &mut NcMenu) -> NcResult<()> {
// yellow rectangle // yellow rectangle
let planeopts = NcPlaneOptions::new_aligned(10, NCALIGN_CENTER, 3, 40); let planeopts = NcPlaneOptions::new_aligned(10, NCALIGN_CENTER, 3, 40);
let stdplane = nc.stdplane()?; let stdplane = nc.stdplane();
let selplane = NcPlane::with_options_bound(stdplane, planeopts)?; let selplane = NcPlane::with_options_bound(stdplane, planeopts)?;
selplane.set_fg_rgb(0); selplane.set_fg_rgb(0);
selplane.set_bg_rgb(0xdddddd); selplane.set_bg_rgb(0xdddddd);

@ -11,7 +11,7 @@ use crate::{
/// Safely wraps an [NcDirect], /// Safely wraps an [NcDirect],
/// and implements Drop, AsRef, AsMut, Deref & DerefMut around it. /// and implements Drop, AsRef, AsMut, Deref & DerefMut around it.
pub struct DirectMode<'a> { pub struct DirectMode<'a> {
raw: &'a mut NcDirect, pub(crate) raw: &'a mut NcDirect,
} }
impl<'a> AsRef<NcDirect> for DirectMode<'a> { impl<'a> AsRef<NcDirect> for DirectMode<'a> {

@ -11,7 +11,7 @@
use std::ffi::c_void; use std::ffi::c_void;
use crate::{NcIntResult, NcNotcurses, NcPlane, NcTime}; use crate::{NcIntResult, Notcurses, NcPlane, NcTime};
/// Called for each fade iteration on the NcPlane. /// Called for each fade iteration on the NcPlane.
/// ///
@ -20,7 +20,7 @@ use crate::{NcIntResult, NcNotcurses, NcPlane, NcTime};
/// ///
/// The recommended absolute display time target is passed in 'tspec'. /// The recommended absolute display time target is passed in 'tspec'.
pub type NcFadeCb = Option< pub type NcFadeCb = Option<
unsafe extern "C" fn(*mut NcNotcurses, *mut NcPlane, *const NcTime, *mut c_void) -> NcIntResult, unsafe extern "C" fn(*mut Notcurses, *mut NcPlane, *const NcTime, *mut c_void) -> NcIntResult,
>; >;
/// Context for a palette fade operation /// Context for a palette fade operation

@ -5,42 +5,45 @@
//! //!
//! # How to use this library //! # How to use this library
//! //!
//! Since this library is built with several layers of zero-overhead //! This library is built with several layers of zero-overhead abstractions
//! abstractions over the FFI functions, there are multiple ways to use it. //! over the FFI functions and pointers.
//! //!
//! But basically there are two ways: //! There are basically two ways:
//! //!
//! ## 1. The Rust way //! ## 1. The Rust way
//! //!
//! Use the safely wrapped types, their methods and constructors: //! Is preferible to use the safely wrapped types, with methods and constructors:
//! //!
//! ```rust //! ```rust
//! use libnotcurses_sys::*; //! use libnotcurses_sys::*;
//! //!
//! fn main() -> NcResult<()> { //! fn main() -> NcResult<()> {
//! let mut nc = FullMode::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?; //! let mut nc = FullMode::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
//! let plane = nc.stdplane()?; //! let plane = nc.stdplane();
//! plane.putstr("hello world")?; //! plane.putstr("hello world")?;
//! nc.render()?; //! nc.render()?;
//! Ok(()) //! Ok(())
//! } //! }
//! ``` //! ```
//! Specifically, and for example: //! Specifically:
//! //!
//! [`FullMode`] is the safe wrapper over [`NcNotcurses`], which is the //! [`FullMode`] and [`DirectMode`] are safe wrappers over [`Notcurses`]
//! `&mut` reference over the raw `*mut` pointer received from FFI. //! and [`NcDirectMode`][NcDirectMode], respectively.
//! //!
//! FullMode implements the [Drop], [AsRef], [AsMut], [Deref][std::ops::Deref] //! FullMode and DirectMode both implement the [Drop], [AsRef], [AsMut],
//! & [DerefMut][std::ops::DerefMut] traits. //! [Deref][std::ops::Deref] and [DerefMut][std::ops::DerefMut] traits.
//! //!
//! Most methods are directly implemented for NcNotcurses, //! Most methods are directly implemented for Notcurses and NcDirect,
//! and automatically available also from FullMode. //! are also automatically made available to FullMode & DirectMode,
//! minus some function overrides, like their destructors,
//! plus the associated functions that had to be recreated.
//! //!
//! The destructor ([notcurses_stop()]) is called automatically at the end //! Their destructors are called automatically at the end of their scope.
//! of its scope, so you don't ever have to call it by hand.
//! //!
//! The Rust style methods manage errors by means of returning an //! Error handling is painless using [`NcResult`] as the return type.
//! [`NcResult`]`<T, `[`NcError`]`>`, for painless handling. //!
//! The rest of the objects allocated by notcurses, like NcPlane, NcMenu…
//! don't implement Drop, and have to be `*_destroy()`ed manually.
//! //!
//! ## 2. The C way //! ## 2. The C way
//! //!
@ -74,8 +77,8 @@
//! ``` //! ```
//! It requires the use of unsafe. //! It requires the use of unsafe.
//! //!
//! The C style functions handle errors by the means of returning an i32 value //! Error handling requires to check the returned [NcIntResult],
//! aliased to [NcIntResult]. //! or in case of a pointer, comparing it to [null_mut()][core::ptr::null_mut].
//! //!
//! ## The `notcurses` C API docs //! ## The `notcurses` C API docs
//! //!

@ -5,7 +5,7 @@
#[allow(unused_imports)] #[allow(unused_imports)]
// enjoy briefer doc comments // enjoy briefer doc comments
use crate::{NcDirect, NcError, NcNotcurses, NcResult, NCRESULT_ERR, NCRESULT_OK}; use crate::{NcDirect, NcError, Notcurses, NcResult, NCRESULT_ERR, NCRESULT_OK};
// Sleep, Render & Flush Macros ------------------------------------------------ // Sleep, Render & Flush Macros ------------------------------------------------
@ -32,9 +32,9 @@ macro_rules! sleep {
}; };
} }
/// NcNotcurses.[render][NcNotcurses#method.render]\(`nc`\)? plus [sleep]!(`sleep_args`). /// Notcurses.[render][Notcurses#method.render]\(`nc`\)? plus [sleep]!(`sleep_args`).
/// ///
/// Renders the `$nc` [NcNotcurses] object and, if there's no error, /// Renders the `$nc` [Notcurses] object and, if there's no error,
/// calls the sleep macro with the rest of the arguments. /// calls the sleep macro with the rest of the arguments.
/// ///
/// Returns [NcResult]. /// Returns [NcResult].
@ -42,7 +42,7 @@ macro_rules! sleep {
macro_rules! rsleep { macro_rules! rsleep {
($nc:expr, $( $sleep_args:expr),+ ) => { ($nc:expr, $( $sleep_args:expr),+ ) => {
// Rust style, with methods & NcResult // Rust style, with methods & NcResult
NcNotcurses::render($nc)?; Notcurses::render($nc)?;
sleep![$( $sleep_args ),+]; sleep![$( $sleep_args ),+];
}; };
($nc:expr, $( $sleep_args:expr),+ ,) => { ($nc:expr, $( $sleep_args:expr),+ ,) => {

@ -1,10 +1,10 @@
use crate::{notcurses_init, NcNotcurses, NcNotcursesOptions, NCOPTION_SUPPRESS_BANNERS}; use crate::{notcurses_init, Notcurses, NotcursesOptions, NCOPTION_SUPPRESS_BANNERS};
/// Helper function for initializing NcNotcurses on C style tests. /// Helper function for initializing Notcurses on C style tests.
#[allow(dead_code)] #[allow(dead_code)]
pub(crate) unsafe fn notcurses_init_test<'a>() -> &'a mut NcNotcurses { pub(crate) unsafe fn notcurses_init_test<'a>() -> &'a mut Notcurses {
&mut *notcurses_init( &mut *notcurses_init(
&NcNotcursesOptions::with_flags(NCOPTION_SUPPRESS_BANNERS), &NotcursesOptions::with_flags(NCOPTION_SUPPRESS_BANNERS),
core::ptr::null_mut(), core::ptr::null_mut(),
) )
} }

@ -1,22 +1,22 @@
//! `NcNotcurses*` methods and associated functions. //! `Notcurses*` methods and associated functions.
use core::ptr::{null, null_mut}; 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, NcNotcurses, NcNotcursesOptions, NcDimension, NcEgc, NcError, NcFile, NcInput, NcLogLevel, Notcurses, NotcursesOptions,
NcPlane, NcResult, NcScale, NcSignalSet, NcStats, NcStyleMask, NcTime, NcPlane, NcResult, NcScale, NcSignalSet, NcStats, NcStyleMask, NcTime,
NCOPTION_NO_ALTERNATE_SCREEN, NCOPTION_SUPPRESS_BANNERS, NCRESULT_ERR, NCOPTION_NO_ALTERNATE_SCREEN, NCOPTION_SUPPRESS_BANNERS, NCRESULT_ERR,
}; };
/// # `NcNotcursesOptions` Constructors /// # `NotcursesOptions` Constructors
impl NcNotcursesOptions { impl NotcursesOptions {
/// New NcNotcursesOptions. /// New NotcursesOptions.
pub const fn new() -> Self { pub const fn new() -> Self {
Self::with_all_options(0, 0, 0, 0, 0, 0) Self::with_all_options(0, 0, 0, 0, 0, 0)
} }
/// New NcNotcursesOptions, with margins. /// New NotcursesOptions, with margins.
pub const fn with_margins( pub const fn with_margins(
top: NcDimension, top: NcDimension,
right: NcDimension, right: NcDimension,
@ -26,12 +26,12 @@ impl NcNotcursesOptions {
Self::with_all_options(0, top, right, bottom, left, 0) Self::with_all_options(0, top, right, bottom, left, 0)
} }
/// New NcNotcursesOptions, with flags. /// New NotcursesOptions, with flags.
pub const fn with_flags(flags: u64) -> Self { pub const fn with_flags(flags: u64) -> Self {
Self::with_all_options(0, 0, 0, 0, 0, flags) Self::with_all_options(0, 0, 0, 0, 0, flags)
} }
/// New NcNotcursesOptions, with all the options. /// New NotcursesOptions, with all the options.
/// ///
/// ## Arguments /// ## Arguments
/// ///
@ -83,46 +83,46 @@ impl NcNotcursesOptions {
} }
} }
/// # `NcNotcurses` Constructors /// # `Notcurses` Constructors
impl NcNotcurses { impl Notcurses {
/// New NcNotcurses (without banners). /// New Notcurses (without banners).
pub fn new<'a>() -> NcResult<&'a mut NcNotcurses> { pub fn new<'a>() -> NcResult<&'a mut Notcurses> {
Self::with_flags(NCOPTION_SUPPRESS_BANNERS) Self::with_flags(NCOPTION_SUPPRESS_BANNERS)
} }
/// New NcNotcurses, with banners. /// New Notcurses, with banners.
/// ///
/// This is the default in the C library. /// This is the default in the C library.
pub fn with_banners<'a>() -> NcResult<&'a mut NcNotcurses> { pub fn with_banners<'a>() -> NcResult<&'a mut Notcurses> {
Self::with_flags(0) Self::with_flags(0)
} }
/// New NcNotcurses, without an alternate screen (nor banners). /// New Notcurses, without an alternate screen (nor banners).
pub fn without_altscreen<'a>() -> NcResult<&'a mut NcNotcurses> { pub fn without_altscreen<'a>() -> NcResult<&'a mut Notcurses> {
Self::with_flags(NCOPTION_NO_ALTERNATE_SCREEN | NCOPTION_SUPPRESS_BANNERS) Self::with_flags(NCOPTION_NO_ALTERNATE_SCREEN | NCOPTION_SUPPRESS_BANNERS)
} }
/// New NcNotcurses, expects `NCOPTION_*` flags. /// New Notcurses, expects `NCOPTION_*` flags.
pub fn with_flags<'a>(flags: u64) -> NcResult<&'a mut NcNotcurses> { pub fn with_flags<'a>(flags: u64) -> NcResult<&'a mut Notcurses> {
Self::with_options(NcNotcursesOptions::with_flags(flags)) Self::with_options(NotcursesOptions::with_flags(flags))
} }
/// New NcNotcurses, expects [NcNotcursesOptions]. /// New Notcurses, expects [NotcursesOptions].
pub fn with_options<'a>(options: NcNotcursesOptions) -> NcResult<&'a mut NcNotcurses> { pub fn with_options<'a>(options: NotcursesOptions) -> NcResult<&'a mut Notcurses> {
let res = unsafe { notcurses_init(&options, null_mut()) }; let res = unsafe { notcurses_init(&options, null_mut()) };
error_ref_mut![res, "NcNotcurses.with_options()"] error_ref_mut![res, "Notcurses.with_options()"]
} }
/// New NcNotcurses, expects [NcLogLevel] and flags. /// New Notcurses, expects [NcLogLevel] and flags.
pub fn with_debug<'a>(loglevel: NcLogLevel, flags: u64) -> NcResult<&'a mut NcNotcurses> { pub fn with_debug<'a>(loglevel: NcLogLevel, flags: u64) -> NcResult<&'a mut Notcurses> {
Self::with_options(NcNotcursesOptions::with_all_options( Self::with_options(NotcursesOptions::with_all_options(
loglevel, 0, 0, 0, 0, flags, loglevel, 0, 0, 0, 0, flags,
)) ))
} }
} }
/// # `NcNotcurses` methods /// # `Notcurses` methods
impl NcNotcurses { impl Notcurses {
/// 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`.
/// ///
@ -253,7 +253,7 @@ impl NcNotcurses {
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) }]
} }
/// Dumps NcNotcurses state to the supplied `debugfp`. /// Dumps Notcurses state to the supplied `debugfp`.
/// ///
/// Output is freeform, and subject to change. It includes geometry of all /// Output is freeform, and subject to change. It includes geometry of all
/// planes, from all piles. /// planes, from all piles.
@ -353,7 +353,7 @@ impl NcNotcurses {
} else { } else {
error![ error![
-1, -1,
&format!("NcNotcurses.getc_blocking({:?})", input_txt), &format!("Notcurses.getc_blocking({:?})", input_txt),
res res
] ]
} }
@ -362,7 +362,7 @@ impl NcNotcurses {
/// Gets a file descriptor suitable for input event poll()ing. /// Gets a file descriptor suitable for input event poll()ing.
/// ///
/// When this descriptor becomes available, you can call /// When this descriptor becomes available, you can call
/// [getc_nblock()][NcNotcurses#method.getc_nblock], and input ought be ready. /// [getc_nblock()][Notcurses#method.getc_nblock], and input ought be ready.
/// ///
/// This file descriptor is not necessarily the file descriptor associated /// This file descriptor is not necessarily the file descriptor associated
/// with stdin (but it might be!). /// with stdin (but it might be!).
@ -383,13 +383,13 @@ impl NcNotcurses {
] ]
} }
/// Lexes a margin argument according to the standard NcNotcurses definition. /// Lexes a margin argument according to the standard Notcurses definition.
/// ///
/// There can be either a single number, which will define all margins equally, /// There can be either a single number, which will define all margins equally,
/// or there can be four numbers separated by commas. /// or there can be four numbers separated by commas.
/// ///
/// *C style function: [notcurses_lex_margins()][crate::notcurses_lex_margins].* /// *C style function: [notcurses_lex_margins()][crate::notcurses_lex_margins].*
pub fn lex_margins(op: &str, options: &mut NcNotcursesOptions) -> NcResult<()> { pub fn lex_margins(op: &str, options: &mut NotcursesOptions) -> NcResult<()> {
error![unsafe { crate::notcurses_lex_margins(cstring![op], options) }] error![unsafe { crate::notcurses_lex_margins(cstring![op], options) }]
} }
@ -432,13 +432,13 @@ impl NcNotcurses {
/// Enable the mouse in "button-event tracking" mode with focus detection /// Enable the mouse in "button-event tracking" mode with focus detection
/// and UTF8-style extended coordinates. /// and UTF8-style extended coordinates.
/// ///
/// On success, mouse events will be published to [getc()][NcNotcurses#method.getc]. /// On success, mouse events will be published to [getc()][Notcurses#method.getc].
/// ///
/// *C style function: [notcurses_mouse_enable()][crate::notcurses_mouse_enable].* /// *C style function: [notcurses_mouse_enable()][crate::notcurses_mouse_enable].*
pub fn mouse_enable(&mut self) -> NcResult<()> { pub fn mouse_enable(&mut self) -> NcResult<()> {
error![ error![
unsafe { crate::notcurses_mouse_enable(self) }, unsafe { crate::notcurses_mouse_enable(self) },
"NcNotcurses.mouse_enable()" "Notcurses.mouse_enable()"
] ]
} }
@ -455,7 +455,7 @@ impl NcNotcurses {
/// Refreshes the physical screen to match what was last rendered (i.e., /// Refreshes the physical screen to match what was last rendered (i.e.,
/// without reflecting any changes since the last call to /// without reflecting any changes since the last call to
/// [render][crate::NcNotcurses#method.render]). /// [render][crate::Notcurses#method.render]).
/// ///
/// This is primarily useful if the screen is externally corrupted, or if an /// This is primarily useful if the screen is externally corrupted, or if an
/// [NCKEY_RESIZE][crate::NCKEY_RESIZE] event has been read and you're not /// [NCKEY_RESIZE][crate::NCKEY_RESIZE] event has been read and you're not
@ -478,12 +478,12 @@ impl NcNotcurses {
pub fn render(&mut self) -> NcResult<()> { pub fn render(&mut self) -> NcResult<()> {
error![ error![
unsafe { crate::notcurses_render(self) }, unsafe { crate::notcurses_render(self) },
"NcNotcurses.render()" "Notcurses.render()"
] ]
} }
/// Performs the rendering and rasterization portion of /// Performs the rendering and rasterization portion of
/// [render][NcNotcurses#method.render] but do not write the resulting buffer /// [render][Notcurses#method.render] but do not write the resulting buffer
/// out to the terminal. /// out to the terminal.
/// ///
/// Using this function, the user can control the writeout process, /// Using this function, the user can control the writeout process,
@ -502,7 +502,7 @@ impl NcNotcurses {
/// Writes the last rendered frame, in its entirety, to 'fp'. /// Writes the last rendered frame, in its entirety, to 'fp'.
/// ///
/// If [render()][NcNotcurses#method.render] has not yet been called, /// If [render()][Notcurses#method.render] has not yet been called,
/// nothing will be written. /// nothing will be written.
/// ///
/// *C style function: [notcurses_render_to_file()][crate::notcurses_render_to_file].* /// *C style function: [notcurses_render_to_file()][crate::notcurses_render_to_file].*
@ -510,7 +510,7 @@ impl NcNotcurses {
error![unsafe { crate::notcurses_render_to_file(self, fp.as_nc_ptr()) }] error![unsafe { crate::notcurses_render_to_file(self, fp.as_nc_ptr()) }]
} }
/// Acquires an atomic snapshot of the NcNotcurses object's stats. /// Acquires an atomic snapshot of the Notcurses object's stats.
/// ///
/// *C style function: [notcurses_stats()][crate::notcurses_stats].* /// *C style function: [notcurses_stats()][crate::notcurses_stats].*
pub fn stats(&mut self, stats: &mut NcStats) { pub fn stats(&mut self, stats: &mut NcStats) {
@ -522,7 +522,7 @@ impl NcNotcurses {
/// Allocates an ncstats object. /// Allocates an ncstats object.
/// ///
/// Use this rather than allocating your own, since future versions of /// Use this rather than allocating your own, since future versions of
/// NcNotcurses might enlarge this structure. /// Notcurses might enlarge this structure.
/// ///
/// *C style function: [notcurses_stats_alloc()][crate::notcurses_stats_alloc].* /// *C style function: [notcurses_stats_alloc()][crate::notcurses_stats_alloc].*
pub fn stats_alloc<'a>(&'a mut self) -> &'a mut NcStats { pub fn stats_alloc<'a>(&'a mut self) -> &'a mut NcStats {
@ -538,6 +538,8 @@ impl NcNotcurses {
} }
} }
// TODO: decide what to do with these two:
//
// /// [notcurses_stdplane()][crate::notcurses_stdplane], plus free bonus // /// [notcurses_stdplane()][crate::notcurses_stdplane], plus free bonus
// /// dimensions written to non-NULL y/x! // /// dimensions written to non-NULL y/x!
// /// // ///
@ -551,7 +553,7 @@ impl NcNotcurses {
// crate::notcurses_stddim_yx(self, y, x) // crate::notcurses_stddim_yx(self, y, x)
// } // }
// /// [stdplane_const()][NcNotcurses#method.stdplane_const], plus free // /// [stdplane_const()][Notcurses#method.stdplane_const], plus free
// /// bonus dimensions written to non-NULL y/x! // /// bonus dimensions written to non-NULL y/x!
// /// // ///
// /// *C style function: [notcurses_stddim_yx()][crate::notcurses_stddim_yx].* // /// *C style function: [notcurses_stddim_yx()][crate::notcurses_stddim_yx].*
@ -570,11 +572,8 @@ impl NcNotcurses {
/// uppermost, leftmost cell. /// uppermost, leftmost cell.
/// ///
/// *C style function: [notcurses_stdplane()][crate::notcurses_stdplane].* /// *C style function: [notcurses_stdplane()][crate::notcurses_stdplane].*
pub fn stdplane<'a>(&mut self) -> NcResult<&'a mut NcPlane> { pub fn stdplane<'a>(&mut self) -> &'a mut NcPlane {
error_ref_mut![ unsafe { &mut *crate::notcurses_stdplane(self) }
unsafe { crate::notcurses_stdplane(self) },
"NcNotcurses.stdplane()"
]
} }
/// Returns a reference to the standard [NcPlane] for this terminal. /// Returns a reference to the standard [NcPlane] for this terminal.
@ -587,7 +586,7 @@ impl NcNotcurses {
unsafe { &*crate::notcurses_stdplane_const(self) } unsafe { &*crate::notcurses_stdplane_const(self) }
} }
/// Destroys the NcNotcurses context. /// Destroys the Notcurses context.
/// ///
/// *C style function: [notcurses_stop()][crate::notcurses_stop].* /// *C style function: [notcurses_stop()][crate::notcurses_stop].*
pub fn stop(&mut self) -> NcResult<()> { pub fn stop(&mut self) -> NcResult<()> {
@ -641,7 +640,7 @@ impl NcNotcurses {
rstring![crate::notcurses_version()].to_string() rstring![crate::notcurses_version()].to_string()
} }
/// Returns the running NcNotcurses version components /// Returns the running Notcurses version components
/// (major, minor, patch, tweak). /// (major, minor, patch, tweak).
/// ///
/// *C style function: [notcurses_version_components()][crate::notcurses_version_components].* /// *C style function: [notcurses_version_components()][crate::notcurses_version_components].*

@ -1,4 +1,4 @@
//! `NcNotcurses` //! `Notcurses`
// functions already exported by bindgen : 42 // functions already exported by bindgen : 42
// ------------------------------------------ // ------------------------------------------
@ -74,14 +74,14 @@ pub(crate) use helpers::*;
pub use reimplemented::*; pub use reimplemented::*;
pub use wrapper::*; pub use wrapper::*;
/// NcNotcurses builds atop the terminfo abstraction layer to /// Notcurses builds atop the terminfo abstraction layer to
/// provide reasonably portable vivid character displays. /// provide reasonably portable vivid character displays.
/// ///
/// This is the internal type safely wrapped by [FullMode]. /// This is the internal type safely wrapped by [FullMode].
pub type NcNotcurses = crate::bindings::ffi::notcurses; pub type Notcurses = crate::bindings::ffi::notcurses;
/// Options struct for [`NcNotcurses`] /// Options struct for [`Notcurses`]
pub type NcNotcursesOptions = crate::bindings::ffi::notcurses_options; pub type NotcursesOptions = crate::bindings::ffi::notcurses_options;
/// Do not call setlocale() /// Do not call setlocale()
/// ///
@ -97,17 +97,17 @@ pub const NCOPTION_INHIBIT_SETLOCALE: u64 = crate::bindings::ffi::NCOPTION_INHIB
/// Do not enter alternate mode. /// Do not enter alternate mode.
/// ///
/// If smcup/rmcup capabilities are indicated, NcNotcurses defaults to making use /// If smcup/rmcup capabilities are indicated, Notcurses defaults to making use
/// of the "alternate screen". This flag inhibits use of smcup/rmcup. /// of the "alternate screen". This flag inhibits use of smcup/rmcup.
pub const NCOPTION_NO_ALTERNATE_SCREEN: u64 = pub const NCOPTION_NO_ALTERNATE_SCREEN: u64 =
crate::bindings::ffi::NCOPTION_NO_ALTERNATE_SCREEN as u64; crate::bindings::ffi::NCOPTION_NO_ALTERNATE_SCREEN as u64;
/// Do not modify the font. /// Do not modify the font.
/// ///
/// NcNotcurses might attempt to change the font slightly, to support certain /// Notcurses might attempt to change the font slightly, to support certain
/// glyphs (especially on the Linux console). If this is set, no such /// glyphs (especially on the Linux console). If this is set, no such
/// modifications will be made. Note that font changes will not affect anything /// modifications will be made. Note that font changes will not affect anything
/// but the virtual console/terminal in which NcNotcurses is running. /// but the virtual console/terminal in which Notcurses is running.
pub const NCOPTION_NO_FONT_CHANGES: u64 = crate::bindings::ffi::NCOPTION_NO_FONT_CHANGES as u64; pub const NCOPTION_NO_FONT_CHANGES: u64 = crate::bindings::ffi::NCOPTION_NO_FONT_CHANGES as u64;
/// Do not handle SIG{ING, SEGV, ABRT, QUIT} /// Do not handle SIG{ING, SEGV, ABRT, QUIT}
@ -128,7 +128,7 @@ pub const NCOPTION_NO_WINCH_SIGHANDLER: u64 =
/// Do not print banners /// Do not print banners
/// ///
/// NcNotcurses typically prints version info in notcurses_init() and performance /// Notcurses typically prints version info in notcurses_init() and performance
/// info in notcurses_stop(). This inhibits that output. /// info in notcurses_stop(). This inhibits that output.
pub const NCOPTION_SUPPRESS_BANNERS: u64 = crate::bindings::ffi::NCOPTION_SUPPRESS_BANNERS as u64; pub const NCOPTION_SUPPRESS_BANNERS: u64 = crate::bindings::ffi::NCOPTION_SUPPRESS_BANNERS as u64;
@ -142,11 +142,11 @@ pub const NCOPTION_VERIFY_SIXEL: u64 = crate::bindings::ffi::NCOPTION_VERIFY_SIX
// NcLogLevel ------------------------------------------------------------------ // NcLogLevel ------------------------------------------------------------------
/// Log level for [`NcNotcursesOptions`] /// Log level for [`NotcursesOptions`]
/// ///
/// These log levels consciously map cleanly to those of libav; NcNotcurses itself /// These log levels consciously map cleanly to those of libav; Notcurses itself
/// does not use this full granularity. The log level does not affect the opening /// does not use this full granularity. The log level does not affect the opening
/// and closing banners, which can be disabled via the `NcNotcursesOptions` /// and closing banners, which can be disabled via the `NotcursesOptions`
/// `NCOPTION_SUPPRESS_BANNERS`. /// `NCOPTION_SUPPRESS_BANNERS`.
/// Note that if stderr is connected to the same terminal on which we're /// Note that if stderr is connected to the same terminal on which we're
/// rendering, any kind of logging will disrupt the output. /// rendering, any kind of logging will disrupt the output.

@ -3,7 +3,7 @@
use core::ptr::{null, null_mut}; use core::ptr::{null, null_mut};
use crate::{ use crate::{
NcAlign, NcDimension, NcError, NcInput, NcNotcurses, NcOffset, NcPlane, NcResult, NcSignalSet, NcAlign, NcDimension, NcError, NcInput, Notcurses, NcOffset, NcPlane, NcResult, NcSignalSet,
NcTime, NCALIGN_CENTER, NCALIGN_LEFT, NCALIGN_RIGHT, NCRESULT_ERR, NCRESULT_MAX, NcTime, NCALIGN_CENTER, NCALIGN_LEFT, NCALIGN_RIGHT, NCRESULT_ERR, NCRESULT_MAX,
}; };
@ -13,7 +13,7 @@ use crate::{
/// Returns `-`[`NCRESULT_MAX`] if [NCALIGN_UNALIGNED][crate::NCALIGN_UNALIGNED] /// Returns `-`[`NCRESULT_MAX`] if [NCALIGN_UNALIGNED][crate::NCALIGN_UNALIGNED]
/// or invalid [NcAlign]. /// or invalid [NcAlign].
/// ///
/// *Method: NcNotcurses.[align()][NcNotcurses#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: NcDimension, align: NcAlign, cols: NcDimension) -> NcOffset {
if align == NCALIGN_LEFT { if align == NCALIGN_LEFT {
@ -34,11 +34,11 @@ pub fn notcurses_align(availcols: NcDimension, align: NcAlign, cols: NcDimension
/// ///
/// If no event is ready, returns 0. /// If no event is ready, returns 0.
/// ///
/// *Method: NcNotcurses.[getc_nblock()][NcNotcurses#method.getc_nblock].* /// *Method: Notcurses.[getc_nblock()][Notcurses#method.getc_nblock].*
// //
// TODO: use from_u32 & return Option. // TODO: use from_u32 & return Option.
#[inline] #[inline]
pub fn notcurses_getc_nblock(nc: &mut NcNotcurses, input: &mut NcInput) -> char { pub fn notcurses_getc_nblock(nc: &mut Notcurses, input: &mut NcInput) -> char {
unsafe { unsafe {
let mut sigmask = NcSignalSet::new(); let mut sigmask = NcSignalSet::new();
sigmask.fillset(); sigmask.fillset();
@ -56,9 +56,9 @@ pub fn notcurses_getc_nblock(nc: &mut NcNotcurses, input: &mut NcInput) -> char
/// ///
/// In case of an invalid read (including on EOF) *-1 as char* is returned. /// In case of an invalid read (including on EOF) *-1 as char* is returned.
/// ///
/// *Method: NcNotcurses.[getc_blocking()][NcNotcurses#method.getc_blocking].* /// *Method: Notcurses.[getc_blocking()][Notcurses#method.getc_blocking].*
#[inline] #[inline]
pub fn notcurses_getc_blocking(nc: &mut NcNotcurses, input: Option<&mut NcInput>) -> char { pub fn notcurses_getc_blocking(nc: &mut Notcurses, input: Option<&mut NcInput>) -> char {
let input_ptr; let input_ptr;
if let Some(i) = input { if let Some(i) = input {
input_ptr = i as *mut _; input_ptr = i as *mut _;
@ -75,10 +75,10 @@ pub fn notcurses_getc_blocking(nc: &mut NcNotcurses, input: Option<&mut NcInput>
/// [notcurses_stdplane()][crate::notcurses_stdplane], plus free bonus /// [notcurses_stdplane()][crate::notcurses_stdplane], plus free bonus
/// dimensions written to non-NULL y/x! /// dimensions written to non-NULL y/x!
/// ///
/// *Method: NcNotcurses.[getc_stddim_yx()][NcNotcurses#method.stddim_yx].* /// *Method: Notcurses.[getc_stddim_yx()][Notcurses#method.stddim_yx].*
#[inline] #[inline]
pub fn notcurses_stddim_yx<'a>( pub fn notcurses_stddim_yx<'a>(
nc: &'a mut NcNotcurses, nc: &'a mut Notcurses,
y: &mut NcDimension, y: &mut NcDimension,
x: &mut NcDimension, x: &mut NcDimension,
) -> NcResult<&'a mut NcPlane> { ) -> NcResult<&'a mut NcPlane> {
@ -95,10 +95,10 @@ pub fn notcurses_stddim_yx<'a>(
/// [notcurses_stdplane_const()][crate::notcurses_stdplane_const], plus free /// [notcurses_stdplane_const()][crate::notcurses_stdplane_const], plus free
/// bonus dimensions written to non-NULL y/x! /// bonus dimensions written to non-NULL y/x!
/// ///
/// *Method: NcNotcurses.[getc_stddim_yx_const()][NcNotcurses#method.stddim_yx_const].* /// *Method: Notcurses.[getc_stddim_yx_const()][Notcurses#method.stddim_yx_const].*
#[inline] #[inline]
pub fn notcurses_stddim_yx_const<'a>( pub fn notcurses_stddim_yx_const<'a>(
nc: &'a NcNotcurses, nc: &'a Notcurses,
y: &mut NcDimension, y: &mut NcDimension,
x: &mut NcDimension, x: &mut NcDimension,
) -> NcResult<&'a NcPlane> { ) -> NcResult<&'a NcPlane> {
@ -114,9 +114,9 @@ pub fn notcurses_stddim_yx_const<'a>(
/// Returns our current idea of the terminal dimensions in rows and cols. /// Returns our current idea of the terminal dimensions in rows and cols.
/// ///
/// *Method: NcNotcurses.[getc_term_yx()][NcNotcurses#method.term_yx].* /// *Method: Notcurses.[getc_term_yx()][Notcurses#method.term_yx].*
#[inline] #[inline]
pub fn notcurses_term_dim_yx(nc: &NcNotcurses) -> (NcDimension, NcDimension) { pub fn notcurses_term_dim_yx(nc: &Notcurses) -> (NcDimension, NcDimension) {
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);

@ -3,32 +3,32 @@
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use crate::{ use crate::{
raw_wrap, NcAlign, NcBlitter, NcDimension, NcLogLevel, NcNotcurses, NcNotcursesOptions, raw_wrap, NcAlign, NcBlitter, NcDimension, NcLogLevel, Notcurses, NotcursesOptions,
NcResult, NcScale, NcResult, NcScale,
}; };
/// The main struct of the TUI library (full mode). /// The main struct of the TUI library (full mode).
/// ///
/// Safely wraps an [NcNotcurses], /// Safely wraps an [Notcurses],
/// and implements Drop, AsRef, AsMut, Deref & DerefMut around it. /// and implements Drop, AsRef, AsMut, Deref & DerefMut around it.
pub struct FullMode<'a> { pub struct FullMode<'a> {
raw: &'a mut NcNotcurses, pub(crate) raw: &'a mut Notcurses,
} }
impl<'a> AsRef<NcNotcurses> for FullMode<'a> { impl<'a> AsRef<Notcurses> for FullMode<'a> {
fn as_ref(&self) -> &NcNotcurses { fn as_ref(&self) -> &Notcurses {
self.raw self.raw
} }
} }
impl<'a> AsMut<NcNotcurses> for FullMode<'a> { impl<'a> AsMut<Notcurses> for FullMode<'a> {
fn as_mut(&mut self) -> &mut NcNotcurses { fn as_mut(&mut self) -> &mut Notcurses {
self.raw self.raw
} }
} }
impl<'a> Deref for FullMode<'a> { impl<'a> Deref for FullMode<'a> {
type Target = NcNotcurses; type Target = Notcurses;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
self.as_ref() self.as_ref()
@ -48,38 +48,38 @@ impl<'a> Drop for FullMode<'a> {
} }
} }
/// # Constructors and methods overriden from NcNotcurses /// # Constructors and methods overriden from Notcurses
impl<'a> FullMode<'a> { impl<'a> FullMode<'a> {
// wrap constructors // wrap constructors
/// New FullMode (without banners). /// New FullMode (without banners).
pub fn new() -> NcResult<Self> { pub fn new() -> NcResult<Self> {
raw_wrap![NcNotcurses::new()] raw_wrap![Notcurses::new()]
} }
/// New FullMode, without banners. /// New FullMode, without banners.
pub fn with_banners() -> NcResult<Self> { pub fn with_banners() -> NcResult<Self> {
raw_wrap![NcNotcurses::with_banners()] raw_wrap![Notcurses::with_banners()]
} }
/// New FullMode, without an alternate screen (nor banners). /// New FullMode, without an alternate screen (nor banners).
pub fn without_altscreen() -> NcResult<Self> { pub fn without_altscreen() -> NcResult<Self> {
raw_wrap![NcNotcurses::without_altscreen()] raw_wrap![Notcurses::without_altscreen()]
} }
/// New FullMode, expects `NCOPTION_*` flags. /// New FullMode, expects `NCOPTION_*` flags.
pub fn with_flags(flags: u64) -> NcResult<Self> { pub fn with_flags(flags: u64) -> NcResult<Self> {
raw_wrap![NcNotcurses::with_flags(flags)] raw_wrap![Notcurses::with_flags(flags)]
} }
/// New FullMode, expects [NcNotcursesOptions]. /// New FullMode, expects [NotcursesOptions].
pub fn with_options(options: NcNotcursesOptions) -> NcResult<Self> { pub fn with_options(options: NotcursesOptions) -> NcResult<Self> {
raw_wrap![NcNotcurses::with_options(options)] raw_wrap![Notcurses::with_options(options)]
} }
/// New FullMode, expects [NcLogLevel] and flags. /// New FullMode, expects [NcLogLevel] and flags.
pub fn with_debug(loglevel: NcLogLevel, flags: u64) -> NcResult<Self> { pub fn with_debug(loglevel: NcLogLevel, flags: u64) -> NcResult<Self> {
raw_wrap![NcNotcurses::with_debug(loglevel, flags)] raw_wrap![Notcurses::with_debug(loglevel, flags)]
} }
// disable destructor // disable destructor
@ -95,46 +95,46 @@ 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: NcDimension, align: NcAlign, cols: NcDimension) -> NcResult<()> {
NcNotcurses::align(availcols, align, cols) Notcurses::align(availcols, align, cols)
} }
/// Gets the name of an [NcBlitter] blitter. /// Gets the name of an [NcBlitter] blitter.
pub fn str_blitter(blitter: NcBlitter) -> String { pub fn str_blitter(blitter: NcBlitter) -> String {
NcNotcurses::str_blitter(blitter) Notcurses::str_blitter(blitter)
} }
/// Gets the name of an [NcScale] scaling mode. /// Gets the name of an [NcScale] scaling mode.
pub fn str_scalemode(scalemode: NcScale) -> String { pub fn str_scalemode(scalemode: NcScale) -> String {
NcNotcurses::str_scalemode(scalemode) Notcurses::str_scalemode(scalemode)
} }
/// Returns an [NcBlitter] from a string representation. /// Returns an [NcBlitter] from a string representation.
pub fn lex_blitter(op: &str) -> NcResult<NcBlitter> { pub fn lex_blitter(op: &str) -> NcResult<NcBlitter> {
NcNotcurses::lex_blitter(op) Notcurses::lex_blitter(op)
} }
/// Lexes a margin argument according to the standard NcNotcurses definition. /// Lexes a margin argument according to the standard Notcurses definition.
/// ///
/// There can be either a single number, which will define all margins equally, /// There can be either a single number, which will define all margins equally,
/// or there can be four numbers separated by commas. /// or there can be four numbers separated by commas.
/// ///
pub fn lex_margins(op: &str, options: &mut NcNotcursesOptions) -> NcResult<()> { pub fn lex_margins(op: &str, options: &mut NotcursesOptions) -> NcResult<()> {
NcNotcurses::lex_margins(op, options) Notcurses::lex_margins(op, options)
} }
/// Returns an [NcScale] from a string representation. /// Returns an [NcScale] from a string representation.
pub fn lex_scalemode(op: &str) -> NcResult<NcScale> { pub fn lex_scalemode(op: &str) -> NcResult<NcScale> {
NcNotcurses::lex_scalemode(op) Notcurses::lex_scalemode(op)
} }
/// Returns a human-readable string describing the running FullMode version. /// Returns a human-readable string describing the running FullMode version.
pub fn version() -> String { pub fn version() -> String {
NcNotcurses::version() Notcurses::version()
} }
/// Returns the running NcNotcurses version components /// Returns the running Notcurses version components
/// (major, minor, patch, tweak). /// (major, minor, patch, tweak).
pub fn version_components() -> (u32, u32, u32, u32) { pub fn version_components() -> (u32, u32, u32, u32) {
NcNotcurses::version_components() Notcurses::version_components()
} }
} }

@ -1,12 +1,12 @@
//! `NcPalette` methods and associated functions. //! `NcPalette` methods and associated functions.
use crate::{error, NcChannel, NcColor, NcNotcurses, NcPalette, NcPaletteIndex, NcResult, NcRgb}; use crate::{error, NcChannel, NcColor, Notcurses, NcPalette, NcPaletteIndex, NcResult, NcRgb};
impl NcPalette { impl NcPalette {
/// New NcPalette. /// New NcPalette.
/// ///
/// *C style function: [palette256_new()][crate::palette256_new].* /// *C style function: [palette256_new()][crate::palette256_new].*
pub fn new<'a>(nc: &mut NcNotcurses) -> &'a mut Self { pub fn new<'a>(nc: &mut Notcurses) -> &'a mut Self {
unsafe { &mut *crate::palette256_new(nc) } unsafe { &mut *crate::palette256_new(nc) }
} }
@ -22,7 +22,7 @@ impl NcPalette {
/// Attempts to configure the terminal with this NcPalette. /// Attempts to configure the terminal with this NcPalette.
/// ///
/// *C style function: [palette256_use()][crate::palette256_use].* /// *C style function: [palette256_use()][crate::palette256_use].*
pub fn r#use(&self, nc: &mut NcNotcurses) -> NcResult<()> { pub fn r#use(&self, nc: &mut Notcurses) -> NcResult<()> {
error![unsafe { crate::palette256_use(nc, self) }] error![unsafe { crate::palette256_use(nc, self) }]
} }

@ -1,9 +1,9 @@
use crate::{NcDimension, NcNotcurses, NcOffset, NcPlane, NcPlaneOptions}; use crate::{NcDimension, Notcurses, NcOffset, NcPlane, NcPlaneOptions};
/// 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)]
pub(crate) unsafe fn ncplane_new_test<'a>( pub(crate) unsafe fn ncplane_new_test<'a>(
nc: &mut NcNotcurses, nc: &mut Notcurses,
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDimension,

@ -4,7 +4,7 @@ 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, NcNotcurses, NcChannel, NcChannelPair, NcColor, NcDimension, NcEgc, NcError, NcFadeCb, Notcurses,
NcOffset, NcPaletteIndex, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb, NcStyleMask, NcOffset, NcPaletteIndex, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb, NcStyleMask,
NcTime, NCRESULT_ERR, NcTime, NCRESULT_ERR,
}; };
@ -76,7 +76,7 @@ impl NcPlane {
/// ///
/// *C style function: [ncpile_create()][crate::ncpile_create].* /// *C style function: [ncpile_create()][crate::ncpile_create].*
pub fn new<'a>( pub fn new<'a>(
nc: &mut NcNotcurses, nc: &mut Notcurses,
y: NcOffset, y: NcOffset,
x: NcOffset, x: NcOffset,
rows: NcDimension, rows: NcDimension,
@ -91,12 +91,12 @@ impl NcPlane {
/// ///
/// *C style function: [ncpile_create()][crate::ncpile_create].* /// *C style function: [ncpile_create()][crate::ncpile_create].*
pub fn with_options<'a>( pub fn with_options<'a>(
nc: &mut NcNotcurses, nc: &mut Notcurses,
options: NcPlaneOptions, options: NcPlaneOptions,
) -> NcResult<&'a mut NcPlane> { ) -> NcResult<&'a mut NcPlane> {
error_ref_mut![ error_ref_mut![
unsafe { crate::ncpile_create(nc, &options) }, unsafe { crate::ncpile_create(nc, &options) },
&format!["NcPlane::with_options(NcNotcurses, {:?})", options] &format!["NcPlane::with_options(Notcurses, {:?})", options]
] ]
} }
@ -115,8 +115,6 @@ impl NcPlane {
/// New NcPlane, bound to another plane, expects an [NcPlaneOptions] struct. /// New NcPlane, bound to another plane, expects an [NcPlaneOptions] struct.
/// ///
/// The returned plane will be the top, bottom, and root of this new pile.
///
/// *C style function: [ncplane_create()][crate::ncplane_create].* /// *C style function: [ncplane_create()][crate::ncplane_create].*
pub fn with_options_bound<'a>( pub fn with_options_bound<'a>(
bound_to: &mut NcPlane, bound_to: &mut NcPlane,
@ -133,7 +131,7 @@ impl NcPlane {
/// The returned plane will be the top, bottom, and root of this new pile. /// The returned plane will be the top, bottom, and root of this new pile.
/// ///
/// *(No equivalent C style function)* /// *(No equivalent C style function)*
pub fn new_termsize<'a>(nc: &mut NcNotcurses) -> NcResult<&'a mut NcPlane> { pub fn with_termsize<'a>(nc: &mut Notcurses) -> NcResult<&'a mut NcPlane> {
let (trows, tcols) = crate::notcurses_term_dim_yx(nc); let (trows, tcols) = crate::notcurses_term_dim_yx(nc);
assert![(trows > 0) & (tcols > 0)]; assert![(trows > 0) & (tcols > 0)];
Self::with_options( Self::with_options(
@ -310,7 +308,7 @@ impl NcPlane {
/// the provided values will be interpreted in some lossy fashion. /// the provided values will be interpreted in some lossy fashion.
/// ///
/// "HP-like" terminals require setting foreground and background at the same /// "HP-like" terminals require setting foreground and background at the same
/// time using "color pairs"; NcNotcurses will manage color pairs transparently. /// time using "color pairs"; Notcurses will manage color pairs transparently.
/// ///
/// *C style function: [ncplane_set_fg_rgb8()][crate::ncplane_set_fg_rgb8].* /// *C style function: [ncplane_set_fg_rgb8()][crate::ncplane_set_fg_rgb8].*
pub fn set_fg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) { pub fn set_fg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) {
@ -327,7 +325,7 @@ impl NcPlane {
/// the provided values will be interpreted in some lossy fashion. /// the provided values will be interpreted in some lossy fashion.
/// ///
/// "HP-like" terminals require setting foreground and background at the same /// "HP-like" terminals require setting foreground and background at the same
/// time using "color pairs"; NcNotcurses will manage color pairs transparently. /// time using "color pairs"; Notcurses will manage color pairs transparently.
/// ///
/// *C style function: [ncplane_set_bg_rgb8()][crate::ncplane_set_bg_rgb8].* /// *C style function: [ncplane_set_bg_rgb8()][crate::ncplane_set_bg_rgb8].*
pub fn set_bg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) { pub fn set_bg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) {
@ -871,7 +869,7 @@ impl NcPlane {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
/// ## NcPlane methods: `NcPlane` & `NcNotcurses` /// ## NcPlane methods: `NcPlane` & `Notcurses`
impl NcPlane { impl NcPlane {
/// Duplicates this NcPlane. /// Duplicates this NcPlane.
/// ///
@ -1116,20 +1114,20 @@ impl NcPlane {
error![unsafe { crate::ncpile_render(self) }, "NcPlane.render()"] error![unsafe { crate::ncpile_render(self) }, "NcPlane.render()"]
} }
/// Gets a mutable reference to the [NcNotcurses] context of this NcPlane. /// Gets a mutable reference to the [Notcurses] context of this NcPlane.
/// ///
/// *C style function: [ncplane_notcurses()][crate::ncplane_notcurses].* /// *C style function: [ncplane_notcurses()][crate::ncplane_notcurses].*
pub fn notcurses<'a>(&mut self) -> NcResult<&'a mut NcNotcurses> { pub fn notcurses<'a>(&mut self) -> NcResult<&'a mut Notcurses> {
error_ref_mut![ error_ref_mut![
unsafe { crate::ncplane_notcurses(self) }, unsafe { crate::ncplane_notcurses(self) },
"NcPlane.notcurses()" "NcPlane.notcurses()"
] ]
} }
/// Gets an immutable reference to the [NcNotcurses] context of this NcPlane. /// Gets an immutable reference to the [Notcurses] context of this NcPlane.
/// ///
/// *C style function: [ncplane_notcurses_const()][crate::ncplane_notcurses_const].* /// *C style function: [ncplane_notcurses_const()][crate::ncplane_notcurses_const].*
pub fn notcurses_const<'a>(&self) -> NcResult<&'a NcNotcurses> { pub fn notcurses_const<'a>(&self) -> NcResult<&'a Notcurses> {
error_ref![ error_ref![
unsafe { crate::ncplane_notcurses_const(self) }, unsafe { crate::ncplane_notcurses_const(self) },
"NcPlane.notcurses()" "NcPlane.notcurses()"

@ -1,6 +1,6 @@
//! `NcStats` //! `NcStats`
use crate::NcNotcurses; use crate::Notcurses;
/// notcurses runtime statistics /// notcurses runtime statistics
pub type NcStats = crate::bindings::ffi::ncstats; pub type NcStats = crate::bindings::ffi::ncstats;
@ -8,17 +8,17 @@ pub type NcStats = crate::bindings::ffi::ncstats;
/// # `NcStats` Methods. /// # `NcStats` Methods.
impl NcStats { impl NcStats {
/// Allocates an NcStats object. /// Allocates an NcStats object.
pub fn new<'a>(nc: &'a NcNotcurses) -> &'a mut Self { pub fn new<'a>(nc: &'a Notcurses) -> &'a mut Self {
unsafe { &mut *crate::notcurses_stats_alloc(nc) } unsafe { &mut *crate::notcurses_stats_alloc(nc) }
} }
/// Acquires an atomic snapshot of the NcNotcurses object's stats. /// Acquires an atomic snapshot of the Notcurses object's stats.
pub fn stats(&mut self, nc: &NcNotcurses) { pub fn stats(&mut self, nc: &Notcurses) {
unsafe { crate::notcurses_stats(nc, self) } unsafe { crate::notcurses_stats(nc, self) }
} }
/// Resets all cumulative stats (immediate ones are not reset). /// Resets all cumulative stats (immediate ones are not reset).
pub fn reset(&mut self, nc: &mut NcNotcurses) { pub fn reset(&mut self, nc: &mut Notcurses) {
unsafe { crate::notcurses_stats_reset(nc, self) } unsafe { crate::notcurses_stats_reset(nc, self) }
} }
} }

@ -9,7 +9,7 @@ use crate::{
impl NcMenu { impl NcMenu {
/// Creates an [NcMenu] with the specified options. /// Creates an [NcMenu] with the specified options.
/// ///
/// Menus are currently bound to an overall [Notcurses][crate::Notcurses] /// Menus are currently bound to an overall [FullMode][crate::FullMode]
/// object (as opposed to a particular plane), and are implemented as /// object (as opposed to a particular plane), and are implemented as
/// [NcPlane]s kept atop other NcPlanes. /// [NcPlane]s kept atop other NcPlanes.
/// ///

@ -1,12 +1,13 @@
//! `NcReel` widget. //! `NcReel` widget.
/// A wheel with `NcTablet`s on the outside /// A wheel with [`NcTablet`]s on the outside.
/// ///
/// An `NcReel` is projected onto the 2d rendering area, showing some portion of /// An `NcReel` is projected onto the 2d rendering area, showing some portion of
/// the `NcReel`, and zero or more `NcTablet`s. /// the `NcReel`, and zero or more `NcTablet`s.
/// ///
/// An `NcReel` is a `Notcurses` region devoted to displaying zero or more /// An `NcReel` is a [`FullMode`][crate::FullMode] region devoted to displaying
/// line-oriented, contained `NcTablet`s between which the user may navigate. /// zero or more line-oriented, contained [`NcTablet`]s
/// between which the user may navigate.
/// ///
/// If at least one `NcTablet`s exists, there is a "focused tablet". /// If at least one `NcTablet`s exists, there is a "focused tablet".
/// As much of the focused tablet as is possible is always displayed. /// As much of the focused tablet as is possible is always displayed.

Loading…
Cancel
Save