-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crossterm::style::Stylize; | ||
use cursive_core::views::{Dialog, LinearLayout, TextView}; | ||
|
||
fn main() { | ||
// Using the crossterm function for text styling and casting it to a string. | ||
let crossterm_colored = "Crossterm colored text.".red().to_string(); | ||
|
||
// Using this same function with another text, but parsing it as ANSI-decorated content. | ||
let cursive_colored = cursive::utils::markup::ansi::parse( | ||
"Cursive colored text (using Crossterm + ANSI)".red().to_string(), | ||
); | ||
|
||
// Minimal application for text output | ||
let mut siv = cursive::default(); | ||
siv.add_layer( | ||
Dialog::new() | ||
.content( | ||
LinearLayout::vertical() | ||
.child(TextView::new(crossterm_colored)) | ||
.child(TextView::new(cursive_colored)), | ||
) | ||
.button("Quit!", |s| s.quit()), | ||
); | ||
siv.run(); | ||
} |