fixed wrong version nummber and crucial bug
This commit is contained in:
parent
336ecfe804
commit
f70baa5987
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "crossterm"
|
name = "crossterm"
|
||||||
version = "0.5.2"
|
version = "0.5.3"
|
||||||
authors = ["T. Post"]
|
authors = ["T. Post"]
|
||||||
description = "An crossplatform terminal library for manipulating terminals."
|
description = "An crossplatform terminal library for manipulating terminals."
|
||||||
repository = "https://github.com/TimonPost/crossterm"
|
repository = "https://github.com/TimonPost/crossterm"
|
||||||
|
17
README.md
17
README.md
@ -10,9 +10,6 @@
|
|||||||
[s3]: https://docs.rs/crossterm/badge.svg
|
[s3]: https://docs.rs/crossterm/badge.svg
|
||||||
[l3]: https://docs.rs/crossterm/
|
[l3]: https://docs.rs/crossterm/
|
||||||
|
|
||||||
[s3]: https://docs.rs/crossterm/badge.svg
|
|
||||||
[l3]: https://docs.rs/crossterm/
|
|
||||||
|
|
||||||
[s6]: https://tokei.rs/b1/github/TimonPost/crossterm?category=code
|
[s6]: https://tokei.rs/b1/github/TimonPost/crossterm?category=code
|
||||||
[s7]: https://travis-ci.org/TimonPost/crossterm.svg?branch=master
|
[s7]: https://travis-ci.org/TimonPost/crossterm.svg?branch=master
|
||||||
|
|
||||||
@ -49,7 +46,7 @@ Add the Crossterm package to your `Cargo.toml` file.
|
|||||||
|
|
||||||
```
|
```
|
||||||
[dependencies]
|
[dependencies]
|
||||||
crossterm = "0.5.2"
|
crossterm = "0.5.3"
|
||||||
|
|
||||||
```
|
```
|
||||||
And import the Crossterm modules you want to use.
|
And import the Crossterm modules you want to use.
|
||||||
@ -139,7 +136,7 @@ use crossterm::style::{Color, style};
|
|||||||
let style1 = style("Some Blue font on Black background").with(Color::Blue).on(Color::Black);
|
let style1 = style("Some Blue font on Black background").with(Color::Blue).on(Color::Black);
|
||||||
let style2 = style("Some Red font on Yellow background").with(Color::Red).on(Color::Yellow);
|
let style2 = style("Some Red font on Yellow background").with(Color::Red).on(Color::Yellow);
|
||||||
|
|
||||||
// syling font with (Windows 10 and UNIX systems)
|
// styling font with (Windows 10 and UNIX systems)
|
||||||
let normal = style("Normal text");
|
let normal = style("Normal text");
|
||||||
let bold = style("Bold text").bold();
|
let bold = style("Bold text").bold();
|
||||||
let italic = style("Italic text").italic();
|
let italic = style("Italic text").italic();
|
||||||
@ -158,7 +155,7 @@ println!("{}", bold);
|
|||||||
println!("{}", hidden);
|
println!("{}", hidden);
|
||||||
...
|
...
|
||||||
|
|
||||||
// cursom rgb value (Windows 10 and UNIX systems)
|
// custom rgb value (Windows 10 and UNIX systems)
|
||||||
style("RGB color (10,10,10) ").with(Color::Rgb {
|
style("RGB color (10,10,10) ").with(Color::Rgb {
|
||||||
r: 10,
|
r: 10,
|
||||||
g: 10,
|
g: 10,
|
||||||
@ -286,17 +283,17 @@ This crate supports all Unix terminals and windows terminals down to Windows 7 b
|
|||||||
If you have used this library for a terminal other than the above list without issues feel free to add it to the above list, I really would appreciate it.
|
If you have used this library for a terminal other than the above list without issues feel free to add it to the above list, I really would appreciate it.
|
||||||
|
|
||||||
## Notice
|
## Notice
|
||||||
This library is average stable now but I don't expect it to not to change that much.
|
This library is quite stable now, changes could be expected but they will probably be not that big.
|
||||||
If there are any changes that will affect previous versions I will [describe](https://github.com/TimonPost/crossterm/blob/master/docs/UpgradeManual.md) what to change to upgrade.
|
If there are any changes that will affect previous versions I will [describe](https://github.com/TimonPost/crossterm/blob/master/docs/UpgradeManual.md) what to change to upgrade.
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
I still have some things in mind to implement.
|
I still have some things in mind to implement.
|
||||||
|
|
||||||
- Handling mouse events
|
- Handling mouse events:
|
||||||
I want to be able to do something based on the clicks the user has done with its mouse.
|
I want to be able to do something based on the clicks the user has done with its mouse.
|
||||||
- Handling key events
|
- Handling key events:
|
||||||
I want to be able to read key combination inputs.
|
I want to be able to read key combination inputs.
|
||||||
- Tests
|
- Tests:
|
||||||
Find a way to test: color, alternate screen, rawscreen
|
Find a way to test: color, alternate screen, rawscreen
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
@ -14,6 +14,7 @@ fn main() {
|
|||||||
let screen = Screen::new(true);
|
let screen = Screen::new(true);
|
||||||
let crossterm = Crossterm::from_screen(&screen);
|
let crossterm = Crossterm::from_screen(&screen);
|
||||||
let cursor = crossterm.cursor();
|
let cursor = crossterm.cursor();
|
||||||
|
|
||||||
cursor.hide();
|
cursor.hide();
|
||||||
|
|
||||||
let input_buf = Arc::new(Mutex::new(String::new()));
|
let input_buf = Arc::new(Mutex::new(String::new()));
|
||||||
@ -62,7 +63,6 @@ fn log(input_buf: Arc<Mutex<String>>, screen: &Screen) -> Vec<thread::JoinHandle
|
|||||||
let _clone_stdout = screen.stdout.clone();
|
let _clone_stdout = screen.stdout.clone();
|
||||||
|
|
||||||
let crossterm = Crossterm::from(screen.stdout.clone());
|
let crossterm = Crossterm::from(screen.stdout.clone());
|
||||||
|
|
||||||
let join = thread::spawn(move || {
|
let join = thread::spawn(move || {
|
||||||
let cursor = crossterm.cursor();
|
let cursor = crossterm.cursor();
|
||||||
let terminal = crossterm.terminal();
|
let terminal = crossterm.terminal();
|
||||||
|
@ -41,7 +41,7 @@ impl Map
|
|||||||
if (y == 0 || y == self.size.height - 1) || (x == 0 || x == self.size.width - 1)
|
if (y == 0 || y == self.size.height - 1) || (x == 0 || x == self.size.width - 1)
|
||||||
{
|
{
|
||||||
cursor.goto(x as u16, y as u16);
|
cursor.goto(x as u16, y as u16);
|
||||||
terminal.write("█")
|
terminal.write("█");
|
||||||
}else {
|
}else {
|
||||||
free_positions.insert(format!("{},{}",x,y), Position::new(x,y));
|
free_positions.insert(format!("{},{}",x,y), Position::new(x,y));
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ pub fn exit_terminal() {
|
|||||||
/// If the current platform is unix it will return the ansi implementation.
|
/// If the current platform is unix it will return the ansi implementation.
|
||||||
pub fn get_module<T>(winapi_impl: T, unix_impl: T) -> Option<T> {
|
pub fn get_module<T>(winapi_impl: T, unix_impl: T) -> Option<T> {
|
||||||
let mut term: Option<T> = None;
|
let mut term: Option<T> = None;
|
||||||
let mut does_support = false;
|
let mut does_support = true;
|
||||||
|
|
||||||
if !windows_supportable() {
|
if !windows_supportable() {
|
||||||
// Try to enable ansi on windows if not than use WINAPI.
|
// Try to enable ansi on windows if not than use WINAPI.
|
||||||
|
611
src/lib.rs
611
src/lib.rs
@ -1,301 +1,316 @@
|
|||||||
//! Ever got disappointed when a terminal library for rust was only written for UNIX systems?
|
/// # Crossterm | cross-platform terminal manipulating library.
|
||||||
//! Crossterm provides the same core functionalities for both Windows and UNIX systems.
|
/// ![Lines of Code][s7] [![Latest Version][s1]][l1] [![MIT][s2]][l2] [![docs][s3]][l3] ![Lines of Code][s6]
|
||||||
//!
|
///
|
||||||
//! Crossterm aims to be simple and easy to call in code.
|
/// [s1]: https://img.shields.io/crates/v/crossterm.svg
|
||||||
//! Through the simplicity of Crossterm, you do not have to worry about the platform you are working with.
|
/// [l1]: https://crates.io/crates/crossterm
|
||||||
//!
|
///
|
||||||
//! This crate supports all UNIX and windows terminals down to windows 7 (not all terminals are tested see [Tested Terminals](#tested-terminals) for more info)
|
/// [s2]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||||
//!
|
/// [l2]: ./LICENSE
|
||||||
//! ## Table of contents:
|
///
|
||||||
//! - [Getting started](#getting-started)
|
/// [s3]: https://docs.rs/crossterm/badge.svg
|
||||||
//! - [Useful links](#useful-links)
|
/// [l3]: https://docs.rs/crossterm/
|
||||||
//! - [Features](#features)
|
///
|
||||||
//! - [Examples](#examples)
|
/// [s6]: https://tokei.rs/b1/github/TimonPost/crossterm?category=code
|
||||||
//! - [Crossterm Wrapper](#crossterm-type--see-more)
|
/// [s7]: https://travis-ci.org/TimonPost/crossterm.svg?branch=master
|
||||||
//! - [Styling](#crossterm-type--see-more)
|
///
|
||||||
//! - [Cursor](#cursor--see-more)
|
/// Ever got disappointed when a terminal library for rust was only written for UNIX systems?
|
||||||
//! - [Input](#input--see-more)
|
/// Crossterm provides the same core functionalities for both Windows and UNIX systems.
|
||||||
//! - [Terminal](#terminal--see-more)
|
///
|
||||||
//! - [Tested Terminals](#tested-terminals)
|
/// Crossterm aims to be simple and easy to call in code.
|
||||||
//! - [Notice](#notice)
|
/// Through the simplicity of Crossterm, you do not have to worry about the platform you are working with.
|
||||||
//! - [Todo](#todo)
|
///
|
||||||
//! - [Contributing](#contributing)
|
/// This crate supports all UNIX and windows terminals down to windows 7 (not all terminals are tested see [Tested Terminals](#tested-terminals) for more info)
|
||||||
//! - [Authors](#authors)
|
///
|
||||||
//! - [License](#license)
|
/// ## Table of contents:
|
||||||
//!
|
/// - [Getting started](#getting-started)
|
||||||
//! ## Getting Started
|
/// - [Useful links](#useful-links)
|
||||||
//!
|
/// - [Features](#features)
|
||||||
//! This documentation is only for Crossterm version `0.5` if you have an older version of Crossterm I suggest you check the [Upgrade Manual](https://github.com/TimonPost/crossterm/blob/master/docs/UpgradeManual.md). Also, check out the [examples](https://github.com/TimonPost/crossterm/tree/master/examples) folders with detailed examples for all functionality of this crate.
|
/// - [Examples](#examples)
|
||||||
//!
|
/// - [Crossterm Wrapper](#crossterm-type--see-more)
|
||||||
//! Add the Crossterm package to your `Cargo.toml` file.
|
/// - [Styling](#crossterm-type--see-more)
|
||||||
//!
|
/// - [Cursor](#cursor--see-more)
|
||||||
//! ```
|
/// - [Input](#input--see-more)
|
||||||
//! [dependencies]
|
/// - [Terminal](#terminal--see-more)
|
||||||
//! crossterm = "0.5.2"
|
/// - [Tested Terminals](#tested-terminals)
|
||||||
//!
|
/// - [Notice](#notice)
|
||||||
//! ```
|
/// - [Todo](#todo)
|
||||||
//! And import the Crossterm modules you want to use.
|
/// - [Contributing](#contributing)
|
||||||
//!
|
/// - [Authors](#authors)
|
||||||
//! ```rust
|
/// - [License](#license)
|
||||||
//! extern crate crossterm;
|
///
|
||||||
//!
|
/// ## Getting Started
|
||||||
//! // this module is used for styling the terminal
|
///
|
||||||
//! use crossterm::style::*;
|
/// This documentation is only for Crossterm version `0.5.^` if you have an older version of Crossterm I suggest you check the [Upgrade Manual](https://github.com/TimonPost/crossterm/blob/master/docs/UpgradeManual.md). Also, check out the [examples](https://github.com/TimonPost/crossterm/tree/master/examples) folders with detailed examples for all functionality of this crate.
|
||||||
//! // this module is used for cursor related actions
|
///
|
||||||
//! use crossterm::cursor::*;
|
/// Add the Crossterm package to your `Cargo.toml` file.
|
||||||
//! // this module is used for terminal related actions
|
///
|
||||||
//! use crossterm::terminal::*;
|
/// ```
|
||||||
//! // this module is used for input related actions
|
/// [dependencies]
|
||||||
//! use crossterm::input::*;
|
/// crossterm = "0.5.3"
|
||||||
//!
|
///
|
||||||
//! ```
|
/// ```
|
||||||
//!
|
/// And import the Crossterm modules you want to use.
|
||||||
//! ### Useful Links
|
///
|
||||||
//!
|
/// ```rust
|
||||||
//! - [Book](http://atcentra.com/crossterm/)
|
/// extern crate crossterm;
|
||||||
//! - [Documentation](https://docs.rs/crossterm/)
|
///
|
||||||
//! - [Crates.io](https://crates.io/crates/crossterm)
|
/// // this module is used for styling the terminal
|
||||||
//! - [Program Examples](https://github.com/TimonPost/crossterm/tree/master/examples/program_examples)
|
/// use crossterm::style::*;
|
||||||
//! - [Examples](https://github.com/TimonPost/crossterm/tree/master/examples)
|
/// // this module is used for cursor related actions
|
||||||
//!
|
/// use crossterm::cursor::*;
|
||||||
//! ## Features
|
/// // this module is used for terminal related actions
|
||||||
//! These are the features from this crate:
|
/// use crossterm::terminal::*;
|
||||||
//!
|
/// // this module is used for input related actions
|
||||||
//! - Cross-platform
|
/// use crossterm::input::*;
|
||||||
//! - Everything is multithreaded (Send, Sync)
|
///
|
||||||
//! - Detailed documentation on every item
|
/// ```
|
||||||
//! - Very few dependenties.
|
///
|
||||||
//! - Cursor.
|
/// ### Useful Links
|
||||||
//! - Moving _n_ times Up, Down, Left, Right
|
///
|
||||||
//! - Goto a certain position
|
/// - [Book](http://atcentra.com/crossterm/)
|
||||||
//! - Get cursor position
|
/// - [Documentation](https://docs.rs/crossterm/)
|
||||||
//! - Storing the current cursor position and resetting to that stored cursor position later
|
/// - [Crates.io](https://crates.io/crates/crossterm)
|
||||||
//! - Hiding an showing the cursor
|
/// - [Program Examples](https://github.com/TimonPost/crossterm/tree/master/examples/program_examples)
|
||||||
//! - Control over blinking of the terminal cursor (only some terminals are supporting this)
|
/// - [Examples](https://github.com/TimonPost/crossterm/tree/master/examples)
|
||||||
//! - Styled output
|
///
|
||||||
//! - Foreground color (16 base colors)
|
/// ## Features
|
||||||
//! - Background color (16 base colors)
|
/// These are the features from this crate:
|
||||||
//! - 256 color support (Windows 10 and UNIX only)
|
///
|
||||||
//! - RGB support (Windows 10 and UNIX only)
|
/// - Cross-platform
|
||||||
//! - Text Attributes like: bold, italic, underscore and crossed word ect (unix only)
|
/// - Everything is multithreaded (Send, Sync)
|
||||||
//! - Terminal
|
/// - Detailed documentation on every item
|
||||||
//! - Clearing (all lines, current line, from cursor down and up, until new line)
|
/// - Very few dependenties.
|
||||||
//! - Scrolling (Up, down)
|
/// - Cursor.
|
||||||
//! - Get the size of the terminal
|
/// - Moving _n_ times Up, Down, Left, Right
|
||||||
//! - Set the size of the terminal
|
/// - Goto a certain position
|
||||||
//! - Alternate screen
|
/// - Get cursor position
|
||||||
//! - Raw screen
|
/// - Storing the current cursor position and resetting to that stored cursor position later
|
||||||
//! - Exit the current process
|
/// - Hiding an showing the cursor
|
||||||
//! - Input
|
/// - Control over blinking of the terminal cursor (only some terminals are supporting this)
|
||||||
//! - Read character
|
/// - Styled output
|
||||||
//! - Read line
|
/// - Foreground color (16 base colors)
|
||||||
//! - Read async
|
/// - Background color (16 base colors)
|
||||||
//! - Read async until
|
/// - 256 color support (Windows 10 and UNIX only)
|
||||||
//! - Wait for key event (terminal pause)
|
/// - RGB support (Windows 10 and UNIX only)
|
||||||
//!
|
/// - Text Attributes like: bold, italic, underscore and crossed word ect (Windows 10 and UNIX only)
|
||||||
//! ## Examples
|
/// - Terminal
|
||||||
//! These are some basic examples demonstrating how to use this crate. See [examples](https://github.com/TimonPost/crossterm/blob/master/examples/) for more.
|
/// - Clearing (all lines, current line, from cursor down and up, until new line)
|
||||||
//!
|
/// - Scrolling (Up, down)
|
||||||
//! ### Crossterm Type | [see more](https://github.com/TimonPost/crossterm/blob/master/examples/some_types/mod.rs)
|
/// - Get the size of the terminal
|
||||||
//! This is a wrapper for all the modules crossterm provides like terminal, cursor, styling and input.
|
/// - Set the size of the terminal
|
||||||
//!
|
/// - Alternate screen
|
||||||
//! ```rust
|
/// - Raw screen
|
||||||
//! // screen wheron the `Crossterm` methods will be executed.
|
/// - Exit the current process
|
||||||
//! let crossterm = Crossterm::new();
|
/// - Input
|
||||||
//!
|
/// - Read character
|
||||||
//! // get instance of the modules, whereafter you can use the methods the particulary module provides.
|
/// - Read line
|
||||||
//! let color = crossterm.color();
|
/// - Read async
|
||||||
//! let cursor = crossterm.cursor();
|
/// - Read async until
|
||||||
//! let terminal = crossterm.terminal();
|
/// - Wait for key event (terminal pause)
|
||||||
//!
|
///
|
||||||
//! // styling
|
/// ## Examples
|
||||||
//! println!("{}", crossterm.style("Black font on Green background color").with(Color::Black).on(Color::Green));
|
/// These are some basic examples demonstrating how to use this crate. See [examples](https://github.com/TimonPost/crossterm/blob/master/examples/) for more.
|
||||||
//!
|
///
|
||||||
//! ```
|
/// ### Crossterm Type | [see more](https://github.com/TimonPost/crossterm/blob/master/examples/some_types/mod.rs)
|
||||||
//! ### Styled Font | [see more](http://atcentra.com/crossterm/styling.html)
|
/// This is a wrapper for all the modules crossterm provides like terminal, cursor, styling and input.
|
||||||
//! This module provides the functionalities to style the terminal.
|
///
|
||||||
//! ```rust
|
/// ```rust
|
||||||
//! use crossterm::style::{Color, style};
|
/// // screen wheron the `Crossterm` methods will be executed.
|
||||||
//!
|
/// let crossterm = Crossterm::new();
|
||||||
//! // store objcets so it could be painted later to the screen.
|
///
|
||||||
//! let style1 = style("Some Blue font on Black background").with(Color::Blue).on(Color::Black);
|
/// // get instance of the modules, whereafter you can use the methods the particulary module provides.
|
||||||
//! let style2 = style("Some Red font on Yellow background").with(Color::Red).on(Color::Yellow);
|
/// let color = crossterm.color();
|
||||||
//!
|
/// let cursor = crossterm.cursor();
|
||||||
//! // attributes are only supported for UNIX terminals.
|
/// let terminal = crossterm.terminal();
|
||||||
//! let normal = style("Normal text");
|
///
|
||||||
//! let bold = style("Bold text").bold();
|
/// // styling
|
||||||
//! let italic = style("Italic text").italic();
|
/// println!("{}", crossterm.style("Black font on Green background color").with(Color::Black).on(Color::Green));
|
||||||
//! let slow_blink = style("Slow blinking text").slow_blink();
|
///
|
||||||
//! let rapid_blink = style("Rapid blinking text").rapid_blink();
|
/// ```
|
||||||
//! let hidden = style("Hidden text").hidden();
|
/// ### Styled Font | [see more](http://atcentra.com/crossterm/styling.html)
|
||||||
//! let underlined = style("Underlined text").underlined();
|
/// This module provides the functionalities to style the terminal.
|
||||||
//! let reversed = style("Reversed text").reverse();
|
/// ```rust
|
||||||
//! let dimmed = style("Dim text").dim();
|
/// use crossterm::style::{Color, style};
|
||||||
//! let crossed_out = style("Crossed out font").crossed_out();
|
///
|
||||||
//!
|
/// // store objcets so it could be painted later to the screen.
|
||||||
//! // paint styled text to screen (this could also be called inline)
|
/// let style1 = style("Some Blue font on Black background").with(Color::Blue).on(Color::Black);
|
||||||
//! println!("{}", style1);
|
/// let style2 = style("Some Red font on Yellow background").with(Color::Red).on(Color::Yellow);
|
||||||
//! println!("{}", style2);
|
///
|
||||||
//! println!("{}", bold);
|
/// // styling font with (Windows 10 and UNIX systems)
|
||||||
//! println!("{}", hidden);
|
/// let normal = style("Normal text");
|
||||||
//! ...
|
/// let bold = style("Bold text").bold();
|
||||||
//!
|
/// let italic = style("Italic text").italic();
|
||||||
//! // cursom rgb value
|
/// let slow_blink = style("Slow blinking text").slow_blink();
|
||||||
//! style("RGB color (10,10,10) ").with(Color::Rgb {
|
/// let rapid_blink = style("Rapid blinking text").rapid_blink();
|
||||||
//! r: 10,
|
/// let hidden = style("Hidden text").hidden();
|
||||||
//! g: 10,
|
/// let underlined = style("Underlined text").underlined();
|
||||||
//! b: 10
|
/// let reversed = style("Reversed text").reverse();
|
||||||
//! }));
|
/// let dimmed = style("Dim text").dim();
|
||||||
//!
|
/// let crossed_out = style("Crossed out font").crossed_out();
|
||||||
//! // custom ansi color value
|
///
|
||||||
//! style("ANSI color value (50) ").with(Color::AnsiValue(50));
|
/// // paint styled text to screen (this could also be called inline)
|
||||||
//!
|
/// println!("{}", style1);
|
||||||
//! ```
|
/// println!("{}", style2);
|
||||||
//! ### Cursor | [see more](https://github.com/TimonPost/crossterm/blob/master/examples/cursor/mod.rs)
|
/// println!("{}", bold);
|
||||||
//! This module provides the functionalities to work with the terminal cursor.
|
/// println!("{}", hidden);
|
||||||
//!
|
/// ...
|
||||||
//! ```rust
|
///
|
||||||
//! use crossterm::cursor;
|
/// // custom rgb value (Windows 10 and UNIX systems)
|
||||||
//!
|
/// style("RGB color (10,10,10) ").with(Color::Rgb {
|
||||||
//! let mut cursor = cursor();
|
/// r: 10,
|
||||||
//!
|
/// g: 10,
|
||||||
//! /// Moving the cursor
|
/// b: 10
|
||||||
//! // Set the cursor to position X: 10, Y: 5 in the terminal
|
/// }));
|
||||||
//! cursor.goto(10,5);
|
///
|
||||||
//!
|
/// // custom ansi color value (Windows 10 and UNIX systems)
|
||||||
//! // Move the cursor up,right,down,left 3 cells.
|
/// style("ANSI color value (50) ").with(Color::AnsiValue(50));
|
||||||
//! cursor.move_up(3);
|
///
|
||||||
//! cursor.move_right(3);
|
/// ```
|
||||||
//! cursor.move_down(3);
|
/// ### Cursor | [see more](https://github.com/TimonPost/crossterm/blob/master/examples/cursor/mod.rs)
|
||||||
//! cursor.move_left(3);
|
/// This module provides the functionalities to work with the terminal cursor.
|
||||||
//!
|
///
|
||||||
//! /// Safe the current cursor position to recall later
|
/// ```rust
|
||||||
//! // Goto X: 5 Y: 5
|
/// use crossterm::cursor;
|
||||||
//! cursor.goto(5,5);
|
///
|
||||||
//! // Safe cursor position: X: 5 Y: 5
|
/// let mut cursor = cursor();
|
||||||
//! cursor.save_position();
|
///
|
||||||
//! // Goto X: 5 Y: 20
|
/// /// Moving the cursor
|
||||||
//! cursor.goto(5,20);
|
/// // Set the cursor to position X: 10, Y: 5 in the terminal
|
||||||
//! // Print at X: 5 Y: 20.
|
/// cursor.goto(10,5);
|
||||||
//! print!("Yea!");
|
///
|
||||||
//! // Reset back to X: 5 Y: 5.
|
/// // Move the cursor up,right,down,left 3 cells.
|
||||||
//! cursor.reset_position();
|
/// cursor.move_up(3);
|
||||||
//! // Print 'Back' at X: 5 Y: 5.
|
/// cursor.move_right(3);
|
||||||
//! print!("Back");
|
/// cursor.move_down(3);
|
||||||
//!
|
/// cursor.move_left(3);
|
||||||
//! // hide cursor
|
///
|
||||||
//! cursor.hide();
|
/// /// Safe the current cursor position to recall later
|
||||||
//! // show cursor
|
/// // Goto X: 5 Y: 5
|
||||||
//! cursor.show();
|
/// cursor.goto(5,5);
|
||||||
//! // blink or not blinking of the cursor (not widely supported)
|
/// // Safe cursor position: X: 5 Y: 5
|
||||||
//! cursor.blink(true)
|
/// cursor.save_position();
|
||||||
//!
|
/// // Goto X: 5 Y: 20
|
||||||
//! ```
|
/// cursor.goto(5,20);
|
||||||
//!
|
/// // Print at X: 5 Y: 20.
|
||||||
//! ### Input | [see more](http://atcentra.com/crossterm/input.html)
|
/// print!("Yea!");
|
||||||
//! This module provides the functionalities to work with terminal input.
|
/// // Reset back to X: 5 Y: 5.
|
||||||
//!
|
/// cursor.reset_position();
|
||||||
//! ```rust
|
/// // Print 'Back' at X: 5 Y: 5.
|
||||||
//! use crossterm::input;
|
/// print!("Back");
|
||||||
//!
|
///
|
||||||
//! let mut input = input();
|
/// // hide cursor
|
||||||
//!
|
/// cursor.hide();
|
||||||
//! match input.read_char() {
|
/// // show cursor
|
||||||
//! Ok(s) => println!("char typed: {}", s),
|
/// cursor.show();
|
||||||
//! Err(e) => println!("char error : {}", e),
|
/// // blink or not blinking of the cursor (not widely supported)
|
||||||
//! }
|
/// cursor.blink(true)
|
||||||
//!
|
///
|
||||||
//! match input.read_line() {
|
/// ```
|
||||||
//! Ok(s) => println!("string typed: {}", s),
|
///
|
||||||
//! Err(e) => println!("error: {}", e),
|
/// ### Input | [see more](http://atcentra.com/crossterm/input.html)
|
||||||
//! }
|
/// This module provides the functionalities to work with terminal input.
|
||||||
//!
|
///
|
||||||
//! ```
|
/// ```rust
|
||||||
//!
|
/// use crossterm::input;
|
||||||
//! ### Terminal | [see more](https://github.com/TimonPost/crossterm/blob/master/examples/terminal/terminal.rs)
|
///
|
||||||
//! This module provides the functionalities to work with the terminal in general.
|
/// let mut input = input();
|
||||||
//!
|
///
|
||||||
//! ```rust
|
/// match input.read_char() {
|
||||||
//! use crossterm::terminal::{terminal,ClearType};
|
/// Ok(s) => println!("char typed: {}", s),
|
||||||
//!
|
/// Err(e) => println!("char error : {}", e),
|
||||||
//! let mut terminal = terminal();
|
/// }
|
||||||
//!
|
///
|
||||||
//! // Clear all lines in terminal;
|
/// match input.read_line() {
|
||||||
//! terminal.clear(ClearType::All);
|
/// Ok(s) => println!("string typed: {}", s),
|
||||||
//! // Clear all cells from current cursor position down.
|
/// Err(e) => println!("error: {}", e),
|
||||||
//! terminal.clear(ClearType::FromCursorDown);
|
/// }
|
||||||
//! // Clear all cells from current cursor position down.
|
///
|
||||||
//! terminal.clear(ClearType::FromCursorUp);
|
/// ```
|
||||||
//! // Clear current line cells.
|
///
|
||||||
//! terminal.clear(ClearType::CurrentLine);
|
/// ### Terminal | [see more](https://github.com/TimonPost/crossterm/blob/master/examples/terminal/terminal.rs)
|
||||||
//! // Clear all the cells until next line.
|
/// This module provides the functionalities to work with the terminal in general.
|
||||||
//! terminal.clear(ClearType::UntilNewLine);
|
///
|
||||||
//!
|
/// ```rust
|
||||||
//! // Get terminal size
|
/// use crossterm::terminal::{terminal,ClearType};
|
||||||
//! let (width, height) = terminal.terminal_size();
|
///
|
||||||
//! print!("X: {}, y: {}", width, height);
|
/// let mut terminal = terminal();
|
||||||
//!
|
///
|
||||||
//! // Scroll down, up 10 lines.
|
/// // Clear all lines in terminal;
|
||||||
//! terminal.scroll_down(10);
|
/// terminal.clear(ClearType::All);
|
||||||
//! terminal.scroll_up(10);
|
/// // Clear all cells from current cursor position down.
|
||||||
//!
|
/// terminal.clear(ClearType::FromCursorDown);
|
||||||
//! // Set terminal size (width, height)
|
/// // Clear all cells from current cursor position down.
|
||||||
//! terminal.set_size(10,10);
|
/// terminal.clear(ClearType::FromCursorUp);
|
||||||
//!
|
/// // Clear current line cells.
|
||||||
//! // exit the current process.
|
/// terminal.clear(ClearType::CurrentLine);
|
||||||
//! terminal.exit();
|
/// // Clear all the cells until next line.
|
||||||
//!
|
/// terminal.clear(ClearType::UntilNewLine);
|
||||||
//! // write to the terminal whether you are on the main screen or alternate screen.
|
///
|
||||||
//! terminal.write("Some text\n Some text on new line");
|
/// // Get terminal size
|
||||||
//! ```
|
/// let (width, height) = terminal.terminal_size();
|
||||||
//!
|
/// print!("X: {}, y: {}", width, height);
|
||||||
//! ### Alternate and Raw Screen
|
///
|
||||||
//! These concepts are a little more complex, please checkout the [book](http://atcentra.com/crossterm/screen.html) topics about these subjects.
|
/// // Scroll down, up 10 lines.
|
||||||
//!
|
/// terminal.scroll_down(10);
|
||||||
//! ## Tested terminals
|
/// terminal.scroll_up(10);
|
||||||
//!
|
///
|
||||||
//! - Windows Powershell
|
/// // Set terminal size (width, height)
|
||||||
//! - Windows 10 (pro)
|
/// terminal.set_size(10,10);
|
||||||
//! - Windows CMD
|
///
|
||||||
//! - Windows 10 (pro)
|
/// // exit the current process.
|
||||||
//! - Windows 8.1 (N)
|
/// terminal.exit();
|
||||||
//! - Ubuntu Desktop Terminal
|
///
|
||||||
//! - Ubuntu 17.10
|
/// // write to the terminal whether you are on the main screen or alternate screen.
|
||||||
//! - (Arch, Manjaro) KDE Konsole
|
/// terminal.write("Some text\n Some text on new line");
|
||||||
//! - Linux Mint
|
/// ```
|
||||||
//!
|
///
|
||||||
//! This crate supports all Unix terminals and windows terminals down to Windows 7 but not all of them have been tested.
|
/// ### Alternate and Raw Screen
|
||||||
//! If you have used this library for a terminal other than the above list without issues feel free to add it to the above list, I really would appreciate it.
|
/// These concepts are a little more complex, please checkout the [book](http://atcentra.com/crossterm/screen.html) topics about these subjects.
|
||||||
//!
|
///
|
||||||
//! ## Notice
|
/// ## Tested terminals
|
||||||
//! This library is average stable now but I don't expect it to not to change that much.
|
///
|
||||||
//! If there are any changes that will affect previous versions I will [describe](https://github.com/TimonPost/crossterm/blob/master/docs/UpgradeManual.md) what to change to upgrade.
|
/// - Windows Powershell
|
||||||
//!
|
/// - Windows 10 (pro)
|
||||||
//! ## Todo
|
/// - Windows CMD
|
||||||
//! I still have some things in mind to implement.
|
/// - Windows 10 (pro)
|
||||||
//!
|
/// - Windows 8.1 (N)
|
||||||
//! - Handling mouse events
|
/// - Ubuntu Desktop Terminal
|
||||||
//! I want to be able to do something based on the clicks the user has done with its mouse.
|
/// - Ubuntu 17.10
|
||||||
//! - Handling key events
|
/// - (Arch, Manjaro) KDE Konsole
|
||||||
//! I want to be able to read key combination inputs.
|
/// - Linux Mint
|
||||||
//! - Tests
|
///
|
||||||
//! Find a way to test: color, alternate screen, rawscreen
|
/// This crate supports all Unix terminals and windows terminals down to Windows 7 but not all of them have been tested.
|
||||||
//!
|
/// If you have used this library for a terminal other than the above list without issues feel free to add it to the above list, I really would appreciate it.
|
||||||
//! ## Contributing
|
///
|
||||||
//!
|
/// ## Notice
|
||||||
//! I highly appreciate it when you are contributing to this crate.
|
/// This library is quite stable now, changes could be expected but they will probably be not that big.
|
||||||
//! Also Since my native language is not English my grammar and sentence order will not be perfect.
|
/// If there are any changes that will affect previous versions I will [describe](https://github.com/TimonPost/crossterm/blob/master/docs/UpgradeManual.md) what to change to upgrade.
|
||||||
//! So improving this by correcting these mistakes will help both me and the reader of the docs.
|
///
|
||||||
//!
|
/// ## Todo
|
||||||
//! Check [Contributing](https://github.com/TimonPost/crossterm/blob/master/docs/Contributing.md) for more info about branches and code architecture.
|
/// I still have some things in mind to implement.
|
||||||
//!
|
///
|
||||||
//! ## Authors
|
/// - Handling mouse events:
|
||||||
//!
|
/// I want to be able to do something based on the clicks the user has done with its mouse.
|
||||||
//! * **Timon Post** - *Project Owner & creator*
|
/// - Handling key events:
|
||||||
//!
|
/// I want to be able to read key combination inputs.
|
||||||
//! ## License
|
/// - Tests:
|
||||||
//!
|
/// Find a way to test: color, alternate screen, rawscreen
|
||||||
//! This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/TimonPost/crossterm/blob/master/LICENSE) file for details
|
///
|
||||||
|
/// ## Contributing
|
||||||
|
///
|
||||||
|
/// I highly appreciate it when you are contributing to this crate.
|
||||||
|
/// Also Since my native language is not English my grammar and sentence order will not be perfect.
|
||||||
|
/// So improving this by correcting these mistakes will help both me and the reader of the docs.
|
||||||
|
///
|
||||||
|
/// Check [Contributing](https://github.com/TimonPost/crossterm/blob/master/docs/Contributing.md) for more info about branches and code architecture.
|
||||||
|
///
|
||||||
|
/// ## Authors
|
||||||
|
///
|
||||||
|
/// * **Timon Post** - *Project Owner & creator*
|
||||||
|
///
|
||||||
|
/// ## License
|
||||||
|
///
|
||||||
|
/// This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/TimonPost/crossterm/blob/master/LICENSE) file for details
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
Loading…
Reference in New Issue
Block a user