Curses

Struct Curses 

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

The curses instance. To initialize the curses instance, call initscr.

Many curses functions have been renamed for one reason or another. All renamed functions state the curses function they corollate to.

Implementations§

Source§

impl Curses

Source

pub fn window(&self) -> &Window

Get a reference to the main Window of the curses instance.

This corresponds to stdscr.

Source

pub fn window_mut(&mut self) -> &mut Window

Get a mutable reference to the main Window of the curses instance.

This corresponds to stdscr.

Source

pub fn has_colors(&self) -> bool

Check if the terminal has support for colors.

Source

pub fn start_color(&mut self) -> Result<(), ()>

Start the color subsystem.

If it has already been started, this does nothing.

Source

pub fn color(&self) -> &Color

Get an immutable reference to the Color subsystem.

This method will panic if start_color has not successfully completed yet.

Source

pub fn color_mut(&mut self) -> &mut Color

Get a mutable reference to the Color subsystem.

This method will panic if start_color has not successfully completed yet.

Source

pub fn set_cursor_visibility( &mut self, visibility: CursorVisibility, ) -> Result<(), ()>

Set the visibility of the cursor.

This corresponds of curs_set.

Source

pub fn define_program_mode(&mut self) -> Result<(), ()>

Save the current terminal state as program mode (in curses).

This is done automatically by initscr.

This corresponds of def_prog_mode.

Source

pub fn define_shell_mode(&mut self) -> Result<(), ()>

Save the current terminal state as shell mode (not in curses).

This is done automatically by initscr.

This corresponds of def_shell_mode.

Source

pub fn restore_program_mode(&mut self) -> Result<(), ()>

Restore the terminal to program mode (in curses).

This corresponds of reset_prog_mode.

Source

pub fn restore_shell_mode(&mut self) -> Result<(), ()>

Restore the terminal to program mode (not in curses).

This corresponds of reset_shell_mode.

Source

pub fn output_rate(&self) -> BitsPerSecond

Get the output rate of the terminal in bits per second.

This corresponds to baudrate.

Source

pub fn delay_output(&mut self, time: Duration) -> Result<(), ()>

Insert a millisecond pause in output. Don’t use this extensively.

Source

pub fn update(&mut self) -> Result<(), ()>

Push updates from the virtual screen to the physical screen.

This corresponds of doupdate.

Source

pub fn set_echo_input(&mut self, echo: bool) -> Result<(), ()>

Control whether characters typed by the user are written to the screen as they are typed.

If enabled, characters typed by the user are written to the screen as they are typed.

If disabled, characters typed by the user are interpretted by the program and not echoed to the screen.

This corresponds of echo and noecho.

Source

pub fn set_input_buffering_mode( &mut self, mode: InputBufferingMode, ) -> Result<(), ()>

Set the input buffering mode.

See InputBufferingMode for more informatation.

This corresponds of cbreak, nocbreak, raw, and noraw.

Source

pub fn set_translate_new_lines(&mut self, translate: bool) -> Result<(), ()>

Enable new line translations.

When enabled, the return key is translated into newline on input and return and line-feed on output.

This is enabled by default. Disabling this can cause curses to make better use of the line-feed capability, will have faster cursor motion, and will detect the return key (see Input::KeyEnter).

This corresponds of nl and nonl.

Source

pub fn flush_input(&mut self) -> Result<(), ()>

Throw away all unread key events.

This corresponds of flushinp.

Source

pub fn set_timeout(&mut self, duration: Duration) -> Result<(), ()>

[read_char] will block for at most duration and wait for input.

This will fail if duration is not inbetween 0.1 and 2.55 seconds. duration is rounded down to the nearest tenth of a second. For more fidelity, see Window::set_timeout.

From reading the ncurses source code, I have deduced that this overrides the specific Window’s timeout.

Use disable_cbreak to stop this.

This corresponds of halfdelay.

Source

pub fn end_curses(self) -> Result<(), ()>

End the instance of curses, allowing for error handling outside of panicking.

This returns the terminal to shell mode.

This disposes of the main Window.

This corresponds of endwin.

Source

pub fn flash(&mut self) -> Result<(), ()>

Flash the terminal screen. If not possible, an alert is sounded.

Returns Ok if flashing succeeds, and Err otherwise.

Source

pub fn key_name(&self, key_code: i32) -> Option<String>

Get a string representing a key code.

This corresponds of keyname.

Source

pub fn mouse_read(&self) -> Result<MouseEvent, ()>

Get the status of the mouse.

This corresponds of getmouse.

Source

pub fn mouse_interval(&self) -> Duration

Get the maximum time between press and release events for it to be recognized as a click.

This corresponds of mouseinterval(-1).

Source

pub fn set_mouse_interval(&mut self, interval: Duration) -> Result<(), ()>

Set the maximum time between press and release events for it to be recognized as a click.

As of right now this will always succeed, but it is possible this behavior will change in the future.

This corresponds of mouseinterval.

Source

pub fn set_mouse_mask( &mut self, mask: MouseMask, old_mask: Option<&mut MouseMask>, ) -> Result<MouseMask, ()>

Set the mouse events to be reported.

Returns the masks that were applied.

As of right now this will always succeed, but it is possible this behavior will change in the future.

If mask == 0 then the mouse pointer may be turned off.

This corresponds of mousemask.

Source

pub fn sleep(&mut self, duration: Duration) -> Result<(), ()>

Sleep for a certain number of milliseconds.

This corresponds of napms.

Source

pub fn resize_terminal(&mut self, rows: i32, columns: i32) -> Result<(), ()>

Attempt to resize the terminal.

This corresponds of resize_term.

Source

pub fn beep(&mut self) -> Result<(), ()>

Attempt to beep the terminal.

Control whether characters with A_BLINK will actually blink the screen or if it will set a high intensity background.

When enabled, the screen will actually blink instead of setting a high intensity background.

When disabled, Allow the terminal to either actually blink or set a high intensity background when blink is called.

This is only supported on Windows.

This corresponds of set_blink.

Source

pub fn set_title<T: AsRef<str>>(&mut self, title: T) -> Result<(), ()>

Set the title of the terminal.

This is only supported on Windows.

Trait Implementations§

Source§

impl Drop for Curses

Call end_window and unwrap the result.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Curses

§

impl RefUnwindSafe for Curses

§

impl Send for Curses

§

impl Sync for Curses

§

impl Unpin for Curses

§

impl UnwindSafe for Curses

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.