[rust] deprecate `Notcurses` use and rename it to `Nc`.

In order to be consistent with the rest of the naming scheme, and in order to avoid conflicts with the higher level rust wrappers, which will be using `Notcurses` for the wrapper struct from now on.

- also deprecate `NotcursesOptions` and rename it to `NcOptions`.
- update examples, docs and readme.
pull/1779/head
joseLuís 3 years ago
parent 9ee120dfa2
commit bcd09be7d3

@ -22,7 +22,7 @@ and painless error handling, like this:
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut nc = Notcurses::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
let mut nc = Nc::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
let plane = nc.stdplane();
plane.putstr("hello world")?;
nc.render()?;
@ -31,7 +31,7 @@ fn main() -> NcResult<()> {
}
```
Although you still have to manually call the `stop()` method for `Notcurses`
Although you still have to manually call the `stop()` method for `Nc`
and `NcDirect` objects, and the `destroy()` method for the rest of types that
allocate, (like `NcPlane`, `NcMenu`…) at the end of their scope, since the Drop
trait is not implemented for any wrapping type in libnotcurses-sys.

@ -1,7 +1,7 @@
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let nc = Notcurses::without_altscreen()?;
let nc = Nc::without_altscreen()?;
let (t_rows, t_cols) = nc.term_dim_yx();
println!("Terminal rows={0}, cols={1}", t_rows, t_cols);

@ -6,7 +6,7 @@
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut nc = Notcurses::with_flags(
let mut nc = Nc::with_flags(
NCOPTION_SUPPRESS_BANNERS | NCOPTION_NO_WINCH_SIGHANDLER | NCOPTION_NO_QUIT_SIGHANDLERS,
)?;

@ -1,7 +1,7 @@
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut nc = Notcurses::new()?;
let mut nc = Nc::new()?;
// get the terminal size in character rows & columns
let (t_rows, t_cols) = nc.term_dim_yx();

@ -4,7 +4,7 @@ const W: u32 = 32;
const H: u32 = 32;
fn main() -> NcResult<()> {
let nc = Notcurses::new()?;
let nc = Nc::new()?;
// create a white rectangle
let buffer = vec![255; H as usize * W as usize * 4];

@ -12,7 +12,7 @@ use rand::{distributions::Uniform, Rng};
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut nc = Notcurses::new()?;
let mut nc = Nc::new()?;
if !nc.check_pixel_support()? {
return Err(NcError::new_msg("Current terminal doesn't support pixels."));

@ -3,7 +3,7 @@
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut nc = Notcurses::new()?;
let mut nc = Nc::new()?;
let plane = nc.stdplane();
plane.set_scrolling(true);

@ -6,7 +6,7 @@
use libnotcurses_sys::*;
fn main() -> NcResult<()> {
let mut nc = Notcurses::new()?;
let mut nc = Nc::new()?;
nc.mouse_enable()?;
let mut demo_items = [
@ -72,7 +72,7 @@ fn main() -> NcResult<()> {
Ok(())
}
fn run_menu(nc: &mut Notcurses, menu: &mut NcMenu) -> NcResult<()> {
fn run_menu(nc: &mut Nc, menu: &mut NcMenu) -> NcResult<()> {
// yellow rectangle
let planeopts = NcPlaneOptions::new_aligned(10, NCALIGN_CENTER, 3, 40);
let stdplane = nc.stdplane();

@ -1,6 +1,6 @@
//! Test `NcCell` methods and associated functions.
use crate::{NcCell, NcPlane, Notcurses};
use crate::{NcCell, NcPlane, Nc};
use serial_test::serial;
@ -10,7 +10,7 @@ fn constructors() -> crate::NcResult<()> {
let _c1 = NcCell::new();
let _c2 = NcCell::with_char7b('C');
let nc = Notcurses::new()?;
let nc = Nc::new()?;
let plane = NcPlane::new(nc, 0, 0, 10, 10)?;
let _c3 = NcCell::with_char('௵', plane);
nc.stop()?;

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

@ -22,7 +22,7 @@
//! use libnotcurses_sys::*;
//!
//! fn main() -> NcResult<()> {
//! let mut nc = Notcurses::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
//! let mut nc = Nc::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
//! let plane = nc.stdplane();
//! plane.putstr("hello world")?;
//! nc.render()?;
@ -31,10 +31,10 @@
//! }
//! ```
//!
//! Although you still have to manually call the `stop()` method for [`Notcurses`]
//! and [`NcDirect`] objects, and the `destroy()` method for the rest of types that
//! allocate, (like [`NcPlane`], [`NcMenu`]…) at the end of their scope, since the
//! Drop trait is not implemented for any wrapping type in libnotcurses-sys.
//! Although you still have to manually call the `stop()` method for [`Nc`] and
//! [`NcDirect`] objects, and the `destroy()` method for the rest of types that
//! allocate, (like [`NcPlane`], [`NcMenu`]…) at the end of their scope, since
//! the Drop trait is not implemented for any wrapping type in libnotcurses-sys.
//!
//! But they do implement methods and use [`NcResult`] as the return type,
//! for handling errors in the way we are used to in Rust.

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

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

@ -1,32 +1,32 @@
//! `Notcurses*` methods and associated functions.
//! `Nc*` methods and associated functions.
use core::ptr::{null, null_mut};
use crate::{
cstring, error, error_ref_mut, notcurses_init, rstring, NcAlign, NcBlitter, NcChannelPair,
NcDim, NcEgc, NcError, NcFile, NcInput, NcLogLevel, NcPlane, NcResult, NcScale, NcSignalSet,
NcStats, NcStyle, NcTime, Notcurses, NotcursesOptions, NCOPTION_NO_ALTERNATE_SCREEN,
NcStats, NcStyle, NcTime, Nc, NcOptions, NCOPTION_NO_ALTERNATE_SCREEN,
NCOPTION_SUPPRESS_BANNERS, NCRESULT_ERR,
};
/// # `NotcursesOptions` Constructors
impl NotcursesOptions {
/// New NotcursesOptions.
/// # `NcOptions` Constructors
impl NcOptions {
/// New NcOptions.
pub const fn new() -> Self {
Self::with_all_options(0, 0, 0, 0, 0, 0)
}
/// New NotcursesOptions, with margins.
/// New NcOptions, with margins.
pub const fn with_margins(top: NcDim, right: NcDim, bottom: NcDim, left: NcDim) -> Self {
Self::with_all_options(0, top, right, bottom, left, 0)
}
/// New NotcursesOptions, with flags.
/// New NcOptions, with flags.
pub const fn with_flags(flags: u64) -> Self {
Self::with_all_options(0, 0, 0, 0, 0, flags)
}
/// New NotcursesOptions, with all the options.
/// New NcOptions, with all the options.
///
/// ## Arguments
///
@ -78,46 +78,46 @@ impl NotcursesOptions {
}
}
/// # `Notcurses` Constructors
impl Notcurses {
/// New Notcurses (without banners).
pub fn new<'a>() -> NcResult<&'a mut Notcurses> {
/// # `Nc` Constructors
impl Nc {
/// New notcurses context (without banners).
pub fn new<'a>() -> NcResult<&'a mut Nc> {
Self::with_flags(NCOPTION_SUPPRESS_BANNERS)
}
/// New Notcurses, with banners.
/// New notcurses context, with banners.
///
/// This is the default in the C library.
pub fn with_banners<'a>() -> NcResult<&'a mut Notcurses> {
pub fn with_banners<'a>() -> NcResult<&'a mut Nc> {
Self::with_flags(0)
}
/// New Notcurses, without an alternate screen (nor banners).
pub fn without_altscreen<'a>() -> NcResult<&'a mut Notcurses> {
/// New notcurses context, without an alternate screen (nor banners).
pub fn without_altscreen<'a>() -> NcResult<&'a mut Nc> {
Self::with_flags(NCOPTION_NO_ALTERNATE_SCREEN | NCOPTION_SUPPRESS_BANNERS)
}
/// New Notcurses, expects `NCOPTION_*` flags.
pub fn with_flags<'a>(flags: u64) -> NcResult<&'a mut Notcurses> {
Self::with_options(NotcursesOptions::with_flags(flags))
/// New notcurses context, expects `NCOPTION_*` flags.
pub fn with_flags<'a>(flags: u64) -> NcResult<&'a mut Nc> {
Self::with_options(NcOptions::with_flags(flags))
}
/// New Notcurses, expects [NotcursesOptions].
pub fn with_options<'a>(options: NotcursesOptions) -> NcResult<&'a mut Notcurses> {
/// New notcurses context, expects [NcOptions].
pub fn with_options<'a>(options: NcOptions) -> NcResult<&'a mut Nc> {
let res = unsafe { notcurses_init(&options, null_mut()) };
error_ref_mut![res, "Notcurses.with_options()"]
}
/// New Notcurses, expects [NcLogLevel] and flags.
pub fn with_debug<'a>(loglevel: NcLogLevel, flags: u64) -> NcResult<&'a mut Notcurses> {
Self::with_options(NotcursesOptions::with_all_options(
/// New notcurses context, expects [NcLogLevel] and flags.
pub fn with_debug<'a>(loglevel: NcLogLevel, flags: u64) -> NcResult<&'a mut Nc> {
Self::with_options(NcOptions::with_all_options(
loglevel, 0, 0, 0, 0, flags,
))
}
}
/// # `Notcurses` methods
impl Notcurses {
/// # `Nc` methods
impl Nc {
/// Returns the offset into `availcols` at which `cols` ought be output given
/// the requirements of `align`.
///
@ -289,7 +289,7 @@ impl Notcurses {
error![unsafe { crate::notcurses_cursor_enable(self, y as i32, x as i32) }]
}
/// Dumps Notcurses state to the supplied `debugfp`.
/// Dumps notcurses state to the supplied `debugfp`.
///
/// Output is freeform, and subject to change. It includes geometry of all
/// planes, from all piles.
@ -407,7 +407,7 @@ impl Notcurses {
} else {
error![
-1,
&format!("Notcurses.getc_blocking({:?})", input_txt),
&format!("Nc.getc_blocking({:?})", input_txt),
res
]
}
@ -416,7 +416,7 @@ impl Notcurses {
/// Gets a file descriptor suitable for input event poll()ing.
///
/// When this descriptor becomes available, you can call
/// [getc_nblock()][Notcurses#method.getc_nblock], and input ought be ready.
/// [getc_nblock()][Nc#method.getc_nblock], and input ought be ready.
///
/// This file descriptor is not necessarily the file descriptor associated
/// with stdin (but it might be!).
@ -437,13 +437,13 @@ impl Notcurses {
]
}
/// Lexes a margin argument according to the standard Notcurses definition.
/// Lexes a margin argument according to the standard notcurses definition.
///
/// There can be either a single number, which will define all margins equally,
/// or there can be four numbers separated by commas.
///
/// *C style function: [notcurses_lex_margins()][crate::notcurses_lex_margins].*
pub fn lex_margins(op: &str, options: &mut NotcursesOptions) -> NcResult<()> {
pub fn lex_margins(op: &str, options: &mut NcOptions) -> NcResult<()> {
error![unsafe { crate::notcurses_lex_margins(cstring![op], options) }]
}
@ -486,13 +486,13 @@ impl Notcurses {
/// Enable the mouse in "button-event tracking" mode with focus detection
/// and UTF8-style extended coordinates.
///
/// On success, mouse events will be published to [getc()][Notcurses#method.getc].
/// On success, mouse events will be published to [getc()][Nc#method.getc].
///
/// *C style function: [notcurses_mouse_enable()][crate::notcurses_mouse_enable].*
pub fn mouse_enable(&mut self) -> NcResult<()> {
error![
unsafe { crate::notcurses_mouse_enable(self) },
"Notcurses.mouse_enable()"
"Nc.mouse_enable()"
]
}
@ -508,7 +508,7 @@ impl Notcurses {
if res == 1 {
return Err(NcError::with_msg(
1,
"No color support ← Notcurses.palette_size()",
"No color support ← Nc.palette_size()",
));
}
Ok(res)
@ -516,7 +516,9 @@ impl Notcurses {
/// Refreshes the physical screen to match what was last rendered (i.e.,
/// without reflecting any changes since the last call to
/// [render][crate::Notcurses#method.render]).
/// [render][crate::Nc#method.render]).
///
/// Returns the current screen geometry (`y`, `x`).
///
/// 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
@ -539,12 +541,12 @@ impl Notcurses {
pub fn render(&mut self) -> NcResult<()> {
error![
unsafe { crate::notcurses_render(self) },
"Notcurses.render()"
"Nc.render()"
]
}
/// Performs the rendering and rasterization portion of
/// [render][Notcurses#method.render] but do not write the resulting buffer
/// [render][Nc#method.render] but do not write the resulting buffer
/// out to the terminal.
///
/// Using this function, the user can control the writeout process,
@ -570,7 +572,7 @@ impl Notcurses {
/// Writes the last rendered frame, in its entirety, to 'fp'.
///
/// If [render()][Notcurses#method.render] has not yet been called,
/// If [render()][Nc#method.render] has not yet been called,
/// nothing will be written.
///
/// *C style function: [notcurses_render_to_file()][crate::notcurses_render_to_file].*
@ -578,7 +580,7 @@ impl Notcurses {
error![unsafe { crate::notcurses_render_to_file(self, fp.as_nc_ptr()) }]
}
/// Acquires an atomic snapshot of the Notcurses object's stats.
/// Acquires an atomic snapshot of the notcurses object's stats.
///
/// *C style function: [notcurses_stats()][crate::notcurses_stats].*
pub fn stats(&mut self, stats: &mut NcStats) {
@ -590,7 +592,7 @@ impl Notcurses {
/// Allocates an [`NcStats`] object.
///
/// Use this rather than allocating your own, since future versions of
/// Notcurses might enlarge this structure.
/// notcurses might enlarge this structure.
///
/// *C style function: [notcurses_stats_alloc()][crate::notcurses_stats_alloc].*
pub fn stats_alloc(&mut self) -> &mut NcStats {
@ -654,7 +656,7 @@ impl Notcurses {
unsafe { &*crate::notcurses_stdplane_const(self) }
}
/// Destroys the Notcurses context.
/// Destroys the notcurses context.
///
/// *C style function: [notcurses_stop()][crate::notcurses_stop].*
pub fn stop(&mut self) -> NcResult<()> {
@ -708,7 +710,7 @@ impl Notcurses {
rstring![crate::notcurses_version()].to_string()
}
/// Returns the running Notcurses version components
/// Returns the running notcurses version components
/// (major, minor, patch, tweak).
///
/// *C style function: [notcurses_version_components()][crate::notcurses_version_components].*

@ -1,4 +1,4 @@
//! `Notcurses`
//! `Nc`
// total: 53
// ---------------------------------------------------
@ -79,12 +79,20 @@ mod reimplemented;
pub(crate) use helpers::*;
pub use reimplemented::*;
/// Notcurses builds atop the terminfo abstraction layer to
/// provide reasonably portable vivid character displays.
pub type Notcurses = crate::bindings::ffi::notcurses;
/// The full **notcurses** context.
///
/// It's built atop the terminfo abstraction layer to provide reasonably
/// portable vivid character displays.
pub type Nc = crate::bindings::ffi::notcurses;
#[deprecated]
pub type Notcurses = Nc;
/// Options struct for [`Notcurses`]
pub type NotcursesOptions = crate::bindings::ffi::notcurses_options;
pub type NcOptions = crate::bindings::ffi::notcurses_options;
#[deprecated]
pub type NotcursesOptions = NcOptions;
/// Do not call setlocale()
///
@ -100,7 +108,7 @@ pub const NCOPTION_INHIBIT_SETLOCALE: u64 = crate::bindings::ffi::NCOPTION_INHIB
/// Do not enter alternate mode.
///
/// If smcup/rmcup capabilities are indicated, Notcurses 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.
pub const NCOPTION_NO_ALTERNATE_SCREEN: u64 =
crate::bindings::ffi::NCOPTION_NO_ALTERNATE_SCREEN as u64;
@ -116,7 +124,7 @@ pub const NCOPTION_NO_CLEAR_BITMAPS: u64 = crate::bindings::ffi::NCOPTION_NO_CLE
/// Notcurses might attempt to change the font slightly, to support certain
/// glyphs (especially on the Linux console). If this is set, no such
/// modifications will be made. Note that font changes will not affect anything
/// but the virtual console/terminal in which Notcurses 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;
/// Do not handle SIG{ING, SEGV, ABRT, QUIT}
@ -143,11 +151,11 @@ pub const NCOPTION_SUPPRESS_BANNERS: u64 = crate::bindings::ffi::NCOPTION_SUPPRE
// NcLogLevel ------------------------------------------------------------------
/// Log level for [`NotcursesOptions`]
/// Log level for [`NcOptions`]
///
/// These log levels consciously map cleanly to those of libav; Notcurses 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
/// and closing banners, which can be disabled via the `NotcursesOptions`
/// and closing banners, which can be disabled via the `NcOptions`
/// `NCOPTION_SUPPRESS_BANNERS`.
/// Note that if stderr is connected to the same terminal on which we're
/// rendering, any kind of logging will disrupt the output.

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

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

@ -1,9 +1,9 @@
use crate::{NcDim, NcOffset, NcPlane, NcPlaneOptions, Notcurses};
use crate::{NcDim, NcOffset, NcPlane, NcPlaneOptions, Nc};
/// Helper function for a new NcPlane on C style tests.
#[allow(dead_code)]
pub(crate) unsafe fn ncplane_new_test<'a>(
nc: &mut Notcurses,
nc: &mut Nc,
y: NcOffset,
x: NcOffset,
rows: NcDim,

@ -8,7 +8,7 @@ use crate::{
cstring, error, error_ref, error_ref_mut, rstring, NcAlign, NcAlphaBits, NcBlitter, NcBoxMask,
NcCell, NcChannel, NcChannelPair, NcColor, NcDim, NcEgc, NcError, NcFadeCb, NcOffset,
NcPaletteIndex, NcPixelGeometry, NcPlane, NcPlaneOptions, NcResizeCb, NcResult, NcRgb, NcStyle,
NcTime, Notcurses, NCRESULT_ERR,
NcTime, Nc, NCRESULT_ERR,
};
/// # NcPlaneOptions Constructors
@ -84,7 +84,7 @@ impl NcPlane {
///
/// *C style function: [ncpile_create()][crate::ncpile_create].*
pub fn new<'a>(
nc: &mut Notcurses,
nc: &mut Nc,
y: NcOffset,
x: NcOffset,
rows: NcDim,
@ -99,12 +99,12 @@ impl NcPlane {
///
/// *C style function: [ncpile_create()][crate::ncpile_create].*
pub fn with_options<'a>(
nc: &mut Notcurses,
nc: &mut Nc,
options: NcPlaneOptions,
) -> NcResult<&'a mut NcPlane> {
error_ref_mut![
unsafe { crate::ncpile_create(nc, &options) },
&format!["NcPlane::with_options(Notcurses, {:?})", &options]
&format!["NcPlane::with_options(Nc, {:?})", &options]
]
}
@ -139,7 +139,7 @@ impl NcPlane {
/// The returned plane will be the top, bottom, and root of this new pile.
///
/// *(No equivalent C style function)*
pub fn with_termsize<'a>(nc: &mut Notcurses) -> NcResult<&'a mut NcPlane> {
pub fn with_termsize<'a>(nc: &mut Nc) -> NcResult<&'a mut NcPlane> {
let (trows, tcols) = crate::notcurses_term_dim_yx(nc);
assert![(trows > 0) & (tcols > 0)];
Self::with_options(
@ -306,7 +306,7 @@ impl NcPlane {
/// the provided values will be interpreted in some lossy fashion.
///
/// "HP-like" terminals require setting foreground and background at the same
/// time using "color pairs"; Notcurses 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].*
pub fn set_fg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) {
@ -323,7 +323,7 @@ impl NcPlane {
/// the provided values will be interpreted in some lossy fashion.
///
/// "HP-like" terminals require setting foreground and background at the same
/// time using "color pairs"; Notcurses 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].*
pub fn set_bg_rgb8(&mut self, red: NcColor, green: NcColor, blue: NcColor) {
@ -876,7 +876,7 @@ impl NcPlane {
}
// -----------------------------------------------------------------------------
/// ## NcPlane methods: `NcPlane` & `Notcurses`
/// ## NcPlane methods: `NcPlane` & `Nc`
impl NcPlane {
/// Gets the origin of this plane relative to its pile.
///
@ -1164,20 +1164,20 @@ impl NcPlane {
error![unsafe { crate::ncpile_render(self) }, "NcPlane.render()"]
}
/// Gets a mutable reference to the [Notcurses] context of this NcPlane.
/// Gets a mutable reference to the [`Nc`] context of this NcPlane.
///
/// *C style function: [ncplane_notcurses()][crate::ncplane_notcurses].*
pub fn notcurses<'a>(&mut self) -> NcResult<&'a mut Notcurses> {
pub fn notcurses<'a>(&mut self) -> NcResult<&'a mut Nc> {
error_ref_mut![
unsafe { crate::ncplane_notcurses(self) },
"NcPlane.notcurses()"
]
}
/// Gets an immutable reference to the [Notcurses] context of this NcPlane.
/// Gets an immutable reference to the [`Nc`] context of this NcPlane.
///
/// *C style function: [ncplane_notcurses_const()][crate::ncplane_notcurses_const].*
pub fn notcurses_const<'a>(&self) -> NcResult<&'a Notcurses> {
pub fn notcurses_const<'a>(&self) -> NcResult<&'a Nc> {
error_ref![
unsafe { crate::ncplane_notcurses_const(self) },
"NcPlane.notcurses()"

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

@ -6,7 +6,7 @@ use libc::c_void;
use crate::{
cstring, error, error_ref_mut, rstring, NcBlitter, NcDim, NcDirect, NcDirectF, NcDirectV,
NcError, NcIntResult, NcPixel, NcPlane, NcResult, NcRgba, NcScale, NcTime, NcVGeom, NcVisual,
NcVisualOptions, Notcurses, NCBLIT_PIXEL, NCRESULT_ERR,
NcVisualOptions, Nc, NCBLIT_PIXEL, NCRESULT_ERR,
};
/// # NcVisualOptions Constructors
@ -276,7 +276,7 @@ impl NcVisual {
/// *C style function: [ncvisual_blitter_geom()][crate::ncvisual_blitter_geom].*
pub fn geom(
&self,
nc: &Notcurses,
nc: &Nc,
options: &NcVisualOptions,
) -> NcResult<(NcDim, NcDim, NcDim, NcDim)> {
let mut y = 0;
@ -314,7 +314,7 @@ impl NcVisual {
/// aspect ratio, thus NCBLIT_2x1 is used outside of NCSCALE_STRETCH.
///
/// *C style function: [ncvisual_media_defblitter()][crate::ncvisual_media_defblitter].*
pub fn media_defblitter(nc: &Notcurses, scale: NcScale) -> NcBlitter {
pub fn media_defblitter(nc: &Nc, scale: NcScale) -> NcBlitter {
unsafe { crate::ncvisual_media_defblitter(nc, scale) }
}
@ -335,12 +335,12 @@ impl NcVisual {
/// *C style function: [ncvisual_render()][crate::ncvisual_render].*
pub fn render(
&mut self,
nc: &mut Notcurses,
nc: &mut Nc,
options: &NcVisualOptions,
) -> NcResult<&mut NcPlane> {
error_ref_mut![
unsafe { crate::ncvisual_render(nc, self, options) },
"NcVisual.render(Notcurses, &NcVisualOptions)"
"NcVisual.render(Nc, &NcVisualOptions)"
]
}
@ -454,7 +454,7 @@ impl NcVisual {
// //
// pub fn simple_streamer(
// &mut self,
// nc: &mut Notcurses,
// nc: &mut Nc,
// timescale: f32,
// //streamer: Option<streamcb>
// options: &NcVisualOptions,

Loading…
Cancel
Save