mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Cargo clippy
This commit is contained in:
@@ -228,13 +228,11 @@ impl Activity for AuthActivity {
|
||||
return;
|
||||
}
|
||||
// Read one event
|
||||
if let Ok(event) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||
if let Some(event) = event {
|
||||
// Set redraw to true
|
||||
self.redraw = true;
|
||||
// Handle event
|
||||
self.handle_input_event(&event);
|
||||
}
|
||||
if let Ok(Some(event)) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||
// Set redraw to true
|
||||
self.redraw = true;
|
||||
// Handle event
|
||||
self.handle_input_event(&event);
|
||||
}
|
||||
// Redraw if necessary
|
||||
if self.redraw {
|
||||
|
||||
@@ -41,17 +41,11 @@ impl FileTransferActivity {
|
||||
/// Read one event.
|
||||
/// Returns whether at least one event has been handled
|
||||
pub(super) fn read_input_event(&mut self) -> bool {
|
||||
if let Ok(event) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||
// Iterate over input events
|
||||
if let Some(event) = event {
|
||||
// Handle event
|
||||
self.handle_input_event(&event);
|
||||
// Return true
|
||||
true
|
||||
} else {
|
||||
// No event
|
||||
false
|
||||
}
|
||||
if let Ok(Some(event)) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||
// Handle event
|
||||
self.handle_input_event(&event);
|
||||
// Return true
|
||||
true
|
||||
} else {
|
||||
// Error
|
||||
false
|
||||
@@ -103,7 +97,7 @@ impl FileTransferActivity {
|
||||
KeyCode::Esc => {
|
||||
// Handle quit event
|
||||
// Create quit prompt dialog
|
||||
self.popup = self.create_disconnect_popup();
|
||||
self.popup = Some(self.create_disconnect_popup());
|
||||
}
|
||||
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
|
||||
KeyCode::Right => self.tab = FileExplorerTab::Remote, // <RIGHT> switch to right tab
|
||||
@@ -269,7 +263,7 @@ impl FileTransferActivity {
|
||||
}
|
||||
'q' | 'Q' => {
|
||||
// Create quit prompt dialog
|
||||
self.popup = self.create_quit_popup();
|
||||
self.popup = Some(self.create_quit_popup());
|
||||
}
|
||||
'r' | 'R' => {
|
||||
// Rename
|
||||
@@ -326,7 +320,7 @@ impl FileTransferActivity {
|
||||
KeyCode::Esc => {
|
||||
// Handle quit event
|
||||
// Create quit prompt dialog
|
||||
self.popup = self.create_disconnect_popup();
|
||||
self.popup = Some(self.create_disconnect_popup());
|
||||
}
|
||||
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
|
||||
KeyCode::Left => self.tab = FileExplorerTab::Local, // <LEFT> switch to local tab
|
||||
@@ -490,7 +484,7 @@ impl FileTransferActivity {
|
||||
}
|
||||
'q' | 'Q' => {
|
||||
// Create quit prompt dialog
|
||||
self.popup = self.create_quit_popup();
|
||||
self.popup = Some(self.create_quit_popup());
|
||||
}
|
||||
'r' | 'R' => {
|
||||
// Rename
|
||||
@@ -547,7 +541,7 @@ impl FileTransferActivity {
|
||||
KeyCode::Esc => {
|
||||
// Handle quit event
|
||||
// Create quit prompt dialog
|
||||
self.popup = self.create_disconnect_popup();
|
||||
self.popup = Some(self.create_disconnect_popup());
|
||||
}
|
||||
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
|
||||
KeyCode::Down => {
|
||||
@@ -586,7 +580,7 @@ impl FileTransferActivity {
|
||||
KeyCode::Char(ch) => match ch {
|
||||
'q' | 'Q' => {
|
||||
// Create quit prompt dialog
|
||||
self.popup = self.create_quit_popup();
|
||||
self.popup = Some(self.create_quit_popup());
|
||||
}
|
||||
_ => { /* Nothing to do */ }
|
||||
},
|
||||
|
||||
@@ -62,23 +62,23 @@ impl FileTransferActivity {
|
||||
/// ### create_quit_popup
|
||||
///
|
||||
/// Create quit popup input mode (since must be shared between different input handlers)
|
||||
pub(super) fn create_disconnect_popup(&mut self) -> Option<Popup> {
|
||||
Some(Popup::YesNo(
|
||||
pub(super) fn create_disconnect_popup(&mut self) -> Popup {
|
||||
Popup::YesNo(
|
||||
String::from("Are you sure you want to disconnect?"),
|
||||
FileTransferActivity::disconnect,
|
||||
FileTransferActivity::callback_nothing_to_do,
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
/// ### create_quit_popup
|
||||
///
|
||||
/// Create quit popup input mode (since must be shared between different input handlers)
|
||||
pub(super) fn create_quit_popup(&mut self) -> Option<Popup> {
|
||||
Some(Popup::YesNo(
|
||||
pub(super) fn create_quit_popup(&mut self) -> Popup {
|
||||
Popup::YesNo(
|
||||
String::from("Are you sure you want to quit?"),
|
||||
FileTransferActivity::disconnect_and_quit,
|
||||
FileTransferActivity::callback_nothing_to_do,
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
/// ### switch_input_field
|
||||
|
||||
@@ -441,15 +441,11 @@ impl SetupActivity {
|
||||
// Iterate over ssh keys
|
||||
let mut ssh_keys: Vec<ListItem> = Vec::with_capacity(cli.iter_ssh_keys().count());
|
||||
for key in cli.iter_ssh_keys() {
|
||||
if let Ok(host) = cli.get_ssh_key(key) {
|
||||
if let Some((addr, username, _)) = host {
|
||||
ssh_keys.push(ListItem::new(Span::from(format!(
|
||||
"{} at {}",
|
||||
username, addr,
|
||||
))));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if let Ok(Some((addr, username, _))) = cli.get_ssh_key(key) {
|
||||
ssh_keys.push(ListItem::new(Span::from(format!(
|
||||
"{} at {}",
|
||||
username, addr,
|
||||
))));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -168,13 +168,11 @@ impl Activity for SetupActivity {
|
||||
return;
|
||||
}
|
||||
// Read one event
|
||||
if let Ok(event) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||
if let Some(event) = event {
|
||||
// Set redraw to true
|
||||
self.redraw = true;
|
||||
// Handle event
|
||||
self.handle_input_event(&event);
|
||||
}
|
||||
if let Ok(Some(event)) = self.context.as_ref().unwrap().input_hnd.read_event() {
|
||||
// Set redraw to true
|
||||
self.redraw = true;
|
||||
// Handle event
|
||||
self.handle_input_event(&event);
|
||||
}
|
||||
// Redraw if necessary
|
||||
if self.redraw {
|
||||
|
||||
Reference in New Issue
Block a user