Active voice

This commit is contained in:
Andy Gauge 2018-10-02 15:38:41 -07:00
parent 2b29e72423
commit bb607c6069
2 changed files with 11 additions and 20 deletions

View file

@ -4,9 +4,9 @@
This program depicts the use of [`ansi_term` crate] and how it is used for controlling colours and formatting, such as blue bold text or yellow underlined text, on ANSI terminals.
There are two main data structures in this crate that our code needs to be concerned with: [`ANSIString`] and [`Style`]. A [`Style`] holds stylistic information: colours, whether the text should be bold, or blinking, or whatever. There are also Colour variants that represent simple foreground colour styles. An [`ANSIString`] is a string paired with a [`Style`].
There are two main data structures in [`ansi_term`]: [`ANSIString`] and [`Style`]. A [`Style`] holds stylistic information: colours, whether the text should be bold, or blinking, or whatever. There are also Colour variants that represent simple foreground colour styles. An [`ANSIString`] is a string paired with a [`Style`].
**Note:** British english uses *Colour* instead of *Color*, don't get confused
**Note:** British English uses *Colour* instead of *Color*, don't get confused
### Printing colored text to the Terminal
@ -23,21 +23,12 @@ fn main() {
}
```
#### Another way to print colored text to Terminal
The code can be reformatted such that it converts the [`ANSIString`] to a string as so any other `Display` value
```rust
extern crate ansi_term;
use ansi_term::Colour;
fn main() {
let blue_string = Colour::Blue.paint("Blue").to_string();
println!("This is {} color", blue_string);
}
```
### Bold text in Terminal
For anything more complex than plain foreground colour changes, the code needs to construct `Style` objects themselves, rather than beginning with a `Colour`. It can be achieved by chaining methods based on a new `Style`, created with [`Style::new()`]
For anything more complex than plain foreground colour changes, the code
needs to construct `Style` struct. [`Style::new()`] creates the struct,
and properties chained.
```rust
extern crate ansi_term;
@ -49,7 +40,8 @@ fn main() {
}
```
### Bold and colored text in terminal
`Bold` methods can also been implemented for `Colour` values, and can be done by giving `styles` a foreground colour without having to begin with an empty Style value
`Colour` returns a `Style`.
```rust
extern crate ansi_term;
@ -69,4 +61,4 @@ fn main(){
[`ansi_term` crate]: https://crates.io/crates/ansi_term
[`ANSIString`]: https://docs.rs/ansi_term/*/ansi_term/type.ANSIString.html
[`Style`]: https://docs.rs/ansi_term/*/ansi_term/struct.Style.html
[`Style::new()`]: https://docs.rs/ansi_term/0.11.0/ansi_term/struct.Style.html#method.new
[`Style::new()`]: https://docs.rs/ansi_term/0.11.0/ansi_term/struct.Style.html#method.new

View file

@ -5,8 +5,7 @@
Uses [`reqwest::Client::head`] to get the [Content-Length] of the response.
The code then uses [`reqwest::Client::get`] to download the content in
chunks of 10240 bytes, while printing progress messages. The requested
ranges are specified using with the [Range] header.
chunks of 10240 bytes, while printing progress messages. The [Range] header specifies the chunk size and position.
The Range header is defined in [RFC7233][HTTP Range RFC7233].