mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
fmt
This commit is contained in:
@@ -29,8 +29,8 @@ extern crate tui;
|
|||||||
extern crate unicode_width;
|
extern crate unicode_width;
|
||||||
|
|
||||||
// locals
|
// locals
|
||||||
use crate::filetransfer::FileTransferProtocol;
|
|
||||||
use super::{Activity, Context};
|
use super::{Activity, Context};
|
||||||
|
use crate::filetransfer::FileTransferProtocol;
|
||||||
|
|
||||||
// File transfer
|
// File transfer
|
||||||
use crate::filetransfer::sftp_transfer::SftpFileTransfer;
|
use crate::filetransfer::sftp_transfer::SftpFileTransfer;
|
||||||
@@ -216,11 +216,16 @@ impl FileTransferActivity {
|
|||||||
/// Connect to remote
|
/// Connect to remote
|
||||||
fn connect(&mut self) {
|
fn connect(&mut self) {
|
||||||
// Connect to remote
|
// Connect to remote
|
||||||
match self.client.connect(self.params.address.clone(), self.params.port, self.params.username.clone(), self.params.password.clone()) {
|
match self.client.connect(
|
||||||
|
self.params.address.clone(),
|
||||||
|
self.params.port,
|
||||||
|
self.params.username.clone(),
|
||||||
|
self.params.password.clone(),
|
||||||
|
) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Set state to explorer
|
// Set state to explorer
|
||||||
self.input_mode = InputMode::Explorer;
|
self.input_mode = InputMode::Explorer;
|
||||||
},
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Set popup fatal error
|
// Set popup fatal error
|
||||||
self.input_mode = InputMode::Popup(PopupType::Fatal(err.msg()));
|
self.input_mode = InputMode::Popup(PopupType::Fatal(err.msg()));
|
||||||
@@ -270,25 +275,38 @@ impl FileTransferActivity {
|
|||||||
fn handle_input_event_mode_explorer(&mut self, context: &mut Context, ev: &InputEvent) {
|
fn handle_input_event_mode_explorer(&mut self, context: &mut Context, ev: &InputEvent) {
|
||||||
// Match input field
|
// Match input field
|
||||||
match self.input_field {
|
match self.input_field {
|
||||||
InputField::Explorer => match self.tab { // Match current selected tab
|
InputField::Explorer => match self.tab {
|
||||||
FileExplorerTab::Local => self.handle_input_event_mode_explorer_tab_local(context, ev),
|
// Match current selected tab
|
||||||
FileExplorerTab::Remote => self.handle_input_event_mode_explorer_tab_remote(context, ev)
|
FileExplorerTab::Local => {
|
||||||
|
self.handle_input_event_mode_explorer_tab_local(context, ev)
|
||||||
|
}
|
||||||
|
FileExplorerTab::Remote => {
|
||||||
|
self.handle_input_event_mode_explorer_tab_remote(context, ev)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
InputField::Logs => self.handle_input_event_mode_explorer_log(ev)
|
InputField::Logs => self.handle_input_event_mode_explorer_log(ev),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### handle_input_event_mode_explorer_tab_local
|
/// ### handle_input_event_mode_explorer_tab_local
|
||||||
///
|
///
|
||||||
/// Input event handler for explorer mode when localhost tab is selected
|
/// Input event handler for explorer mode when localhost tab is selected
|
||||||
fn handle_input_event_mode_explorer_tab_local(&mut self, context: &mut Context, ev: &InputEvent) {
|
fn handle_input_event_mode_explorer_tab_local(
|
||||||
|
&mut self,
|
||||||
|
context: &mut Context,
|
||||||
|
ev: &InputEvent,
|
||||||
|
) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### handle_input_event_mode_explorer_tab_local
|
/// ### handle_input_event_mode_explorer_tab_local
|
||||||
///
|
///
|
||||||
/// Input event handler for explorer mode when remote tab is selected
|
/// Input event handler for explorer mode when remote tab is selected
|
||||||
fn handle_input_event_mode_explorer_tab_remote(&mut self, context: &mut Context, ev: &InputEvent) {
|
fn handle_input_event_mode_explorer_tab_remote(
|
||||||
|
&mut self,
|
||||||
|
context: &mut Context,
|
||||||
|
ev: &InputEvent,
|
||||||
|
) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,13 +325,13 @@ impl FileTransferActivity {
|
|||||||
if self.log_index > 0 {
|
if self.log_index > 0 {
|
||||||
self.log_index = self.log_index - 1;
|
self.log_index = self.log_index - 1;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
KeyCode::Down => {
|
KeyCode::Down => {
|
||||||
// Increase log index
|
// Increase log index
|
||||||
if self.log_index + 1 >= self.log_size {
|
if self.log_index + 1 >= self.log_size {
|
||||||
self.log_index = self.log_index + 1;
|
self.log_index = self.log_index + 1;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
KeyCode::PageUp => {
|
KeyCode::PageUp => {
|
||||||
// Fast decreasing of log index
|
// Fast decreasing of log index
|
||||||
if self.log_index >= records_block {
|
if self.log_index >= records_block {
|
||||||
@@ -321,10 +339,11 @@ impl FileTransferActivity {
|
|||||||
} else {
|
} else {
|
||||||
self.log_index = 0; // Set to 0 otherwise
|
self.log_index = 0; // Set to 0 otherwise
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
KeyCode::PageDown => {
|
KeyCode::PageDown => {
|
||||||
// Fast increasing of log index
|
// Fast increasing of log index
|
||||||
if self.log_index + records_block >= self.log_size { // If overflows, set to size
|
if self.log_index + records_block >= self.log_size {
|
||||||
|
// If overflows, set to size
|
||||||
self.log_index = self.log_size - 1;
|
self.log_index = self.log_size - 1;
|
||||||
} else {
|
} else {
|
||||||
self.log_index = self.log_index + records_block; // Increase by `records_block`
|
self.log_index = self.log_index + records_block; // Increase by `records_block`
|
||||||
@@ -347,7 +366,9 @@ impl FileTransferActivity {
|
|||||||
PopupType::Input(_, cb) => self.handle_input_event_mode_popup_input(ev, cb),
|
PopupType::Input(_, cb) => self.handle_input_event_mode_popup_input(ev, cb),
|
||||||
PopupType::Progress(_) => self.handle_input_event_mode_popup_progress(ev),
|
PopupType::Progress(_) => self.handle_input_event_mode_popup_progress(ev),
|
||||||
PopupType::Wait(_) => self.handle_input_event_mode_popup_wait(ev),
|
PopupType::Wait(_) => self.handle_input_event_mode_popup_wait(ev),
|
||||||
PopupType::YesNo(_, opt, yes_cb, no_cb) => self.handle_input_event_mode_popup_yesno(ev, opt, yes_cb, no_cb),
|
PopupType::YesNo(_, opt, yes_cb, no_cb) => {
|
||||||
|
self.handle_input_event_mode_popup_yesno(ev, opt, yes_cb, no_cb)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +459,13 @@ impl FileTransferActivity {
|
|||||||
/// ### handle_input_event_mode_explorer_alert
|
/// ### handle_input_event_mode_explorer_alert
|
||||||
///
|
///
|
||||||
/// Input event handler for popup alert
|
/// Input event handler for popup alert
|
||||||
fn handle_input_event_mode_popup_yesno(&mut self, ev: &InputEvent, opt: DialogYesNoOption, yes_cb: DialogCallback, no_cb: DialogCallback) {
|
fn handle_input_event_mode_popup_yesno(
|
||||||
|
&mut self,
|
||||||
|
ev: &InputEvent,
|
||||||
|
opt: DialogYesNoOption,
|
||||||
|
yes_cb: DialogCallback,
|
||||||
|
no_cb: DialogCallback,
|
||||||
|
) {
|
||||||
// If enter, close popup
|
// If enter, close popup
|
||||||
match ev {
|
match ev {
|
||||||
InputEvent::Key(key) => {
|
InputEvent::Key(key) => {
|
||||||
@@ -449,7 +476,7 @@ impl FileTransferActivity {
|
|||||||
// Check if user selected yes or not
|
// Check if user selected yes or not
|
||||||
match opt {
|
match opt {
|
||||||
DialogYesNoOption::No => no_cb(),
|
DialogYesNoOption::No => no_cb(),
|
||||||
DialogYesNoOption::Yes => yes_cb()
|
DialogYesNoOption::Yes => yes_cb(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => { /* Nothing to do */ }
|
_ => { /* Nothing to do */ }
|
||||||
@@ -559,7 +586,10 @@ impl Activity for FileTransferActivity {
|
|||||||
// Check if connected
|
// Check if connected
|
||||||
if !self.client.is_connected() {
|
if !self.client.is_connected() {
|
||||||
// Set init state to connecting popup
|
// Set init state to connecting popup
|
||||||
self.input_mode = InputMode::Popup(PopupType::Wait(format!("Connecting to {}:{}...", self.params.address, self.params.port)));
|
self.input_mode = InputMode::Popup(PopupType::Wait(format!(
|
||||||
|
"Connecting to {}:{}...",
|
||||||
|
self.params.address, self.params.port
|
||||||
|
)));
|
||||||
// Force ui draw
|
// Force ui draw
|
||||||
let _ = context.terminal.draw(|f| {
|
let _ = context.terminal.draw(|f| {
|
||||||
self.draw(f);
|
self.draw(f);
|
||||||
|
|||||||
Reference in New Issue
Block a user