Switch usages of ContentStyle to Style

This commit is contained in:
Joscha 2023-02-16 21:24:52 +01:00
parent 4c304ffe79
commit 9ff8007cae
8 changed files with 48 additions and 61 deletions

View file

@ -1,18 +1,12 @@
use crossterm::event::Event;
use crossterm::style::{ContentStyle, Stylize};
use toss::{Frame, Pos, Terminal};
use crossterm::style::Stylize;
use toss::{Frame, Pos, Style, Terminal};
fn draw(f: &mut Frame) {
f.write(
Pos::new(0, 0),
("Hello world!", ContentStyle::default().green()),
);
f.write(Pos::new(0, 0), ("Hello world!", Style::new().green()));
f.write(
Pos::new(0, 1),
(
"Press any key to exit",
ContentStyle::default().on_dark_blue(),
),
("Press any key to exit", Style::new().on_dark_blue()),
);
f.show_cursor(Pos::new(16, 0));
}

View file

@ -1,25 +1,22 @@
use std::convert::Infallible;
use crossterm::event::Event;
use crossterm::style::{ContentStyle, Stylize};
use crossterm::style::Stylize;
use toss::widgets::{BorderLook, Text};
use toss::{Styled, Terminal, Widget, WidgetExt};
use toss::{Style, Styled, Terminal, Widget, WidgetExt};
fn widget() -> impl Widget<Infallible> {
let styled = Styled::new("Hello world!", ContentStyle::default().green())
let styled = Styled::new("Hello world!", Style::new().green())
.then_plain("\n")
.then(
"Press any key to exit",
ContentStyle::default().on_dark_blue(),
);
.then("Press any key to exit", Style::new().on_dark_blue());
Text::new(styled)
.padding()
.horizontal(1)
.border()
.look(BorderLook::LINE_DOUBLE)
.style(ContentStyle::default().dark_red())
.style(Style::new().dark_red())
.background()
.style(ContentStyle::default().on_dark_yellow())
.style(Style::new().on_dark_yellow().opaque())
.float()
.all(0.5)
}

View file

@ -1,14 +1,14 @@
use crossterm::event::Event;
use crossterm::style::{ContentStyle, Stylize};
use toss::{Frame, Pos, Terminal};
use crossterm::style::Stylize;
use toss::{Frame, Pos, Style, Terminal};
fn draw(f: &mut Frame) {
f.write(
Pos::new(0, 0),
"Writing over wide graphemes removes the entire overwritten grapheme.",
);
let under = ContentStyle::default().white().on_dark_blue();
let over = ContentStyle::default().black().on_dark_yellow();
let under = Style::new().white().on_dark_blue();
let over = Style::new().black().on_dark_yellow();
for i in 0..6 {
let delta = i - 2;
f.write(Pos::new(2 + i * 7, 2), ("a😀", under));