2018-07-30 05:30:09 +10:00
|
|
|
//! Module that contains all the actions related to the terminal. like clearing, resizing and scrolling the terminal.
|
2018-06-10 05:59:43 +10:00
|
|
|
|
|
|
|
pub mod terminal;
|
2018-01-18 09:06:45 +11:00
|
|
|
|
2018-07-31 05:35:35 +10:00
|
|
|
mod ansi_terminal;
|
2018-03-04 03:07:51 +11:00
|
|
|
#[cfg(target_os = "windows")]
|
2018-01-18 09:06:45 +11:00
|
|
|
mod winapi_terminal;
|
|
|
|
|
2018-07-31 05:35:35 +10:00
|
|
|
use self::ansi_terminal::AnsiTerminal;
|
2018-06-17 04:10:51 +10:00
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
use self::winapi_terminal::WinApiTerminal;
|
|
|
|
|
2018-08-12 01:58:15 +10:00
|
|
|
pub use self::terminal::{terminal, Terminal};
|
2018-08-20 07:14:45 +10:00
|
|
|
|
2018-08-12 01:58:15 +10:00
|
|
|
use std::sync::Arc;
|
2018-08-20 07:14:45 +10:00
|
|
|
use super::functions;
|
|
|
|
use {Screen, TerminalOutput};
|
2018-06-17 04:10:51 +10:00
|
|
|
|
2018-07-30 05:30:09 +10:00
|
|
|
/// Enum that specifies a way of clearing.
|
2018-03-06 08:06:43 +11:00
|
|
|
pub enum ClearType {
|
|
|
|
All,
|
|
|
|
FromCursorDown,
|
|
|
|
FromCursorUp,
|
|
|
|
CurrentLine,
|
|
|
|
UntilNewLine,
|
|
|
|
}
|
|
|
|
|
2018-07-30 05:30:09 +10:00
|
|
|
/// This trait defines the actions that can be preformed with the terminal color.
|
|
|
|
/// This trait can be implemented so that an concrete implementation of the ITerminalColor can forfill
|
|
|
|
/// the wishes to work on an specific platform.
|
|
|
|
///
|
|
|
|
/// ## For example:
|
|
|
|
///
|
|
|
|
/// This trait is implemented for `WINAPI` (Windows specific) and `ANSI` (Unix specific),
|
|
|
|
/// so that color related actions can be preformed on both unix and windows systems.
|
2018-08-15 07:02:25 +10:00
|
|
|
trait ITerminal {
|
2018-03-06 08:06:43 +11:00
|
|
|
/// Clear the current cursor by specifying the clear type
|
2018-08-20 07:14:45 +10:00
|
|
|
fn clear(&self, clear_type: ClearType, stdout: &Arc<TerminalOutput>);
|
2018-03-06 08:06:43 +11:00
|
|
|
/// Get the terminal size (x,y)
|
2018-08-20 07:14:45 +10:00
|
|
|
fn terminal_size(&self, stdout: &Arc<TerminalOutput>) -> (u16, u16);
|
2018-03-06 08:06:43 +11:00
|
|
|
/// Scroll `n` lines up in the current terminal.
|
2018-08-20 07:14:45 +10:00
|
|
|
fn scroll_up(&self, count: i16, stdout: &Arc<TerminalOutput>);
|
2018-03-06 08:06:43 +11:00
|
|
|
/// Scroll `n` lines down in the current terminal.
|
2018-08-20 07:14:45 +10:00
|
|
|
fn scroll_down(&self, count: i16, stdout: &Arc<TerminalOutput>);
|
2018-03-06 08:06:43 +11:00
|
|
|
/// Resize terminal to the given width and height.
|
2018-08-20 07:14:45 +10:00
|
|
|
fn set_size(&self, width: i16, height: i16, stdout: &Arc<TerminalOutput>);
|
2018-06-27 04:21:47 +10:00
|
|
|
/// Close the current terminal
|
2018-08-20 07:14:45 +10:00
|
|
|
fn exit(&self,stdout: &Arc<TerminalOutput>);
|
2018-03-06 08:06:43 +11:00
|
|
|
}
|