Commit ca920b49 authored by Moritz Sokoll's avatar Moritz Sokoll 🦀
Browse files

added some linux stuff

parent 1722e1c5
[package]
name = "btui"
version = "0.3.3"
version = "0.4.3"
edition = "2018"
authors = ["Moritz Sokoll <moritz@sokoll.com>"]
license = "MIT"
......@@ -17,4 +17,7 @@ crate-type = ["lib"]
required-features = []
doc = true
[dependencies]
[features]
default = ["core"]
core = []
linux = ["core"]
......@@ -5,5 +5,9 @@
## Usage
Add this to your `Cargo.toml` dependency list:
```toml
btui = "0.3.3"
btui = "0.4.3"
```
## Features
This crate supports some different features:
- `core`: coloring and graphical special effects (like underline)
- `linux`: extensive support for different linux features (like clear a line/the screen)
......@@ -10,6 +10,7 @@ pub mod effects {
Magenta,
Cyan,
White,
RGB(u8, u8, u8),
}
/// enum to represent special printings other than colors
......@@ -51,6 +52,7 @@ pub mod print {
Color::Magenta => String::from("\x1b[35m"),
Color::Cyan => String::from("\x1b[36m"),
Color::White => String::from("\x1b[37m"),
Color::RGB(r, g, b) => format!("\x1b[38;2;{};{};{}m", r, g, b),
}
}
......@@ -78,6 +80,7 @@ pub mod print {
Color::Magenta => String::from("\x1b[45m"),
Color::Cyan => String::from("\x1b[46m"),
Color::White => String::from("\x1b[47m"),
Color::RGB(r, g, b) => format!("\x1b[48;2;{};{};{}m", r, g, b),
}
}
......
......@@ -4,10 +4,13 @@
//! with btui you can create beautiful text user interfaces for the terminal.
//! To get started add `btui` as a dependency to your project:
//! ```toml
//! btui = "0.3.3"
//! btui = "0.4.3"
//! ```
#[cfg(feature = "core")]
mod ft;
#[cfg(feature = "linux")]
pub mod linux;
pub use ft::{effects, print};
#[cfg(test)]
......
/// module containig enums to represent different console actions for linux
pub mod console {
/// enum for display control
pub enum DisplayControl {
Clear,
ClearLine,
Reset,
}
/// enum for cursor control
pub enum CursorControl {
/// move cursor left specified amount of columns
Left(usize),
/// move cursor right specified amount of columns
Right(usize),
/// move cursor to specified column
Col(usize),
/// move cursor specified amount of rows up
Up(usize),
/// move cursor specified amount of rows down
Down(usize),
/// move cursor to position(col, row)
Pos(usize, usize),
}
/// function to perform an action for display controlling (using a `DisplayControl` enum)
/// # Arguments
/// *`sequence`: sequence to perform
/// # Returns
/// Returns a result for wether or not the sequence was executed correctly
pub fn dc_sequence(sequence: DisplayControl) -> std::io::Result<()> {
let seq: String = match sequence {
Clear => String::from("\x1b[2J"),
ClearLine => String::from("\x1b[2K"),
Reset => String::from("\x1bc")
};
print!("{}", seq);
Ok(())
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment