From b833389cd5651b260f32a1adf908b68ebaa2c088 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:53:01 -0400 Subject: [PATCH] Bump tui-tree-widget from 0.12.0 to 0.13.0 (#4073) Bumps [tui-tree-widget](https://github.com/EdJoPaTo/tui-rs-tree-widget) from 0.12.0 to 0.13.0.
Release notes

Sourced from tui-tree-widget's releases.

v0.13.0

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tui-tree-widget&package-manager=cargo&previous-version=0.12.0&new-version=0.13.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Adam H. Leventhal --- Cargo.lock | 62 +++++++------ Cargo.toml | 2 +- wicket-dbg/Cargo.toml | 2 +- wicket/Cargo.toml | 4 +- wicket/README.md | 4 +- wicket/src/runner.rs | 6 +- wicket/src/state/inventory.rs | 2 +- wicket/src/state/status.rs | 4 +- wicket/src/state/update.rs | 2 +- wicket/src/ui/controls/mod.rs | 4 +- wicket/src/ui/defaults/colors.rs | 2 +- wicket/src/ui/defaults/dimensions.rs | 2 +- wicket/src/ui/defaults/style.rs | 6 +- wicket/src/ui/main.rs | 12 +-- wicket/src/ui/mod.rs | 2 +- wicket/src/ui/panes/mod.rs | 16 ++-- wicket/src/ui/panes/overview.rs | 22 ++--- wicket/src/ui/panes/rack_setup.rs | 121 ++++++++++++------------- wicket/src/ui/panes/update.rs | 114 +++++++++++------------ wicket/src/ui/splash.rs | 4 +- wicket/src/ui/widgets/animated_logo.rs | 8 +- wicket/src/ui/widgets/banner.rs | 8 +- wicket/src/ui/widgets/box_connector.rs | 6 +- wicket/src/ui/widgets/fade.rs | 6 +- wicket/src/ui/widgets/ignition.rs | 14 +-- wicket/src/ui/widgets/popup.rs | 26 +++--- wicket/src/ui/widgets/rack.rs | 20 ++-- wicket/src/ui/widgets/status_view.rs | 2 +- wicket/src/ui/wrap.rs | 34 +++---- 29 files changed, 263 insertions(+), 254 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec530af7b9..2fdadbe0ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1334,15 +1334,17 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.25.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" dependencies = [ "bitflags 1.3.2", "crossterm_winapi", + "futures-core", "libc", "mio", "parking_lot 0.12.1", + "serde", "signal-hook", "signal-hook-mio", "winapi", @@ -1350,17 +1352,15 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.26.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "crossterm_winapi", - "futures-core", "libc", "mio", "parking_lot 0.12.1", - "serde", "signal-hook", "signal-hook-mio", "winapi", @@ -3411,6 +3411,12 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" +[[package]] +name = "indoc" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" + [[package]] name = "inout" version = "0.1.3" @@ -5948,7 +5954,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3833746ee893099f2dff25267b8210394b63983525edb2fe5374bccfb2f77eb" dependencies = [ - "indoc", + "indoc 1.0.9", "js-sys", "lalrpop", "lalrpop-util", @@ -6550,6 +6556,23 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "ratatui" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" +dependencies = [ + "bitflags 2.4.0", + "cassowary", + "crossterm 0.27.0", + "indoc 2.0.3", + "itertools 0.11.0", + "paste", + "strum 0.25.0", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "rayon" version = "1.7.0" @@ -8956,26 +8979,13 @@ dependencies = [ "zip", ] -[[package]] -name = "tui" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" -dependencies = [ - "bitflags 1.3.2", - "cassowary", - "crossterm 0.25.0", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "tui-tree-widget" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af6ca306e86e263aa6dede6305d7d305dea942bde622d4f4910782434d0b98cb" +checksum = "f01f9172fb8f4f925fb1e259c2f411be14af031ab8b35d517fd05cb78c0784d5" dependencies = [ - "tui", + "ratatui", "unicode-width", ] @@ -9561,6 +9571,7 @@ dependencies = [ "once_cell", "owo-colors", "proptest", + "ratatui", "reqwest", "rpassword", "semver 1.0.18", @@ -9577,7 +9588,6 @@ dependencies = [ "tokio-util", "toml 0.7.6", "toml_edit", - "tui", "tui-tree-widget", "unicode-width", "update-engine", @@ -9610,6 +9620,7 @@ dependencies = [ "ciborium", "clap 4.4.2", "crossterm 0.26.1", + "ratatui", "reedline", "serde", "slog", @@ -9617,7 +9628,6 @@ dependencies = [ "slog-envlogger", "slog-term", "tokio", - "tui", "wicket", ] diff --git a/Cargo.toml b/Cargo.toml index 0128ee1f57..e4523e350b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -277,6 +277,7 @@ propolis-server = { git = "https://github.com/oxidecomputer/propolis", rev = "de proptest = "1.2.0" quote = "1.0" rand = "0.8.5" +ratatui = "0.23.0" rayon = "1.7" rcgen = "0.10.0" ref-cast = "1.0" @@ -354,7 +355,6 @@ trust-dns-server = "0.22" trybuild = "1.0.84" tufaceous = { path = "tufaceous" } tufaceous-lib = { path = "tufaceous-lib" } -tui = "0.19.0" unicode-width = "0.1.10" update-engine = { path = "update-engine" } uuid = { version = "1.4.1", features = ["serde", "v4"] } diff --git a/wicket-dbg/Cargo.toml b/wicket-dbg/Cargo.toml index 88c916ad7b..1aa8e10171 100644 --- a/wicket-dbg/Cargo.toml +++ b/wicket-dbg/Cargo.toml @@ -11,13 +11,13 @@ camino.workspace = true ciborium.workspace = true clap.workspace = true crossterm.workspace = true +ratatui.workspace = true serde.workspace = true slog.workspace = true slog-async.workspace = true slog-term.workspace = true slog-envlogger.workspace = true tokio = { workspace = true, features = ["full"] } -tui.workspace = true wicket.workspace = true # used only by wicket-dbg binary diff --git a/wicket/Cargo.toml b/wicket/Cargo.toml index 67123f2d65..d2004e0a68 100644 --- a/wicket/Cargo.toml +++ b/wicket/Cargo.toml @@ -22,6 +22,7 @@ itertools.workspace = true omicron-common.workspace = true once_cell.workspace = true owo-colors.workspace = true +ratatui.workspace = true reqwest.workspace = true rpassword.workspace = true semver.workspace = true @@ -37,8 +38,7 @@ tokio = { workspace = true, features = ["full"] } tokio-util.workspace = true toml.workspace = true toml_edit.workspace = true -tui.workspace = true -tui-tree-widget = "0.12.0" +tui-tree-widget = "0.13.0" unicode-width.workspace = true zeroize.workspace = true diff --git a/wicket/README.md b/wicket/README.md index 5e7fbdc479..8735e5f5c5 100644 --- a/wicket/README.md +++ b/wicket/README.md @@ -75,9 +75,9 @@ upon event receipt, and that a screen never processes an event that can mutate the global state and render in the same method. However, due to the stateful rendering model of `tui.rs`, we do allow `Controls` to mutate their internal state when executing the `draw` method. This allows reuse of `tui.rs` stateful -widgets like `list`. `Controls` create `tui::widget::Widgets` on demand during +widgets like `list`. `Controls` create `ratatui::widget::Widgets` on demand during rendering, which themselves display to a given subset of the terminal, known -as a `tui::layout::Rect`. If necessary, custom `Widgets` can be created, as +as a `ratatui::layout::Rect`. If necessary, custom `Widgets` can be created, as we have done with the `Rack` and `BoxConnector` widgets. Custom widgets can be found in `src/ui/widgets`. diff --git a/wicket/src/runner.rs b/wicket/src/runner.rs index 21282e759d..c37b16d5d9 100644 --- a/wicket/src/runner.rs +++ b/wicket/src/runner.rs @@ -13,6 +13,8 @@ use crossterm::terminal::{ LeaveAlternateScreen, }; use futures::StreamExt; +use ratatui::backend::CrosstermBackend; +use ratatui::Terminal; use slog::Logger; use slog::{debug, error, info}; use std::env::VarError; @@ -23,8 +25,6 @@ use tokio::sync::mpsc::{ unbounded_channel, UnboundedReceiver, UnboundedSender, }; use tokio::time::{interval, Duration}; -use tui::backend::CrosstermBackend; -use tui::Terminal; use wicketd_client::types::AbortUpdateOptions; use wicketd_client::types::ClearUpdateStateOptions; use wicketd_client::types::StartUpdateOptions; @@ -38,7 +38,7 @@ use crate::{Action, Cmd, Event, KeyHandler, Recorder, State, TICK_INTERVAL}; // We can avoid a bunch of unnecessary type parameters by picking them ahead of time. pub type Term = Terminal>; -pub type Frame<'a> = tui::Frame<'a, CrosstermBackend>; +pub type Frame<'a> = ratatui::Frame<'a, CrosstermBackend>; const MAX_RECORDED_EVENTS: usize = 10000; diff --git a/wicket/src/state/inventory.rs b/wicket/src/state/inventory.rs index 7de9c795da..02019898e8 100644 --- a/wicket/src/state/inventory.rs +++ b/wicket/src/state/inventory.rs @@ -6,11 +6,11 @@ use anyhow::anyhow; use once_cell::sync::Lazy; +use ratatui::text::Text; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fmt::Display; use std::iter::Iterator; -use tui::text::Text; use wicketd_client::types::{ RackV1Inventory, RotInventory, RotSlot, SpComponentCaboose, SpComponentInfo, SpIgnition, SpState, SpType, diff --git a/wicket/src/state/status.rs b/wicket/src/state/status.rs index b5a5e7f6c2..aa6fd001b7 100644 --- a/wicket/src/state/status.rs +++ b/wicket/src/state/status.rs @@ -8,10 +8,10 @@ //! through wicketd. use crate::ui::defaults::style; +use ratatui::style::Style; +use ratatui::text::Span; use serde::{Deserialize, Serialize}; use std::time::Duration; -use tui::style::Style; -use tui::text::Span; // This should be greater than the highest poll value for each service const LIVENESS_THRESHOLD: Duration = Duration::from_secs(30); diff --git a/wicket/src/state/update.rs b/wicket/src/state/update.rs index 6536184217..1a0aafb9cf 100644 --- a/wicket/src/state/update.rs +++ b/wicket/src/state/update.rs @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -use tui::style::Style; +use ratatui::style::Style; use wicket_common::update_events::{ EventReport, ProgressEventKind, StepEventKind, UpdateComponent, UpdateStepId, diff --git a/wicket/src/ui/controls/mod.rs b/wicket/src/ui/controls/mod.rs index 61dfd3c679..4305fb5809 100644 --- a/wicket/src/ui/controls/mod.rs +++ b/wicket/src/ui/controls/mod.rs @@ -3,10 +3,10 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. use crate::{Action, Cmd, Frame, State}; -use tui::layout::Rect; +use ratatui::layout::Rect; /// A [`Control`] is the an item on a screen that can be selected and interacted with. -/// Control's render [`tui::widgets::Widget`]s when drawn. +/// Control's render [`ratatui::widgets::Widget`]s when drawn. /// /// /// Due to the rendering model of stateful widgets in `tui.rs`, `self` must diff --git a/wicket/src/ui/defaults/colors.rs b/wicket/src/ui/defaults/colors.rs index 1dda0d5648..e273e146a3 100644 --- a/wicket/src/ui/defaults/colors.rs +++ b/wicket/src/ui/defaults/colors.rs @@ -6,7 +6,7 @@ //! //! Thanks for the idea JMC! -use tui::style::Color; +use ratatui::style::Color; pub const OX_YELLOW: Color = Color::Rgb(0xF5, 0xCF, 0x65); pub const OX_OFF_WHITE: Color = Color::Rgb(0xE0, 0xE0, 0xE0); diff --git a/wicket/src/ui/defaults/dimensions.rs b/wicket/src/ui/defaults/dimensions.rs index 4be230d85b..ca76807786 100644 --- a/wicket/src/ui/defaults/dimensions.rs +++ b/wicket/src/ui/defaults/dimensions.rs @@ -4,7 +4,7 @@ //! Default dimensions for various widgets common across screens -use tui::layout::Rect; +use ratatui::layout::Rect; // Extension trait for Rects that provide centering and placement capabilities pub trait RectExt { diff --git a/wicket/src/ui/defaults/style.rs b/wicket/src/ui/defaults/style.rs index 289afb2660..46badf5bdb 100644 --- a/wicket/src/ui/defaults/style.rs +++ b/wicket/src/ui/defaults/style.rs @@ -5,9 +5,9 @@ //! Default consistent styling for various widgets use super::colors::*; -use tui::style::Color; -use tui::style::Modifier; -use tui::style::Style; +use ratatui::style::Color; +use ratatui::style::Modifier; +use ratatui::style::Style; pub fn selected() -> Style { Style::default().fg(TUI_GREEN) diff --git a/wicket/src/ui/main.rs b/wicket/src/ui/main.rs index 67548b778e..42cc6bf587 100644 --- a/wicket/src/ui/main.rs +++ b/wicket/src/ui/main.rs @@ -9,11 +9,11 @@ use crate::ui::defaults::colors::*; use crate::ui::defaults::style; use crate::ui::widgets::Fade; use crate::{Action, Cmd, Frame, State, Term}; +use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect}; +use ratatui::style::{Modifier, Style}; +use ratatui::text::{Line, Span}; +use ratatui::widgets::{Block, BorderType, Borders, List, ListItem, Paragraph}; use slog::{o, Logger}; -use tui::layout::{Alignment, Constraint, Direction, Layout, Rect}; -use tui::style::{Modifier, Style}; -use tui::text::{Span, Spans}; -use tui::widgets::{Block, BorderType, Borders, List, ListItem, Paragraph}; use wicketd_client::types::GetLocationResponse; /// The [`MainScreen`] is the primary UI element of the terminal, covers the @@ -204,7 +204,7 @@ impl MainScreen { spans.push(Span::styled(" | ", style::divider())); spans.push(Span::styled("MGS: ", style::service())); spans.extend_from_slice(&mgs_spans); - let main = Paragraph::new(Spans::from(spans)); + let main = Paragraph::new(Line::from(spans)); frame.render_widget(main, rect); let system_version = state @@ -213,7 +213,7 @@ impl MainScreen { .as_ref() .map_or_else(|| "UNKNOWN".to_string(), |v| v.to_string()); - let test = Paragraph::new(Spans::from(vec![ + let test = Paragraph::new(Line::from(vec![ Span::styled( "UPDATE VERSION: ", Style::default().fg(TUI_GREEN_DARK), diff --git a/wicket/src/ui/mod.rs b/wicket/src/ui/mod.rs index 6ab3be8146..1430a67659 100644 --- a/wicket/src/ui/mod.rs +++ b/wicket/src/ui/mod.rs @@ -11,8 +11,8 @@ mod widgets; mod wrap; use crate::{Action, Cmd, State, Term}; +use ratatui::widgets::ListState; use slog::{o, Logger}; -use tui::widgets::ListState; use main::MainScreen; use splash::SplashScreen; diff --git a/wicket/src/ui/panes/mod.rs b/wicket/src/ui/panes/mod.rs index 0bce598795..42cb205d50 100644 --- a/wicket/src/ui/panes/mod.rs +++ b/wicket/src/ui/panes/mod.rs @@ -11,9 +11,9 @@ use crate::ui::defaults::style; use crate::Cmd; pub use overview::OverviewPane; pub use rack_setup::RackSetupPane; -use tui::layout::{Constraint, Direction, Layout, Rect}; -use tui::text::{Span, Spans, Text}; -use tui::widgets::Paragraph; +use ratatui::layout::{Constraint, Direction, Layout, Rect}; +use ratatui::text::{Line, Span, Text}; +use ratatui::widgets::Paragraph; pub use update::UpdatePane; /// Generate one line of text for the help bar in panes @@ -26,16 +26,16 @@ pub fn help_text<'a>(data: &'a [(&'a str, &'a str)]) -> Paragraph<'a> { text.push(Span::styled(" | ", style::divider())); } text.pop(); - Paragraph::new(Spans::from(text)) + Paragraph::new(Line::from(text)) } -/// Split up a text into lines and push them into a `Spans` one at a time. +/// Split up a text into lines and push them into a `Line` one at a time. /// /// This makes text wrapping offsets work correctly. pub fn push_text_lines<'a>( message: &str, prefix: Vec>, - spans: &mut Vec>, + spans: &mut Vec>, ) { // If the message has multiple lines of text, split them // into separate spans. This makes text wrapping offsets @@ -43,7 +43,7 @@ pub fn push_text_lines<'a>( let mut next_line = prefix; for line in message.lines() { next_line.push(Span::styled(line.to_owned(), style::plain_text())); - spans.push(Spans::from(next_line)); + spans.push(Line::from(next_line)); next_line = Vec::new(); } } @@ -73,7 +73,7 @@ pub fn align_by( text.push(span); text.push(Span::raw(format!("{:spaces$}", ""))); } - Text::from(Spans::from(text)) + Text::from(Line::from(text)) } /// A pending scroll command. diff --git a/wicket/src/ui/panes/overview.rs b/wicket/src/ui/panes/overview.rs index 6a95d68516..b7a04c055d 100644 --- a/wicket/src/ui/panes/overview.rs +++ b/wicket/src/ui/panes/overview.rs @@ -17,10 +17,10 @@ use crate::ui::widgets::IgnitionPopup; use crate::ui::widgets::{BoxConnector, BoxConnectorKind, Rack}; use crate::ui::wrap::wrap_text; use crate::{Action, Cmd, Frame, State}; -use tui::layout::{Constraint, Direction, Layout, Rect}; -use tui::style::Style; -use tui::text::{Span, Spans, Text}; -use tui::widgets::{Block, BorderType, Borders, Paragraph}; +use ratatui::layout::{Constraint, Direction, Layout, Rect}; +use ratatui::style::Style; +use ratatui::text::{Line, Span, Text}; +use ratatui::widgets::{Block, BorderType, Borders, Paragraph}; use wicketd_client::types::RotState; use wicketd_client::types::SpComponentCaboose; use wicketd_client::types::SpComponentInfo; @@ -169,7 +169,7 @@ impl Control for RackView { .style(border_style); // Draw the sled title (subview look) - let title_bar = Paragraph::new(Spans::from(vec![Span::styled( + let title_bar = Paragraph::new(Line::from(vec![Span::styled( "OXIDE RACK", component_style, )])) @@ -340,7 +340,7 @@ impl Control for InventoryView { .style(border_style); // Draw the sled title (subview look) - let title_bar = Paragraph::new(Spans::from(vec![ + let title_bar = Paragraph::new(Line::from(vec![ Span::styled("OXIDE RACK / ", border_style), Span::styled( state.rack_state.selected.to_string(), @@ -466,7 +466,7 @@ fn inventory_description(component: &Component) -> Text { let bullet = || Span::styled(" • ", label_style); let nest_bullet = || Span::styled(" • ", label_style); - let mut spans: Vec = Vec::new(); + let mut spans: Vec = Vec::new(); // Describe ignition. let mut label = vec![Span::styled("Ignition: ", label_style)]; @@ -559,7 +559,7 @@ fn inventory_description(component: &Component) -> Text { } // blank line separator - spans.push(Spans::default()); + spans.push(Line::default()); // Describe the SP. let mut label = vec![Span::styled("Service Processor: ", label_style)]; @@ -668,7 +668,7 @@ fn inventory_description(component: &Component) -> Text { } // blank line separator - spans.push(Spans::default()); + spans.push(Line::default()); // Describe the RoT. let mut label = vec![Span::styled("Root of Trust: ", label_style)]; @@ -818,7 +818,7 @@ fn inventory_description(component: &Component) -> Text { } // blank line separator - spans.push(Spans::default()); + spans.push(Line::default()); // Describe all components. // TODO-correctness: component information will change with the IPCC / @@ -872,7 +872,7 @@ fn inventory_description(component: &Component) -> Text { // Helper function for appending caboose details to a section of the // inventory (used for both SP and RoT above). fn append_caboose( - spans: &mut Vec, + spans: &mut Vec, prefix: Span<'static>, caboose: &SpComponentCaboose, ) { diff --git a/wicket/src/ui/panes/rack_setup.rs b/wicket/src/ui/panes/rack_setup.rs index e670aeba82..212ddff4da 100644 --- a/wicket/src/ui/panes/rack_setup.rs +++ b/wicket/src/ui/panes/rack_setup.rs @@ -18,18 +18,18 @@ use crate::Cmd; use crate::Control; use crate::Frame; use crate::State; +use ratatui::layout::Constraint; +use ratatui::layout::Direction; +use ratatui::layout::Layout; +use ratatui::layout::Rect; +use ratatui::text::Line; +use ratatui::text::Span; +use ratatui::text::Text; +use ratatui::widgets::Block; +use ratatui::widgets::BorderType; +use ratatui::widgets::Borders; +use ratatui::widgets::Paragraph; use std::borrow::Cow; -use tui::layout::Constraint; -use tui::layout::Direction; -use tui::layout::Layout; -use tui::layout::Rect; -use tui::text::Span; -use tui::text::Spans; -use tui::text::Text; -use tui::widgets::Block; -use tui::widgets::BorderType; -use tui::widgets::Borders; -use tui::widgets::Paragraph; use wicketd_client::types::Baseboard; use wicketd_client::types::CurrentRssUserConfig; use wicketd_client::types::IpRange; @@ -204,11 +204,11 @@ fn draw_rack_setup_popup( match kind { PopupKind::Prompting => { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Start Rack Setup", style::header(true), )]); - let body = Text::from(vec![Spans::from(vec![Span::styled( + let body = Text::from(vec![Line::from(vec![Span::styled( "Would you like to begin rack setup?", style::plain_text(), )])]); @@ -220,11 +220,11 @@ fn draw_rack_setup_popup( frame.render_widget(popup, full_screen); } PopupKind::Waiting => { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Start Rack Setup", style::header(true), )]); - let body = Text::from(vec![Spans::from(vec![Span::styled( + let body = Text::from(vec![Line::from(vec![Span::styled( "Waiting for rack setup to start", style::plain_text(), )])]); @@ -235,7 +235,7 @@ fn draw_rack_setup_popup( frame.render_widget(popup, full_screen); } PopupKind::Failed { message, scroll_offset } => { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Start Rack Setup Failed", style::failed_update(), )]); @@ -268,11 +268,11 @@ fn draw_rack_reset_popup( match kind { PopupKind::Prompting => { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Rack Reset (DESTRUCTIVE!)", style::header(true), )]); - let body = Text::from(vec![Spans::from(vec![Span::styled( + let body = Text::from(vec![Line::from(vec![Span::styled( "Would you like to reset the rack to an uninitialized state?", style::plain_text(), )])]); @@ -284,11 +284,11 @@ fn draw_rack_reset_popup( frame.render_widget(popup, full_screen); } PopupKind::Waiting => { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Rack Reset", style::header(true), )]); - let body = Text::from(vec![Spans::from(vec![Span::styled( + let body = Text::from(vec![Line::from(vec![Span::styled( "Waiting for rack reset to start", style::plain_text(), )])]); @@ -299,7 +299,7 @@ fn draw_rack_reset_popup( frame.render_widget(popup, full_screen); } PopupKind::Failed { message, scroll_offset } => { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Rack Reset Failed", style::failed_update(), )]); @@ -323,7 +323,7 @@ fn draw_rack_status_details_popup( frame: &mut Frame<'_>, scroll_offset: &mut PopupScrollOffset, ) { - let header = Spans::from(vec![Span::styled( + let header = Line::from(vec![Span::styled( "Current Rack Setup Status", style::header(true), )]); @@ -334,93 +334,93 @@ fn draw_rack_status_details_popup( let prefix = vec![Span::styled("Message: ", style::selected())]; match state.rack_setup_state.as_ref() { Ok(RackOperationStatus::Uninitialized { reset_id }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Uninitialized", style::plain_text()), ])); if let Some(id) = reset_id { - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Last reset operation ID: {}", id.0), style::plain_text(), )])); } } Ok(RackOperationStatus::Initialized { id }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Initialized", style::plain_text()), ])); if let Some(id) = id { - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Last initialization operation ID: {}", id.0), style::plain_text(), )])); } } Ok(RackOperationStatus::InitializationFailed { id, message }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Initialization Failed", style::plain_text()), ])); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Last initialization operation ID: {}", id.0), style::plain_text(), )])); push_text_lines(message, prefix, &mut body.lines); } Ok(RackOperationStatus::InitializationPanicked { id }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Initialization Panicked", style::plain_text()), ])); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Last initialization operation ID: {}", id.0), style::plain_text(), )])); } Ok(RackOperationStatus::ResetFailed { id, message }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Reset Failed", style::plain_text()), ])); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Last reset operation ID: {}", id.0), style::plain_text(), )])); push_text_lines(message, prefix, &mut body.lines); } Ok(RackOperationStatus::ResetPanicked { id }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Reset Panicked", style::plain_text()), ])); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Last reset operation ID: {}", id.0), style::plain_text(), )])); } Ok(RackOperationStatus::Initializing { id }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Initializing", style::plain_text()), ])); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Current operation ID: {}", id.0), style::plain_text(), )])); } Ok(RackOperationStatus::Resetting { id }) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled("Resetting", style::plain_text()), ])); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( format!("Current operation ID: {}", id.0), style::plain_text(), )])); } Err(message) => { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ status, Span::styled( "Unknown (request to wicketd failed)", @@ -481,7 +481,7 @@ impl Control for RackSetupPane { &mut self, state: &State, frame: &mut Frame<'_>, - rect: tui::layout::Rect, + rect: ratatui::layout::Rect, active: bool, ) { let chunks = Layout::default() @@ -505,7 +505,7 @@ impl Control for RackSetupPane { .style(border_style); // Draw the screen title (subview look) - let title_bar = Paragraph::new(Spans::from(vec![Span::styled( + let title_bar = Paragraph::new(Line::from(vec![Span::styled( "Oxide Rack Setup", border_style, )])) @@ -618,11 +618,11 @@ fn rss_config_text<'a>( }; let mut spans = vec![ - Spans::from(vec![ + Line::from(vec![ Span::styled("Current rack status: ", label_style), setup_description, ]), - Spans::default(), + Line::default(), ]; let Some(config) = config else { @@ -634,14 +634,14 @@ fn rss_config_text<'a>( // Special single-line values, where we convert some kind of condition into // a user-appropriate string. - spans.push(Spans::from(vec![ + spans.push(Line::from(vec![ Span::styled("Uploaded cert/key pairs: ", label_style), Span::styled( sensitive.num_external_certificates.to_string(), dyn_style(sensitive.num_external_certificates > 0), ), ])); - spans.push(Spans::from(vec![ + spans.push(Line::from(vec![ Span::styled("Recovery password set: ", label_style), dyn_span(sensitive.recovery_silo_password_set, "Yes", "No"), ])); @@ -666,7 +666,7 @@ fn rss_config_text<'a>( .map_or("".into(), |c| c.infra_ip_last.to_string().into()), ), ] { - spans.push(Spans::from(vec![ + spans.push(Line::from(vec![ Span::styled(label, label_style), dyn_span(!contents.is_empty(), contents, "Not set"), ])); @@ -674,21 +674,20 @@ fn rss_config_text<'a>( // Helper function for multivalued items: we either print "None" (in // bad_style) if there are no items, or return a the list of spans. - let append_list = - |spans: &mut Vec, label_str, items: Vec>>| { - let label = Span::styled(label_str, label_style); - if items.is_empty() { - spans.push(Spans::from(vec![ - label, - Span::styled("None", bad_style), - ])); - } else { - spans.push(label.into()); - for item in items { - spans.push(Spans::from(item)); - } + let append_list = |spans: &mut Vec, + label_str, + items: Vec>>| { + let label = Span::styled(label_str, label_style); + if items.is_empty() { + spans + .push(Line::from(vec![label, Span::styled("None", bad_style)])); + } else { + spans.push(label.into()); + for item in items { + spans.push(Line::from(item)); } - }; + } + }; // Helper function to created a bulleted item for a single value. let plain_list_item = |item: String| { @@ -819,7 +818,7 @@ fn rss_config_text<'a>( ); // Add a "trailing newline" for scrolling to work correctly. - spans.push(Spans::default()); + spans.push(Line::default()); Text::from(spans) } diff --git a/wicket/src/ui/panes/update.rs b/wicket/src/ui/panes/update.rs index 4f0930554f..ea68cb4a16 100644 --- a/wicket/src/ui/panes/update.rs +++ b/wicket/src/ui/panes/update.rs @@ -20,13 +20,13 @@ use crate::ui::wrap::wrap_text; use crate::{Action, Cmd, Frame, State}; use indexmap::IndexMap; use omicron_common::api::internal::nexus::KnownArtifactKind; -use slog::{info, o, Logger}; -use tui::layout::{Alignment, Constraint, Direction, Layout, Rect}; -use tui::text::{Span, Spans, Text}; -use tui::widgets::{ +use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect}; +use ratatui::text::{Line, Span, Text}; +use ratatui::widgets::{ Block, BorderType, Borders, Cell, List, ListItem, ListState, Paragraph, Row, Table, }; +use slog::{info, o, Logger}; use tui_tree_widget::{Tree, TreeItem, TreeState}; use update_engine::{ AbortReason, ExecutionStatus, StepKey, WillNotBeRunReason, @@ -233,7 +233,7 @@ impl UpdatePane { .expect("selected_key is always valid"); let step_info = value.step_info(); - let header = Spans::from(vec![ + let header = Line::from(vec![ Span::styled("Step: ", style::header(true)), Span::styled(step_info.description.clone(), style::header(true)), ]); @@ -250,7 +250,7 @@ impl UpdatePane { style::plain_text(), ), ]; - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); } StepStatus::Running { progress_event, .. } => { let mut spans = vec![ @@ -271,9 +271,9 @@ impl UpdatePane { spans.push(Span::styled(")", style::plain_text())); } } - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); - body.lines.push(Spans::default()); + body.lines.push(Line::default()); let progress_spans = progress_event_spans(progress_event, "Progress:"); @@ -323,10 +323,10 @@ impl UpdatePane { format!(" after {:.2?}", info.step_elapsed), style::plain_text(), )); - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); if let Some(message) = message { - body.lines.push(Spans::default()); + body.lines.push(Line::default()); let prefix = vec![Span::styled("Message: ", style::selected())]; push_text_lines(&message, prefix, &mut body.lines); @@ -335,7 +335,7 @@ impl UpdatePane { StepStatus::Completed { info: None } => { // No information is available, so all we can do is say that // this step is completed. - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ Span::styled("Status: ", style::selected()), Span::styled("Completed", style::successful_update_bold()), ])); @@ -358,9 +358,9 @@ impl UpdatePane { format!(" after {:.2?}", info.step_elapsed), style::plain_text(), )); - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); - body.lines.push(Spans::default()); + body.lines.push(Line::default()); // Show the message. let prefix = vec![Span::styled("Message: ", style::selected())]; @@ -368,13 +368,13 @@ impl UpdatePane { // Show causes. if !info.causes.is_empty() { - body.lines.push(Spans::default()); - body.lines.push(Spans::from(Span::styled( + body.lines.push(Line::default()); + body.lines.push(Line::from(Span::styled( "Caused by:", style::selected(), ))); for cause in &info.causes { - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(vec![ Span::raw("-> "), Span::styled(cause, style::plain_text()), ])) @@ -388,7 +388,7 @@ impl UpdatePane { Span::styled("Status: ", style::selected()), Span::styled("Failed", style::failed_update_bold()), ]; - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); } StepStatus::Aborted { reason: AbortReason::StepAborted(info), @@ -414,9 +414,9 @@ impl UpdatePane { format!(" after {:.2?}", info.step_elapsed), style::plain_text(), )); - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); - body.lines.push(Spans::default()); + body.lines.push(Line::default()); // Show the message. let prefix = vec![Span::styled("Message: ", style::selected())]; @@ -426,7 +426,7 @@ impl UpdatePane { if let Some(last_progress) = last_progress { let progress_spans = progress_event_spans(last_progress, "Last progress:"); - body.lines.push(Spans::default()); + body.lines.push(Line::default()); body.lines.push(progress_spans); } } @@ -448,13 +448,13 @@ impl UpdatePane { style::selected(), )); } - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); // Show last progress if available. if let Some(last_progress) = last_progress { let progress_spans = progress_event_spans(last_progress, "Last progress:"); - body.lines.push(Spans::default()); + body.lines.push(Line::default()); body.lines.push(progress_spans); } } @@ -494,7 +494,7 @@ impl UpdatePane { )); }; } - body.lines.push(Spans::from(spans)); + body.lines.push(Line::from(spans)); } } @@ -520,11 +520,11 @@ impl UpdatePane { frame: &mut Frame<'_>, ) { let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("START UPDATE: {}", state.rack_state.selected), style::header(true), )]), - body: Text::from(vec![Spans::from(vec![Span::styled( + body: Text::from(vec![Line::from(vec![Span::styled( "Would you like to start an update?", style::plain_text(), )])]), @@ -550,11 +550,11 @@ impl UpdatePane { frame: &mut Frame<'_>, ) { let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("START UPDATE: {}", state.rack_state.selected), style::header(true), )]), - body: Text::from(vec![Spans::from(vec![Span::styled( + body: Text::from(vec![Line::from(vec![Span::styled( "Waiting for update to start", style::plain_text(), )])]), @@ -583,7 +583,7 @@ impl UpdatePane { push_text_lines(message, prefix, &mut body.lines); let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("START UPDATE FAILED: {}", state.rack_state.selected), style::failed_update(), )]), @@ -609,12 +609,12 @@ impl UpdatePane { frame: &mut Frame<'_>, ) { let mut body = Text::default(); - body.lines.push(Spans::from(vec![Span::styled( + body.lines.push(Line::from(vec![Span::styled( "Would you like to abort this update?", style::plain_text(), )])); - body.lines.push(Spans::from(Vec::new())); - body.lines.push(Spans::from(vec![ + body.lines.push(Line::from(Vec::new())); + body.lines.push(Line::from(vec![ Span::styled("Warning: ", style::warning_update()), Span::styled( "This might result in an inconsistent state. \ @@ -624,7 +624,7 @@ impl UpdatePane { ])); let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("ABORT UPDATE: {}", state.rack_state.selected), style::header(true), )]), @@ -651,11 +651,11 @@ impl UpdatePane { frame: &mut Frame<'_>, ) { let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("ABORT UPDATE: {}", state.rack_state.selected), style::header(true), )]), - body: Text::from(vec![Spans::from(vec![Span::styled( + body: Text::from(vec![Line::from(vec![Span::styled( "Waiting for update to be aborted", style::plain_text(), )])]), @@ -684,7 +684,7 @@ impl UpdatePane { push_text_lines(message, prefix, &mut body.lines); let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("ABORT UPDATE FAILED: {}", state.rack_state.selected), style::failed_update(), )]), @@ -710,11 +710,11 @@ impl UpdatePane { frame: &mut Frame<'_>, ) { let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("CLEAR UPDATE STATE: {}", state.rack_state.selected), style::header(true), )]), - body: Text::from(vec![Spans::from(vec![Span::styled( + body: Text::from(vec![Line::from(vec![Span::styled( "Waiting for update state to be cleared", style::plain_text(), )])]), @@ -743,7 +743,7 @@ impl UpdatePane { push_text_lines(message, prefix, &mut body.lines); let popup_builder = PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!( "CLEAR UPDATE STATE FAILED: {}", state.rack_state.selected @@ -1301,7 +1301,7 @@ impl UpdatePane { .style(border_style); // Draw the title/tab bar - let title_bar = Paragraph::new(Spans::from(vec![Span::styled( + let title_bar = Paragraph::new(Line::from(vec![Span::styled( "UPDATE STATUS", header_style, )])) @@ -1366,7 +1366,7 @@ impl UpdatePane { .style(border_style); // Draw the title/tab bar - let title_bar = Paragraph::new(Spans::from(vec![ + let title_bar = Paragraph::new(Line::from(vec![ Span::styled("UPDATE STATUS / ", border_style), Span::styled(state.rack_state.selected.to_string(), header_style), ])) @@ -1447,13 +1447,13 @@ impl UpdatePane { // Show this command. let text = Text::from(vec![ - Spans::from(Vec::new()), - Spans::from(vec![Span::styled( + Line::from(Vec::new()), + Line::from(vec![Span::styled( "Use the following command to transfer an update:", style::plain_text(), )]), "".into(), - Spans::from(vec![ + Line::from(vec![ Span::styled("cat", style::plain_text()), Span::styled(" $UPDATE", style::popup_highlight()), Span::styled(".zip | ssh", style::plain_text()), @@ -1491,8 +1491,8 @@ impl UpdatePane { // support today because updating the switch requires rebooting // the sled). let text = Text::from(vec![ - Spans::from(Vec::new()), - Spans::from(vec![Span::styled( + Line::from(Vec::new()), + Line::from(vec![Span::styled( format!( "Update unavailable: You are connected to wicket \ via this {sled_or_switch}." @@ -1510,8 +1510,8 @@ impl UpdatePane { let force_update = ForceUpdateSelectionState::from(state); let mut text = force_update.spans(); text.extend_from_slice(&[ - Spans::from(Vec::new()), - Spans::from(vec![ + Line::from(Vec::new()), + Line::from(vec![ Span::styled( "Update ready: Press ", style::plain_text(), @@ -1543,7 +1543,7 @@ impl UpdatePane { UpdateItemState::UpdateStarted => { // This should show up very briefly, if at all, and then // be replaced with the events list. - let status_text = Text::from(Spans::from(vec![ + let status_text = Text::from(Line::from(vec![ Span::styled("Update ", style::plain_text()), Span::styled("started", style::successful_update_bold()), Span::styled(", waiting for events", style::plain_text()), @@ -1551,7 +1551,7 @@ impl UpdatePane { // Don't display any text here; status_text should be // enough for the user. - let message_text = Text::from(Vec::new()); + let message_text = Text::default(); // Wrap the text to the screen width. let options = crate::ui::wrap::Options { @@ -1617,7 +1617,7 @@ impl UpdatePane { fn progress_event_spans( progress_event: &ProgressEvent, header: &str, -) -> Spans<'static> { +) -> Line<'static> { let mut progress_spans = Vec::new(); progress_spans.push(Span::styled(header.to_owned(), style::selected())); progress_spans.push(Span::raw(" ")); @@ -1651,7 +1651,7 @@ fn progress_event_spans( )); } - Spans(progress_spans) + Line::from(progress_spans) } struct ComponentForceUpdateSelectionState { @@ -1779,18 +1779,18 @@ impl ForceUpdateSelectionState { } } - fn spans(&self) -> Vec> { + fn spans(&self) -> Vec> { fn make_spans( name: &str, c: &ComponentForceUpdateSelectionState, - ) -> Spans<'static> { + ) -> Line<'static> { let prefix = if c.toggled_on { "[✔]" } else { "[ ]" }; let style = if c.selected { style::highlighted() } else { style::plain_text() }; - Spans::from(vec![Span::styled( + Line::from(vec![Span::styled( format!( "{prefix} Force update {name} (version is already {})", c.version @@ -1813,7 +1813,7 @@ impl ForceUpdateSelectionState { #[derive(Debug, Default)] struct ComponentUpdateListState { event_buffer: EventBuffer, - status_text: Spans<'static>, + status_text: Line<'static>, list_items: IndexMap>, // The help text lives on the `UpdatePane`, not here, so all we can do here // is figure out which help text to show (if any). @@ -2015,11 +2015,11 @@ impl ComponentUpdateListState { )); // Add step keys and items to the list. - list_items.insert(step_key, ListItem::new(Spans::from(item_spans))); + list_items.insert(step_key, ListItem::new(Line::from(item_spans))); } self.event_buffer = event_buffer; - self.status_text = Spans::from(status_text); + self.status_text = Line::from(status_text); self.show_help = show_help; self.list_items = list_items; let selected_needs_reset = match self.selected { diff --git a/wicket/src/ui/splash.rs b/wicket/src/ui/splash.rs index de5c16336e..cc8ab0bff8 100644 --- a/wicket/src/ui/splash.rs +++ b/wicket/src/ui/splash.rs @@ -11,8 +11,8 @@ use super::defaults::dimensions::RectExt; use super::defaults::style; use super::widgets::{Logo, LogoState, LOGO_HEIGHT, LOGO_WIDTH}; use crate::{Cmd, Frame, Term}; -use tui::style::Style; -use tui::widgets::Block; +use ratatui::style::Style; +use ratatui::widgets::Block; const TOTAL_FRAMES: usize = 100; diff --git a/wicket/src/ui/widgets/animated_logo.rs b/wicket/src/ui/widgets/animated_logo.rs index adcb538322..cae6487fa8 100644 --- a/wicket/src/ui/widgets/animated_logo.rs +++ b/wicket/src/ui/widgets/animated_logo.rs @@ -4,10 +4,10 @@ //! Animated Oxide logo used for the splash screen -use tui::buffer::Buffer; -use tui::layout::Rect; -use tui::style::Style; -use tui::widgets::Widget; +use ratatui::buffer::Buffer; +use ratatui::layout::Rect; +use ratatui::style::Style; +use ratatui::widgets::Widget; pub const LOGO_HEIGHT: u16 = 7; pub const LOGO_WIDTH: u16 = 46; diff --git a/wicket/src/ui/widgets/banner.rs b/wicket/src/ui/widgets/banner.rs index afd0c2dafa..b633137fe2 100644 --- a/wicket/src/ui/widgets/banner.rs +++ b/wicket/src/ui/widgets/banner.rs @@ -2,11 +2,11 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. +use ratatui::buffer::Buffer; +use ratatui::layout::Rect; +use ratatui::style::Style; +use ratatui::widgets::Widget; use std::str::Lines; -use tui::buffer::Buffer; -use tui::layout::Rect; -use tui::style::Style; -use tui::widgets::Widget; /// A banner draws the text output from `banner` as stored in string. /// diff --git a/wicket/src/ui/widgets/box_connector.rs b/wicket/src/ui/widgets/box_connector.rs index e5c30a74d8..af4630773c 100644 --- a/wicket/src/ui/widgets/box_connector.rs +++ b/wicket/src/ui/widgets/box_connector.rs @@ -2,9 +2,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -use tui::buffer::Buffer; -use tui::layout::Rect; -use tui::widgets::Widget; +use ratatui::buffer::Buffer; +use ratatui::layout::Rect; +use ratatui::widgets::Widget; /// Do we want to connect this box (bordered block) to the one above it, below /// it, or both? diff --git a/wicket/src/ui/widgets/fade.rs b/wicket/src/ui/widgets/fade.rs index 40faa093f8..d1669cd5b7 100644 --- a/wicket/src/ui/widgets/fade.rs +++ b/wicket/src/ui/widgets/fade.rs @@ -1,7 +1,7 @@ use crate::ui::defaults::style; -use tui::buffer::Buffer; -use tui::layout::Rect; -use tui::widgets::Widget; +use ratatui::buffer::Buffer; +use ratatui::layout::Rect; +use ratatui::widgets::Widget; /// Style every character as `style::faded_background` #[derive(Default)] diff --git a/wicket/src/ui/widgets/ignition.rs b/wicket/src/ui/widgets/ignition.rs index 079f9cb39c..af0818e52a 100644 --- a/wicket/src/ui/widgets/ignition.rs +++ b/wicket/src/ui/widgets/ignition.rs @@ -8,9 +8,9 @@ use super::ButtonText; use super::PopupBuilder; use crate::state::ComponentId; use crate::ui::defaults::style; -use tui::text::Span; -use tui::text::Spans; -use tui::text::Text; +use ratatui::text::Line; +use ratatui::text::Span; +use ratatui::text::Text; use wicketd_client::types::IgnitionCommand; pub struct IgnitionPopup { @@ -57,25 +57,25 @@ impl IgnitionPopup { component: ComponentId, ) -> PopupBuilder<'static> { PopupBuilder { - header: Spans::from(vec![Span::styled( + header: Line::from(vec![Span::styled( format!("IGNITION: {}", component), style::header(true), )]), body: Text { lines: vec![ - Spans::from(vec![Span::styled( + Line::from(vec![Span::styled( "Power On", style::line( self.selected_command == IgnitionCommand::PowerOn, ), )]), - Spans::from(vec![Span::styled( + Line::from(vec![Span::styled( "Power Off", style::line( self.selected_command == IgnitionCommand::PowerOff, ), )]), - Spans::from(vec![Span::styled( + Line::from(vec![Span::styled( "Power Reset", style::line( self.selected_command diff --git a/wicket/src/ui/widgets/popup.rs b/wicket/src/ui/widgets/popup.rs index f690a59487..19d7aa18b1 100644 --- a/wicket/src/ui/widgets/popup.rs +++ b/wicket/src/ui/widgets/popup.rs @@ -4,11 +4,11 @@ //! A popup dialog box widget -use tui::{ +use ratatui::{ buffer::Buffer, layout::{Constraint, Direction, Layout, Rect}, style::Style, - text::{Span, Spans, Text}, + text::{Line, Span, Text}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Widget}, }; @@ -29,18 +29,18 @@ const BUTTON_HEIGHT: u16 = 3; #[derive(Clone, Debug)] pub struct ButtonText<'a> { - pub instruction: Spans<'a>, - pub key: Spans<'a>, + pub instruction: Line<'a>, + pub key: Line<'a>, } impl<'a> ButtonText<'a> { pub fn new(instruction: &'a str, key: &'a str) -> Self { Self { - instruction: Spans::from(Span::styled( + instruction: Line::from(Span::styled( instruction, Self::default_instruction_style(), )), - key: Spans::from(Span::styled(key, Self::default_key_style())), + key: Line::from(Span::styled(key, Self::default_key_style())), } } @@ -55,7 +55,7 @@ impl<'a> ButtonText<'a> { #[derive(Default)] pub struct PopupBuilder<'a> { - pub header: Spans<'a>, + pub header: Line<'a>, pub body: Text<'a>, pub buttons: Vec>, } @@ -175,7 +175,7 @@ impl PopupScrollability for Scrollable { ButtonText::default_instruction_style(), ) .into(), - key: Spans::from(vec![ + key: Line::from(vec![ Span::styled("Up", up_style), Span::styled("/", ButtonText::default_key_style()), Span::styled("Down", down_style), @@ -239,7 +239,7 @@ pub struct Popup<'a, S: PopupScrollability> { impl<'a, S: PopupScrollability> Popup<'a, S> { fn new( full_screen: Rect, - header: &'a Spans<'_>, + header: &'a Line<'_>, body: &'a Text<'_>, buttons: Vec>, scrollability: S, @@ -289,7 +289,7 @@ impl<'a, S: PopupScrollability> Popup<'a, S> { Self { data, rect, - chunks, + chunks: chunks.to_vec(), body_rect, actual_scroll_offset: actual_scroll, _marker: PhantomData, @@ -474,12 +474,12 @@ pub fn draw_buttons( for (i, button) in buttons.into_iter().enumerate() { let mut spans = vec![Span::raw(" ")]; - spans.extend(button.instruction.0); + spans.extend(button.instruction.spans); spans.push(Span::styled(" <", ButtonText::default_key_style())); - spans.extend(button.key.0); + spans.extend(button.key.spans); spans.push(Span::styled(">", ButtonText::default_key_style())); - let b = Paragraph::new(Spans(spans)).block(block.clone()); + let b = Paragraph::new(Line::from(spans)).block(block.clone()); b.render(button_rects[i + 1], buf); } } diff --git a/wicket/src/ui/widgets/rack.rs b/wicket/src/ui/widgets/rack.rs index 73fe46cd6b..0ffeab6439 100644 --- a/wicket/src/ui/widgets/rack.rs +++ b/wicket/src/ui/widgets/rack.rs @@ -6,17 +6,17 @@ use crate::state::Inventory; use crate::state::{ComponentId, KnightRiderMode, RackState}; +use ratatui::buffer::Buffer; +use ratatui::layout::Alignment; +use ratatui::layout::Rect; +use ratatui::style::Color; +use ratatui::style::Style; +use ratatui::text::Text; +use ratatui::widgets::Block; +use ratatui::widgets::Borders; +use ratatui::widgets::Paragraph; +use ratatui::widgets::Widget; use std::collections::BTreeMap; -use tui::buffer::Buffer; -use tui::layout::Alignment; -use tui::layout::Rect; -use tui::style::Color; -use tui::style::Style; -use tui::text::Text; -use tui::widgets::Block; -use tui::widgets::Borders; -use tui::widgets::Paragraph; -use tui::widgets::Widget; use wicketd_client::types::SpIgnition; #[derive(Debug, Clone)] diff --git a/wicket/src/ui/widgets/status_view.rs b/wicket/src/ui/widgets/status_view.rs index d83dc76cfc..7418fed512 100644 --- a/wicket/src/ui/widgets/status_view.rs +++ b/wicket/src/ui/widgets/status_view.rs @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -use tui::{ +use ratatui::{ layout::{Alignment, Rect}, text::Text, widgets::{Block, Borders, List, Paragraph, StatefulWidget, Widget}, diff --git a/wicket/src/ui/wrap.rs b/wicket/src/ui/wrap.rs index 5a02d802fd..6cd5f7010a 100644 --- a/wicket/src/ui/wrap.rs +++ b/wicket/src/ui/wrap.rs @@ -16,11 +16,11 @@ //! won't break the output, but they might make the output look a bit weird.) use itertools::{Itertools, Position}; +use ratatui::text::{Line, Span, Text}; use textwrap::{ core::{display_width, Fragment}, wrap_algorithms::{wrap_optimal_fit, Penalties}, }; -use tui::text::{Span, Spans, Text}; pub struct Options<'a> { /// The width in columns at which the text will be wrapped. @@ -52,11 +52,11 @@ pub(crate) fn wrap_text<'a>( Text::from(lines) } -/// Wraps a [`Spans`] representing a single line. +/// Wraps a [`Line`] representing a single line. /// /// If the text contains multiple lines, use [`wrap_text`] instead. pub(crate) fn wrap_line<'a>( - line: &'a Spans<'_>, + line: &'a Line<'_>, options: Options<'a>, ) -> Text<'a> { let mut lines = Vec::new(); @@ -65,9 +65,9 @@ pub(crate) fn wrap_line<'a>( } fn wrap_single_line<'a>( - line: &'a Spans<'_>, + line: &'a Line<'_>, options: &Options<'a>, - lines: &mut Vec>, + lines: &mut Vec>, ) { let indent = if lines.is_empty() { options.initial_indent.clone() @@ -81,19 +81,19 @@ fn wrap_single_line<'a>( } } -fn borrow_line<'a>(line: &'a Spans<'_>) -> Spans<'a> { +fn borrow_line<'a>(line: &'a Line<'_>) -> Line<'a> { let spans = line - .0 + .spans .iter() .map(|span| Span::styled(span.content.as_ref(), span.style)) - .collect(); - Spans(spans) + .collect::>(); + Line::from(spans) } fn wrap_single_line_slow_path<'a>( - line: &'a Spans<'_>, + line: &'a Line<'_>, options: &Options<'a>, - lines: &mut Vec>, + lines: &mut Vec>, ) { // Span::width (options.initial_indent.width() etc) use the Unicode display // width, which is what we expect. @@ -156,14 +156,14 @@ fn wrap_single_line_slow_path<'a>( } } - lines.push(Spans::from(output_line)); + lines.push(Line::from(output_line)); } } fn find_words_in_line<'a>( - line: &'a Spans<'_>, + line: &'a Line<'_>, ) -> impl Iterator> { - line.0.iter().flat_map(|span| find_words_in_span(span)) + line.spans.iter().flat_map(|span| find_words_in_span(span)) } /// Breaks this span into smaller words. @@ -209,7 +209,7 @@ struct StyledWord<'a> { word: &'a str, width: usize, whitespace: &'a str, - style: tui::style::Style, + style: ratatui::style::Style, } impl<'a> StyledWord<'a> { @@ -225,7 +225,7 @@ impl<'a> StyledWord<'a> { Self::new_impl(content, span.style) } - fn new_impl(content: &'a str, style: tui::style::Style) -> Self { + fn new_impl(content: &'a str, style: ratatui::style::Style) -> Self { let trimmed = content.trim_end_matches(' '); Self { word: trimmed, @@ -240,7 +240,7 @@ impl<'a> StyledWord<'a> { word: "", width: 0, whitespace: "", - style: tui::style::Style::default(), + style: ratatui::style::Style::default(), } }