[][src]Struct simpleterm::terminal::Terminal

pub struct Terminal {
    pub window: PistonWindow,
    pub bg_color: Color,
    pub fg_color: Color,
    pub scanlines: bool,
    pub font_size: FontSize,
    pub art_font_size: FontSize,
    // some fields omitted
}

A terminal stores a PistonWindow, background and foreground colors, a font, fontsize, and glyph cache, and the current message and input strings.

Fields

window: PistonWindow

The window that displays our terminal.

bg_color: Color

The background color of our terminal.

fg_color: Color

The foreground color of our terminal.

scanlines: bool

Whether or not to use scanlines

font_size: FontSize

The font size of normal text in our terminal.

art_font_size: FontSize

The font size of art in our terminal.

Implementations

impl Terminal[src]

pub fn new(
    title: &str,
    size: (u32, u32),
    bg: Color,
    fg: Color,
    font: &str,
    font_size: u32
) -> Terminal
[src]

Creates a new window with the given title, colors, and font info

let mut term: Terminal = Terminal::new("simpleterm test", (800, 600), DARK_GREY, GOLD, "LeagueSpartan-Regular.ttf", 32);

pub fn ask(&mut self, message: &str) -> Option<String>[src]

Types out the given message, then waits for the user to type something and returns Some(input string). If the window is closed before input can be returned, returns None.

let user_input: String = term.ask("This will wait for the user enter input!").unwrap();

pub fn display_art(&mut self, art: &str, time: Duration)[src]

Displays an ascii art string centered on the terminal. This uses 10pt font and a monospace font.

term.display_art(GEO, Duration::from_secs(2));

pub fn show(&mut self, message: &str, time: Duration)[src]

Types out the given message, then waits for the given amount of time to continue.

term.show("This will wait for 1 second!", Duration::from_secs(1));

pub fn tell(&mut self, message: &str)[src]

Types out the given message, then waits for the user to press Enter to continue.

term.tell("This will wait for the user to hit enter!");

pub fn resize(&mut self, new_size: Size)[src]

Closes the current window and creates a new one with the given (x, y) Size.

term.resize((800, 600).into());

pub fn set_font(&mut self, font: &str, size: FontSize)[src]

Loads a new font from the given font filename and sets the given font size

term.set_font("LeagueSpartan-Regular.ttf", 24);

pub fn set_art_font(&mut self, font: &str, size: FontSize)[src]

Loads a new art font from the given font filename and sets the given font size. You probably want to use a mono-space font here, and a small size.

The default is LeagueMono-Regular.ttf at 10pt.

term.set_art_font("LeagueMono-Regular.ttf", 10);

pub fn set_colors(&mut self, bgc: Color, fgc: Color)[src]

Changes the terminal's background and foreground to the given colors. The change will be apparent in the next text command.

term.set_colors(DARK_GREY, CRIMSON);

Auto Trait Implementations

impl !RefUnwindSafe for Terminal

impl !Send for Terminal

impl !Sync for Terminal

impl Unpin for Terminal

impl !UnwindSafe for Terminal

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.