Struct pancurses_result::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
sourceimpl Window
impl Window
sourcepub fn put_char<T: Into<chtype>>(&mut self, ch: T) -> Result<(), ()>
pub fn put_char<T: Into<chtype>>(&mut self, ch: T) -> Result<(), ()>
Put a character at the point.
This corresponds to addch
.
sourcepub fn put_str<T: AsRef<str>>(&mut self, string: T) -> Result<(), ()>
pub fn put_str<T: AsRef<str>>(&mut self, string: T) -> Result<(), ()>
Put a string at the point.
This corresponds to addch
.
sourcepub fn printw(&mut self, args: Arguments<'_>) -> Result<(), ()>
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.
sourcepub fn put_window(&mut self, window: &Window) -> Result<(), ()>
pub fn put_window(&mut self, window: &Window) -> Result<(), ()>
Put the contents of window
that overlap with this Window
.
The two Window
s are not required to be the same size;
overlapping portions are copied.
This corresponds to overwrite
but with the arguments flipped.
sourcepub fn put_window_text(&mut self, window: &Window) -> Result<(), ()>
pub fn put_window_text(&mut self, window: &Window) -> Result<(), ()>
Put the non-blank contents of window
that overlap with this
Window
.
The two Window
s are not required to be the same size;
overlapping portions are copied.
This corresponds to overlay
but with the arguments flipped.
sourcepub fn attributes(&self) -> (chtype, i16)
pub fn attributes(&self) -> (chtype, i16)
Get the attributes of the character at the point.
This corresponds to attrget
.
sourcepub fn turn_off_attributes<T: Into<chtype>>(
&mut self,
attributes: T
) -> Result<(), ()>
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
.
sourcepub fn turn_on_attributes<T: Into<chtype>>(
&mut self,
attributes: T
) -> Result<(), ()>
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
.
sourcepub fn set_attributes<T: Into<chtype>>(
&mut self,
attributes: T
) -> Result<(), ()>
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
.
sourcepub fn change_attributes<T: Into<chtype>, N: Into<EndOfLineOrNumber>>(
&mut self,
n: N,
attributes: T,
color_pair: i16
) -> Result<(), ()>
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
.
sourcepub fn set_background<T: Into<chtype>>(&mut self, ch: T)
pub fn set_background<T: Into<chtype>>(&mut self, ch: T)
Set the background of the Window
.
This corresponds to bkgdset
.
sourcepub fn set_background_and_apply<T: Into<chtype>>(
&mut self,
background: T
) -> Result<(), ()>
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
.
sourcepub fn clear(&mut self) -> Result<(), ()>
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 refresh_force_clear
.
sourcepub fn erase(&mut self) -> Result<(), ()>
pub fn erase(&mut self) -> Result<(), ()>
Clear the virtual screen.
See clear
for a comparison of these two methods.
sourcepub fn clear_to_bottom(&mut self) -> Result<(), ()>
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
.
sourcepub fn clear_to_end_of_line(&mut self) -> Result<(), ()>
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
.
sourcepub fn set_color(&mut self, color_pair: i16) -> Result<(), ()>
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
.
sourcepub fn copy_overlay<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>(
&self,
destination: &mut Window,
source_start: P1,
destination_start: P2,
destination_end: P3
) -> Result<(), ()>
pub fn copy_overlay<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>(
&self,
destination: &mut Window,
source_start: P1,
destination_start: P2,
destination_end: P3
) -> Result<(), ()>
Copy this Window
on top of the destination
non-destructively.
For more information on how this works, see overlay
.
This corresponds to copywin
with a final argument of true
.
sourcepub fn copy_overwrite<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>(
&self,
destination: &mut Window,
source_start: P1,
destination_start: P2,
destination_end: P3
) -> Result<(), ()>
pub fn copy_overwrite<P1: Into<Point>, P2: Into<Point>, P3: Into<Point>>(
&self,
destination: &mut Window,
source_start: P1,
destination_start: P2,
destination_end: P3
) -> Result<(), ()>
Copy this Window
on top of the destination
destructively.
For more information on how this works, see overwrite
.
This corresponds to copywin
with a final argument of true
.
sourcepub fn delete_char(&mut self) -> Result<(), ()>
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
.
sourcepub fn delete_line(&mut self) -> Result<(), ()>
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
.
sourcepub fn delete_window(self) -> Result<(), ()>
pub fn delete_window(self) -> Result<(), ()>
Delete this Window
, allowing for error handling outside of
panicking.
sourcepub 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<(), ()>
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
.
sourcepub fn draw_box<VT: Into<chtype>, HT: Into<chtype>>(
&mut self,
vertical: VT,
horizontal: HT
) -> Result<(), ()>
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
.
sourcepub fn draw_horizontal_line<T: Into<chtype>>(
&mut self,
ch: T,
max_length: i32
) -> Result<(), ()>
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
.
sourcepub fn draw_vertical_line<T: Into<chtype>>(
&mut self,
ch: T,
max_length: i32
) -> Result<(), ()>
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
.
sourcepub fn beginning(&self) -> Point
pub fn beginning(&self) -> Point
Get the start of the Window
on the physical screen.
This corresponds to get_beg_yx
.
sourcepub fn insert_lines(&mut self, n: i32) -> Result<(), ()>
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
.
sourcepub fn insert_line(&mut self) -> Result<(), ()>
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
.
sourcepub fn insert_char<T: Into<chtype>>(&self, ch: T) -> Result<(), ()>
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
.
sourcepub fn window_to_screen<P: Into<Point>>(&self, p: P) -> Point
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
.
sourcepub fn screen_to_window<P: Into<Point>>(&self, p: P) -> Point
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
.
sourcepub fn move_to<P: Into<Point>>(&mut self, p: P) -> Result<(), ()>
pub fn move_to<P: Into<Point>>(&mut self, p: P) -> Result<(), ()>
Move to the point to p
.
This corresponds to mv
.
sourcepub fn move_put_char<P: Into<Point>, T: Into<chtype>>(
&mut self,
p: P,
ch: T
) -> Result<(), ()>
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
.
sourcepub fn move_put_str<P: Into<Point>, T: AsRef<str>>(
&mut self,
p: P,
string: T
) -> Result<(), ()>
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
.
sourcepub 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<(), ()>
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
.
sourcepub fn move_get_char<P: Into<Point>>(&mut self, p: P) -> chtype
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
.
sourcepub fn move_insert_char<P: Into<Point>, T: Into<chtype>>(
&mut self,
p: P,
ch: T
) -> Result<(), ()>
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
.
sourcepub fn move_window<P: Into<Point>>(&mut self, p: P) -> Result<(), ()>
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
.
sourcepub fn read_char(&mut self) -> Option<Input>
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.
-
To set how we handle a lack of input (with regard to blocking/unblocking)
set_block_on_read
,set_timeout
, andCurses::set_timeout
. -
To set how function keys are handled, see
read_interpolate_function_keys
. -
To set how new lines are handled, see
Curses::set_translate_new_lines
. -
To set how input is buffered, see
Curses::set_input_buffering_mode
. -
To control whether curses will automatically echo characters see
Curses::set_echo_input
.
This corresponds to getch
.
sourcepub fn unread_char(&mut self, input: &Input) -> Result<(), ()>
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
.
sourcepub fn set_block_on_read(&mut self, block: bool) -> Result<(), ()>
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)
.
sourcepub fn set_timeout(&self, duration: Option<Duration>)
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
Window
s, 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
.
sourcepub fn read_interpolate_function_keys(
&mut self,
interpolate: bool
) -> Result<(), ()>
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
.
sourcepub fn refresh(&mut self) -> Result<(), ()>
pub fn refresh(&mut self) -> Result<(), ()>
Copy this Window
to the physical screen.
This corresponds to wrefresh
.
sourcepub fn refresh_virtual_screen(&mut self) -> Result<(), ()>
pub fn refresh_virtual_screen(&mut self) -> Result<(), ()>
Refresh the virtual screen.
This is much faster if multiple Window
s have to be refreshed.
To push the virtual screen changes to the physical screen, use
Curses::update
.
This corresponds to wnoutrefresh
.
sourcepub fn refresh_force_clear(&mut self, force_clear: bool) -> Result<(), ()>
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
.
sourcepub fn set_scroll_enabled(&mut self, scroll: bool) -> Result<(), ()>
pub fn set_scroll_enabled(&mut self, scroll: bool) -> Result<(), ()>
Enable or disable scrolling.
This corresponds to scrollok
.
sourcepub fn set_scroll_region(&mut self, start: i32, end: i32) -> Result<(), ()>
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
.
sourcepub fn create_sub_window<P: Into<Point>, D: Into<Dimension>>(
&self,
point: P,
size: D
) -> Result<Window, ()>
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.
sourcepub fn touched(&self) -> bool
pub fn touched(&self) -> bool
Test if this Window
has been modified since the last call to
refresh
.
This corresponds to is_wintouched
.
sourcepub fn line_touched(&self, line: i32) -> bool
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
.
sourcepub fn touch(&mut self) -> Result<(), ()>
pub fn touch(&mut self) -> Result<(), ()>
Force the entire Window
to be redrawn upon the next call to
refresh
.
This corresponds to touchwin
.
sourcepub fn touch_lines(&mut self, start: i32, count: i32) -> Result<(), ()>
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
.