|
|
|
@ -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()
|
|
|
|
|
}
|
|
|
|
|