Documentation fixes (#156)

This commit is contained in:
Caleb Bassi 2019-06-21 09:10:46 -07:00 committed by Timon
parent 2b36dbf9d9
commit e1b8da03ba
38 changed files with 125 additions and 124 deletions

View File

@ -40,7 +40,7 @@ This crate consists of five modules that are provided behind [feature flags](htt
- [Features](#features) - [Features](#features)
- [Examples](#examples) - [Examples](#examples)
- [Crossterm Type](#crossterm-type) - [Crossterm Type](#crossterm-type)
- [Styled Font](#styled-font) - [Styled Text](#styled-text)
- [Cursor](#cursor) - [Cursor](#cursor)
- [Terminal](#terminal) - [Terminal](#terminal)
- [Input Reading](#input-reading) - [Input Reading](#input-reading)
@ -121,8 +121,8 @@ let terminal = crossterm.terminal();
let input = crossterm.input(); let input = crossterm.input();
``` ```
### Styled Font ### Styled Text
This module enables you to style the terminal font. This module enables you to style the terminal text.
Good documentation can be found at the following places: [docs](https://docs.rs/crossterm_style/), [book](https://timonpost.github.io/crossterm/docs/styling.html), [examples](https://github.com/TimonPost/crossterm/tree/master/examples/key_events.rs) Good documentation can be found at the following places: [docs](https://docs.rs/crossterm_style/), [book](https://timonpost.github.io/crossterm/docs/styling.html), [examples](https://github.com/TimonPost/crossterm/tree/master/examples/key_events.rs)
@ -130,7 +130,7 @@ _imports_
```rust ```rust
use crossterm::{Colored, Color, Colorize, Styler, Attribute}; use crossterm::{Colored, Color, Colorize, Styler, Attribute};
``` ```
_style font with attributes_ _style text with attributes_
```rust ```rust
// pass any `Attribute` value to the formatting braces. // pass any `Attribute` value to the formatting braces.
println!("{} Underlined {} No Underline", Attribute::Underlined, Attribute::NoUnderline); println!("{} Underlined {} No Underline", Attribute::Underlined, Attribute::NoUnderline);
@ -143,7 +143,7 @@ println!("{}", styled_text);
let styled_text = style("Bold Underlined").bold().underlined(); let styled_text = style("Bold Underlined").bold().underlined();
``` ```
_style font with colors_ _style text with colors_
```rust ```rust
println!("{} Red foreground color", Colored::Fg(Color::Red)); println!("{} Red foreground color", Colored::Fg(Color::Red));
println!("{} Blue background color", Colored::Bg(Color::Blue)); println!("{} Blue background color", Colored::Bg(Color::Blue));
@ -155,7 +155,7 @@ println!("{}", styled_text);
// old-way but still usable // old-way but still usable
let styled_text = style("Bold Underlined").with(Color::Red).on(Color::Blue); let styled_text = style("Bold Underlined").with(Color::Red).on(Color::Blue);
``` ```
_style font with RGB and ANSI Value_ _style text with RGB and ANSI Value_
```rust ```rust
// custom rgb value (Windows 10 and UNIX systems) // custom rgb value (Windows 10 and UNIX systems)
println!("{} some colored text", Colored::Fg(Color::Rgb { println!("{} some colored text", Colored::Fg(Color::Rgb {

View File

@ -1,5 +1,5 @@
//! //!
//! Examples of actions that could be performed with te cursor. //! Examples of actions that could be performed with the cursor.
//! //!
extern crate crossterm_cursor; extern crate crossterm_cursor;

View File

@ -16,7 +16,7 @@ use crossterm_utils::supports_ansi;
/// - Goto a certain position /// - Goto a certain position
/// - Get cursor position /// - Get cursor position
/// - Storing the current cursor position and resetting to that stored cursor position later /// - Storing the current cursor position and resetting to that stored cursor position later
/// - Hiding an showing the cursor /// - Hiding and showing the cursor
/// - Control over blinking of the terminal cursor (only some terminals are supporting this) /// - Control over blinking of the terminal cursor (only some terminals are supporting this)
/// ///
/// Note that positions of the cursor are 0 -based witch means that the coordinates (cells) starts counting from 0 /// Note that positions of the cursor are 0 -based witch means that the coordinates (cells) starts counting from 0

View File

@ -24,7 +24,7 @@ pub struct TerminalInput {
} }
impl TerminalInput { impl TerminalInput {
/// Create a new instance of `TerminalInput` whereon input related actions could be preformed. /// Create a new instance of `TerminalInput` whereon input related actions could be performed.
pub fn new() -> TerminalInput { pub fn new() -> TerminalInput {
#[cfg(windows)] #[cfg(windows)]
let input = WindowsInput::new(); let input = WindowsInput::new();
@ -95,7 +95,7 @@ impl TerminalInput {
/// Read the input asynchronously until a certain character is hit, which means that input events are gathered on the background and will be queued for you to read. /// Read the input asynchronously until a certain character is hit, which means that input events are gathered on the background and will be queued for you to read.
/// ///
/// If you want a blocking, or less resource consuming read to happen use `read_sync()`, this will leave a way all the thread and queueing and will be a blocking read. /// If you want a blocking or less resource consuming read to happen, use `read_sync()`. This will leave alone the background thread and queues and will be a blocking read.
/// ///
/// This is the same as `read_async()` but stops reading when a certain character is hit. /// This is the same as `read_async()` but stops reading when a certain character is hit.
/// ///
@ -114,10 +114,10 @@ impl TerminalInput {
self.input.read_until_async(delimiter) self.input.read_until_async(delimiter)
} }
/// Read the input synchronously from the user, which means that reading call wil be blocking ones. /// Read the input synchronously from the user, which means that reading calls will block.
/// It also uses less resources than the `AsyncReader` because background thread and queues are left away. /// It also uses less resources than the `AsyncReader` because the background thread and queues are left alone.
/// ///
/// In case you don't want the reading to block your program you could consider `read_async`. /// Consider using `read_async` if you don't want the reading call to block your program.
/// ///
/// # Remark /// # Remark
/// - Readings will be blocking calls. /// - Readings will be blocking calls.
@ -130,7 +130,7 @@ impl TerminalInput {
/// Enable mouse events to be captured. /// Enable mouse events to be captured.
/// ///
/// When enabling mouse input you will be able to capture, mouse movements, pressed buttons and locations. /// When enabling mouse input, you will be able to capture mouse movements, pressed buttons, and locations.
/// ///
/// # Remark /// # Remark
/// - Mouse events will be send over the reader created with `read_async`, `read_async_until`, `read_sync`. /// - Mouse events will be send over the reader created with `read_async`, `read_async_until`, `read_sync`.
@ -140,7 +140,7 @@ impl TerminalInput {
/// Disable mouse events to be captured. /// Disable mouse events to be captured.
/// ///
/// When disabling mouse input you won't be able to capture, mouse movements, pressed buttons and locations anymore. /// When disabling mouse input, you won't be able to capture mouse movements, pressed buttons, and locations anymore.
pub fn disable_mouse_mode(&self) -> Result<()> { pub fn disable_mouse_mode(&self) -> Result<()> {
self.input.disable_mouse_mode() self.input.disable_mouse_mode()
} }

View File

@ -28,7 +28,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Receiver, Sender}; use std::sync::mpsc::{Receiver, Sender};
use std::thread; use std::thread;
/// This trait defines the actions that can be preformed with the terminal input. /// This trait defines the actions that can be performed with the terminal input.
/// This trait can be implemented so that a concrete implementation of the ITerminalInput can fulfill /// This trait can be implemented so that a concrete implementation of the ITerminalInput can fulfill
/// the wishes to work on a specific platform. /// the wishes to work on a specific platform.
/// ///

View File

@ -78,9 +78,9 @@ impl ITerminalInput for UnixInput {
} }
} }
/// This type allows you to read input synchronously, which means that reading call will be blocking ones. /// This type allows you to read input synchronously, which means that reading calls will block.
/// ///
/// This type is an iterator, and could be used to iterate over input events. /// This type is an iterator, and can be used to iterate over input events.
/// ///
/// If you don't want to block your calls use [AsyncReader](./LINK), which will read input on the background and queue it for you to read. /// If you don't want to block your calls use [AsyncReader](./LINK), which will read input on the background and queue it for you to read.
pub struct SyncReader { pub struct SyncReader {
@ -92,10 +92,10 @@ impl Iterator for SyncReader {
type Item = InputEvent; type Item = InputEvent;
/// Read input from the user. /// Read input from the user.
/// ///
/// If there are no keys pressed this will be a blocking call until there are. /// If there are no keys pressed, this will be a blocking call until there is one.
/// This will return `None` in case of a failure and `Some(InputEvent) in case of an occurred input event.` /// This will return `None` in case of a failure and `Some(InputEvent)` in case of an occurred input event.
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
// TODO: Currently errors are consumed and converted to a `NONE` maybe we should'nt be doing this? // TODO: Currently errors are consumed and converted to a `None`. Maybe we shouldn't be doing this?
let source = &mut self.source; let source = &mut self.source;
if let Some(c) = self.leftover { if let Some(c) = self.leftover {

View File

@ -113,9 +113,9 @@ impl ITerminalInput for WindowsInput {
} }
} }
/// This type allows you to read input synchronously, which means that reading call will be blocking ones. /// This type allows you to read input synchronously, which means that reading calls will block.
/// ///
/// This type is an iterator, and could be used to iterate over input events. /// This type is an iterator, and can be used to iterate over input events.
/// ///
/// If you don't want to block your calls use [AsyncReader](./LINK), which will read input on the background and queue it for you to read. /// If you don't want to block your calls use [AsyncReader](./LINK), which will read input on the background and queue it for you to read.
pub struct SyncReader; pub struct SyncReader;
@ -125,8 +125,8 @@ impl Iterator for SyncReader {
/// Read input from the user. /// Read input from the user.
/// ///
/// If there are no keys pressed this will be a blocking call until there are. /// If there are no keys pressed, this will be a blocking call until there is one.
/// This will return `None` in case of a failure and `Some(InputEvent) in case of an occurred input event.` /// This will return `None` in case of a failure and `Some(InputEvent)` in case of an occurred input event.
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let mut iterator = into_virtual_terminal_sequence().unwrap().1.into_iter(); let mut iterator = into_virtual_terminal_sequence().unwrap().1.into_iter();

View File

@ -7,7 +7,7 @@ use std::{thread, time};
/// print wait screen on alternate screen, then switch back. /// print wait screen on alternate screen, then switch back.
pub fn print_wait_screen_on_alternate_window() { pub fn print_wait_screen_on_alternate_window() {
// move to alternate screen, 'false' means if the alternate screen should be in raw modes. // move to the alternate screen, 'false' determines if the alternate screen should be in raw mode.
if let Ok(alternate) = AlternateScreen::to_alternate(false) { if let Ok(alternate) = AlternateScreen::to_alternate(false) {
// do some stuff on the alternate screen. // do some stuff on the alternate screen.
} // <- alternate screen will be disabled when dropped. } // <- alternate screen will be disabled when dropped.

View File

@ -6,7 +6,7 @@ use std::io::{stdout, Write};
use std::{thread, time}; use std::{thread, time};
pub fn raw_modes() { pub fn raw_modes() {
// create a Screen instance who operates on the default output; io::stdout(). By passing in 'true' we make this screen 'raw' // create a Screen instance that operates on the default output: io::stdout(). By passing in 'true', we make this screen 'raw'
let screen = RawScreen::into_raw_mode(); let screen = RawScreen::into_raw_mode();
let screen = stdout().into_raw_mode(); let screen = stdout().into_raw_mode();

View File

@ -1,5 +1,5 @@
//! A module which provides some functionalities to work with the terminal screen. //! A module which provides some functionalities to work with the terminal screen.
//! Like allowing you to switch between main and alternate screen or putting the terminal into raw mode. //! Like allowing you to switch between the main and alternate screen or putting the terminal into raw mode.
#[macro_use] #[macro_use]
extern crate crossterm_utils; extern crate crossterm_utils;

View File

@ -15,8 +15,8 @@ use crate::sys::{self, IAlternateScreenCommand};
use super::RawScreen; use super::RawScreen;
use std::io; use std::io;
/// With this type you will be able to switch to alternate screen and back to main screen. /// With this type you will be able to switch to the alternate screen and then back to the main screen.
/// Check also the Screen type for swishing to alternate mode. /// Check also the Screen type for switching to alternate mode.
/// ///
/// Although this type is available for you to use I would recommend using `Screen` instead. /// Although this type is available for you to use I would recommend using `Screen` instead.
pub struct AlternateScreen { pub struct AlternateScreen {
@ -28,13 +28,13 @@ pub struct AlternateScreen {
} }
impl AlternateScreen { impl AlternateScreen {
/// Switch to alternate screen. This function will return an `AlternateScreen` instance if everything went well this type will give you control over the `AlternateScreen`. /// Switch to the alternate screen. This function will return an `AlternateScreen` instance if everything went well. This type will give you control over the `AlternateScreen`.
/// ///
/// The bool specifies whether the screen should be in raw mode or not. /// The bool specifies whether the screen should be in raw mode or not.
/// ///
/// # What is Alternate screen? /// # What is Alternate screen?
/// *Nix style applications often utilize an alternate screen buffer, so that they can modify the entire contents of the buffer, without affecting the application that started them. /// *Nix style applications often utilize an alternate screen buffer, so that they can modify the entire contents of the buffer without affecting the application that started them.
/// The alternate buffer is exactly the dimensions of the window, without any scrollback region. /// The alternate buffer dimensions are exactly the same as the window, without any scrollback region.
/// For an example of this behavior, consider when vim is launched from bash. /// For an example of this behavior, consider when vim is launched from bash.
/// Vim uses the entirety of the screen to edit the file, then returning to bash leaves the original buffer unchanged. /// Vim uses the entirety of the screen to edit the file, then returning to bash leaves the original buffer unchanged.
pub fn to_alternate(raw_mode: bool) -> io::Result<AlternateScreen> { pub fn to_alternate(raw_mode: bool) -> io::Result<AlternateScreen> {
@ -66,7 +66,7 @@ impl AlternateScreen {
}) })
} }
/// Switch the alternate screen back to main screen. /// Switch the alternate screen back to the main screen.
pub fn to_main(&self) -> io::Result<()> { pub fn to_main(&self) -> io::Result<()> {
self.command.disable()?; self.command.disable()?;
Ok(()) Ok(())
@ -74,7 +74,7 @@ impl AlternateScreen {
} }
impl Drop for AlternateScreen { impl Drop for AlternateScreen {
/// This will switch back to main screen on drop. /// This will switch back to the main screen on drop.
fn drop(&mut self) { fn drop(&mut self) {
self.to_main().unwrap(); self.to_main().unwrap();
} }

View File

@ -17,9 +17,9 @@
use crate::sys; use crate::sys;
use std::io::{self, Stdout, Write}; use std::io::{self, Stdout, Write};
/// A wrapper for the raw terminal state. Which can be used to write to. /// A wrapper for the raw terminal state, which can be used to write to.
/// ///
/// Please take in mind that if this type drops the raw screen will be undone, to prevent this behaviour call `disable_drop`. /// Please note that if this type drops, the raw screen will be undone. To prevent this behaviour call `disable_drop`.
pub struct RawScreen { pub struct RawScreen {
drop: bool, drop: bool,
} }

View File

@ -7,7 +7,7 @@ pub mod winapi;
use crossterm_utils::Result; use crossterm_utils::Result;
use std::io::Write; use std::io::Write;
/// This command is used for switching to alternate screen and back to main screen. /// This command is used for switching to the alternate screen and back to the main screen.
pub struct ToAlternateScreenCommand; pub struct ToAlternateScreenCommand;
impl ToAlternateScreenCommand { impl ToAlternateScreenCommand {
@ -30,7 +30,7 @@ impl IAlternateScreenCommand for ToAlternateScreenCommand {
} }
} }
// This trait provides an interface for switching to alternate screen and back. // This trait provides an interface for switching to the alternate screen and back.
pub trait IAlternateScreenCommand: Sync + Send { pub trait IAlternateScreenCommand: Sync + Send {
fn enable(&self) -> Result<()>; fn enable(&self) -> Result<()>;
fn disable(&self) -> Result<()>; fn disable(&self) -> Result<()>;

View File

@ -5,7 +5,7 @@ use std::io;
use winapi::shared::minwindef::DWORD; use winapi::shared::minwindef::DWORD;
use winapi::um::wincon; use winapi::um::wincon;
/// This command is used for enabling and disabling raw mode for windows systems. /// This command is used for enabling and disabling raw mode for Windows systems.
/// For more info check: https://docs.microsoft.com/en-us/windows/console/high-level-console-modes. /// For more info check: https://docs.microsoft.com/en-us/windows/console/high-level-console-modes.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub struct RawModeCommand { pub struct RawModeCommand {
@ -48,7 +48,7 @@ impl RawModeCommand {
} }
} }
/// This command is used for switching to alternate screen and back to main screen. /// This command is used for switching to the alternate screen and back to the main screen.
/// check https://docs.microsoft.com/en-us/windows/console/reading-and-writing-blocks-of-characters-and-attributes for more info /// check https://docs.microsoft.com/en-us/windows/console/reading-and-writing-blocks-of-characters-and-attributes for more info
pub struct ToAlternateScreenCommand; pub struct ToAlternateScreenCommand;

View File

@ -15,10 +15,10 @@
[s7]: https://travis-ci.org/TimonPost/crossterm.svg?branch=master [s7]: https://travis-ci.org/TimonPost/crossterm.svg?branch=master
This crate allows you to style te terminal cross-platform. This crate allows you to style the terminal cross-platform.
It supports all UNIX and windows terminals down to windows 7 (not all terminals are tested see [Tested Terminals](#tested-terminals) for more info) It supports all UNIX and windows terminals down to windows 7 (not all terminals are tested see [Tested Terminals](#tested-terminals) for more info)
This crate is a sub-crate of [crossterm](https://crates.io/crates/crossterm) to style te terminal, and can be use individually. This crate is a sub-crate of [crossterm](https://crates.io/crates/crossterm) to style the terminal, and can be use individually.
Other sub-crates are: Other sub-crates are:
- [Crossterm Input](https://crates.io/crates/crossterm_input) - [Crossterm Input](https://crates.io/crates/crossterm_input)
@ -82,7 +82,7 @@ These are the features of this crate:
## Examples ## Examples
The [examples](./examples) folder has more complete and verbose examples. The [examples](./examples) folder has more complete and verbose examples.
_style font with attributes_ _style text with attributes_
```rust ```rust
use crossterm_style::{Colored, Color, Colorize, Styler, Attribute}; use crossterm_style::{Colored, Color, Colorize, Styler, Attribute};
@ -97,7 +97,7 @@ println!("{}", styled_text);
let styled_text = style("Bold Underlined").bold().underlined(); let styled_text = style("Bold Underlined").bold().underlined();
``` ```
_style font with colors_ _style text with colors_
```rust ```rust
use crossterm_style::{Colored, Color, Colorize}; use crossterm_style::{Colored, Color, Colorize};
@ -111,7 +111,7 @@ println!("{}", styled_text);
// old-way but still usable // old-way but still usable
let styled_text = style("Bold Underlined").with(Color::Red).on(Color::Blue); let styled_text = style("Bold Underlined").with(Color::Red).on(Color::Blue);
``` ```
_style font with RGB and ANSI Value_ _style text with RGB and ANSI Value_
```rust ```rust
// custom rgb value (Windows 10 and UNIX systems) // custom rgb value (Windows 10 and UNIX systems)
println!("{} some colored text", Colored::Fg(Color::Rgb { println!("{} some colored text", Colored::Fg(Color::Rgb {

View File

@ -8,13 +8,13 @@ use self::crossterm_style::{
color, style, Attribute, Color, Colored, Colorize, Styler, TerminalColor, color, style, Attribute, Color, Colored, Colorize, Styler, TerminalColor,
}; };
/// print some red font | demonstration. /// print some red text | demonstration.
pub fn paint_foreground() { pub fn paint_foreground() {
println!("{}", "Red foreground text: {}".red()); println!("{}", "Red foreground text: {}".red());
println!("{} Red foreground text", Colored::Fg(Color::Red)); println!("{} Red foreground text", Colored::Fg(Color::Red));
} }
/// print some font on red background | demonstration. /// print some text on red background | demonstration.
pub fn paint_background() { pub fn paint_background() {
println!("{}", "Red background text: {}".on_red()); println!("{}", "Red background text: {}".on_red());
println!("{} Red background text", Colored::Bg(Color::Red)); println!("{} Red background text", Colored::Bg(Color::Red));
@ -347,9 +347,9 @@ pub fn print_all_background_colors_with_method() {
); );
} }
/// Print font with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration.. /// Print text with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration..
#[cfg(unix)] #[cfg(unix)]
pub fn print_font_with_attributes() { pub fn print_text_with_attributes() {
println!("{}", "Normal text"); println!("{}", "Normal text");
println!("{}", "Bold text".bold()); println!("{}", "Bold text".bold());
println!("{}", "Italic text".italic()); println!("{}", "Italic text".italic());
@ -359,7 +359,7 @@ pub fn print_font_with_attributes() {
println!("{}", "Underlined text".underlined()); println!("{}", "Underlined text".underlined());
println!("{}", "Reversed text".reverse()); println!("{}", "Reversed text".reverse());
println!("{}", "Dim text".dim()); println!("{}", "Dim text".dim());
println!("{}", "Crossed out font".crossed_out()); println!("{}", "Crossed out text".crossed_out());
// ... // ...
println!( println!(
@ -370,9 +370,9 @@ pub fn print_font_with_attributes() {
// ... // ...
} }
// Print font with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration.. // Print text with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration..
#[cfg(windows)] #[cfg(windows)]
pub fn print_font_with_attributes() { pub fn print_text_with_attributes() {
println!("{}", "Normal text"); println!("{}", "Normal text");
println!("{}", "Bold text".bold()); println!("{}", "Bold text".bold());
println!("{}", "Underlined text".underlined()); println!("{}", "Underlined text".underlined());

View File

@ -1,5 +1,5 @@
//! A module that contains all the actions related to the styling of the terminal. //! A module that contains all the actions related to the styling of the terminal.
//! Like applying attributes to font and changing the foreground and background. //! Like applying attributes to text and changing the foreground and background.
use std::io; use std::io;

View File

@ -2,8 +2,9 @@ use std::fmt::Display;
use std::io::stdout; use std::io::stdout;
use std::io::Write; use std::io::Write;
/// These are all the attributes which **could** be apply to font. /// These are all the attributes which can be applied to text.
/// There are few things to note ///
/// There are few things to note:
/// - Not all attributes are supported, some of them are only supported on Windows some only on Unix, /// - Not all attributes are supported, some of them are only supported on Windows some only on Unix,
/// and some are only very rarely supported. /// and some are only very rarely supported.
/// - I got those attributes, descriptions, supportability from here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters /// - I got those attributes, descriptions, supportability from here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
@ -36,18 +37,18 @@ pub enum Attribute {
/// [Supportability]: Windows, UNIX. /// [Supportability]: Windows, UNIX.
Reset = 0, Reset = 0,
/// Increased Intensity /// Increased Intensity
/// [info]: This will increase the font sensitivity also known as bold. /// [info]: This will increase the text sensitivity also known as bold.
/// [Supportability]: Windows, UNIX. /// [Supportability]: Windows, UNIX.
Bold = 1, Bold = 1,
/// Decreased Intensity /// Decreased Intensity
/// [info]: This will decrease the font sensitivity also known as bold. /// [info]: This will decrease the text sensitivity also known as bold.
/// [Supportability]: Windows, UNIX. /// [Supportability]: Windows, UNIX.
Dim = 2, Dim = 2,
/// Italic Text /// Italic Text
/// [info]: This will make the font italic. /// [info]: This will make the text italic.
/// [Supportability]: Not widely supported, sometimes treated as inverse. /// [Supportability]: Not widely supported, sometimes treated as inverse.
Italic = 3, Italic = 3,
/// This will draw a line under the font. /// This will draw a line under the text.
/// [info]: An line under a word, especially in order to show its importance. /// [info]: An line under a word, especially in order to show its importance.
/// [Supportability]: Windows, UNIX /// [Supportability]: Windows, UNIX
Underlined = 4, Underlined = 4,
@ -63,13 +64,13 @@ pub enum Attribute {
/// [info]: swap foreground and background colors /// [info]: swap foreground and background colors
/// [Supportability]: Windows, UNIX /// [Supportability]: Windows, UNIX
Reverse = 7, Reverse = 7,
/// Hide font /// Hide text
/// [info]: /// [info]:
/// - This will make the font hidden. /// - This will make the text hidden.
/// - Also known as 'Conceal' /// - Also known as 'Conceal'
/// [Supportability]: Windows, UNIX /// [Supportability]: Windows, UNIX
Hidden = 8, Hidden = 8,
/// Cross-out font /// Cross-out text
/// [info]: Characters legible, but marked for deletion. /// [info]: Characters legible, but marked for deletion.
/// [Supportability]: UNIX /// [Supportability]: UNIX
CrossedOut = 9, CrossedOut = 9,
@ -107,7 +108,7 @@ pub enum Attribute {
/// [info]: Opposite of `Reverse`(7) /// [info]: Opposite of `Reverse`(7)
/// [Supportability]: Windows, unknown /// [Supportability]: Windows, unknown
NoInverse = 27, NoInverse = 27,
/// This will make the font visible. /// This will make the text visible.
/// [info]: Opposite of `Hidden`(8) /// [info]: Opposite of `Hidden`(8)
/// [Supportability]: Unknown /// [Supportability]: Unknown
NoHidden = 28, NoHidden = 28,
@ -115,12 +116,12 @@ pub enum Attribute {
/// [info]: Opposite of `CrossedOut`(9) /// [info]: Opposite of `CrossedOut`(9)
/// [Supportability]: Not widely supported /// [Supportability]: Not widely supported
NotCrossedOut = 29, NotCrossedOut = 29,
/// Framed font. /// Framed text.
/// [Supportability]: Not widely supported /// [Supportability]: Not widely supported
Framed = 51, Framed = 51,
/// This will turn on the encircled attribute. /// This will turn on the encircled attribute.
Encircled = 52, Encircled = 52,
/// This will draw a line at the top of the font. /// This will draw a line at the top of the text.
/// [info]: Implementation defined (according to standard) /// [info]: Implementation defined (according to standard)
/// [Supportability]: Unknown /// [Supportability]: Unknown
OverLined = 53, OverLined = 53,

View File

@ -1,7 +1,7 @@
use std::convert::AsRef; use std::convert::AsRef;
use std::str::FromStr; use std::str::FromStr;
/// Colors that are available for coloring the terminal font. /// Colors that are available for coloring the terminal text.
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] #[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub enum Color { pub enum Color {
// This resets the color. // This resets the color.
@ -43,14 +43,14 @@ pub enum Color {
} }
impl<'a> From<&'a str> for Color { impl<'a> From<&'a str> for Color {
/// Get an color from an &str like `Color::from("blue")`. /// Get a `Color` from a `&str` like `Color::from("blue")`.
fn from(src: &str) -> Self { fn from(src: &str) -> Self {
src.parse().unwrap_or(Color::White) src.parse().unwrap_or(Color::White)
} }
} }
impl From<String> for Color { impl From<String> for Color {
/// Get an color from an &str like `Color::from(String::from(blue))`. /// Get a `Color` from a `&str` like `Color::from(String::from(blue))`.
fn from(src: String) -> Self { fn from(src: String) -> Self {
src.parse().unwrap_or(Color::White) src.parse().unwrap_or(Color::White)
} }
@ -59,7 +59,7 @@ impl From<String> for Color {
impl FromStr for Color { impl FromStr for Color {
type Err = (); type Err = ();
/// Convert a string to an Color value /// Convert a `&str` to a `Color` value
fn from_str(src: &str) -> ::std::result::Result<Self, Self::Err> { fn from_str(src: &str) -> ::std::result::Result<Self, Self::Err> {
let src = src.to_lowercase(); let src = src.to_lowercase();

View File

@ -1,5 +1,5 @@
//! A module that contains all the actions related to the styling of the terminal. //! A module that contains all the actions related to the styling of the terminal.
//! Like applying attributes to font and changing the foreground and background. //! Like applying attributes to text and changing the foreground and background.
#[macro_use] #[macro_use]
extern crate crossterm_utils; extern crate crossterm_utils;
@ -31,9 +31,9 @@ pub use self::styledobject::StyledObject;
pub use self::traits::{Colorize, Styler}; pub use self::traits::{Colorize, Styler};
use crossterm_utils::Result; use crossterm_utils::Result;
/// This trait defines the actions that can be preformed with terminal color. /// This trait defines the actions that can be performed with terminal colors.
/// This trait can be implemented so that a concrete implementation of the ITerminalColor can fulfill /// This trait can be implemented so that a concrete implementation of the ITerminalColor can fulfill
/// the wishes to work on an specific platform. /// the wishes to work on a specific platform.
/// ///
/// ## For example: /// ## For example:
/// ///
@ -46,20 +46,20 @@ trait ITerminalColor {
fn set_bg(&self, fg_color: Color) -> Result<()>; fn set_bg(&self, fg_color: Color) -> Result<()>;
/// Reset the terminal color to default. /// Reset the terminal color to default.
fn reset(&self) -> Result<()>; fn reset(&self) -> Result<()>;
/// Gets an value that represents an color from the given `Color` and `ColorType`. /// Gets an value that represents a color from the given `Color` and `ColorType`.
fn color_value(&self, cored: Colored) -> String; fn color_value(&self, cored: Colored) -> String;
} }
/// This could be used to style a type who is implementing `Display` with colors and attributes. /// This could be used to style a type that implements `Display` with colors and attributes.
/// ///
/// # Example /// # Example
/// ```rust /// ```rust
/// // get an styled object which could be painted to the terminal. /// // get a styled object which could be painted to the terminal.
/// let styled_object = style("Some Blue colored text on black background") /// let styled_object = style("Some Blue colored text on black background")
/// .with(Color::Blue) /// .with(Color::Blue)
/// .on(Color::Black); /// .on(Color::Black);
/// ///
/// // print the styled font * times to the current screen. /// // print the styled text * times to the current screen.
/// for i in 1..10 /// for i in 1..10
/// { /// {
/// println!("{}", styled_object); /// println!("{}", styled_object);

View File

@ -6,7 +6,7 @@ use std::fmt::Display;
use super::Attribute; use super::Attribute;
/// Struct that contains the style properties that can be applied to an displayable object. /// Struct that contains the style properties that can be applied to a displayable object.
#[derive(Clone)] #[derive(Clone)]
pub struct ObjectStyle { pub struct ObjectStyle {
pub fg_color: Option<Color>, pub fg_color: Option<Color>,
@ -25,7 +25,7 @@ impl Default for ObjectStyle {
} }
impl ObjectStyle { impl ObjectStyle {
/// Apply an `StyledObject` to the passed displayable object. /// Apply a `StyledObject` to the passed displayable object.
pub fn apply_to<D: Display>(&self, val: D) -> StyledObject<D> { pub fn apply_to<D: Display>(&self, val: D) -> StyledObject<D> {
StyledObject { StyledObject {
object_style: self.clone(), object_style: self.clone(),
@ -33,7 +33,7 @@ impl ObjectStyle {
} }
} }
/// Get an new instance of `ObjectStyle` /// Get a new instance of `ObjectStyle`
pub fn new() -> ObjectStyle { pub fn new() -> ObjectStyle {
ObjectStyle { ObjectStyle {
fg_color: None, fg_color: None,

View File

@ -8,7 +8,7 @@ use std::result;
use super::Attribute; use super::Attribute;
use crate::{Colorize, Styler}; use crate::{Colorize, Styler};
/// Contains both the style and the content wits can be styled. /// Contains both the style and the content which can be styled.
pub struct StyledObject<D: Display> { pub struct StyledObject<D: Display> {
pub object_style: ObjectStyle, pub object_style: ObjectStyle,
pub content: D, pub content: D,

View File

@ -1,4 +1,4 @@
//! This is an `WinApi` specific implementation for styling related action. //! This is a `WinApi` specific implementation for styling related action.
//! This module is used for non supporting `ANSI` Windows terminals. //! This module is used for non supporting `ANSI` Windows terminals.
use crate::{Color, Colored, ITerminalColor}; use crate::{Color, Colored, ITerminalColor};

View File

@ -16,7 +16,7 @@ pub use self::terminal::{terminal, Terminal};
use crossterm_utils::Result; use crossterm_utils::Result;
/// Enum that specifies a way of clearing. /// Enum that specifies ways of clearing the terminal.
pub enum ClearType { pub enum ClearType {
/// clear all cells in terminal. /// clear all cells in terminal.
All, All,
@ -30,14 +30,14 @@ pub enum ClearType {
UntilNewLine, UntilNewLine,
} }
/// This trait defines the actions that can be preformed with the terminal color. /// This trait defines the actions that can be performed with the terminal color.
/// This trait can be implemented so that an concrete implementation of the ITerminalColor can fulfill. /// This trait can be implemented so that an concrete implementation of the ITerminalColor can fulfill.
/// the wishes to work on an specific platform. /// the wishes to work on an specific platform.
/// ///
/// ## For example: /// ## For example:
/// ///
/// This trait is implemented for `WinApi` (Windows specific) and `ANSI` (Unix specific), /// This trait is implemented for `WinApi` (Windows specific) and `ANSI` (Unix specific),
/// so that terminal related actions can be preformed on both Unix and Windows systems. /// so that terminal related actions can be performed on both Unix and Windows systems.
trait ITerminal { trait ITerminal {
/// Clear the current cursor by specifying the clear type /// Clear the current cursor by specifying the clear type
fn clear(&self, clear_type: ClearType) -> Result<()>; fn clear(&self, clear_type: ClearType) -> Result<()>;

View File

@ -131,7 +131,7 @@ impl Terminal {
} }
} }
/// Get a `Terminal` instance whereon terminal related actions could performed. /// Get a `Terminal` instance whereon terminal related actions can be performed.
pub fn terminal() -> Terminal { pub fn terminal() -> Terminal {
Terminal::new() Terminal::new()
} }

View File

@ -1,4 +1,4 @@
//! This is an `WINAPI` specific implementation for terminal related action. //! This is a `WINAPI` specific implementation for terminal related action.
//! This module is used for non supporting `ANSI` windows terminals. //! This module is used for non supporting `ANSI` windows terminals.
//! //!
//! Windows versions lower then windows 10 are not supporting ANSI codes. Those versions will use this implementation instead. //! Windows versions lower then windows 10 are not supporting ANSI codes. Those versions will use this implementation instead.
@ -8,7 +8,7 @@ use crossterm_cursor::sys::winapi::Cursor;
use crossterm_utils::{ErrorKind, Result}; use crossterm_utils::{ErrorKind, Result};
use crossterm_winapi::{Console, Coord, Handle, ScreenBuffer, Size}; use crossterm_winapi::{Console, Coord, Handle, ScreenBuffer, Size};
/// This struct is an winapi implementation for terminal related actions. /// This struct is a winapi implementation for terminal related actions.
pub struct WinApiTerminal; pub struct WinApiTerminal;
impl WinApiTerminal { impl WinApiTerminal {

View File

@ -8,7 +8,7 @@ use std::{
/// The `crossterm` result type. /// The `crossterm` result type.
pub type Result<T> = std::result::Result<T, ErrorKind>; pub type Result<T> = std::result::Result<T, ErrorKind>;
/// Wrapper for all errors who could occur in `crossterm`. /// Wrapper for all errors that can occur in `crossterm`.
#[derive(Debug)] #[derive(Debug)]
pub enum ErrorKind { pub enum ErrorKind {
IoError(io::Error), IoError(io::Error),

View File

@ -119,7 +119,7 @@ impl Console {
Ok(cells_written) Ok(cells_written)
} }
/// Retrieves the size of the largest possible console window, based on the current font and the size of the display. /// Retrieves the size of the largest possible console window, based on the current text and the size of the display.
/// ///
/// Wraps the underlying function call: [GetLargestConsoleWindowSize] /// Wraps the underlying function call: [GetLargestConsoleWindowSize]
/// link: [https://docs.microsoft.com/en-us/windows/console/getlargestconsolewindowsize] /// link: [https://docs.microsoft.com/en-us/windows/console/getlargestconsolewindowsize]

View File

@ -215,10 +215,10 @@ if let Ok(alternate) = screen.enable_alternate_modes(false) {
***WARNING*** ***WARNING***
This new version contains some cool features but to get those features working I needed to add some user API braking changes. This new version contains some cool features but to get those features working I needed to add some user API breaking changes.
I really did not want to do this but it had to be done for some reasons. I really did not want to do this but it had to be done for some reasons.
#### 1. You need to pass a reference to an `Screen` to the modules: `cursor(), color(), terminal()` #### 1. You need to pass a reference to a `Screen` to the modules: `cursor()`, `color()`, `terminal()`
_**old**_ _**old**_
``` ```
@ -255,11 +255,11 @@ use crossterm::style::{Color, input, style};
// 1: use the `Crossterm` type // 1: use the `Crossterm` type
let crossterm = Crossterm::new(); let crossterm = Crossterm::new();
let styled_object = crossterm.style("Red font on Black background").with(Color::Red).on(Color::Black); let styled_object = crossterm.style("Red text on Black background").with(Color::Red).on(Color::Black);
styled_object.paint(&screen); styled_object.paint(&screen);
// 2: use the `Terminal` type // 2: use the `Terminal` type
let styled_object = style("Red font on Black background").with(Color::Red).on(Color::Black); let styled_object = style("Red text on Black background").with(Color::Red).on(Color::Black);
styled_object.paint(&screen); styled_object.paint(&screen);
``` ```

View File

@ -9,14 +9,14 @@ Crossterm provides two ways to read user input, synchronous and asynchronous.
Read the input synchronously from the user, the reads performed will be blocking calls. Read the input synchronously from the user, the reads performed will be blocking calls.
Using synchronous over asynchronous reading has the benefit that it is using fewer resources than the asynchronous because background thread and queues are left away. Using synchronous over asynchronous reading has the benefit that it is using fewer resources than the asynchronous because background thread and queues are left away.
You can get an synchronous event reader by calling: `TerminalInput::read_sync`. You can get a synchronous event reader by calling: `TerminalInput::read_sync`.
### Asynchronous reading ### Asynchronous reading
Read the input asynchronously, input events are gathered on the background and will be queued for you to read. Read the input asynchronously, input events are gathered on the background and will be queued for you to read.
Using asynchronous reading has the benefit that input events are queued until you read them. You can poll for occurred events, and the reads won't block your program. Using asynchronous reading has the benefit that input events are queued until you read them. You can poll for occurred events, and the reads won't block your program.
You can get an synchronous event reader by calling: `TerminalInput::read_async`, `TerminalInput::read_async_until`. You can get a synchronous event reader by calling: `TerminalInput::read_async`, `TerminalInput::read_async_until`.
### Technical details ### Technical details
On UNIX systems crossterm reads from the TTY, on Windows, it uses `ReadConsoleInputW`. On UNIX systems crossterm reads from the TTY, on Windows, it uses `ReadConsoleInputW`.

View File

@ -1,6 +1,6 @@
# Styling Module # Styling Module
Crossterm provides options for you to style your font and terminal. Take for example coloring output and applying attributes. Crossterm provides options for you to style your text and terminal. Take for example coloring output and applying attributes.
**Color support** **Color support**
Windows systems with versions less than 10 will only have support for 16 colors and don't have any support for attributes. Most UNIX-terminal is supporting lots of colors and attributes. Windows systems with versions less than 10 will only have support for 16 colors and don't have any support for attributes. Most UNIX-terminal is supporting lots of colors and attributes.
@ -32,10 +32,10 @@ Crossterm implements almost all attributes shown in this [Wikipedia-list](https:
| Attribute | Support | Note | | Attribute | Support | Note |
| :-------------: | :-------------: | :-------------: | | :-------------: | :-------------: | :-------------: |
| Reset | Windows, UNIX | This will reset all current set attributes. | | Reset | Windows, UNIX | This will reset all current set attributes. |
| Bold | Windows, UNIX | This will increase the font sensitivity also known as bold. | | Bold | Windows, UNIX | This will increase the text sensitivity also known as bold. |
| Dim | Windows, UNIX | This will decrease the font sensitivity also known as bold. | | Dim | Windows, UNIX | This will decrease the text sensitivity also known as bold. |
| Italic | Not widely supported, sometimes treated as inverse. | This will make the font italic. | | Italic | Not widely supported, sometimes treated as inverse. | This will make the text italic. |
| Underlined | Windows, UNIX | An line under a word, especially in order to show its importance. | | Underlined | Windows, UNIX | A line under a word, especially in order to show its importance. |
| SlowBlink | Not widely supported, sometimes treated as inverse. | less than 150 per minute | | SlowBlink | Not widely supported, sometimes treated as inverse. | less than 150 per minute |
| RapidBlink | Not widely supported | MS-DOS ANSI.SYS; 150+ per minute; | | RapidBlink | Not widely supported | MS-DOS ANSI.SYS; 150+ per minute; |
| Reverse | Windows, UNIX | foreground and background colors | | Reverse | Windows, UNIX | foreground and background colors |
@ -43,9 +43,9 @@ Crossterm implements almost all attributes shown in this [Wikipedia-list](https:
| Fraktur | UNIX | characters legible, but marked for deletion. | | Fraktur | UNIX | characters legible, but marked for deletion. |
| DefaultForegroundColor | Unknown | Implementation defined (according to standard) | | DefaultForegroundColor | Unknown | Implementation defined (according to standard) |
| DefaultBackgroundColor | Unknown | Implementation defined (according to standard) | | DefaultBackgroundColor | Unknown | Implementation defined (according to standard) |
| Framed | Not widely supported | Framed font. | Framed | Not widely supported | Framed text.
| Encircled | Unknown | This will turn on the encircled attribute. | | Encircled | Unknown | This will turn on the encircled attribute. |
| OverLined | Unknown | This will draw a line at the top of the font. | | OverLined | Unknown | This will draw a line at the top of the text. |
(There are a few attributes who disable one of the above attributes, I did not write those down to keep the list short). (There are a few attributes who disable one of the above attributes, I did not write those down to keep the list short).

View File

@ -66,7 +66,7 @@ println!("{} some colored text", Colored::Fg(Color::AnsiValue(10)));
``` ```
## Attributes ## Attributes
When working with UNIX or Windows 10 terminals you could also use attributes to style your font. For example, you could cross your text with a line and make it bold. When working with UNIX or Windows 10 terminals you could also use attributes to style your text. For example, you could cross your text with a line and make it bold.
See [this](styling.md#Attributes) for more information. See [this](styling.md#Attributes) for more information.
### Using Enum ### Using Enum

View File

@ -12,7 +12,7 @@ pub fn main() {
let terminal = crossterm.terminal(); let terminal = crossterm.terminal();
let terminal = crossterm.input(); let terminal = crossterm.input();
let style = crossterm let style = crossterm
.style("Black font on green background") .style("Black text on green background")
.with(Color::Black) .with(Color::Black)
.on(Color::Green); .on(Color::Green);

View File

@ -1,5 +1,5 @@
//! //!
//! Examples of actions that could be performed with te cursor. //! Examples of actions that could be performed with the cursor.
//! //!
extern crate crossterm_cursor; extern crate crossterm_cursor;

View File

@ -1,4 +1,4 @@
This folder will contain some examples of how to use this crate in an real live environment. This folder will contain some examples of how to use this crate in a real live environment.
If you have created a game or something feel free to upload it, would be a great help for other people and me to make this crate better! If you have created a game or something feel free to upload it, would be a great help for other people and me to make this crate better!
@ -6,7 +6,7 @@ The programs are:
- First depth search: - First depth search:
This is an search algorithm implemented visually. This program uses the following functionalities: cursor movement, coloring, alternate screen and terminal clearing. This is a search algorithm implemented visually. This program uses the following functionalities: cursor movement, coloring, alternate screen and terminal clearing.
To run this use `cargo run` in the directory of first depth search. To run this use `cargo run` in the directory of first depth search.
- Snake - Snake
@ -20,5 +20,5 @@ The programs are:
- Logging: - Logging:
This is an async logging program to demonstrate asynchronous logging with an queue. This is an async logging program to demonstrate asynchronous logging with a queue.
To run this use `cargo run --example logging` To run this use `cargo run --example logging`

View File

@ -69,7 +69,7 @@ impl Map {
self.map[y][x].visited self.map[y][x].visited
} }
// change an position in the map to visited. // change a position in the map to visited.
pub fn set_visited(&mut self, x: usize, y: usize) { pub fn set_visited(&mut self, x: usize, y: usize) {
self.map[y][x].visited = true; self.map[y][x].visited = true;
} }

View File

@ -5,13 +5,13 @@ extern crate crossterm;
use self::crossterm::{color, Attribute, Color, Colored, Colorize, Styler}; use self::crossterm::{color, Attribute, Color, Colored, Colorize, Styler};
/// print some red font | demonstration. /// print some red text | demonstration.
pub fn paint_foreground() { pub fn paint_foreground() {
println!("{}", "Red foreground text: {}".red()); println!("{}", "Red foreground text: {}".red());
println!("{} Red foreground text", Colored::Fg(Color::Red)); println!("{} Red foreground text", Colored::Fg(Color::Red));
} }
/// print some font on red background | demonstration. /// print some text on red background | demonstration.
pub fn paint_background() { pub fn paint_background() {
println!("{}", "Red background text: {}".on_red()); println!("{}", "Red background text: {}".on_red());
println!("{} Red background text", Colored::Bg(Color::Red)); println!("{} Red background text", Colored::Bg(Color::Red));
@ -364,9 +364,9 @@ pub fn print_all_background_colors_with_method() {
); );
} }
/// Print font with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration.. /// Print text with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration..
#[cfg(unix)] #[cfg(unix)]
pub fn print_font_with_attributes() { pub fn print_text_with_attributes() {
println!("{}", "Normal text"); println!("{}", "Normal text");
println!("{}", "Bold text".bold()); println!("{}", "Bold text".bold());
println!("{}", "Italic text".italic()); println!("{}", "Italic text".italic());
@ -376,7 +376,7 @@ pub fn print_font_with_attributes() {
println!("{}", "Underlined text".underlined()); println!("{}", "Underlined text".underlined());
println!("{}", "Reversed text".reverse()); println!("{}", "Reversed text".reverse());
println!("{}", "Dim text".dim()); println!("{}", "Dim text".dim());
println!("{}", "Crossed out font".crossed_out()); println!("{}", "Crossed out text".crossed_out());
// ... // ...
println!( println!(
@ -387,9 +387,9 @@ pub fn print_font_with_attributes() {
// ... // ...
} }
// Print font with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration.. // Print text with all available attributes. Note that this can only be used at unix systems and that some are not supported widely | demonstration..
#[cfg(windows)] #[cfg(windows)]
pub fn print_font_with_attributes() { pub fn print_text_with_attributes() {
println!("{}", "Normal text"); println!("{}", "Normal text");
println!("{}", "Bold text".bold()); println!("{}", "Bold text".bold());
println!("{}", "Underlined text".underlined()); println!("{}", "Underlined text".underlined());

View File

@ -1,6 +1,6 @@
use std::fmt::Display; use std::fmt::Display;
/// This type offers a easy way to use functionalities like `cursor, terminal, color, input, styling`. /// This type offers an easy way to use functionalities like `cursor`, `terminal`, `color`, `input`, and `styling`.
/// ///
/// To get a cursor instance to perform cursor related actions, you can do the following: /// To get a cursor instance to perform cursor related actions, you can do the following:
/// ///
@ -11,7 +11,7 @@ use std::fmt::Display;
// let terminal = crossterm.terminal(); // let terminal = crossterm.terminal();
// let terminal = crossterm.input(); // let terminal = crossterm.input();
// let style = crossterm // let style = crossterm
// .style(format!("{} {}", 0, "Black font on green background")) // .style(format!("{} {}", 0, "Black text on green background"))
// .with(Color::Black) // .with(Color::Black)
// .on(Color::Green); // .on(Color::Green);
/// ``` /// ```
@ -82,7 +82,7 @@ impl Crossterm {
/// .with(Color::Blue) /// .with(Color::Blue)
/// .on(Color::Black); /// .on(Color::Black);
/// ///
/// // print the styled font * times to the current screen. /// // print the styled text * times to the current screen.
/// for i in 1..10 /// for i in 1..10
/// { /// {
/// println!("{}", styled_object); /// println!("{}", styled_object);