mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
rust: rename Notcurses to FullMode; update doc
This commit is contained in:
parent
f5f9397f7b
commit
bad3449205
@ -1,7 +1,7 @@
|
||||
use libnotcurses_sys::*;
|
||||
|
||||
fn main() -> NcResult<()> {
|
||||
let mut nc = Notcurses::new()?;
|
||||
let mut nc = FullMode::new()?;
|
||||
let stdplane = nc.stdplane()?;
|
||||
|
||||
for ch in "Initializing cells...".chars() {
|
||||
|
@ -6,14 +6,10 @@
|
||||
use libnotcurses_sys::*;
|
||||
|
||||
fn main() -> NcResult<()> {
|
||||
let mut nc = Notcurses::with_flags(
|
||||
let mut nc = FullMode::with_flags(
|
||||
NCOPTION_SUPPRESS_BANNERS | NCOPTION_NO_WINCH_SIGHANDLER | NCOPTION_NO_QUIT_SIGHANDLERS,
|
||||
)?;
|
||||
|
||||
// doesn't seem to be necessary:
|
||||
// let ready = unsafe { notcurses_inputready_fd(nc) };
|
||||
// println!("{}", ready);
|
||||
|
||||
println!("Exit with F1\n");
|
||||
|
||||
let mut input = NcInput::new_empty();
|
||||
|
@ -3,7 +3,7 @@
|
||||
use libnotcurses_sys::*;
|
||||
|
||||
fn main() -> NcResult<()> {
|
||||
let mut nc = Notcurses::new()?;
|
||||
let mut nc = FullMode::new()?;
|
||||
let plane = nc.stdplane()?;
|
||||
plane.set_scrolling(true);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
use libnotcurses_sys::*;
|
||||
|
||||
fn main() -> NcResult<()> {
|
||||
let mut nc = Notcurses::new()?;
|
||||
let mut nc = FullMode::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 FullMode, 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, FullMode};
|
||||
|
||||
use serial_test::serial;
|
||||
|
||||
@ -10,7 +10,7 @@ fn constructors() -> crate::NcResult<()> {
|
||||
let _c1 = NcCell::new();
|
||||
let _c2 = NcCell::with_char7b('C');
|
||||
|
||||
let mut nc = Notcurses::new()?;
|
||||
let mut nc = FullMode::new()?;
|
||||
let plane = NcPlane::new(&mut nc, 0, 0, 10, 10)?;
|
||||
let _c3 = NcCell::with_char('௵', plane);
|
||||
Ok(())
|
||||
|
@ -73,7 +73,7 @@ pub use wrapper::*;
|
||||
|
||||
/// Minimal notcurses instance for styling text.
|
||||
///
|
||||
/// This is the internal type safely wrapped by [Direct].
|
||||
/// This is the internal type safely wrapped by [DirectMode].
|
||||
pub type NcDirect = crate::bindings::ffi::ncdirect;
|
||||
|
||||
/// Flags (options) for [`NcDirect`]
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! `Direct` wrapper struct and traits implementations.
|
||||
//! `DirectMode` wrapper struct and traits implementations.
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
@ -10,23 +10,23 @@ use crate::{
|
||||
///
|
||||
/// Safely wraps an [NcDirect],
|
||||
/// and implements Drop, AsRef, AsMut, Deref & DerefMut around it.
|
||||
pub struct Direct<'a> {
|
||||
pub struct DirectMode<'a> {
|
||||
raw: &'a mut NcDirect,
|
||||
}
|
||||
|
||||
impl<'a> AsRef<NcDirect> for Direct<'a> {
|
||||
impl<'a> AsRef<NcDirect> for DirectMode<'a> {
|
||||
fn as_ref(&self) -> &NcDirect {
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsMut<NcDirect> for Direct<'a> {
|
||||
impl<'a> AsMut<NcDirect> for DirectMode<'a> {
|
||||
fn as_mut(&mut self) -> &mut NcDirect {
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for Direct<'a> {
|
||||
impl<'a> Deref for DirectMode<'a> {
|
||||
type Target = NcDirect;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@ -34,36 +34,36 @@ impl<'a> Deref for Direct<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DerefMut for Direct<'a> {
|
||||
impl<'a> DerefMut for DirectMode<'a> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for Direct<'a> {
|
||||
/// Destroys the Direct context.
|
||||
impl<'a> Drop for DirectMode<'a> {
|
||||
/// Destroys the DirectMode context.
|
||||
fn drop(&mut self) {
|
||||
let _ = self.raw.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// # Constructors and methods overriden from NcDirect
|
||||
impl<'a> Direct<'a> {
|
||||
impl<'a> DirectMode<'a> {
|
||||
// wrap constructors
|
||||
|
||||
/// New Direct (without banners).
|
||||
/// New DirectMode (without banners).
|
||||
pub fn new() -> NcResult<Self> {
|
||||
raw_wrap![NcDirect::new()]
|
||||
}
|
||||
|
||||
/// New Direct, expects `NCOPTION_*` flags.
|
||||
/// New DirectMode, expects `NCOPTION_*` flags.
|
||||
pub fn with_flags(flags: u64) -> NcResult<Self> {
|
||||
raw_wrap![NcDirect::with_flags(flags)]
|
||||
}
|
||||
|
||||
// disable destructor
|
||||
|
||||
/// Since Direct already implements [Drop](#impl-Drop),
|
||||
/// Since DirectMode already implements [Drop](#impl-Drop),
|
||||
/// this function is made no-op.
|
||||
pub fn stop(&mut self) -> NcResult<()> {
|
||||
Ok(())
|
||||
|
@ -18,7 +18,7 @@
|
||||
//! use libnotcurses_sys::*;
|
||||
//!
|
||||
//! fn main() -> NcResult<()> {
|
||||
//! let mut nc = Notcurses::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
|
||||
//! let mut nc = FullMode::with_flags(NCOPTION_NO_ALTERNATE_SCREEN)?;
|
||||
//! let plane = nc.stdplane()?;
|
||||
//! plane.putstr("hello world")?;
|
||||
//! nc.render()?;
|
||||
@ -27,14 +27,14 @@
|
||||
//! ```
|
||||
//! Specifically, and for example:
|
||||
//!
|
||||
//! [`Notcurses`] is the safe wrapper over [`NcNotcurses`], which is the
|
||||
//! [`FullMode`] is the safe wrapper over [`NcNotcurses`], which is the
|
||||
//! `&mut` reference over the raw `*mut` pointer received from FFI.
|
||||
//!
|
||||
//! Notcurses implements the [Drop], [AsRef], [AsMut], [Deref][std::ops::Deref]
|
||||
//! FullMode implements the [Drop], [AsRef], [AsMut], [Deref][std::ops::Deref]
|
||||
//! & [DerefMut][std::ops::DerefMut] traits.
|
||||
//!
|
||||
//! Most methods are directly implemented for NcNotcurses,
|
||||
//! and automatically available also from Notcurses.
|
||||
//! and automatically available also from FullMode.
|
||||
//!
|
||||
//! The destructor ([notcurses_stop()]) is called automatically at the end
|
||||
//! of its scope, so you don't ever have to call it by hand.
|
||||
|
@ -77,7 +77,7 @@ pub use wrapper::*;
|
||||
/// NcNotcurses builds atop the terminfo abstraction layer to
|
||||
/// provide reasonably portable vivid character displays.
|
||||
///
|
||||
/// This is the internal type safely wrapped by [Notcurses].
|
||||
/// This is the internal type safely wrapped by [FullMode].
|
||||
pub type NcNotcurses = crate::bindings::ffi::notcurses;
|
||||
|
||||
/// Options struct for [`NcNotcurses`]
|
||||
|
@ -1,4 +1,4 @@
|
||||
//! `Notcurses` wrapper struct and traits implementations.
|
||||
//! `FullMode` wrapper struct and traits implementations.
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
@ -11,23 +11,23 @@ use crate::{
|
||||
///
|
||||
/// Safely wraps an [NcNotcurses],
|
||||
/// and implements Drop, AsRef, AsMut, Deref & DerefMut around it.
|
||||
pub struct Notcurses<'a> {
|
||||
pub struct FullMode<'a> {
|
||||
raw: &'a mut NcNotcurses,
|
||||
}
|
||||
|
||||
impl<'a> AsRef<NcNotcurses> for Notcurses<'a> {
|
||||
impl<'a> AsRef<NcNotcurses> for FullMode<'a> {
|
||||
fn as_ref(&self) -> &NcNotcurses {
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsMut<NcNotcurses> for Notcurses<'a> {
|
||||
impl<'a> AsMut<NcNotcurses> for FullMode<'a> {
|
||||
fn as_mut(&mut self) -> &mut NcNotcurses {
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Deref for Notcurses<'a> {
|
||||
impl<'a> Deref for FullMode<'a> {
|
||||
type Target = NcNotcurses;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@ -35,56 +35,56 @@ impl<'a> Deref for Notcurses<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DerefMut for Notcurses<'a> {
|
||||
impl<'a> DerefMut for FullMode<'a> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for Notcurses<'a> {
|
||||
/// Destroys the Notcurses context.
|
||||
impl<'a> Drop for FullMode<'a> {
|
||||
/// Destroys the FullMode context.
|
||||
fn drop(&mut self) {
|
||||
let _ = self.raw.stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// # Constructors and methods overriden from NcNotcurses
|
||||
impl<'a> Notcurses<'a> {
|
||||
impl<'a> FullMode<'a> {
|
||||
// wrap constructors
|
||||
|
||||
/// New Notcurses (without banners).
|
||||
/// New FullMode (without banners).
|
||||
pub fn new() -> NcResult<Self> {
|
||||
raw_wrap![NcNotcurses::new()]
|
||||
}
|
||||
|
||||
/// New Notcurses, without banners.
|
||||
/// New FullMode, without banners.
|
||||
pub fn with_banners() -> NcResult<Self> {
|
||||
raw_wrap![NcNotcurses::with_banners()]
|
||||
}
|
||||
|
||||
/// New Notcurses, without an alternate screen (nor banners).
|
||||
/// New FullMode, without an alternate screen (nor banners).
|
||||
pub fn without_altscreen() -> NcResult<Self> {
|
||||
raw_wrap![NcNotcurses::without_altscreen()]
|
||||
}
|
||||
|
||||
/// New Notcurses, expects `NCOPTION_*` flags.
|
||||
/// New FullMode, expects `NCOPTION_*` flags.
|
||||
pub fn with_flags(flags: u64) -> NcResult<Self> {
|
||||
raw_wrap![NcNotcurses::with_flags(flags)]
|
||||
}
|
||||
|
||||
/// New Notcurses, expects [NcNotcursesOptions].
|
||||
/// New FullMode, expects [NcNotcursesOptions].
|
||||
pub fn with_options(options: NcNotcursesOptions) -> NcResult<Self> {
|
||||
raw_wrap![NcNotcurses::with_options(options)]
|
||||
}
|
||||
|
||||
/// New Notcurses, expects [NcLogLevel] and flags.
|
||||
/// New FullMode, expects [NcLogLevel] and flags.
|
||||
pub fn with_debug(loglevel: NcLogLevel, flags: u64) -> NcResult<Self> {
|
||||
raw_wrap![NcNotcurses::with_debug(loglevel, flags)]
|
||||
}
|
||||
|
||||
// disable destructor
|
||||
|
||||
/// Since Notcurses already implements [Drop](#impl-Drop),
|
||||
/// Since FullMode already implements [Drop](#impl-Drop),
|
||||
/// this function is made no-op.
|
||||
pub fn stop(&mut self) -> NcResult<()> {
|
||||
Ok(())
|
||||
@ -127,7 +127,7 @@ impl<'a> Notcurses<'a> {
|
||||
NcNotcurses::lex_scalemode(op)
|
||||
}
|
||||
|
||||
/// Returns a human-readable string describing the running Notcurses version.
|
||||
/// Returns a human-readable string describing the running FullMode version.
|
||||
pub fn version() -> String {
|
||||
NcNotcurses::version()
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ mod methods;
|
||||
|
||||
/// menus on the top or bottom rows
|
||||
///
|
||||
/// A [Notcurses][crate::Notcurses] instance supports menu bars
|
||||
/// A [FullMode][crate::FullMode] instance supports menu bars
|
||||
/// on the top or bottom row of the true screen.
|
||||
///
|
||||
/// An NcMenu is composed of [NcMenuSection]s, which are in turn composed of
|
||||
|
Loading…
Reference in New Issue
Block a user