Removed CTRL key; just press associated key to perform command

This commit is contained in:
ChristianVisintin
2020-12-10 10:28:40 +01:00
parent 145b778ff3
commit 7e6044a41b
4 changed files with 83 additions and 99 deletions

View File

@@ -16,6 +16,9 @@ Work in progress
- file names are now sorted ignoring capital letters - file names are now sorted ignoring capital letters
- file names longer than 23, are now cut to 20 and followed by `...` - file names longer than 23, are now cut to 20 and followed by `...`
- paths which exceed tab size in explorer are elided with the following formato `ANCESTOR[1]/.../PARENT/DIRNAME` - paths which exceed tab size in explorer are elided with the following formato `ANCESTOR[1]/.../PARENT/DIRNAME`
- keybindings:
- `I`: show info about selected file or directory
- Removed `CTRL`; just use keys now.
- bugfix: - bugfix:
- prevent panic in set_progress, for progress values `> 100.0 or < 0.0` - prevent panic in set_progress, for progress values `> 100.0 or < 0.0`

View File

@@ -193,12 +193,13 @@ Password can be basically provided through 3 ways when address argument is provi
| `<PGDOWN>` | Move down in selected list by 8 rows | | `<PGDOWN>` | Move down in selected list by 8 rows |
| `<ENTER>` | Enter directory | | `<ENTER>` | Enter directory |
| `<SPACE>` | Upload / download selected file | | `<SPACE>` | Upload / download selected file |
| `<CTRL+D>` | Make directory | | `<D>` | Make directory |
| `<CTRL+G>` | Go to supplied path | | `<G>` | Go to supplied path |
| `<CTRL+H>` | Show help | | `<H>` | Show help |
| `<CTRL+Q>` | Quit TermSCP | | `<H>` | Show info about selected file or directory |
| `<CTRL+R>` | Rename file | | `<Q>` | Quit TermSCP |
| `<CTRL+U>` | Go to parent directory | | `<R>` | Rename file |
| `<U>` | Go to parent directory |
| `<CANC>` | Delete file | | `<CANC>` | Delete file |
--- ---

View File

@@ -194,24 +194,18 @@ impl FileTransferActivity {
} }
'g' | 'G' => { 'g' | 'G' => {
// Goto // Goto
// If ctrl is enabled... // Show input popup
if key.modifiers.intersects(KeyModifiers::CONTROL) { self.input_mode = InputMode::Popup(PopupType::Input(
// Show input popup String::from("Change working directory"),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_change_directory,
String::from("Change working directory"), ));
FileTransferActivity::callback_change_directory,
));
}
} }
'd' | 'D' => { 'd' | 'D' => {
// Make directory // Make directory
// If ctrl is enabled... self.input_mode = InputMode::Popup(PopupType::Input(
if key.modifiers.intersects(KeyModifiers::CONTROL) { String::from("Insert directory name"),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_mkdir,
String::from("Insert directory name"), ));
FileTransferActivity::callback_mkdir,
));
}
} }
'h' | 'H' => { 'h' | 'H' => {
// Show help // Show help
@@ -223,34 +217,25 @@ impl FileTransferActivity {
} }
'r' | 'R' => { 'r' | 'R' => {
// Rename // Rename
// If ctrl is enabled... self.input_mode = InputMode::Popup(PopupType::Input(
if key.modifiers.intersects(KeyModifiers::CONTROL) { String::from("Insert new name"),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_rename,
String::from("Insert new name"), ));
FileTransferActivity::callback_rename,
));
}
} }
's' | 'S' => { 's' | 'S' => {
// Save as... // Save as...
// If ctrl is enabled... // Ask for input
if key.modifiers.intersects(KeyModifiers::CONTROL) { self.input_mode = InputMode::Popup(PopupType::Input(
// Ask for input String::from("Save as..."),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_save_as,
String::from("Save as..."), ));
FileTransferActivity::callback_save_as,
));
}
} }
'u' | 'U' => { 'u' | 'U' => {
// Go to parent directory // Go to parent directory
// If ctrl is enabled... // Get pwd
if key.modifiers.intersects(KeyModifiers::CONTROL) { let path: PathBuf = self.context.as_ref().unwrap().local.pwd();
// Get pwd if let Some(parent) = path.as_path().parent() {
let path: PathBuf = self.context.as_ref().unwrap().local.pwd(); self.local_changedir(parent, true);
if let Some(parent) = path.as_path().parent() {
self.local_changedir(parent, true);
}
} }
} }
' ' => { ' ' => {
@@ -411,24 +396,18 @@ impl FileTransferActivity {
} }
'g' | 'G' => { 'g' | 'G' => {
// Goto // Goto
// If ctrl is enabled... // Show input popup
if key.modifiers.intersects(KeyModifiers::CONTROL) { self.input_mode = InputMode::Popup(PopupType::Input(
// Show input popup String::from("Change working directory"),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_change_directory,
String::from("Change working directory"), ));
FileTransferActivity::callback_change_directory,
));
}
} }
'd' | 'D' => { 'd' | 'D' => {
// Make directory // Make directory
// If ctrl is enabled... self.input_mode = InputMode::Popup(PopupType::Input(
if key.modifiers.intersects(KeyModifiers::CONTROL) { String::from("Insert directory name"),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_mkdir,
String::from("Insert directory name"), ));
FileTransferActivity::callback_mkdir,
));
}
} }
'h' | 'H' => { 'h' | 'H' => {
// Show help // Show help
@@ -440,43 +419,34 @@ impl FileTransferActivity {
} }
'r' | 'R' => { 'r' | 'R' => {
// Rename // Rename
// If ctrl is enabled... self.input_mode = InputMode::Popup(PopupType::Input(
if key.modifiers.intersects(KeyModifiers::CONTROL) { String::from("Insert new name"),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_rename,
String::from("Insert new name"), ));
FileTransferActivity::callback_rename,
));
}
} }
's' | 'S' => { 's' | 'S' => {
// Save as... // Save as...
// If ctrl is enabled... // Ask for input
if key.modifiers.intersects(KeyModifiers::CONTROL) { self.input_mode = InputMode::Popup(PopupType::Input(
// Ask for input String::from("Save as..."),
self.input_mode = InputMode::Popup(PopupType::Input( FileTransferActivity::callback_save_as,
String::from("Save as..."), ));
FileTransferActivity::callback_save_as,
));
}
} }
'u' | 'U' => { 'u' | 'U' => {
// Go to parent directory // Go to parent directory
// If ctrl is enabled... // Get pwd
if key.modifiers.intersects(KeyModifiers::CONTROL) { match self.client.pwd() {
// Get pwd Ok(path) => {
match self.client.pwd() { if let Some(parent) = path.as_path().parent() {
Ok(path) => { self.remote_changedir(parent, true);
if let Some(parent) = path.as_path().parent() {
self.remote_changedir(parent, true);
}
}
Err(err) => {
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not change working directory: {}", err),
))
} }
} }
Err(err) => {
self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Red,
format!("Could not change working directory: {}", err),
))
}
} }
} }
' ' => { ' ' => {

View File

@@ -761,62 +761,72 @@ impl FileTransferActivity {
])), ])),
ListItem::new(Spans::from(vec![ ListItem::new(Spans::from(vec![
Span::styled( Span::styled(
"<CTRL+D>", "<D>",
Style::default() Style::default()
.fg(Color::Cyan) .fg(Color::Cyan)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
), ),
Span::raw(" "), Span::raw(" "),
Span::raw("make directory"), Span::raw("make directory"),
])), ])),
ListItem::new(Spans::from(vec![ ListItem::new(Spans::from(vec![
Span::styled( Span::styled(
"<CTRL+G>", "<G>",
Style::default() Style::default()
.fg(Color::Cyan) .fg(Color::Cyan)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
), ),
Span::raw(" "), Span::raw(" "),
Span::raw("goto path"), Span::raw("goto path"),
])), ])),
ListItem::new(Spans::from(vec![ ListItem::new(Spans::from(vec![
Span::styled( Span::styled(
"<CTRL+H>", "<H>",
Style::default() Style::default()
.fg(Color::Cyan) .fg(Color::Cyan)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
), ),
Span::raw(" "), Span::raw(" "),
Span::raw("show help"), Span::raw("show help"),
])), ])),
ListItem::new(Spans::from(vec![ ListItem::new(Spans::from(vec![
Span::styled( Span::styled(
"<CTRL+Q>", "<I>",
Style::default() Style::default()
.fg(Color::Cyan) .fg(Color::Cyan)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
), ),
Span::raw(" "), Span::raw(" "),
Span::raw("show info about the selected file or directory"),
])),
ListItem::new(Spans::from(vec![
Span::styled(
"<Q>",
Style::default()
.fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
),
Span::raw(" "),
Span::raw("Quit TermSCP"), Span::raw("Quit TermSCP"),
])), ])),
ListItem::new(Spans::from(vec![ ListItem::new(Spans::from(vec![
Span::styled( Span::styled(
"<CTRL+R>", "<R>",
Style::default() Style::default()
.fg(Color::Cyan) .fg(Color::Cyan)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
), ),
Span::raw(" "), Span::raw(" "),
Span::raw("rename file"), Span::raw("rename file"),
])), ])),
ListItem::new(Spans::from(vec![ ListItem::new(Spans::from(vec![
Span::styled( Span::styled(
"<CTRL+U>", "<U>",
Style::default() Style::default()
.fg(Color::Cyan) .fg(Color::Cyan)
.add_modifier(Modifier::BOLD), .add_modifier(Modifier::BOLD),
), ),
Span::raw(" "), Span::raw(" "),
Span::raw("go to parent directory"), Span::raw("go to parent directory"),
])), ])),
]; ];