Verified Commit b4a99ae4 authored by Moritz Sokoll's avatar Moritz Sokoll 🦀
Browse files

added column control to Terminal

parent f5966536
Pipeline #322 passed with stages
in 1 minute and 31 seconds
[package] [package]
name = "btui" name = "btui"
version = "0.6.9" version = "0.6.10"
edition = "2018" edition = "2018"
authors = ["Moritz Sokoll <moritz@sokoll.com>"] authors = ["Moritz Sokoll <moritz@sokoll.com>"]
license = "MIT" license = "MIT"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
## Usage ## Usage
Add this to your `Cargo.toml` dependency list: Add this to your `Cargo.toml` dependency list:
```toml ```toml
btui = "0.6.8" btui = "0.6.10"
``` ```
## Features ## Features
This crate supports some different features: This crate supports some different features:
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
//! with btui you can create beautiful text user interfaces for the terminal. //! with btui you can create beautiful text user interfaces for the terminal.
//! To get started add `btui` as a dependency to your project: //! To get started add `btui` as a dependency to your project:
//! ```toml //! ```toml
//! btui = "0.6.8" //! btui = "0.6.10"
//! ``` //! ```
//! //!
//! # Examples //! # Examples
......
...@@ -198,12 +198,20 @@ impl Terminal { ...@@ -198,12 +198,20 @@ impl Terminal {
/// *`x`: the x position to move to /// *`x`: the x position to move to
/// *`y`: the y position to move to /// *`y`: the y position to move to
pub fn set_cursor(&self, x: usize, y: usize) -> Result<(), Error> { pub fn set_cursor(&self, x: usize, y: usize) -> Result<(), Error> {
match self.print(format!("\x1b[{};{}H", x, y)) { self.print(format!("\x1b[{};{}H", x, y))
Ok(()) => Ok(()), }
Err(e) => Err(e),
} /// set the cursors x position
/// # Arguments
/// *`x`: the x position to move to
pub fn set_cursor_x(&self, x: usize) -> Result<(), Error> {
self.print(format!("\x1b[{}G", x))
} }
// }}}
// display control: {{{
/// clear the current line /// clear the current line
pub fn clear_line(&self) -> Result<(), Error> { pub fn clear_line(&self) -> Result<(), Error> {
self.print("\x1b[2K") self.print("\x1b[2K")
...@@ -220,6 +228,7 @@ impl Terminal { ...@@ -220,6 +228,7 @@ impl Terminal {
} }
// }}} // }}}
} }
impl Default for Terminal { impl Default for Terminal {
......
Supports Markdown
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