@ -1,32 +1,32 @@
//! `N ot curses *` methods and associated functions.
//! `N c*` 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 ,
NcDim , NcEgc , NcError , NcFile , NcInput , NcLogLevel , NcPlane , NcResult , NcScale , NcSignalSet ,
NcDim , NcEgc , NcError , NcFile , NcInput , NcLogLevel , NcPlane , NcResult , NcScale , NcSignalSet ,
NcStats , NcStyle , NcTime , N ot curses , N ot curses Options, NCOPTION_NO_ALTERNATE_SCREEN ,
NcStats , NcStyle , NcTime , N c, N cOptions, NCOPTION_NO_ALTERNATE_SCREEN ,
NCOPTION_SUPPRESS_BANNERS , NCRESULT_ERR ,
NCOPTION_SUPPRESS_BANNERS , NCRESULT_ERR ,
} ;
} ;
/// # `N ot curses Options` Constructors
/// # `N cOptions` Constructors
impl N ot curses Options {
impl N cOptions {
/// New N ot curses Options.
/// New N cOptions.
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 N ot curses Options, with margins.
/// New N cOptions, with margins.
pub const fn with_margins ( top : NcDim , right : NcDim , bottom : NcDim , left : NcDim ) -> Self {
pub const fn with_margins ( top : NcDim , right : NcDim , bottom : NcDim , left : NcDim ) -> Self {
Self ::with_all_options ( 0 , top , right , bottom , left , 0 )
Self ::with_all_options ( 0 , top , right , bottom , left , 0 )
}
}
/// New N ot curses Options, with flags.
/// New N cOptions, 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 N ot curses Options, with all the options.
/// New N cOptions, with all the options.
///
///
/// ## Arguments
/// ## Arguments
///
///
@ -78,46 +78,46 @@ impl NotcursesOptions {
}
}
}
}
/// # `N ot curses ` Constructors
/// # `N c` Constructors
impl N ot curses {
impl N c {
/// New Notcurses (without banners).
/// New notcurses context (without banners).
pub fn new < ' a > ( ) -> NcResult < & ' a mut N ot curses > {
pub fn new < ' a > ( ) -> NcResult < & ' a mut N c> {
Self ::with_flags ( NCOPTION_SUPPRESS_BANNERS )
Self ::with_flags ( NCOPTION_SUPPRESS_BANNERS )
}
}
/// New Notcurses , with banners.
/// New notcurses context , 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 N ot curses > {
pub fn with_banners < ' a > ( ) -> NcResult < & ' a mut N c> {
Self ::with_flags ( 0 )
Self ::with_flags ( 0 )
}
}
/// New Notcurses , without an alternate screen (nor banners).
/// New notcurses context , without an alternate screen (nor banners).
pub fn without_altscreen < ' a > ( ) -> NcResult < & ' a mut N ot curses > {
pub fn without_altscreen < ' a > ( ) -> NcResult < & ' a mut N c> {
Self ::with_flags ( NCOPTION_NO_ALTERNATE_SCREEN | NCOPTION_SUPPRESS_BANNERS )
Self ::with_flags ( NCOPTION_NO_ALTERNATE_SCREEN | NCOPTION_SUPPRESS_BANNERS )
}
}
/// New Notcurses , expects `NCOPTION_*` flags.
/// New notcurses context , expects `NCOPTION_*` flags.
pub fn with_flags < ' a > ( flags : u64 ) -> NcResult < & ' a mut N ot curses > {
pub fn with_flags < ' a > ( flags : u64 ) -> NcResult < & ' a mut N c> {
Self ::with_options ( N ot curses Options::with_flags ( flags ) )
Self ::with_options ( N cOptions::with_flags ( flags ) )
}
}
/// New Notcurses, expects [Notcurses Options].
/// New notcurses context, expects [Nc Options].
pub fn with_options < ' a > ( options : N ot curses Options) -> NcResult < & ' a mut N ot curses > {
pub fn with_options < ' a > ( options : N cOptions) -> NcResult < & ' a mut N c> {
let res = unsafe { notcurses_init ( & options , null_mut ( ) ) } ;
let res = unsafe { notcurses_init ( & options , null_mut ( ) ) } ;
error_ref_mut ! [ res , "Notcurses.with_options()" ]
error_ref_mut ! [ res , "Notcurses.with_options()" ]
}
}
/// New Notcurses , expects [NcLogLevel] and flags.
/// New notcurses context , expects [NcLogLevel] and flags.
pub fn with_debug < ' a > ( loglevel : NcLogLevel , flags : u64 ) -> NcResult < & ' a mut N ot curses > {
pub fn with_debug < ' a > ( loglevel : NcLogLevel , flags : u64 ) -> NcResult < & ' a mut N c> {
Self ::with_options ( N ot curses Options::with_all_options (
Self ::with_options ( N cOptions::with_all_options (
loglevel , 0 , 0 , 0 , 0 , flags ,
loglevel , 0 , 0 , 0 , 0 , flags ,
) )
) )
}
}
}
}
/// # `N ot curses ` methods
/// # `N c` methods
impl N ot curses {
impl N c {
/// 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`.
///
///
@ -289,7 +289,7 @@ impl Notcurses {
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 N otcurses state to the supplied `debugfp`.
/// Dumps n otcurses 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.
@ -407,7 +407,7 @@ impl Notcurses {
} else {
} else {
error ! [
error ! [
- 1 ,
- 1 ,
& format! ( "N ot curses .getc_blocking({:?})", input_txt ) ,
& format! ( "N c.getc_blocking({:?})", input_txt ) ,
res
res
]
]
}
}
@ -416,7 +416,7 @@ impl Notcurses {
/// 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()][N ot curses #method.getc_nblock], and input ought be ready.
/// [getc_nblock()][N c#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!).
@ -437,13 +437,13 @@ impl Notcurses {
]
]
}
}
/// Lexes a margin argument according to the standard N otcurses definition.
/// Lexes a margin argument according to the standard n otcurses 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 N ot curses Options) -> NcResult < ( ) > {
pub fn lex_margins ( op : & str , options : & mut N cOptions) -> NcResult < ( ) > {
error ! [ unsafe { crate ::notcurses_lex_margins ( cstring ! [ op ] , options ) } ]
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
/// 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()][N ot curses #method.getc].
/// On success, mouse events will be published to [getc()][N c#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 ) } ,
"N ot curses .mouse_enable()"
"N c.mouse_enable()"
]
]
}
}
@ -508,7 +508,7 @@ impl Notcurses {
if res = = 1 {
if res = = 1 {
return Err ( NcError ::with_msg (
return Err ( NcError ::with_msg (
1 ,
1 ,
"No color support ← N ot curses .palette_size()",
"No color support ← N c.palette_size()",
) ) ;
) ) ;
}
}
Ok ( res )
Ok ( res )
@ -516,7 +516,9 @@ impl Notcurses {
/// 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::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
/// 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
@ -539,12 +541,12 @@ impl Notcurses {
pub fn render ( & mut self ) -> NcResult < ( ) > {
pub fn render ( & mut self ) -> NcResult < ( ) > {
error ! [
error ! [
unsafe { crate ::notcurses_render ( self ) } ,
unsafe { crate ::notcurses_render ( self ) } ,
"N ot curses .render()"
"N c.render()"
]
]
}
}
/// Performs the rendering and rasterization portion of
/// Performs the rendering and rasterization portion of
/// [render][N ot curses #method.render] but do not write the resulting buffer
/// [render][N c#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,
@ -570,7 +572,7 @@ impl Notcurses {
/// Writes the last rendered frame, in its entirety, to 'fp'.
/// Writes the last rendered frame, in its entirety, to 'fp'.
///
///
/// If [render()][N ot curses #method.render] has not yet been called,
/// If [render()][N c#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].*
@ -578,7 +580,7 @@ impl Notcurses {
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 N otcurses object's stats.
/// Acquires an atomic snapshot of the n otcurses 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 ) {
@ -590,7 +592,7 @@ impl Notcurses {
/// 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
/// N otcurses might enlarge this structure.
/// n otcurses 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 ( & mut self ) -> & mut NcStats {
pub fn stats_alloc ( & mut self ) -> & mut NcStats {
@ -654,7 +656,7 @@ impl Notcurses {
unsafe { & * crate ::notcurses_stdplane_const ( self ) }
unsafe { & * crate ::notcurses_stdplane_const ( self ) }
}
}
/// Destroys the N otcurses context.
/// Destroys the n otcurses 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 < ( ) > {
@ -708,7 +710,7 @@ impl Notcurses {
rstring ! [ crate ::notcurses_version ( ) ] . to_string ( )
rstring ! [ crate ::notcurses_version ( ) ] . to_string ( )
}
}
/// Returns the running N otcurses version components
/// Returns the running n otcurses 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].*