Window

Struct Window 

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

A curses window.

It will clean up itself on destruction.

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

Implementations§

Source§

impl Window

Source

pub fn put_char<T: Into<Chtype>>(&mut self, ch: T) -> Result<(), ()>

Put a character at the point.

This corresponds to addch.

Source

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

Put a string at the point.

This corresponds to addch.

Source

pub fn printw(&mut self, args: Arguments<'_>) -> Result<(), ()>

Print a formatted string at the point.

This corresponds to printw. It does not use printw under the hood because that function cannot be safe to use within rust code because rust does not allow for variadic arguments.

Source

pub fn put_window(&mut self, source: &Window) -> Result<(), ()>

Put the contents of source that overlap with this Window.

The two Windows are not required to be the same size; overlapping portions are copied.

This corresponds to overwrite but with the arguments flipped.

Source

pub fn put_window_region<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>( &mut self, destination_start: P1, destination_end: P2, source: &Window, source_start: P3, ) -> Result<(), ()>

Put the contents of source in a region at a region of this Window.

The two regions are not required to be the same size; overlapping portions are copied.

This corresponds to copywin but with the arguments flipped and a final argument of true.

Source

pub fn put_window_text(&mut self, source: &Window) -> Result<(), ()>

Put the non-blank contents of source that overlap with this Window.

The two Windows are not required to be the same size; overlapping portions are copied.

This corresponds to overlay but with the arguments flipped.

Source

pub fn put_window_text_region<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>( &mut self, destination_start: P1, destination_end: P2, source: &Window, source_start: P3, ) -> Result<(), ()>

Put the non-blank contents of source in a region at a region of this Window.

The two regions are not required to be the same size; overlapping portions are copied.

This corresponds to copywin but with the arguments flipped and a final argument of true.

Source

pub fn overwrite_onto(&self, destination: &mut Self) -> Result<(), ()>

Put the contents of this Window onto destination where they overlap.

This corresponds to overwrite.

Source

pub fn overlay_onto(&self, destination: &mut Self) -> Result<(), ()>

Put the non-blank contents of this Window onto destination where they overlap.

This corresponds to overlay.

Source

pub fn overwrite_region_onto<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>( &self, source_start: P1, destination: &mut Window, destination_start: P2, destination_end: P3, ) -> Result<(), ()>

Overwrite this Window on top of the destination.

For more information on how this works, see put_window.

This corresponds to copywin with a final argument of true.

Source

pub fn overlay_region_onto<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>( &self, source_start: P1, destination: &mut Window, destination_start: P2, destination_end: P3, ) -> Result<(), ()>

Overlay this Window’s text on top of the destination.

For more information on how this works, see put_window_text.

This corresponds to copywin with a final argument of true.

Source

pub fn attributes(&self) -> (Chtype, i16)

Get the attributes of the character at the point.

This corresponds to attrget.

Source

pub fn turn_off_attributes<T: Into<Chtype>>( &mut self, attributes: T, ) -> Result<(), ()>

Turn off the following attributes of the character at the point.

This corresponds to attroff.

Source

pub fn turn_on_attributes<T: Into<Chtype>>( &mut self, attributes: T, ) -> Result<(), ()>

Turn on the following attributes of the character at the point.

This corresponds to attron.

Source

pub fn set_attributes<T: Into<Chtype>>( &mut self, attributes: T, ) -> Result<(), ()>

Set the attributes of the character at the point.

This corresponds to attrset.

Source

pub fn change_attributes<T: Into<Chtype>, N: Into<EndOfLineOrNumber>>( &mut self, n: N, attributes: T, color_pair: i16, ) -> Result<(), ()>

Turn off the following attributes of the character at the point.

This corresponds to chgat.

Source

pub fn set_background<T: Into<Chtype>>(&mut self, ch: T)

Set the background of the Window.

This corresponds to bkgdset.

Source

pub fn set_background_and_apply<T: Into<Chtype>>( &mut self, background: T, ) -> Result<(), ()>

Set the background of the Window and apply it.

This sets the attributes of every character to the attributes of background and replaces old background characters with background.

This corresponds to bkgd.

Source

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

Clear the screen.

This fills the screen with background characters. This can be customized via set_background.

Unlike erase, clear will also invoke force a the next call to refresh to clear the screen (as if by refresh_force_clear).

Source

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

Clear the virtual screen.

See clear for a comparison of these two methods.

Source

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

Erase all characters after the point.

This will clear to the end of the line, then clear each line after the one the point is on.

This corresponds to clrtobot.

Source

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

Erase all characters to the right of the point on this line.

This corresponds to clrtobot.

Source

pub fn set_color(&mut self, color_pair: i16) -> Result<(), ()>

Set the current color of the given window to the foregrond/background pair color_pair.

This corresponds to color_set.

Source

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

Delete the character at the point.

This will shift left the characters on the rest of the line.

This corresponds to delch.

Source

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

Delete the line the point is on.

This will shift left the characters on the rest of the line.

This corresponds to delch.

Source

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

Delete this Window, allowing for error handling outside of panicking.

Source

pub fn draw_border<LS: Into<Chtype>, RS: Into<Chtype>, TS: Into<Chtype>, BS: Into<Chtype>, TLC: Into<Chtype>, TRC: Into<Chtype>, BLC: Into<Chtype>, BRC: Into<Chtype>>( &mut self, left_side: LS, right_side: RS, top_side: TS, bottom_side: BS, top_left_corner: TLC, top_right_corner: TRC, bottom_left_corner: BLC, bottom_right_corner: BRC, ) -> Result<(), ()>

Draw a border around the edges of the Window.

This corresponds to border.

Source

pub fn draw_box<VT: Into<Chtype>, HT: Into<Chtype>>( &mut self, vertical: VT, horizontal: HT, ) -> Result<(), ()>

Drow a box around the edges of the Window.

This is shorthand for draw_border with default corners.

This corresponds to border.

Source

pub fn draw_horizontal_line<T: Into<Chtype>>( &mut self, ch: T, max_length: i32, ) -> Result<(), ()>

Draw a horizontal line starting at the point.

This corresponds to hline.

Source

pub fn draw_vertical_line<T: Into<Chtype>>( &mut self, ch: T, max_length: i32, ) -> Result<(), ()>

Draw a vertical line starting at the point.

This corresponds to vline.

Source

pub fn encloses<P: Into<Point>>(&self, p: P) -> bool

Test if p is enclosed in this Window.

Source

pub fn beginning(&self) -> Point

Get the start of the Window on the physical screen.

This corresponds to get_beg_yx.

Source

pub fn ending(&self) -> Point

Get the ending of the Window on the physical screen.

Source

pub fn point(&self) -> Point

Get the position of the point.

This corresponds to get_cur_yx.

Source

pub fn size(&self) -> Dimension

Get the size of the Window.

This corresponds to get_max_yx.

Source

pub fn insert_lines(&mut self, n: i32) -> Result<(), ()>

Insert n blank lines above the cursor.

If n > 0, then n blank lines are inserted above the cursor. The last n lines of the screen are lost.

If n < 0, then n lines below the cursor are deleted and the rest are shifted up. This clears the bottom n lines of the screen.

The point remains the same after this operation.

This corresponds to insdelln.

Source

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

Insert a blank line above the current line.

This effectively erases the last line on the screen.

The point remains the same after this operation.

This corresponds to insertln.

Source

pub fn insert_char<T: Into<Chtype>>(&self, ch: T) -> Result<(), ()>

Insert a character into the current line.

This shifts to the right characters after the cursor. The rightmost character will thus be lost.

The point remains the same after this operation.

This corresponds to insch.

Source

pub fn window_to_screen<P: Into<Point>>(&self, p: P) -> Point

Transform the point p from Window-relative to screen-relative.

This corresponds to mouse_trafo.

Source

pub fn screen_to_window<P: Into<Point>>(&self, p: P) -> Point

Transform the point p from screen-relative to Window-relative.

This corresponds to mouse_trafo.

Source

pub fn move_to<P: Into<Point>>(&mut self, p: P) -> Result<(), ()>

Move to the point to p.

This corresponds to mv.

Source

pub fn move_put_char<P: Into<Point>, T: Into<Chtype>>( &mut self, p: P, ch: T, ) -> Result<(), ()>

Move to the point p then put ch at that point.

This corresponds to mvaddch.

Source

pub fn move_put_str<P: Into<Point>, T: AsRef<str>>( &mut self, p: P, string: T, ) -> Result<(), ()>

Move to the point p then put string at that point.

This corresponds to mvaddstr.

Source

pub fn move_change_attributes<P: Into<Point>, N: Into<EndOfLineOrNumber>, T: Into<Chtype>>( &mut self, p: P, n: N, attributes: T, color_pair: i16, ) -> Result<(), ()>

Move to the point p then change the attributes of n characters after that point.

This corresponds to mvchgat.

Source

pub fn move_get_char<P: Into<Point>>(&mut self, p: P) -> Chtype

Move to p then get the character at the point.

This corresponds to mvinch.

Source

pub fn move_insert_char<P: Into<Point>, T: Into<Chtype>>( &mut self, p: P, ch: T, ) -> Result<(), ()>

Move to p then insert the character at the point.

This corresponds to mvinsch.

Source

pub fn move_window<P: Into<Point>>(&mut self, p: P) -> Result<(), ()>

Move the Window such that it starts at p on the screen.

This corresponds to mvwin.

Source

pub fn read_char(&mut self) -> Option<Input>

Read a key event from the Window.

The exact behavior of this procedure depends on other configuration procedures.

This corresponds to getch.

Source

pub fn unread_char(&mut self, input: &Input) -> Result<(), ()>

Place input into the front of the input queue.

Thus the next call to read_char will return input.

This corresponds to ungetch.

Source

pub fn set_block_on_read(&mut self, block: bool) -> Result<(), ()>

Set whether [read_char] will block until an input is ready.

With an argument true, [read_char] will block until it receives an input to yield.

With an argument false, [read_char] will immediately return None if there is no input to yield.

This corresponds to nodelay(!block).

Source

pub fn set_timeout(&self, duration: Option<Duration>)

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

duration is rounded down to the nearest millisecond. This will only change the way input is read in this Window. To set it for all Windows, see Curses::set_timeout.

From reading the ncurses source code, I have deduced that this is overriden by the global Curses’s timeout (see Curses::set_timeout).

Use None as the timeout to stop this.

This corresponds to timeout.

Source

pub fn read_interpolate_function_keys( &mut self, interpolate: bool, ) -> Result<(), ()>

Enable or disable function key interpolation.

When enabled and a function key is pressed, read_char will return a single value representing the function key instead of a series of escape sequences.

When disabled and a function key is pressed, read_char will return a series of escape sequences instead of a single value representing the function key.

It is disabled by default.

This corresponds to keypad.

Source

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

Copy this Window to the physical screen.

This corresponds to wrefresh.

Source

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

Refresh the virtual screen.

This is much faster if multiple Windows have to be refreshed.

To push the virtual screen changes to the physical screen, use Curses::update.

This corresponds to wnoutrefresh.

Source

pub fn refresh_force_clear(&mut self, force_clear: bool) -> Result<(), ()>

Make the next call to refresh clear and then rerender.

This corresponds to clearok.

Source

pub fn set_scroll_enabled(&mut self, scroll: bool) -> Result<(), ()>

Enable or disable scrolling.

This corresponds to scrollok.

Source

pub fn set_scroll_region(&mut self, start: i32, end: i32) -> Result<(), ()>

Set a software scrolling region.

This will do nothing unless scrolling has been enabled (see set_scroll_enabled).

This corresponds to setscrreg.

Source

pub fn create_sub_window<P: Into<Point>, D: Into<Dimension>>( &self, point: P, size: D, ) -> Result<Window, ()>

Create a new window

This corresponds to subwin. Note that the arguments have been reordered to be more consistent with other functions.

Source

pub fn touched(&self) -> bool

Test if this Window has been modified since the last call to refresh.

This corresponds to is_wintouched.

Source

pub fn line_touched(&self, line: i32) -> bool

Test if the specified line has been modified since the last call to refresh.

This corresponds to is_linetouched.

Source

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

Force the entire Window to be redrawn upon the next call to refresh.

This corresponds to touchwin.

Source

pub fn touch_lines(&mut self, start: i32, count: i32) -> Result<(), ()>

Force the specified lines to be redrawn upon the next call to refresh.

This corresponds to touchline.

Source

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

Pretend this Window hasn’t changed and thus won’t redraw it upon the next call to refresh.

This corresponds to touchline.

Source

pub fn untouch_lines(&mut self, start: i32, count: i32) -> Result<(), ()>

Pretend the specified lines haven’t changed and thus won’t redraw it upon the next call to refresh.

This corresponds to touchline.

Trait Implementations§

Source§

impl Clone for Window

Duplicate this Window.

This corresponds to dupwin.

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Send for Window

Source§

impl Sync for Window

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.