Skip to content

Commit

Permalink
Migration completed
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Nov 29, 2021
1 parent a94623e commit 6b61e29
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ Released on FIXME:
- It is now possible to keep navigating on the other explorer while "found tab" is open
- ❗ It is not possible though to have the "found tab" on both explorers (otherwise you wouldn't be able to tell whether you're transferring files)
- Files found from search are now displayed with their relative path from working directory
- **Ui**:
- Transfer abortion is now more responsive
- Selected files will now be rendered with **Reversed, underlined and italic** text modifiers instead of being prepended with `*`.
- **Tui-realm migration**:
- migrated application to tui-realm 1.x
- Improved application performance
- Dependencies:
- Updated `tui-realm` to `1.3.0`
- Updated `tui-realm-stdlib` to `1.1.4`
- Removed `crossterm` (since bridged by tui-realm)

## 0.7.0

Expand Down
16 changes: 9 additions & 7 deletions src/ui/activities/filetransfer/components/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ impl MockComponent for Log {

fn attr(&mut self, attr: Attribute, value: AttrValue) {
self.props.set(attr, value);
self.states.set_list_len(
match self.props.get(Attribute::Content).map(|x| x.unwrap_table()) {
Some(spans) => spans.len(),
_ => 0,
},
);
self.states.reset_list_index();
if matches!(attr, Attribute::Content) {
self.states.set_list_len(
match self.props.get(Attribute::Content).map(|x| x.unwrap_table()) {
Some(spans) => spans.len(),
_ => 0,
},
);
self.states.reset_list_index();
}
}

fn state(&self) -> State {
Expand Down
19 changes: 14 additions & 5 deletions src/ui/activities/filetransfer/components/popups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,11 @@ impl GoToPopup {
)
.foreground(color)
.input_type(InputType::Text)
.placeholder("Go to…", Style::default().fg(Color::Rgb(128, 128, 128)))
.title("/foo/bar/buzz", Alignment::Center),
.placeholder(
"/foo/bar/buzz",
Style::default().fg(Color::Rgb(128, 128, 128)),
)
.title("Go to…", Alignment::Center),
}
}
}
Expand Down Expand Up @@ -714,6 +717,9 @@ impl KeybindingsPopup {
.add_col(TextSpan::new("<D>").bold().fg(key_color))
.add_col(TextSpan::from(" Make directory"))
.add_row()
.add_col(TextSpan::new("<F>").bold().fg(key_color))
.add_col(TextSpan::from(" Search files"))
.add_row()
.add_col(TextSpan::new("<G>").bold().fg(key_color))
.add_col(TextSpan::from(" Go to path"))
.add_row()
Expand Down Expand Up @@ -1373,6 +1379,8 @@ impl ReplacingFilesListPopup {
.color(color)
.modifiers(BorderType::Rounded),
)
.scroll(true)
.step(4)
.highlighted_color(color)
.highlighted_str("➤ ")
.title(
Expand Down Expand Up @@ -1553,9 +1561,10 @@ impl Component<Msg, NoUserEvent> for SortingPopup {
Event::Keyboard(KeyEvent {
code: Key::Right, ..
}) => self.perform(Cmd::Move(Direction::Right)),
Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => {
return Some(Msg::Ui(UiMsg::CloseFileSortingPopup))
}
Event::Keyboard(KeyEvent {
code: Key::Esc | Key::Enter,
..
}) => return Some(Msg::Ui(UiMsg::CloseFileSortingPopup)),
_ => return None,
};
if let CmdResult::Changed(State::One(StateValue::Usize(i))) = result {
Expand Down
31 changes: 17 additions & 14 deletions src/ui/activities/filetransfer/components/transfer/file_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl MockComponent for FileList {
.props
.get_or(
Attribute::Title,
AttrValue::Title((String::default(), Alignment::Center)),
AttrValue::Title((String::default(), Alignment::Left)),
)
.unwrap_title();
let borders = self
Expand All @@ -258,14 +258,15 @@ impl MockComponent for FileList {
let columns: Vec<Span> = row
.iter()
.map(|col| {
let (fg, bg, modifiers) =
let (fg, bg, mut modifiers) =
tui_realm_stdlib::utils::use_or_default_styles(&self.props, col);
let to_display: String = match self.states.is_selected(num) {
true => format!("*{}", col.content),
false => col.content.clone(),
};
if self.states.is_selected(num) {
modifiers |= TextModifiers::REVERSED
| TextModifiers::UNDERLINED
| TextModifiers::ITALIC;
}
Span::styled(
to_display,
col.content.clone(),
Style::default().add_modifier(modifiers).fg(fg).bg(bg),
)
})
Expand Down Expand Up @@ -301,13 +302,15 @@ impl MockComponent for FileList {

fn attr(&mut self, attr: Attribute, value: AttrValue) {
self.props.set(attr, value);
self.states.init_list_states(
match self.props.get(Attribute::Content).map(|x| x.unwrap_table()) {
Some(spans) => spans.len(),
_ => 0,
},
);
self.states.fix_list_index();
if matches!(attr, Attribute::Content) {
self.states.init_list_states(
match self.props.get(Attribute::Content).map(|x| x.unwrap_table()) {
Some(spans) => spans.len(),
_ => 0,
},
);
self.states.fix_list_index();
}
}

fn query(&self, attr: Attribute) -> Option<AttrValue> {
Expand Down
6 changes: 2 additions & 4 deletions src/ui/activities/filetransfer/components/transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ impl Component<Msg, NoUserEvent> for ExplorerLocal {
Some(Msg::Ui(UiMsg::ShowDisconnectPopup))
}
Event::Keyboard(KeyEvent {
code: Key::Left | Key::Right,
..
code: Key::Right, ..
}) => Some(Msg::Ui(UiMsg::ChangeTransferWindow)),
Event::Keyboard(KeyEvent {
code: Key::Backspace,
Expand Down Expand Up @@ -404,8 +403,7 @@ impl Component<Msg, NoUserEvent> for ExplorerRemote {
Some(Msg::Ui(UiMsg::ShowDisconnectPopup))
}
Event::Keyboard(KeyEvent {
code: Key::Left | Key::Right,
..
code: Key::Left, ..
}) => Some(Msg::Ui(UiMsg::ChangeTransferWindow)),
Event::Keyboard(KeyEvent {
code: Key::Backspace,
Expand Down
21 changes: 16 additions & 5 deletions src/ui/activities/filetransfer/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl FileTransferActivity {
.attr(
&Id::ExplorerLocal,
Attribute::Title,
AttrValue::Title((hostname, Alignment::Center))
AttrValue::Title((hostname, Alignment::Left))
)
.is_ok());
}
Expand Down Expand Up @@ -326,7 +326,7 @@ impl FileTransferActivity {
.attr(
&Id::ExplorerRemote,
Attribute::Title,
AttrValue::Title((hostname, Alignment::Center))
AttrValue::Title((hostname, Alignment::Left))
)
.is_ok());
}
Expand Down Expand Up @@ -421,7 +421,7 @@ impl FileTransferActivity {
.attr(
&Id::ProgressBarPartial,
Attribute::Title,
AttrValue::Title((filename, Alignment::Center))
AttrValue::Title((filename, Alignment::Left))
)
.is_ok());
}
Expand All @@ -433,11 +433,22 @@ impl FileTransferActivity {
// Set found to none
self.browser.del_found();
// Restore tab
self.browser.change_tab(match self.browser.tab() {
let new_tab = match self.browser.tab() {
FileExplorerTab::FindLocal => FileExplorerTab::Local,
FileExplorerTab::FindRemote => FileExplorerTab::Remote,
_ => FileExplorerTab::Local,
});
};
// Give focus to new tab
match new_tab {
FileExplorerTab::Local => assert!(self.app.active(&Id::ExplorerLocal).is_ok()),
FileExplorerTab::Remote => {
assert!(self.app.active(&Id::ExplorerRemote).is_ok())
}
FileExplorerTab::FindLocal | FileExplorerTab::FindRemote => {
assert!(self.app.active(&Id::ExplorerFind).is_ok())
}
}
self.browser.change_tab(new_tab);
}

pub(super) fn update_find_list(&mut self) {
Expand Down
18 changes: 11 additions & 7 deletions src/ui/activities/filetransfer/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use super::{
actions::SelectedEntry,
browser::{FileExplorerTab, FoundExplorerTab},
FileTransferActivity, Id, Msg, TransferMsg, TransferOpts, UiMsg,
ExitReason, FileTransferActivity, Id, Msg, TransferMsg, TransferOpts, UiMsg,
};
use crate::fs::FsEntry;
// externals
Expand All @@ -56,7 +56,7 @@ impl FileTransferActivity {
}
TransferMsg::CopyFileTo(dest) => {
self.umount_copy();
self.mount_wait("Copying file(s)…");
self.mount_blocking_wait("Copying file(s)…");
match self.browser.tab() {
FileExplorerTab::Local => self.action_local_copy(dest),
FileExplorerTab::Remote => self.action_remote_copy(dest),
Expand All @@ -68,7 +68,7 @@ impl FileTransferActivity {
}
TransferMsg::DeleteFile => {
self.umount_radio_delete();
self.mount_wait("Removing file(s)…");
self.mount_blocking_wait("Removing file(s)…");
match self.browser.tab() {
FileExplorerTab::Local => self.action_local_delete(),
FileExplorerTab::Remote => self.action_remote_delete(),
Expand Down Expand Up @@ -140,7 +140,7 @@ impl FileTransferActivity {
TransferMsg::ExecuteCmd(cmd) => {
// Exex command
self.umount_exec();
self.mount_wait(format!("Executing '{}'…", cmd).as_str());
self.mount_blocking_wait(format!("Executing '{}'…", cmd).as_str());
match self.browser.tab() {
FileExplorerTab::Local => self.action_local_exec(cmd),
FileExplorerTab::Remote => self.action_remote_exec(cmd),
Expand Down Expand Up @@ -253,7 +253,7 @@ impl FileTransferActivity {
TransferMsg::ReloadDir => self.update_browser_file_list(),
TransferMsg::RenameFile(dest) => {
self.umount_rename();
self.mount_wait("Moving file(s)…");
self.mount_blocking_wait("Moving file(s)…");
match self.browser.tab() {
FileExplorerTab::Local => self.action_local_rename(dest),
FileExplorerTab::Remote => self.action_remote_rename(dest),
Expand All @@ -264,6 +264,7 @@ impl FileTransferActivity {
self.update_browser_file_list()
}
TransferMsg::SaveFileAs(dest) => {
self.umount_saveas();
match self.browser.tab() {
FileExplorerTab::Local => self.action_local_saveas(dest),
FileExplorerTab::Remote => self.action_remote_saveas(dest),
Expand All @@ -279,7 +280,7 @@ impl FileTransferActivity {
TransferMsg::SearchFile(search) => {
self.umount_find_input();
// Mount wait
self.mount_wait(format!(r#"Searching for "{}"…"#, search).as_str());
self.mount_blocking_wait(format!(r#"Searching for "{}"…"#, search).as_str());
// Find
let res: Result<Vec<FsEntry>, String> = match self.browser.tab() {
FileExplorerTab::Local => self.action_local_find(search.clone()),
Expand Down Expand Up @@ -390,7 +391,10 @@ impl FileTransferActivity {
UiMsg::CloseDisconnectPopup => self.umount_disconnect(),
UiMsg::CloseErrorPopup => self.umount_error(),
UiMsg::CloseExecPopup => self.umount_exec(),
UiMsg::CloseFatalPopup => self.umount_fatal(),
UiMsg::CloseFatalPopup => {
self.umount_fatal();
self.exit_reason = Some(ExitReason::Disconnect);
}
UiMsg::CloseFileInfoPopup => self.umount_file_info(),
UiMsg::CloseFileSortingPopup => self.umount_file_sorting(),
UiMsg::CloseFindExplorer => {
Expand Down
16 changes: 13 additions & 3 deletions src/ui/activities/filetransfer/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::WaitPopup).is_ok());
}

pub(super) fn mount_blocking_wait<S: AsRef<str>>(&mut self, text: S) {
self.mount_wait(text);
self.view();
}

pub(super) fn umount_wait(&mut self) {
let _ = self.app.umount(&Id::WaitPopup);
}
Expand Down Expand Up @@ -931,9 +936,14 @@ impl FileTransferActivity {
Box::new(SubClause::Not(Box::new(SubClause::IsMounted(
Id::SortingPopup,
)))),
Box::new(SubClause::Not(Box::new(SubClause::IsMounted(
Id::WaitPopup,
)))),
Box::new(SubClause::And(
Box::new(SubClause::Not(Box::new(SubClause::IsMounted(
Id::FindPopup,
)))),
Box::new(SubClause::Not(Box::new(SubClause::IsMounted(
Id::WaitPopup,
)))),
)),
)),
)),
)),
Expand Down

0 comments on commit 6b61e29

Please sign in to comment.