Struct easycurses::EasyCurses
[−]
[src]
pub struct EasyCurses { pub win: Window, // some fields omitted }
This is a handle to all your fun curses functionality.
EasyCurses
will automatically restore the terminal when you drop it, so
you don't need to worry about any manual cleanup. Automatic cleanup will
happen even if your program panics and unwinds, but it will not happen
if your program panics and aborts (obviously). So, don't abort the program
while curses is active, or your terminal session will just be ruined.
Except in the case of is_color_terminal
, all EasyCurses
methods that
return a bool
use it to indicate if the requested operation was successful
or not.
Fields
win: Window
This is the inner pancurses Window
that the EasyCurses
type wraps
over.
This is only intended to be used as a last resort, if you really want to
call something that's not here. Under normal circumstances you shouldn't
need to touch this field at all. It's not "unsafe" to use in the
rust/memory sense, but if you access this field and then cause a bug in
EasyCurses
, that's your fault.
Methods
impl EasyCurses
[src]
fn initialize_system() -> Self
Initializes the curses system so that you can begin using curses. This isn't called "new" because you shouldn't be making more than one EasyCurses value at the same time ever.
If the terminal supports colors, they are automatcially activated and color pairs are initialized for all color foreground and background combinations.
Panics
Since this uses the initscr curses function, any error during initialization will generally cause the program to print an error message to stdout and then immediately exit. C libs are silly like that. Your terminal will be left in a usable state, but anything else in your program that's not abort-safe is probably not fullly safe with this. It is expected that you deal with that by calling this just once at the start of your program, before you've started anything that's not abort-safe.
fn set_title_win32(&mut self, title: &str)
On Win32 systems this allows you to set the title of the PDcurses window. On other systems this does nothing at all.
fn set_cursor_visibility(
&mut self,
vis: CursorVisibility
) -> Option<CursorVisibility>
&mut self,
vis: CursorVisibility
) -> Option<CursorVisibility>
Attempts to assign a new cursor visibility. If this is successful you
get a Some
back with the old setting inside. If this fails you get a
None
back. For more info see
curs_set
fn set_character_break(&mut self, cbreak: bool) -> bool
In character break mode (cbreak), characters typed by the user are made available immediately, and erase/kill/backspace character processing is not performed. When this mode is off (nocbreak) user input is not available to the application until a newline has been typed. The default mode is not specified (but happens to often be cbreak).
See also the Input Mode section of the curses documentation.
fn set_keypad_enabled(&mut self, use_keypad: bool) -> bool
Enables special key processing from buttons such as the keypad and arrow
keys. This defaults to false
. You probably want to set it to true
.
If it's not on and the user presses a special key then get_key will
return will do nothing or give ERR
.
fn set_echo(&mut self, echoing: bool) -> bool
Enables or disables the automatic echoing of input into the window as the user types. Default to on, but you probably want it to be off most of the time.
fn is_color_terminal(&mut self) -> bool
Checks if the current terminal supports the use of colors.
fn set_color_pair(&mut self, pair: ColorPair)
Sets the current color pair of the window. Output at any location will use this pair until a new pair is set. Does nothing if the terminal does not support colors in the first place.
fn set_bold(&mut self, bold_on: bool) -> bool
Enables or disables bold text for all future input.
fn set_underline(&mut self, underline_on: bool) -> bool
Enables or disables unerlined text for all future input.
fn get_row_col_count(&mut self) -> (i32, i32)
Returns the number of rows and columns available in the window.
fn move_rc(&mut self, row: i32, col: i32) -> bool
Moves the virtual cursor to the row and column specified, relative to
the top left ("notepad" space). Does not move the terminal's dispayed
cursor (if any) until refresh
is also called.
fn move_xy(&mut self, x: i32, y: i32) -> bool
Moves the virtual cursor to the x and y specified, relative to the
bottom left ("cartesian" space). Does not move the terminal's displayed
cursor (if any) until refresh
is also called.
fn set_scrolling(&mut self, scrolling: bool) -> bool
When scrolling is enabled, any attempt to move off the bottom margin
will cause lines within the scrolling region to scroll up one line. If a
scrolling region is set but scolling is not enabled then attempts to go
off the bottom will just print nothing instead. Use set_scroll_region
to control the size of the scrolling region.
fn set_scroll_region(&mut self, top: i32, bottom: i32) -> bool
Sets the top and bottom margins of the scrolling region.
fn print(&mut self, string: &str) -> bool
Prints the given string into the window.
fn print_char(&mut self, character: char) -> bool
Prints the given character into the window.
fn delete_char(&mut self) -> bool
Deletes the character under the cursor. Characters after it on same the line are pulled left one position and the final character cell is left blank. The cursor position does not move.
fn delete_line(&mut self) -> bool
Deletes the line under the cursor. Lines below are moved up one line and the final line is left blank. The cursor position does not move.
fn clear(&mut self) -> bool
Clears the entire screen.
fn refresh(&mut self) -> bool
Refreshes the window's appearance on the screen. With some implementations you don't need to call this, the screen will refresh itself on its own. However, for portability, you should call this at the end of each draw cycle.
fn beep(&mut self)
Plays an audible beep if possible, if not the screen is flashed. If neither is available then nothing happens.
fn flash(&mut self)
Flashes the screen if possible, if not an audible beep is played. If neither is available then nothing happens.
fn set_input_mode(&mut self, mode: InputMode)
This controls if get_input
is blocking or not. The default mode is Blocking
.
See also: The notimeout curses function.
fn get_input(&mut self) -> Option<Input>
Gets an Input
from the curses input buffer. Depending on the timeout
setting that y
fn flush_input(&mut self)
Discards all type-ahead that has been input by the user but not yet read by the program.
fn un_get_input(&mut self, input: &Input) -> bool
Pushes an Input
value into the input stack so that it will be returned
by the next call to get_input
. The return value is if the operation
was successful.