Struct pancurses_result::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
sourceimpl Curses
impl Curses
sourcepub fn window(&self) -> &Window
pub fn window(&self) -> &Window
Get a reference to the main Window
of the curses instance.
This corresponds to stdscr
.
sourcepub fn window_mut(&mut self) -> &mut Window
pub fn window_mut(&mut self) -> &mut Window
Get a mutable reference to the main Window
of the curses instance.
This corresponds to stdscr
.
sourcepub fn has_colors(&self) -> bool
pub fn has_colors(&self) -> bool
Check if the terminal has support for colors.
sourcepub fn start_color(&mut self) -> Result<(), ()>
pub fn start_color(&mut self) -> Result<(), ()>
Start the color subsystem.
If it has already been started, this does nothing.
sourcepub fn color(&self) -> &Color
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.
sourcepub fn color_mut(&mut self) -> &mut Color
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.
sourcepub fn set_cursor_visibility(
&mut self,
visibility: CursorVisibility
) -> Result<(), ()>
pub fn set_cursor_visibility(
&mut self,
visibility: CursorVisibility
) -> Result<(), ()>
Set the visibility of the cursor.
This corresponds of curs_set
.
sourcepub fn define_program_mode(&mut self) -> Result<(), ()>
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
.
sourcepub fn define_shell_mode(&mut self) -> Result<(), ()>
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
.
sourcepub fn restore_program_mode(&mut self) -> Result<(), ()>
pub fn restore_program_mode(&mut self) -> Result<(), ()>
Restore the terminal to program mode (in curses).
This corresponds of reset_prog_mode
.
sourcepub fn restore_shell_mode(&mut self) -> Result<(), ()>
pub fn restore_shell_mode(&mut self) -> Result<(), ()>
Restore the terminal to program mode (not in curses).
This corresponds of reset_shell_mode
.
sourcepub fn output_rate(&self) -> BitsPerSecond
pub fn output_rate(&self) -> BitsPerSecond
Get the output rate of the terminal in bits per second.
This corresponds to baudrate
.
sourcepub fn delay_output(&mut self, time: Duration) -> Result<(), ()>
pub fn delay_output(&mut self, time: Duration) -> Result<(), ()>
Insert a millisecond pause in output. Don’t use this extensively.
sourcepub fn update(&mut self) -> Result<(), ()>
pub fn update(&mut self) -> Result<(), ()>
Push updates from the virtual screen to the physical screen.
This corresponds of doupdate
.
sourcepub fn set_echo_input(&mut self, echo: bool) -> Result<(), ()>
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
.
sourcepub fn set_input_buffering_mode(
&mut self,
mode: InputBufferingMode
) -> Result<(), ()>
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
.
sourcepub fn set_translate_new_lines(&mut self, translate: bool) -> Result<(), ()>
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
.
sourcepub fn flush_input(&mut self) -> Result<(), ()>
pub fn flush_input(&mut self) -> Result<(), ()>
Throw away all unread key events.
This corresponds of flushinp
.
sourcepub fn set_timeout(&mut self, duration: Duration) -> Result<(), ()>
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
.
sourcepub fn end_curses(self) -> Result<(), ()>
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
.
sourcepub fn flash(&mut self) -> Result<(), ()>
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.
sourcepub fn key_name(&self, key_code: i32) -> Option<String>
pub fn key_name(&self, key_code: i32) -> Option<String>
Get a string representing a key code.
This corresponds of keyname
.
sourcepub fn mouse_read(&self) -> Result<MouseEvent, ()>
pub fn mouse_read(&self) -> Result<MouseEvent, ()>
Get the status of the mouse.
This corresponds of getmouse
.
sourcepub fn mouse_interval(&self) -> Duration
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)
.
sourcepub fn set_mouse_interval(&mut self, interval: Duration) -> Result<(), ()>
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
.
sourcepub fn set_mouse_mask(
&mut self,
mask: MouseMask,
old_mask: Option<&mut MouseMask>
) -> Result<MouseMask, ()>
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
.
sourcepub fn sleep(&mut self, duration: Duration) -> Result<(), ()>
pub fn sleep(&mut self, duration: Duration) -> Result<(), ()>
Sleep for a certain number of milliseconds.
This corresponds of napms
.
sourcepub fn resize_terminal(&mut self, rows: i32, columns: i32) -> Result<(), ()>
pub fn resize_terminal(&mut self, rows: i32, columns: i32) -> Result<(), ()>
Attempt to resize the terminal.
This corresponds of resize_term
.
sourcepub fn set_force_blink(&mut self, blink: bool) -> Result<(), ()>
pub fn set_force_blink(&mut self, blink: bool) -> Result<(), ()>
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
.