Notcurses

Struct Notcurses 

Source
pub struct Notcurses { /* private fields */ }
Expand description

Notcurses state for a given terminal, composed of Planes.

There can only be a single Notcurses instance per thread at any given moment.

Implementations§

Source§

impl Notcurses

Source

pub fn is_initialized() -> bool

Returns true if there’s already a notcurses instance initialized in this thread.

Source§

impl Notcurses

§constructors & deconstructors.

Source

pub fn new() -> Result<Self>

Returns a new Notcurses context.

Source

pub fn with_banners() -> Result<Self>

Returns a new Notcurses context, with banners.

Source

pub fn new_cli() -> Result<Self>

Returns a new Notcurses context in CLI mode.

Source

pub fn with_banners_cli() -> Result<Self>

Returns a new Notcurses context in CLI mode, with banners.

Source

pub fn with_nc<F, R>(&self, f: F) -> R
where F: FnOnce(&Nc) -> R,

Safely access the Nc reference.

Source

pub fn with_nc_mut<F, R>(&self, f: F) -> R
where F: FnOnce(&mut Nc) -> R,

Safely access the mutable Nc reference.

Source§

impl Notcurses

§constructors for other types.

Source

pub fn cli_plane(&self) -> Result<Plane>

Source

pub fn new_palette(&mut self) -> Palette

Source§

impl Notcurses

§event methods

Source

pub fn refresh(&self) -> Result<(u32, u32)>

Refreshes the physical screen to match what was last rendered (i.e., without reflecting any changes since the last call to render).

Returns the current screen geometry (y, x).

This is primarily useful if the screen is externally corrupted, or if a resize] event has been read and you’re not yet ready to render.

Source

pub fn mice_enable(&self, input: MiceEvents) -> Result<()>

Enables receiving the provided mice events.

Source

pub fn mice_disable(&self) -> Result<()>

Disables receiving the mice events.

Source

pub fn get_event(&self) -> Result<Input>

Waits for an event, blocking.

Source

pub fn poll_event(&self) -> Result<Input>

Tries to get an event, non blocking.

Source§

impl Notcurses

§general query methods

Source

pub fn size(&self) -> Size

Returns the terminal size.

Source

pub fn geometry_best(&self) -> PlaneGeometry

Returns the terminal geometry with the best resolution blitter available, using the following rules of graceful degradation:

Pixel > Sextant > Quadrant > Half > Ascii.

Source

pub fn geometry_try(&self, blitter: Blitter) -> Option<PlaneGeometry>

Returns the terminal geometry using the requested blitter, if available.

Source

pub fn geometry_first(&self, blitters: &[Blitter]) -> Option<PlaneGeometry>

Returns the first terminal geometry available from the provided list.

Source

pub fn geometries_all(&self, blitters: &[Blitter]) -> Vec<PlaneGeometry>

Returns all the availeble terminal geometries from the provided list.

Source

pub fn visual_geometry(&self, visual: &Visual) -> Result<VisualGeometry>

Returns the visual geometry of a visual.

Source

pub fn capabilities(&self) -> Capabilities

Returns the capabilities of the terminal.

Source

pub fn supported_styles(&self) -> Style

Returns an Style with the supported curses-style attributes.

The attribute is only indicated as supported if the terminal can support it together with color.

Source

pub fn default_background(&self) -> Option<Rgb>

Returns the default background color, if it is known.

Source

pub fn default_foreground(&self) -> Option<Rgb>

Returns the default foreground color, if it is known.

Source

pub fn version() -> String

Returns a human-readable string describing the running notcurses version.

Source

pub fn version_components() -> (u32, u32, u32, u32)

Returns the running notcurses version components (major, minor, patch, tweak).

Source

pub fn accountname() -> String

Returns the name of the user under which we are running.

Source

pub fn hostname() -> String

Returns the name of the local hostname.

Source

pub fn osversion() -> String

Returns the name of the detected OS version.

Source

pub fn detected_terminal(&self) -> String

Returns the name of the detected terminal.

Source§

impl Notcurses

§settings methods

Source

pub fn cursor_disable(&self) -> Result<()>

Disables the terminal’s cursor.

Source

pub fn cursor_enable(&self, position: impl Into<Position>) -> Result<()>

Enables the terminal’s cursor, if available, placing it at position.

Source

pub fn leave_alternate_screen(&mut self) -> Result<()>

Leaves the alternate screen.

Source

pub fn enter_alternate_screen(&mut self) -> Result<()>

Enters the alternate screen, if available.

Entering the alternate screen turns off scrolling for the CLI plane.

Source

pub fn signals_disable(&mut self) -> Result<()>

Disables signals originating from the terminal’s line discipline, i.e. SIGINT (^C), SIGQUIT (^), and SIGTSTP (^Z). They are enabled by default.

Source

pub fn signals_enable(&mut self) -> Result<()>

Restores signals originating from the terminal’s line discipline, i.e. SIGINT (^C), SIGQUIT (^), and SIGTSTP (^Z), if disabled.

Source§

impl Notcurses

§statistics methods

Source

pub fn statistics(&mut self) -> Statistics

Allocates a Statistics object.

Source

pub fn statistics_reset(&mut self, stats: Statistics)

Resets all cumulative statistics.

Immediate ones, such as fbbytes, are not reset.

Source

pub fn statistics_update(&mut self, stats: Statistics)

Acquires an atomic snapshot of the notcurses statistics.

Trait Implementations§

Source§

impl Debug for Notcurses

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.