[][src]Struct utile_cli::cli::Terminal

pub struct Terminal { /* fields omitted */ }

A terminal containing a pancurses window.

Contains multiple abstractions over pancurses.

Examples

Creating a terminal:

let t = Terminal::new()

Methods

impl Terminal[src]

pub fn new() -> Terminal[src]

Creates a new terminal

pub fn add_layer(&mut self, layer: Layer) -> &mut Layer[src]

pub fn add_layer2d(&mut self, layer: Layer2D) -> &mut Layer2D[src]

pub fn refresh(&self)[src]

Refreshes and re-draws all layers.

pub fn layer_front(&mut self) -> &mut Layer2D[src]

Returns the layer at the front.

pub fn layer_back(&mut self) -> &mut Layer2D[src]

Returns the layer at the back.

pub fn layer_swap(&mut self, a: i32, b: i32)[src]

Swaps two layers. Check the layer_locate documentation about the number parameters.

pub fn layer_locate(&mut self, l: i32) -> &mut Layer2D[src]

Locates a layer by the distance to the stack or by the last item -

A negative number such as -1 returns the layer after the top layer, A positive number such as 1 returns the second to last layer, A zero returns the top layer.

Examples:

Imagine a stack:

[ L1 ] <- `layer_locate(0)` or `layer_front()`
[ L2 ] <- `layer_locate(-1)`
[ L3 ] <- `layer_locate(1)` or `layer_locate(-2)`
[ L4 ] <- `layer_back()`

pub fn draw_layer(&self, layer: &Layer)[src]

Draws a layer to the console.

pub fn draw_layer_static(&self, layer: &Layer)[src]

Draws a layer to the console however does not affect the cursor.

pub fn draw_layer2d(&self, layer: &Layer2D)[src]

Draws a layer2D to the console.

pub fn draw_layer2d_static(&self, layer: &Layer)[src]

Draws a layer2D to the console however does not affect the cursor.

pub fn out(&self, s: String)[src]

Outputs a string over the cursor.

pub fn out_static(&self, s: String)[src]

Outputs a string that does not affect the cursor position.

pub fn outln(&self, s: String)[src]

Outputs a string over the cursor and outputs a break / newline.

pub fn outbr(&self)[src]

Outputs a newline.

pub fn raw_out(&self, s: String)[src]

Outputs a string without refreshing the terminal.

pub fn raw_out_static(&self, s: String)[src]

Outputs a string that does not affect the cursor position and does not refresh the terminal.

pub fn raw_outln(&self, s: String)[src]

Outputs a string and a break / newline without refreshing the terminal.

pub fn raw_br(&self)[src]

Outputs a newline without refreshing the terminal.

pub fn raw_posxy(&self) -> (i32, i32)[src]

Returns a tuple containing the current cursor position in the form (x, y)

pub fn raw_posx(&self) -> i32[src]

Returns the x position of the current cursor position.

pub fn raw_posy(&self) -> i32[src]

Returns the y position of the current cursor position.

pub fn raw_move(&self, x: i32, y: i32)[src]

Moves the cursor to position x and y.

pub fn raw_move_offset(&self, xoffs: i32, yoffs: i32)[src]

Offsets the cursor by x and y.

pub fn raw_move_first(&self)[src]

Moves the cursor to the start of the line.

pub fn raw_move_prev(&self)[src]

Moves one position back (x - 1).

pub fn raw_move_next(&self)[src]

Moves one position forwards (x + 1).

pub fn raw_delete(&self)[src]

Deletes the character that the current cursor is on.

pub fn raw_delete_prev(&self)[src]

Deletes the last character (not letter).

pub fn raw_delete_offset(&self, xoffs: i32)[src]

Deletes all the characters from the cursor until the current position is offset position.

Examples

t.out("Hello world!".into());
t.raw_delete_offset(-6);

Output: Hello

pub fn raw_delete_from(&self, chars: usize)[src]

Deletes, from the start of the line, all the characters until chars position.

Examples

t.out("Hello world!".into());
t.raw_delete_from(5);

Output: world!

pub fn raw_delete_to(&self, x: i32)[src]

Deletes all characters from the cursor until the x position is x

Examples

t.out("Hello world!".into());
t.raw_delete_to(5);

Output: Hello

pub fn get_char(&self) -> Option<Key>[src]

Gets a character from input.

pub fn get_char_hidden(&self) -> Option<Key>[src]

Returns a character however hides it from input.

pub fn ask(&self, prefix: String) -> String[src]

Asks the user for input, prefixing the question with prefix

Examples

t.ask("> ".into())

pub fn mask(&self, prefix: String, mask: char) -> String[src]

Asks the user for input, however the input is masked by a series of mask to hide the input.

pub fn yesno(&self, suffix: String, default: bool) -> bool[src]

Asks a y/n question to the user, returning a boolean (true if yes).

The suffix parameter must be specified like "exampley/examplen" (must contain a '/') The default parameter is the default highlighted y/n

You can choose a yes or a no using the left and right arrow keys.

Examples

t.yesno("y/n".into(), true)

Outputs: (Y/n)

pub fn choices(&self, prefix: String, strs: Vec<String>) -> String[src]

Gives the user choices between strings. Takes in a prefix to be added as a prefix on the current choice, and vector strs as the choices. The result output is a list in which options can be highlighted by using the arrow keys.

Examples

let x = t.choices("-> ".into(), vec!["c1".into(), "c22".into(), "c333".into(), "c4444".into()]);
t.outln(x);

Output if selected was c2: c2

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, 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.