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

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]

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.

On Win32 systems this allows you to set the title of the PDcurses window. On other systems this does nothing at all.

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

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.

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.

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.

Checks if the current terminal supports the use of colors.

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.

Enables or disables bold text for all future input.

Enables or disables unerlined text for all future input.

Returns the number of rows and columns available in the window.

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.

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.

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.

Sets the top and bottom margins of the scrolling region.

Prints the given string into the window.

Prints the given character into the window.

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.

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.

Clears the entire screen.

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.

Plays an audible beep if possible, if not the screen is flashed. If neither is available then nothing happens.

Flashes the screen if possible, if not an audible beep is played. If neither is available then nothing happens.

This controls if get_input is blocking or not. The default mode is Blocking.

See also: The notimeout curses function.

Gets an Input from the curses input buffer. Depending on the timeout setting that y

Discards all type-ahead that has been input by the user but not yet read by the program.

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.

Trait Implementations

impl Debug for EasyCurses
[src]

Formats the value using the given formatter.

impl Drop for EasyCurses
[src]

Dropping EasyCurses causes the endwin curses function to be called.