mirror of
https://github.com/veeso/termscp.git
synced 2026-09-27 22:41:19 -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:
@@ -8,7 +8,8 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
|
||||
use tuirealm::{State, StateValue};
|
||||
use tuirealm::state::{State, StateValue};
|
||||
use tuirealm::terminal::TerminalAdapter;
|
||||
|
||||
use super::{
|
||||
Context, Id, IdCommon, IdConfig, RADIO_PROTOCOL_KUBE, RADIO_PROTOCOL_WEBDAV, SetupActivity,
|
||||
@@ -256,13 +257,13 @@ impl SetupActivity {
|
||||
|
||||
/// Collect values from input and put them into the configuration
|
||||
pub(crate) fn collect_input_values(&mut self) {
|
||||
if let Ok(State::One(StateValue::String(editor))) =
|
||||
if let Ok(State::Single(StateValue::String(editor))) =
|
||||
self.app.state(&Id::Config(IdConfig::TextEditor))
|
||||
{
|
||||
self.config_mut()
|
||||
.set_text_editor(PathBuf::from(editor.as_str()));
|
||||
}
|
||||
if let Ok(State::One(StateValue::Usize(protocol))) =
|
||||
if let Ok(State::Single(StateValue::Usize(protocol))) =
|
||||
self.app.state(&Id::Config(IdConfig::DefaultProtocol))
|
||||
{
|
||||
let protocol: FileTransferProtocol = match protocol {
|
||||
@@ -277,35 +278,35 @@ impl SetupActivity {
|
||||
};
|
||||
self.config_mut().set_default_protocol(protocol);
|
||||
}
|
||||
if let Ok(State::One(StateValue::Usize(opt))) =
|
||||
if let Ok(State::Single(StateValue::Usize(opt))) =
|
||||
self.app.state(&Id::Config(IdConfig::HiddenFiles))
|
||||
{
|
||||
let show: bool = matches!(opt, 0);
|
||||
self.config_mut().set_show_hidden_files(show);
|
||||
}
|
||||
if let Ok(State::One(StateValue::Usize(opt))) =
|
||||
if let Ok(State::Single(StateValue::Usize(opt))) =
|
||||
self.app.state(&Id::Config(IdConfig::CheckUpdates))
|
||||
{
|
||||
let check: bool = matches!(opt, 0);
|
||||
self.config_mut().set_check_for_updates(check);
|
||||
}
|
||||
if let Ok(State::One(StateValue::Usize(opt))) =
|
||||
if let Ok(State::Single(StateValue::Usize(opt))) =
|
||||
self.app.state(&Id::Config(IdConfig::PromptOnFileReplace))
|
||||
{
|
||||
let check: bool = matches!(opt, 0);
|
||||
self.config_mut().set_prompt_on_file_replace(check);
|
||||
}
|
||||
if let Ok(State::One(StateValue::String(fmt))) =
|
||||
if let Ok(State::Single(StateValue::String(fmt))) =
|
||||
self.app.state(&Id::Config(IdConfig::LocalFileFmt))
|
||||
{
|
||||
self.config_mut().set_local_file_fmt(fmt);
|
||||
}
|
||||
if let Ok(State::One(StateValue::String(fmt))) =
|
||||
if let Ok(State::Single(StateValue::String(fmt))) =
|
||||
self.app.state(&Id::Config(IdConfig::RemoteFileFmt))
|
||||
{
|
||||
self.config_mut().set_remote_file_fmt(fmt);
|
||||
}
|
||||
if let Ok(State::One(StateValue::Usize(opt))) =
|
||||
if let Ok(State::Single(StateValue::Usize(opt))) =
|
||||
self.app.state(&Id::Config(IdConfig::GroupDirs))
|
||||
{
|
||||
let dirs: Option<GroupDirs> = match opt {
|
||||
@@ -315,18 +316,18 @@ impl SetupActivity {
|
||||
};
|
||||
self.config_mut().set_group_dirs(dirs);
|
||||
}
|
||||
if let Ok(State::One(StateValue::Usize(opt))) =
|
||||
if let Ok(State::Single(StateValue::Usize(opt))) =
|
||||
self.app.state(&Id::Config(IdConfig::NotificationsEnabled))
|
||||
{
|
||||
self.config_mut().set_notifications(opt == 0);
|
||||
}
|
||||
if let Ok(State::One(StateValue::U64(bytes))) = self
|
||||
if let Ok(State::Single(StateValue::U64(bytes))) = self
|
||||
.app
|
||||
.state(&Id::Config(IdConfig::NotificationsThreshold))
|
||||
{
|
||||
self.config_mut().set_notification_threshold(bytes);
|
||||
}
|
||||
if let Ok(State::One(StateValue::String(mut path))) =
|
||||
if let Ok(State::Single(StateValue::String(mut path))) =
|
||||
self.app.state(&Id::Config(IdConfig::SshConfig))
|
||||
{
|
||||
if path.is_empty() {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// Ext
|
||||
use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
|
||||
use tuirealm::ratatui::widgets::Clear;
|
||||
use tuirealm::terminal::TerminalAdapter;
|
||||
|
||||
use super::{Context, Id, IdCommon, IdSsh, SetupActivity, ViewLayout, components};
|
||||
use crate::utils::ui::{Popup, Size};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Locals
|
||||
// Ext
|
||||
use tuirealm::ratatui::layout::{Constraint, Direction, Layout};
|
||||
use tuirealm::terminal::TerminalAdapter;
|
||||
|
||||
use super::{Context, Id, IdCommon, IdTheme, SetupActivity, Theme, ViewLayout, components};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user