[][src]Struct glerminal::Terminal

pub struct Terminal { /* fields omitted */ }

The Terminal acts as the window and "canvas" of the terminal, handling most behind-the-sceneries

The Terminal is used to create the window and canvas for the TextBuffer which can then draw it, close the window, reset the title of the window or handle events.

Note when building with debug-mode, you are able to press F3 to toggle between debug and non-debug. see (set_debug) for more information.

The terminal can also be created with Default::default (see Default creation example)

Terminal example:

use glerminal::TerminalBuilder;

let terminal = TerminalBuilder::new()
    .with_title("Hello GLerminal!")
    .with_dimensions((1280, 720))
    .build();

let mut terminal vs let terminal

In most cases you might just want to initialize the terminal as immutable, but in some, you will need to initialize it as mutable, allowing it to run some additional methods, such as .show() and .set_title("title")

Example of a mutable terminal:

use glerminal::TerminalBuilder;

let mut terminal = TerminalBuilder::new()
    .with_title("Hello GLerminal!")
    .with_dimensions((1280, 720))
    .with_visibility(false)
    .build();

terminal.set_title("Changed title!");
terminal.show();

Default creation example:

use glerminal::TerminalBuilder;

let mut terminal = TerminalBuilder {
    title: "Hello GLerminal".to_owned(),
    dimensions: (1280, 720),
    visibility: false,
    ..Default::default()
}
.build();

terminal.set_title("Changed title!");
terminal.show();

Methods

impl Terminal
[src]

pub fn set_debug(&self, debug: bool)
[src]

Sets debug mode (changes characters and backgrounds into wireframe)

pub fn refresh(&self) -> bool
[src]

Refreshes the screen and returns whether the while-loop should continue (is the program running)

pub fn flush(&self, text_buffer: &mut TextBuffer)
[src]

Flushes TextBuffer, taking it's character-grid and making it show for the next draw.

This is quite a heavy function and it's calling should be avoided when unnecessary.

pub fn draw(&self, text_buffer: &TextBuffer)
[src]

Draws a TextBuffer. This should be called every frame for each text buffer.

pub fn get_current_events(&self) -> Events
[src]

Gets the current Events, must be retrieved every time you want new events. (ie. every frame)

pub fn close(&self)
[src]

Closes the Terminal

pub fn set_title<T: Into<String>>(&mut self, title: T)
[src]

Sets the title for the window.

Warning: This is a nuclear hazard (takes up a lot of performance), it might melt down your computer if called every frame (or so).

pub fn show(&mut self)
[src]

Shows the window, if it's hidden

pub fn delta_time(&self) -> f32
[src]

Get the delta-time (in seconds).

Auto Trait Implementations

impl !Send for Terminal

impl !Sync for Terminal

Blanket Implementations

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Erased for T

impl<T> Downcast for T where
    T: Any