Skip to content

Commit

Permalink
Rename tui package to ratatui
Browse files Browse the repository at this point in the history
  • Loading branch information
grtcdr committed Jun 28, 2023
1 parent 3114b61 commit 089c831
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dirs = "4.0.0"
toml = "0.5.10"
serde_json = "1.0.91"
thiserror = "1.0.38"
tui = { package = "ratatui", version = "0.20.1", default-features = false, features = ["crossterm"] }
ratatui = { version = "0.*", default-features = false, features = ["crossterm"] }
serde = { version = "1.0.152", features = ["derive"] }

[build-dependencies.vergen]
Expand Down
134 changes: 67 additions & 67 deletions src/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use io::Read;
use std::fs::File;
use std::io::{self, BufReader};
use std::path::Path;
use tui::style::{Color, Style};
use tui::text::{Span, Spans, Text};
use ratatui::style::{Color, Style};
use ratatui::text::{Span, Line, Text};

lazy_static! {
static ref BLUE: Style = Style::default().fg(Color::Blue);
Expand Down Expand Up @@ -106,8 +106,8 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {

vec![Text::from(
art.iter()
.map(|f| Spans::from(f.to_owned()))
.collect::<Vec<Spans>>(),
.map(|f| Line::from(f.to_owned()))
.collect::<Vec<Line>>(),
)]
}
AsciiSize::Small => {
Expand All @@ -124,8 +124,8 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {

vec![Text::from(
art.iter()
.map(|f| Spans::from(f.to_owned()))
.collect::<Vec<Spans>>(),
.map(|f| Line::from(f.to_owned()))
.collect::<Vec<Line>>(),
)]
}
}
Expand Down Expand Up @@ -153,8 +153,8 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {

vec![Text::from(
art.iter()
.map(|f| Spans::from(f.to_owned()))
.collect::<Vec<Spans>>(),
.map(|f| Line::from(f.to_owned()))
.collect::<Vec<Line>>(),
)]
}
AsciiSize::Small => {
Expand All @@ -169,8 +169,8 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {

vec![Text::from(
art.iter()
.map(|f| Spans::from(f.to_owned()))
.collect::<Vec<Spans>>(),
.map(|f| Line::from(f.to_owned()))
.collect::<Vec<Line>>(),
)]
}
}
Expand Down Expand Up @@ -201,8 +201,8 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {

vec![Text::from(
art.iter()
.map(|f| Spans::from(f.to_owned()))
.collect::<Vec<Spans>>(),
.map(|f| Line::from(f.to_owned()))
.collect::<Vec<Line>>(),
)]
}
AsciiSize::Small => {
Expand All @@ -218,8 +218,8 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {

vec![Text::from(
art.iter()
.map(|f| Spans::from(f.to_owned()))
.collect::<Vec<Spans>>(),
.map(|f| Line::from(f.to_owned()))
.collect::<Vec<Line>>(),
)]
}
}
Expand All @@ -230,72 +230,72 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {
pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {
match size {
AsciiSize::Big => {
let art: Vec<Spans> = vec![
Spans::from(vec![Span::styled(" a8888b.", *WHITE)]),
Spans::from(vec![Span::styled(" d888888b.", *WHITE)]),
Spans::from(vec![Span::styled(" 8P\"YP\"Y88", *WHITE)]),
Spans::from(vec![Span::styled(" 8|o||o|88", *WHITE)]),
Spans::from(vec![
let art: Vec<Line> = vec![
Line::from(vec![Span::styled(" a8888b.", *WHITE)]),
Line::from(vec![Span::styled(" d888888b.", *WHITE)]),
Line::from(vec![Span::styled(" 8P\"YP\"Y88", *WHITE)]),
Line::from(vec![Span::styled(" 8|o||o|88", *WHITE)]),
Line::from(vec![
Span::styled(" 8", *WHITE),
Span::styled("' .", *YELLOW),
Span::styled("88", *WHITE),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" 8", *WHITE),
Span::styled("`._.'", *YELLOW),
Span::styled(" Y8.", *WHITE),
]),
Spans::from(vec![Span::styled(" d/ `8b.", *WHITE)]),
Spans::from(vec![Span::styled(" dP Y8b.", *WHITE)]),
Spans::from(vec![Span::styled(" d8: ::88b.", *WHITE)]),
Spans::from(vec![Span::styled(" d8\" 'Y88b", *WHITE)]),
Spans::from(vec![Span::styled(" :8P :888", *WHITE)]),
Spans::from(vec![Span::styled(" 8a. _a88P", *WHITE)]),
Spans::from(vec![
Line::from(vec![Span::styled(" d/ `8b.", *WHITE)]),
Line::from(vec![Span::styled(" dP Y8b.", *WHITE)]),
Line::from(vec![Span::styled(" d8: ::88b.", *WHITE)]),
Line::from(vec![Span::styled(" d8\" 'Y88b", *WHITE)]),
Line::from(vec![Span::styled(" :8P :888", *WHITE)]),
Line::from(vec![Span::styled(" 8a. _a88P", *WHITE)]),
Line::from(vec![
Span::styled("._/\"Y", *YELLOW),
Span::styled("aa .", *WHITE),
Span::styled("|", *YELLOW),
Span::styled(" 88P", *WHITE),
Span::styled("|", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled("\\ Y", *YELLOW),
Span::styled("P\" `", *WHITE),
Span::styled("| `.", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled("/ \\", *YELLOW),
Span::styled(".___.d", *WHITE),
Span::styled("| .'", *YELLOW),
]),
Spans::from(vec![Span::styled("`--..__) `._.'", *YELLOW)]),
Line::from(vec![Span::styled("`--..__) `._.'", *YELLOW)]),
];

vec![Text::from(
art.iter().map(|f| f.to_owned()).collect::<Vec<Spans>>(),
art.iter().map(|f| f.to_owned()).collect::<Vec<Line>>(),
)]
}
AsciiSize::Small => {
// The following penguin ASCII art was found and
// taken from: https://asciiart.website/index.php
// Artist attribution missing.
// Thank you to whoever made it :^)
let art: Vec<Spans> = vec![
Spans::from(vec![Span::styled(" .--.", *WHITE)]),
Spans::from(vec![
let art: Vec<Line> = vec![
Line::from(vec![Span::styled(" .--.", *WHITE)]),
Line::from(vec![
Span::styled(" |o", *WHITE),
Span::styled("_", *YELLOW),
Span::styled("o |", *WHITE),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" |", *WHITE),
Span::styled("\\_/", *YELLOW),
Span::styled(" |", *WHITE),
]),
Spans::from(vec![Span::styled(" // \\ \\", *WHITE)]),
Spans::from(vec![Span::styled(" (| | )", *WHITE)]),
Spans::from(vec![Span::styled("/'\\_ _/`\\", *WHITE)]),
Spans::from(vec![Span::styled("\\___)=(___/", *WHITE)]),
Line::from(vec![Span::styled(" // \\ \\", *WHITE)]),
Line::from(vec![Span::styled(" (| | )", *WHITE)]),
Line::from(vec![Span::styled("/'\\_ _/`\\", *WHITE)]),
Line::from(vec![Span::styled("\\___)=(___/", *WHITE)]),
];

vec![Text::from(art)]
Expand All @@ -308,13 +308,13 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {
// The following ASCII art was made by Dylan Araps
// and taken from https://github.com/dylanaraps/pfetch

let art: Vec<Spans> = vec![
Spans::from(vec![Span::styled("/\\,-'''''-,/\\", *RED)]),
Spans::from(vec![Span::styled("\\_) (_//", *RED)]),
Spans::from(vec![Span::styled(" | |", *RED)]),
Spans::from(vec![Span::styled(" | |", *RED)]),
Spans::from(vec![Span::styled(" ; ;", *RED)]),
Spans::from(vec![Span::styled(" '-_____-'", *RED)]),
let art: Vec<Line> = vec![
Line::from(vec![Span::styled("/\\,-'''''-,/\\", *RED)]),
Line::from(vec![Span::styled("\\_) (_//", *RED)]),
Line::from(vec![Span::styled(" | |", *RED)]),
Line::from(vec![Span::styled(" | |", *RED)]),
Line::from(vec![Span::styled(" ; ;", *RED)]),
Line::from(vec![Span::styled(" '-_____-'", *RED)]),
];

vec![Text::from(art)]
Expand All @@ -324,53 +324,53 @@ pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {
pub(crate) fn get_ascii_art(size: AsciiSize) -> Vec<Text<'static>> {
match size {
AsciiSize::Big => {
let art: Vec<Spans> = vec![
Spans::from(vec![
let art: Vec<Line> = vec![
Line::from(vec![
Span::styled("\\\\", *WHITE),
Span::styled("`-______,----__", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" \\\\", *WHITE),
Span::styled(" __,---`.", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" \\\\", *WHITE),
Span::styled(" `.____", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" \\\\", *WHITE),
Span::styled("-______,----`.", *YELLOW),
]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Spans::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
Line::from(vec![Span::styled(" \\\\", *WHITE)]),
];

vec![Text::from(
art.iter().map(|f| f.to_owned()).collect::<Vec<Spans>>(),
art.iter().map(|f| f.to_owned()).collect::<Vec<Line>>(),
)]
}
AsciiSize::Small => {
let art: Vec<Spans> = vec![
Spans::from(vec![
let art: Vec<Line> = vec![
Line::from(vec![
Span::styled("()", *BLACK),
Span::styled("ncncncncncnc", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" \\\\", *BLACK),
Span::styled("ncncncnc", *YELLOW),
]),
Spans::from(vec![
Line::from(vec![
Span::styled(" \\\\", *BLACK),
Span::styled("ncncncncncn", *YELLOW),
]),
Spans::from(vec![Span::styled(" \\\\", *BLACK)]),
Spans::from(vec![Span::styled(" \\\\", *BLACK)]),
Spans::from(vec![Span::styled(" \\\\", *BLACK)]),
Line::from(vec![Span::styled(" \\\\", *BLACK)]),
Line::from(vec![Span::styled(" \\\\", *BLACK)]),
Line::from(vec![Span::styled(" \\\\", *BLACK)]),
];

vec![Text::from(art)]
Expand Down
10 changes: 5 additions & 5 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::widgets::readout::ReadoutList;
use atty::Stream;
use std::io;
use std::io::Stdout;
use tui::backend::{Backend, CrosstermBackend};
use tui::buffer::{Buffer, Cell};
use tui::layout::{Margin, Rect};
use tui::text::Text;
use tui::widgets::{Block, Borders, Paragraph, Widget};
use ratatui::backend::{Backend, CrosstermBackend};
use ratatui::buffer::{Buffer, Cell};
use ratatui::layout::{Margin, Rect};
use ratatui::text::Text;
use ratatui::widgets::{Block, Borders, Paragraph, Widget};
use unicode_width::UnicodeWidthStr;

pub fn create_backend() -> CrosstermBackend<Stdout> {
Expand Down
4 changes: 2 additions & 2 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use libmacchina::{BatteryReadout, GeneralReadout, KernelReadout, MemoryReadout,
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::fmt::Display;
use tui::style::{Color, Style};
use tui::text::{Span, Spans, Text};
use ratatui::style::{Color, Style};
use ratatui::text::{Span, Line, Text};

/// This enum contains all the possible keys, e.g. _Host_, _Machine_, _Kernel_, etc.
#[allow(clippy::upper_case_acronyms)]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod widgets;

use cli::{Opt, PKG_NAME};
use error::Result;
use tui::{backend::Backend, buffer::Buffer, layout::Rect};
use ratatui::{backend::Backend, buffer::Buffer, layout::Rect};

#[macro_use]
extern crate lazy_static;
Expand Down
2 changes: 1 addition & 1 deletion src/theme/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use dirs;
use serde::{Deserialize, Serialize};
use std::fmt;
use std::path::{Path, PathBuf};
use tui::style::Color;
use ratatui::style::Color;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
Expand Down
2 changes: 1 addition & 1 deletion src/theme/color.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rand::seq::SliceRandom;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use tui::style::Color;
use ratatui::style::Color;

#[derive(Debug, Clone)]
pub enum ColorTypes {
Expand Down
4 changes: 2 additions & 2 deletions src/theme/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::theme::color::*;
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use tui::style::Color;
use tui::widgets::BorderType;
use ratatui::style::Color;
use ratatui::widgets::BorderType;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Palette {
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/readout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::data::{Readout, ReadoutKey};
use crate::theme::components::{Palette, PaletteType};
use crate::theme::Theme;
use std::collections::HashMap;
use tui::buffer::Buffer;
use tui::layout::{Margin, Rect};
use tui::style::{Color, Style};
use tui::text::{Span, Spans, Text};
use tui::widgets::{Block, Paragraph, Widget};
use ratatui::buffer::Buffer;
use ratatui::layout::{Margin, Rect};
use ratatui::style::{Color, Style};
use ratatui::text::{Span, Line, Text};
use ratatui::widgets::{Block, Paragraph, Widget};

pub struct ReadoutList<'a> {
block: Option<Block<'a>>,
Expand Down

0 comments on commit 089c831

Please sign in to comment.