mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Fixed YesNoDialog
This commit is contained in:
@@ -96,7 +96,7 @@ enum PopupType {
|
|||||||
Input(String, OnInputSubmitCallback), // Input description; Callback for submit
|
Input(String, OnInputSubmitCallback), // Input description; Callback for submit
|
||||||
Progress(String), // Progress block text
|
Progress(String), // Progress block text
|
||||||
Wait(String), // Wait block text
|
Wait(String), // Wait block text
|
||||||
YesNo(String, DialogYesNoOption, DialogCallback, DialogCallback), // Yes, no callback
|
YesNo(String, DialogCallback, DialogCallback), // Yes, no callback
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ## InputMode
|
/// ## InputMode
|
||||||
@@ -182,6 +182,7 @@ pub struct FileTransferActivity {
|
|||||||
input_mode: InputMode, // Current input mode
|
input_mode: InputMode, // Current input mode
|
||||||
input_field: InputField, // Current selected input mode
|
input_field: InputField, // Current selected input mode
|
||||||
input_txt: String, // Input text
|
input_txt: String, // Input text
|
||||||
|
choice_opt: DialogYesNoOption, // Dialog popup selected option
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileTransferActivity {
|
impl FileTransferActivity {
|
||||||
@@ -194,6 +195,10 @@ impl FileTransferActivity {
|
|||||||
disconnected: false,
|
disconnected: false,
|
||||||
quit: false,
|
quit: false,
|
||||||
params: params,
|
params: params,
|
||||||
|
client: match protocol {
|
||||||
|
FileTransferProtocol::Sftp => Box::new(SftpFileTransfer::new()),
|
||||||
|
FileTransferProtocol::Ftp => Box::new(SftpFileTransfer::new()), // FIXME: FTP
|
||||||
|
},
|
||||||
local: FileExplorer::new(),
|
local: FileExplorer::new(),
|
||||||
remote: FileExplorer::new(),
|
remote: FileExplorer::new(),
|
||||||
tab: FileExplorerTab::Local,
|
tab: FileExplorerTab::Local,
|
||||||
@@ -204,10 +209,7 @@ impl FileTransferActivity {
|
|||||||
input_mode: InputMode::Explorer,
|
input_mode: InputMode::Explorer,
|
||||||
input_field: InputField::Explorer,
|
input_field: InputField::Explorer,
|
||||||
input_txt: String::new(),
|
input_txt: String::new(),
|
||||||
client: match protocol {
|
choice_opt: DialogYesNoOption::Yes,
|
||||||
FileTransferProtocol::Sftp => Box::new(SftpFileTransfer::new()),
|
|
||||||
FileTransferProtocol::Ftp => Box::new(SftpFileTransfer::new()), // FIXME: FTP
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,8 +368,8 @@ 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) => {
|
PopupType::YesNo(_, yes_cb, no_cb) => {
|
||||||
self.handle_input_event_mode_popup_yesno(ev, opt, yes_cb, no_cb)
|
self.handle_input_event_mode_popup_yesno(ev, yes_cb, no_cb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,11 +464,10 @@ impl FileTransferActivity {
|
|||||||
fn handle_input_event_mode_popup_yesno(
|
fn handle_input_event_mode_popup_yesno(
|
||||||
&mut self,
|
&mut self,
|
||||||
ev: &InputEvent,
|
ev: &InputEvent,
|
||||||
opt: DialogYesNoOption,
|
|
||||||
yes_cb: DialogCallback,
|
yes_cb: DialogCallback,
|
||||||
no_cb: DialogCallback,
|
no_cb: DialogCallback,
|
||||||
) {
|
) {
|
||||||
// If enter, close popup
|
// If enter, close popup, otherwise move dialog option
|
||||||
match ev {
|
match ev {
|
||||||
InputEvent::Key(key) => {
|
InputEvent::Key(key) => {
|
||||||
match key.code {
|
match key.code {
|
||||||
@@ -474,11 +475,13 @@ impl FileTransferActivity {
|
|||||||
// @! Set input mode to Explorer BEFORE CALLBACKS!!! Callback can then overwrite this, clever uh?
|
// @! Set input mode to Explorer BEFORE CALLBACKS!!! Callback can then overwrite this, clever uh?
|
||||||
self.input_mode = InputMode::Explorer;
|
self.input_mode = InputMode::Explorer;
|
||||||
// Check if user selected yes or not
|
// Check if user selected yes or not
|
||||||
match opt {
|
match self.choice_opt {
|
||||||
DialogYesNoOption::No => no_cb(),
|
DialogYesNoOption::No => no_cb(),
|
||||||
DialogYesNoOption::Yes => yes_cb(),
|
DialogYesNoOption::Yes => yes_cb(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
KeyCode::Right => self.choice_opt = DialogYesNoOption::No, // Set to NO
|
||||||
|
KeyCode::Left => self.choice_opt = DialogYesNoOption::Yes, // Set to YES
|
||||||
_ => { /* Nothing to do */ }
|
_ => { /* Nothing to do */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user