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 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`
- keybindings:
- `I`: show info about selected file or directory
- Removed `CTRL`; just use keys now.
- bugfix:
- 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 |
| `<ENTER>` | Enter directory |
| `<SPACE>` | Upload / download selected file |
| `<CTRL+D>` | Make directory |
| `<CTRL+G>` | Go to supplied path |
| `<CTRL+H>` | Show help |
| `<CTRL+Q>` | Quit TermSCP |
| `<CTRL+R>` | Rename file |
| `<CTRL+U>` | Go to parent directory |
| `<D>` | Make directory |
| `<G>` | Go to supplied path |
| `<H>` | Show help |
| `<H>` | Show info about selected file or directory |
| `<Q>` | Quit TermSCP |
| `<R>` | Rename file |
| `<U>` | Go to parent directory |
| `<CANC>` | Delete file |
---

View file

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

View file

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