Module ruscii::terminal

source ·
Expand description

Terminal

The terminal module contains declarations that interact with the terminal. It provides functionality for styling text and other characters as well as implementations for drawing them through a Canvas and Window.

Examples

The majority of applications do not interact with either of the Canvas or the Window directly, but instead draw to the terminal using a Pencil.

An example of direct use of these elements can be seen in window.rs from the examples folder of the ruscii repository:

fn main() {
    let mut window = Window::default();
    window.open();
    println!("This is an open window");
    std::thread::sleep(std::time::Duration::from_secs(2));

    let mut default = VisualElement::default();
    default.background = Color::Red;
    window.canvas_mut().set_default_element(&default);
    window.clear();
    window.draw();
    println!("With a custom background color!");

    std::thread::sleep(std::time::Duration::from_secs(2));
    window.close();
}

Structs

  • An object that holds the data for a grid of VisualElements for a single frame.
  • Represents all the data needed to display a character on the terminal screen with text Style and foreground and background Color.
  • An object that exposes a Canvas and can write the data within it to the standard output.

Enums

  • A set of common colors and a Color::Xterm value that allows you to pass an arbitrary ANSI 8-bit color using its Xterm number (compatible with Windows 10 and most UNIX terminals).
  • The font weight.

Functions

  • Returns the detected size of the terminal.