mirror of
https://github.com/veeso/termscp.git
synced 2026-09-26 22:11:26 -07:00
build: migrate to tui-realm 4.0
Upgrade tuirealm (3.x -> 4.0.0), tui-realm-stdlib (3 -> 4), tui-term (0.2 -> 0.3). Apply all breaking changes from the 4.0 migration guide across the termscp UI. Key changes: - Root-level re-exports removed; imports moved to module-qualified paths (`tuirealm::application`, `::component`, `::event`, `::props`, `::state`, `::subscription`, `::listener`, `::ratatui`). Same for stdlib component types (`tui_realm_stdlib::components::*`). - `MockComponent` trait renamed to `Component`; old `Component` trait renamed to `AppComponent`. `#[derive(MockComponent)]` is now `#[derive(Component)]`. `Component::on` now takes `&Event<_>`. - `TextSpan` replaced with `SpanStatic`/`LineStatic`/`TextStatic` (ratatui-based); tuple `(String, Alignment)` titles replaced with the new `Title` builder; `Alignment` split into `HorizontalAlignment`/`VerticalAlignment`; stdlib components use `.alignment_horizontal` instead of `.alignment`. - `State::One`/`PropPayload::One` -> `Single`. `CmdResult::None` -> `NoChange`. `Props::get_or` removed; `Props::get` now returns a borrowed `Option<&AttrValue>` (call sites switched to `.and_then(AttrValue::as_*)`). `Component::query` returns `Option<QueryResult<'a>>`. - `Attribute::HighlightedColor` -> `HighlightStyle` (a full `Style`). `.highlighted_*` helpers renamed to `.highlight_*`. - `PollStrategy::UpTo(n)` now requires a `Duration`; tick timeout moved from `EventListenerCfg::poll_timeout` into `PollStrategy`. - `TerminalBridge` removed; `Context` now holds `CrosstermTerminalAdapter` directly and enables raw mode + alternate screen explicitly. The `TerminalAdapter` trait is imported where its methods are used. - `Update` trait removed; activity `update` methods are plain inherent functions. - `ProgressBar` replaced by stdlib `Gauge`. Paragraph `.wrap` renamed to `.wrap_trim`; `.text` now takes an `Into<Text>`. Stdlib `List` row items are now individual lines (`Vec<Span>` per row) rather than a `Table` of spans; custom `FileList`/`Log` convert between the two models. - Radio builders drop `.foreground(color)` so unselected items render with the terminal default foreground, and set `highlight_style(Style::default().fg(color).add_modifier(REVERSED))` so the selected entry is visibly highlighted only with the theme color. - Custom `FileList` keeps the selected row highlighted with the full highlight style when focused and falls back to a foreground-only style when unfocused. - Theme loading is now backwards compatible: `Theme` uses a custom `Deserialize` through an intermediate `ThemeFile` with optional fields, so missing keys, unknown values or legacy aliases (`transfer_progress_bar_full`/`_partial`) fall back to defaults on a per-field basis instead of failing the whole load.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
use tuirealm::command::{Cmd, CmdResult, Direction};
|
||||
use tuirealm::component::{AppComponent, Component};
|
||||
use tuirealm::event::{Event, Key, KeyEvent, NoUserEvent};
|
||||
use tuirealm::props::{Alignment, BorderType, Borders, Color};
|
||||
use tuirealm::{Component, MockComponent, State, StateValue};
|
||||
use tuirealm::props::{
|
||||
BorderType, Borders, Color, HorizontalAlignment, Style, TextModifiers, Title,
|
||||
};
|
||||
use tuirealm::state::{State, StateValue};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(MockComponent)]
|
||||
#[derive(Component)]
|
||||
pub struct RemoteProtocolRadio {
|
||||
component: Radio,
|
||||
}
|
||||
@@ -14,6 +17,11 @@ impl RemoteProtocolRadio {
|
||||
pub fn new(default_protocol: FileTransferProtocol, color: Color) -> Self {
|
||||
Self {
|
||||
component: Radio::default()
|
||||
.highlight_style(
|
||||
Style::default()
|
||||
.fg(color)
|
||||
.add_modifier(TextModifiers::REVERSED),
|
||||
)
|
||||
.borders(
|
||||
Borders::default()
|
||||
.color(color)
|
||||
@@ -24,9 +32,8 @@ impl RemoteProtocolRadio {
|
||||
} else {
|
||||
vec!["SFTP", "SCP", "FTP", "FTPS", "S3", "Kube", "WebDAV"].into_iter()
|
||||
})
|
||||
.foreground(color)
|
||||
.rewind(true)
|
||||
.title("Protocol", Alignment::Left)
|
||||
.title(Title::from("Protocol").alignment(HorizontalAlignment::Left))
|
||||
.value(Self::protocol_enum_to_opt(default_protocol)),
|
||||
}
|
||||
}
|
||||
@@ -58,8 +65,8 @@ impl RemoteProtocolRadio {
|
||||
}
|
||||
}
|
||||
|
||||
impl Component<Msg, NoUserEvent> for RemoteProtocolRadio {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
impl AppComponent<Msg, NoUserEvent> for RemoteProtocolRadio {
|
||||
fn on(&mut self, ev: &Event<NoUserEvent>) -> Option<Msg> {
|
||||
let result = match ev {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
@@ -86,7 +93,7 @@ impl Component<Msg, NoUserEvent> for RemoteProtocolRadio {
|
||||
};
|
||||
|
||||
match result {
|
||||
CmdResult::Changed(State::One(StateValue::Usize(choice))) => Some(Msg::Form(
|
||||
CmdResult::Changed(State::Single(StateValue::Usize(choice))) => Some(Msg::Form(
|
||||
FormMsg::RemoteProtocolChanged(Self::protocol_opt_to_enum(choice)),
|
||||
)),
|
||||
_ => Some(Msg::None),
|
||||
@@ -94,7 +101,7 @@ impl Component<Msg, NoUserEvent> for RemoteProtocolRadio {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(MockComponent)]
|
||||
#[derive(Component)]
|
||||
pub struct HostBridgeProtocolRadio {
|
||||
component: Radio,
|
||||
}
|
||||
@@ -103,6 +110,11 @@ impl HostBridgeProtocolRadio {
|
||||
pub fn new(protocol: HostBridgeProtocol, color: Color) -> Self {
|
||||
Self {
|
||||
component: Radio::default()
|
||||
.highlight_style(
|
||||
Style::default()
|
||||
.fg(color)
|
||||
.add_modifier(TextModifiers::REVERSED),
|
||||
)
|
||||
.borders(
|
||||
Borders::default()
|
||||
.color(color)
|
||||
@@ -134,9 +146,8 @@ impl HostBridgeProtocolRadio {
|
||||
]
|
||||
.into_iter()
|
||||
})
|
||||
.foreground(color)
|
||||
.rewind(true)
|
||||
.title("Host type", Alignment::Left)
|
||||
.title(Title::from("Host type").alignment(HorizontalAlignment::Left))
|
||||
.value(Self::protocol_to_opt(protocol)),
|
||||
}
|
||||
}
|
||||
@@ -195,8 +206,8 @@ impl HostBridgeProtocolRadio {
|
||||
}
|
||||
}
|
||||
|
||||
impl Component<Msg, NoUserEvent> for HostBridgeProtocolRadio {
|
||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||
impl AppComponent<Msg, NoUserEvent> for HostBridgeProtocolRadio {
|
||||
fn on(&mut self, ev: &Event<NoUserEvent>) -> Option<Msg> {
|
||||
let result = match ev {
|
||||
Event::Keyboard(KeyEvent {
|
||||
code: Key::Left, ..
|
||||
@@ -223,7 +234,7 @@ impl Component<Msg, NoUserEvent> for HostBridgeProtocolRadio {
|
||||
};
|
||||
|
||||
match result {
|
||||
CmdResult::Changed(State::One(StateValue::Usize(choice))) => Some(Msg::Form(
|
||||
CmdResult::Changed(State::Single(StateValue::Usize(choice))) => Some(Msg::Form(
|
||||
FormMsg::HostBridgeProtocolChanged(Self::protocol_opt_to_enum(choice)),
|
||||
)),
|
||||
_ => Some(Msg::None),
|
||||
|
||||
Reference in New Issue
Block a user