CTRL + M (makedir)

This commit is contained in:
ChristianVisintin
2020-11-27 17:15:59 +01:00
parent dc7e7b726e
commit 64c3d88318

View File

@@ -441,8 +441,7 @@ impl FileTransferActivity {
// Make directory // Make directory
// If ctrl is enabled... // If ctrl is enabled...
if key.modifiers.intersects(KeyModifiers::CONTROL) { if key.modifiers.intersects(KeyModifiers::CONTROL) {
// TODO: self.input_mode = InputMode::Popup(PopupType::Input(String::from("Insert directory name"), FileTransferActivity::callback_mkdir));
//self.input_mode = InputMode::Popup(PopupType::Input(String::from("Insert directory name")))
} }
} }
'r' | 'R' => { 'r' | 'R' => {
@@ -724,6 +723,48 @@ impl FileTransferActivity {
} }
} }
/// ### callback_mkdir
///
/// Callback for MKDIR command (supports both locale and remote)
fn callback_mkdir(&mut self, context: &mut Context, input: String) {
match self.tab {
FileExplorerTab::Local => {
match context.local.mkdir(input.clone()) {
Ok(_) => {
// Reload files
self.log(LogLevel::Info, format!("Created directory \"{}\"", input));
self.local.files = context.local.list_dir();
},
Err(err) => {
// Report err
self.log(LogLevel::Error, format!("Could not create directory \"{}\": {}", input, err));
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not create directory \"{}\": {}", input, err),
));
}
}
}
FileExplorerTab::Remote => {
match self.client.mkdir(input.clone()) {
Ok(_) => {
// Reload files
self.log(LogLevel::Info, format!("Created directory \"{}\"", input));
self.reload_remote_dir();
},
Err(err) => {
// Report err
self.log(LogLevel::Error, format!("Could not create directory \"{}\": {}", input, err));
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not create directory \"{}\": {}", input, err),
));
}
}
}
}
}
/// ### callback_delete_fsentry /// ### callback_delete_fsentry
/// ///
/// Delete current selected fsentry in the currently selected TAB /// Delete current selected fsentry in the currently selected TAB
@@ -750,7 +791,7 @@ impl FileTransferActivity {
} }
Err(err) => { Err(err) => {
self.log( self.log(
LogLevel::Info, LogLevel::Error,
format!( format!(
"Could not delete file \"{}\": {}", "Could not delete file \"{}\": {}",
full_path.display(), full_path.display(),
@@ -784,7 +825,7 @@ impl FileTransferActivity {
} }
Err(err) => { Err(err) => {
self.log( self.log(
LogLevel::Info, LogLevel::Error,
format!( format!(
"Could not delete file \"{}\": {}", "Could not delete file \"{}\": {}",
full_path.display(), full_path.display(),