Bumped tui-realm to 0.2.1

This commit is contained in:
veeso
2021-05-02 12:09:32 +02:00
parent 4bd18c1386
commit e90f561584
14 changed files with 87 additions and 83 deletions

View File

@@ -28,8 +28,9 @@ Released on FIXME: ??
- Fixed error message not being shown after an upload failure - Fixed error message not being shown after an upload failure
- [Issue 23](https://github.com/veeso/termscp/issues/23): Remove created file if transfer failed or was abrupted - [Issue 23](https://github.com/veeso/termscp/issues/23): Remove created file if transfer failed or was abrupted
- Dependencies: - Dependencies:
- Added `tui-realm 0.1.0` - Added `tui-realm 0.2.1`
- Removed `tui` - Removed `tui` (as direct dependency)
- Updated `regex` to `1.5.3`
## 0.4.2 ## 0.4.2

12
Cargo.lock generated
View File

@@ -986,9 +986,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.5.2" version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efb2352a0f4d4b128f734b5c44c79ff80117351138733f12f982fe3e2b13343" checksum = "ce5f1ceb7f74abbce32601642fcf8e8508a8a8991e0621c7d750295b9095702b"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@@ -997,9 +997,9 @@ dependencies = [
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.24" version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00efb87459ba4f6fb2169d20f68565555688e1250ee6825cdf6254f8b48fafb2" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
@@ -1392,9 +1392,9 @@ dependencies = [
[[package]] [[package]]
name = "tuirealm" name = "tuirealm"
version = "0.1.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb016a1b4aa98d5488cd109d568c31ef0f3f34196b6f3b551deefab01443f83" checksum = "2cade7d98a40066164d9c8e52bf01f86ecaa4fa810e854855a5a4ec3deca83c2"
dependencies = [ dependencies = [
"crossterm 0.19.0", "crossterm 0.19.0",
"textwrap", "textwrap",

View File

@@ -39,14 +39,14 @@ hostname = "0.3.1"
lazy_static = "1.4.0" lazy_static = "1.4.0"
magic-crypt = "3.1.7" magic-crypt = "3.1.7"
rand = "0.8.3" rand = "0.8.3"
regex = "1.4.5" regex = "1.5.3"
rpassword = "5.0.1" rpassword = "5.0.1"
ssh2 = "0.9.0" ssh2 = "0.9.0"
tempfile = "3.1.0" tempfile = "3.1.0"
textwrap = "0.13.4" textwrap = "0.13.4"
thiserror = "^1.0.0" thiserror = "^1.0.0"
toml = "0.5.8" toml = "0.5.8"
tuirealm = { version = "0.1.0", features = [ "with-components" ] } tuirealm = { version = "0.2.1", features = [ "with-components" ] }
whoami = "1.1.1" whoami = "1.1.1"
wildmatch = "2.0.0" wildmatch = "2.0.0"

View File

@@ -36,7 +36,7 @@ use crate::system::environment;
// Ext // Ext
use std::path::PathBuf; use std::path::PathBuf;
use tuirealm::components::{input::InputPropsBuilder, radio::RadioPropsBuilder}; use tuirealm::components::{input::InputPropsBuilder, radio::RadioPropsBuilder};
use tuirealm::{Payload, PropsBuilder}; use tuirealm::{Payload, PropsBuilder, Value};
impl AuthActivity { impl AuthActivity {
/// ### del_bookmark /// ### del_bookmark
@@ -85,8 +85,8 @@ impl AuthActivity {
.view .view
.get_state(super::COMPONENT_RADIO_BOOKMARK_SAVE_PWD) .get_state(super::COMPONENT_RADIO_BOOKMARK_SAVE_PWD)
{ {
Some(Payload::Unsigned(0)) => Some(password), // Yes Some(Payload::One(Value::Usize(0))) => Some(password), // Yes
_ => None, // No such component / No _ => None, // No such component / No
}, },
false => None, false => None,
}; };

View File

@@ -35,7 +35,7 @@ use super::{
COMPONENT_TEXT_HELP, COMPONENT_TEXT_HELP,
}; };
use crate::ui::activities::keymap::*; use crate::ui::activities::keymap::*;
use tuirealm::{Msg, Payload}; use tuirealm::{Msg, Payload, Value};
// -- update // -- update
@@ -140,13 +140,13 @@ impl AuthActivity {
None None
} }
// Enter // Enter
(COMPONENT_BOOKMARKS_LIST, Msg::OnSubmit(Payload::Unsigned(idx))) => { (COMPONENT_BOOKMARKS_LIST, Msg::OnSubmit(Payload::One(Value::Usize(idx)))) => {
self.load_bookmark(*idx); self.load_bookmark(*idx);
// Give focus to input password // Give focus to input password
self.view.active(COMPONENT_INPUT_PASSWORD); self.view.active(COMPONENT_INPUT_PASSWORD);
None None
} }
(COMPONENT_RECENTS_LIST, Msg::OnSubmit(Payload::Unsigned(idx))) => { (COMPONENT_RECENTS_LIST, Msg::OnSubmit(Payload::One(Value::Usize(idx)))) => {
self.load_recent(*idx); self.load_recent(*idx);
// Give focus to input password // Give focus to input password
self.view.active(COMPONENT_INPUT_PASSWORD); self.view.active(COMPONENT_INPUT_PASSWORD);
@@ -156,7 +156,7 @@ impl AuthActivity {
// Del bookmarks // Del bookmarks
( (
COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK, COMPONENT_RADIO_BOOKMARK_DEL_BOOKMARK,
Msg::OnSubmit(Payload::Unsigned(index)), Msg::OnSubmit(Payload::One(Value::Usize(index))),
) => { ) => {
// hide bookmark delete // hide bookmark delete
self.umount_bookmark_del_dialog(); self.umount_bookmark_del_dialog();
@@ -165,7 +165,7 @@ impl AuthActivity {
0 => { 0 => {
// Get selected bookmark // Get selected bookmark
match self.view.get_state(COMPONENT_BOOKMARKS_LIST) { match self.view.get_state(COMPONENT_BOOKMARKS_LIST) {
Some(Payload::Unsigned(index)) => { Some(Payload::One(Value::Usize(index))) => {
// Delete bookmark // Delete bookmark
self.del_bookmark(index); self.del_bookmark(index);
// Update bookmarks // Update bookmarks
@@ -177,7 +177,10 @@ impl AuthActivity {
_ => None, _ => None,
} }
} }
(COMPONENT_RADIO_BOOKMARK_DEL_RECENT, Msg::OnSubmit(Payload::Unsigned(index))) => { (
COMPONENT_RADIO_BOOKMARK_DEL_RECENT,
Msg::OnSubmit(Payload::One(Value::Usize(index))),
) => {
// hide bookmark delete // hide bookmark delete
self.umount_recent_del_dialog(); self.umount_recent_del_dialog();
// Index must be 0 => YES // Index must be 0 => YES
@@ -185,7 +188,7 @@ impl AuthActivity {
0 => { 0 => {
// Get selected bookmark // Get selected bookmark
match self.view.get_state(COMPONENT_RECENTS_LIST) { match self.view.get_state(COMPONENT_RECENTS_LIST) {
Some(Payload::Unsigned(index)) => { Some(Payload::One(Value::Usize(index))) => {
// Delete recent // Delete recent
self.del_recent(index); self.del_recent(index);
// Update bookmarks // Update bookmarks
@@ -246,12 +249,12 @@ impl AuthActivity {
// Get values // Get values
let bookmark_name: String = let bookmark_name: String =
match self.view.get_state(COMPONENT_INPUT_BOOKMARK_NAME) { match self.view.get_state(COMPONENT_INPUT_BOOKMARK_NAME) {
Some(Payload::Text(s)) => s, Some(Payload::One(Value::Str(s))) => s,
_ => String::new(), _ => String::new(),
}; };
let save_pwd: bool = matches!( let save_pwd: bool = matches!(
self.view.get_state(COMPONENT_RADIO_BOOKMARK_SAVE_PWD), self.view.get_state(COMPONENT_RADIO_BOOKMARK_SAVE_PWD),
Some(Payload::Unsigned(0)) Some(Payload::One(Value::Usize(0)))
); );
// Save bookmark // Save bookmark
self.save_bookmark(bookmark_name, save_pwd); self.save_bookmark(bookmark_name, save_pwd);
@@ -274,7 +277,7 @@ impl AuthActivity {
None None
} }
// Quit dialog // Quit dialog
(COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::Unsigned(choice))) => { (COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::One(Value::Usize(choice)))) => {
// If choice is 0, quit termscp // If choice is 0, quit termscp
if *choice == 0 { if *choice == 0 {
self.exit_reason = Some(super::ExitReason::Quit); self.exit_reason = Some(super::ExitReason::Quit);

View File

@@ -47,7 +47,7 @@ use tuirealm::tui::{
}; };
use tuirealm::{ use tuirealm::{
props::{InputType, PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder}, props::{InputType, PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder},
Msg, Payload, Msg, Payload, Value,
}; };
impl AuthActivity { impl AuthActivity {
@@ -689,16 +689,16 @@ impl AuthActivity {
/// Collect input values from view /// Collect input values from view
pub(super) fn get_input(&self) -> (String, u16, FileTransferProtocol, String, String) { pub(super) fn get_input(&self) -> (String, u16, FileTransferProtocol, String, String) {
let addr: String = match self.view.get_state(super::COMPONENT_INPUT_ADDR) { let addr: String = match self.view.get_state(super::COMPONENT_INPUT_ADDR) {
Some(Payload::Text(a)) => a, Some(Payload::One(Value::Str(a))) => a,
_ => String::new(), _ => String::new(),
}; };
let port: u16 = match self.view.get_state(super::COMPONENT_INPUT_PORT) { let port: u16 = match self.view.get_state(super::COMPONENT_INPUT_PORT) {
Some(Payload::Unsigned(p)) => p as u16, Some(Payload::One(Value::Usize(p))) => p as u16,
_ => 0, _ => 0,
}; };
let protocol: FileTransferProtocol = let protocol: FileTransferProtocol =
match self.view.get_state(super::COMPONENT_RADIO_PROTOCOL) { match self.view.get_state(super::COMPONENT_RADIO_PROTOCOL) {
Some(Payload::Unsigned(p)) => match p { Some(Payload::One(Value::Usize(p))) => match p {
1 => FileTransferProtocol::Scp, 1 => FileTransferProtocol::Scp,
2 => FileTransferProtocol::Ftp(false), 2 => FileTransferProtocol::Ftp(false),
3 => FileTransferProtocol::Ftp(true), 3 => FileTransferProtocol::Ftp(true),
@@ -707,11 +707,11 @@ impl AuthActivity {
_ => FileTransferProtocol::Sftp, _ => FileTransferProtocol::Sftp,
}; };
let username: String = match self.view.get_state(super::COMPONENT_INPUT_USERNAME) { let username: String = match self.view.get_state(super::COMPONENT_INPUT_USERNAME) {
Some(Payload::Text(a)) => a, Some(Payload::One(Value::Str(a))) => a,
_ => String::new(), _ => String::new(),
}; };
let password: String = match self.view.get_state(super::COMPONENT_INPUT_PASSWORD) { let password: String = match self.view.get_state(super::COMPONENT_INPUT_PASSWORD) {
Some(Payload::Text(a)) => a, Some(Payload::One(Value::Str(a))) => a,
_ => String::new(), _ => String::new(),
}; };
(addr, port, protocol, username, password) (addr, port, protocol, username, password)

View File

@@ -27,7 +27,7 @@
*/ */
// locals // locals
use super::{FileExplorerTab, FileTransferActivity, FsEntry, LogLevel}; use super::{FileExplorerTab, FileTransferActivity, FsEntry, LogLevel};
use tuirealm::Payload; use tuirealm::{Payload, Value};
// externals // externals
use std::path::PathBuf; use std::path::PathBuf;
@@ -623,7 +623,7 @@ impl FileTransferActivity {
/// Get index of selected file in the local tab /// Get index of selected file in the local tab
fn get_local_file_idx(&self) -> Option<usize> { fn get_local_file_idx(&self) -> Option<usize> {
match self.view.get_state(super::COMPONENT_EXPLORER_LOCAL) { match self.view.get_state(super::COMPONENT_EXPLORER_LOCAL) {
Some(Payload::Unsigned(idx)) => Some(idx), Some(Payload::One(Value::Usize(idx))) => Some(idx),
_ => None, _ => None,
} }
} }
@@ -633,7 +633,7 @@ impl FileTransferActivity {
/// Get index of selected file in the remote file /// Get index of selected file in the remote file
fn get_remote_file_idx(&self) -> Option<usize> { fn get_remote_file_idx(&self) -> Option<usize> {
match self.view.get_state(super::COMPONENT_EXPLORER_REMOTE) { match self.view.get_state(super::COMPONENT_EXPLORER_REMOTE) {
Some(Payload::Unsigned(idx)) => Some(idx), Some(Payload::One(Value::Usize(idx))) => Some(idx),
_ => None, _ => None,
} }
} }

View File

@@ -48,7 +48,7 @@ use tuirealm::{
components::progress_bar::ProgressBarPropsBuilder, components::progress_bar::ProgressBarPropsBuilder,
props::{PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder}, props::{PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder},
tui::style::Color, tui::style::Color,
Msg, Payload, Msg, Payload, Value,
}; };
impl FileTransferActivity { impl FileTransferActivity {
@@ -79,7 +79,7 @@ impl FileTransferActivity {
// Reload file list component // Reload file list component
self.update_local_filelist() self.update_local_filelist()
} }
(COMPONENT_EXPLORER_LOCAL, Msg::OnSubmit(Payload::Unsigned(idx))) => { (COMPONENT_EXPLORER_LOCAL, Msg::OnSubmit(Payload::One(Value::Usize(idx)))) => {
// Match selected file // Match selected file
let mut entry: Option<FsEntry> = None; let mut entry: Option<FsEntry> = None;
if let Some(e) = self.local.get(*idx) { if let Some(e) = self.local.get(*idx) {
@@ -186,7 +186,7 @@ impl FileTransferActivity {
self.tab = FileExplorerTab::Local; self.tab = FileExplorerTab::Local;
None None
} }
(COMPONENT_EXPLORER_REMOTE, Msg::OnSubmit(Payload::Unsigned(idx))) => { (COMPONENT_EXPLORER_REMOTE, Msg::OnSubmit(Payload::One(Value::Usize(idx)))) => {
// Match selected file // Match selected file
let mut entry: Option<FsEntry> = None; let mut entry: Option<FsEntry> = None;
if let Some(e) = self.remote.get(*idx) { if let Some(e) = self.remote.get(*idx) {
@@ -380,7 +380,7 @@ impl FileTransferActivity {
self.finalize_find(); self.finalize_find();
None None
} }
(COMPONENT_EXPLORER_FIND, Msg::OnSubmit(Payload::Unsigned(idx))) => { (COMPONENT_EXPLORER_FIND, Msg::OnSubmit(Payload::One(Value::Usize(idx)))) => {
// Find changedir // Find changedir
self.action_find_changedir(*idx); self.action_find_changedir(*idx);
// Umount find // Umount find
@@ -397,7 +397,7 @@ impl FileTransferActivity {
(COMPONENT_EXPLORER_FIND, &MSG_KEY_SPACE) => { (COMPONENT_EXPLORER_FIND, &MSG_KEY_SPACE) => {
// Get entry // Get entry
match self.view.get_state(COMPONENT_EXPLORER_FIND) { match self.view.get_state(COMPONENT_EXPLORER_FIND) {
Some(Payload::Unsigned(idx)) => { Some(Payload::One(Value::Usize(idx))) => {
self.action_find_transfer(idx, None); self.action_find_transfer(idx, None);
// Reload files // Reload files
match self.tab { match self.tab {
@@ -426,7 +426,7 @@ impl FileTransferActivity {
self.umount_copy(); self.umount_copy();
None None
} }
(COMPONENT_INPUT_COPY, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_COPY, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
// Copy file // Copy file
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_copy(input.to_string()), FileExplorerTab::Local => self.action_local_copy(input.to_string()),
@@ -446,7 +446,7 @@ impl FileTransferActivity {
self.umount_exec(); self.umount_exec();
None None
} }
(COMPONENT_INPUT_EXEC, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_EXEC, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
// Exex command // Exex command
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_exec(input.to_string()), FileExplorerTab::Local => self.action_local_exec(input.to_string()),
@@ -466,7 +466,7 @@ impl FileTransferActivity {
self.umount_find_input(); self.umount_find_input();
None None
} }
(COMPONENT_INPUT_FIND, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_FIND, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
self.umount_find_input(); self.umount_find_input();
// Find // Find
let res: Result<Vec<FsEntry>, String> = match self.tab { let res: Result<Vec<FsEntry>, String> = match self.tab {
@@ -503,7 +503,7 @@ impl FileTransferActivity {
self.umount_goto(); self.umount_goto();
None None
} }
(COMPONENT_INPUT_GOTO, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_GOTO, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_change_local_dir(input.to_string()), FileExplorerTab::Local => self.action_change_local_dir(input.to_string()),
FileExplorerTab::Remote => self.action_change_remote_dir(input.to_string()), FileExplorerTab::Remote => self.action_change_remote_dir(input.to_string()),
@@ -523,7 +523,7 @@ impl FileTransferActivity {
self.umount_mkdir(); self.umount_mkdir();
None None
} }
(COMPONENT_INPUT_MKDIR, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_MKDIR, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_mkdir(input.to_string()), FileExplorerTab::Local => self.action_local_mkdir(input.to_string()),
FileExplorerTab::Remote => self.action_remote_mkdir(input.to_string()), FileExplorerTab::Remote => self.action_remote_mkdir(input.to_string()),
@@ -542,7 +542,7 @@ impl FileTransferActivity {
self.umount_newfile(); self.umount_newfile();
None None
} }
(COMPONENT_INPUT_NEWFILE, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_NEWFILE, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_newfile(input.to_string()), FileExplorerTab::Local => self.action_local_newfile(input.to_string()),
FileExplorerTab::Remote => self.action_remote_newfile(input.to_string()), FileExplorerTab::Remote => self.action_remote_newfile(input.to_string()),
@@ -561,7 +561,7 @@ impl FileTransferActivity {
self.umount_rename(); self.umount_rename();
None None
} }
(COMPONENT_INPUT_RENAME, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_RENAME, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_rename(input.to_string()), FileExplorerTab::Local => self.action_local_rename(input.to_string()),
FileExplorerTab::Remote => self.action_remote_rename(input.to_string()), FileExplorerTab::Remote => self.action_remote_rename(input.to_string()),
@@ -580,13 +580,13 @@ impl FileTransferActivity {
self.umount_saveas(); self.umount_saveas();
None None
} }
(COMPONENT_INPUT_SAVEAS, Msg::OnSubmit(Payload::Text(input))) => { (COMPONENT_INPUT_SAVEAS, Msg::OnSubmit(Payload::One(Value::Str(input)))) => {
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_saveas(input.to_string()), FileExplorerTab::Local => self.action_local_saveas(input.to_string()),
FileExplorerTab::Remote => self.action_remote_saveas(input.to_string()), FileExplorerTab::Remote => self.action_remote_saveas(input.to_string()),
FileExplorerTab::FindLocal | FileExplorerTab::FindRemote => { FileExplorerTab::FindLocal | FileExplorerTab::FindRemote => {
// Get entry // Get entry
if let Some(Payload::Unsigned(idx)) = if let Some(Payload::One(Value::Usize(idx))) =
self.view.get_state(COMPONENT_EXPLORER_FIND) self.view.get_state(COMPONENT_EXPLORER_FIND)
{ {
self.action_find_transfer(idx, Some(input.to_string())); self.action_find_transfer(idx, Some(input.to_string()));
@@ -611,18 +611,18 @@ impl FileTransferActivity {
} }
// -- delete // -- delete
(COMPONENT_RADIO_DELETE, &MSG_KEY_ESC) (COMPONENT_RADIO_DELETE, &MSG_KEY_ESC)
| (COMPONENT_RADIO_DELETE, Msg::OnSubmit(Payload::Unsigned(1))) => { | (COMPONENT_RADIO_DELETE, Msg::OnSubmit(Payload::One(Value::Usize(1)))) => {
self.umount_radio_delete(); self.umount_radio_delete();
None None
} }
(COMPONENT_RADIO_DELETE, Msg::OnSubmit(Payload::Unsigned(0))) => { (COMPONENT_RADIO_DELETE, Msg::OnSubmit(Payload::One(Value::Usize(0)))) => {
// Choice is 'YES' // Choice is 'YES'
match self.tab { match self.tab {
FileExplorerTab::Local => self.action_local_delete(), FileExplorerTab::Local => self.action_local_delete(),
FileExplorerTab::Remote => self.action_remote_delete(), FileExplorerTab::Remote => self.action_remote_delete(),
FileExplorerTab::FindLocal | FileExplorerTab::FindRemote => { FileExplorerTab::FindLocal | FileExplorerTab::FindRemote => {
// Get entry // Get entry
if let Some(Payload::Unsigned(idx)) = if let Some(Payload::One(Value::Usize(idx))) =
self.view.get_state(COMPONENT_EXPLORER_FIND) self.view.get_state(COMPONENT_EXPLORER_FIND)
{ {
self.action_find_delete(idx); self.action_find_delete(idx);
@@ -643,22 +643,22 @@ impl FileTransferActivity {
} }
// -- disconnect // -- disconnect
(COMPONENT_RADIO_DISCONNECT, &MSG_KEY_ESC) (COMPONENT_RADIO_DISCONNECT, &MSG_KEY_ESC)
| (COMPONENT_RADIO_DISCONNECT, Msg::OnSubmit(Payload::Unsigned(1))) => { | (COMPONENT_RADIO_DISCONNECT, Msg::OnSubmit(Payload::One(Value::Usize(1)))) => {
self.umount_disconnect(); self.umount_disconnect();
None None
} }
(COMPONENT_RADIO_DISCONNECT, Msg::OnSubmit(Payload::Unsigned(0))) => { (COMPONENT_RADIO_DISCONNECT, Msg::OnSubmit(Payload::One(Value::Usize(0)))) => {
self.disconnect(); self.disconnect();
self.umount_disconnect(); self.umount_disconnect();
None None
} }
// -- quit // -- quit
(COMPONENT_RADIO_QUIT, &MSG_KEY_ESC) (COMPONENT_RADIO_QUIT, &MSG_KEY_ESC)
| (COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::Unsigned(1))) => { | (COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::One(Value::Usize(1)))) => {
self.umount_quit(); self.umount_quit();
None None
} }
(COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::Unsigned(0))) => { (COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::One(Value::Usize(0)))) => {
self.disconnect_and_quit(); self.disconnect_and_quit();
self.umount_quit(); self.umount_quit();
None None
@@ -669,7 +669,7 @@ impl FileTransferActivity {
self.umount_file_sorting(); self.umount_file_sorting();
None None
} }
(COMPONENT_RADIO_SORTING, Msg::OnChange(Payload::Unsigned(mode))) => { (COMPONENT_RADIO_SORTING, Msg::OnChange(Payload::One(Value::Usize(mode)))) => {
// Get sorting mode // Get sorting mode
let sorting: FileSorting = match mode { let sorting: FileSorting = match mode {
1 => FileSorting::ByModifyTime, 1 => FileSorting::ByModifyTime,

View File

@@ -31,7 +31,7 @@ use super::SetupActivity;
// Ext // Ext
use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use std::env; use std::env;
use tuirealm::Payload; use tuirealm::{Payload, Value};
impl SetupActivity { impl SetupActivity {
/// ### action_save_config /// ### action_save_config
@@ -64,7 +64,7 @@ impl SetupActivity {
if let Some(config_cli) = self.context.as_mut().unwrap().config_client.as_mut() { if let Some(config_cli) = self.context.as_mut().unwrap().config_client.as_mut() {
// get index // get index
let idx: Option<usize> = match self.view.get_state(super::COMPONENT_LIST_SSH_KEYS) { let idx: Option<usize> = match self.view.get_state(super::COMPONENT_LIST_SSH_KEYS) {
Some(Payload::Unsigned(idx)) => Some(idx), Some(Payload::One(Value::Usize(idx))) => Some(idx),
_ => None, _ => None,
}; };
if let Some(idx) = idx { if let Some(idx) = idx {
@@ -100,11 +100,11 @@ impl SetupActivity {
if let Some(cli) = self.context.as_mut().unwrap().config_client.as_mut() { if let Some(cli) = self.context.as_mut().unwrap().config_client.as_mut() {
// get parameters // get parameters
let host: String = match self.view.get_state(super::COMPONENT_INPUT_SSH_HOST) { let host: String = match self.view.get_state(super::COMPONENT_INPUT_SSH_HOST) {
Some(Payload::Text(host)) => host, Some(Payload::One(Value::Str(host))) => host,
_ => String::new(), _ => String::new(),
}; };
let username: String = match self.view.get_state(super::COMPONENT_INPUT_SSH_USERNAME) { let username: String = match self.view.get_state(super::COMPONENT_INPUT_SSH_USERNAME) {
Some(Payload::Text(user)) => user, Some(Payload::One(Value::Str(user))) => user,
_ => String::new(), _ => String::new(),
}; };
// Prepare text editor // Prepare text editor

View File

@@ -37,7 +37,7 @@ use super::{
use crate::ui::activities::keymap::*; use crate::ui::activities::keymap::*;
// ext // ext
use tuirealm::{Msg, Payload}; use tuirealm::{Msg, Payload, Value};
impl SetupActivity { impl SetupActivity {
/// ### update /// ### update
@@ -115,7 +115,7 @@ impl SetupActivity {
None None
} }
// Exit // Exit
(COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::Unsigned(0))) => { (COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::One(Value::Usize(0)))) => {
// Save changes // Save changes
if let Err(err) = self.action_save_config() { if let Err(err) = self.action_save_config() {
self.mount_error(err.as_str()); self.mount_error(err.as_str());
@@ -124,7 +124,7 @@ impl SetupActivity {
self.exit_reason = Some(super::ExitReason::Quit); self.exit_reason = Some(super::ExitReason::Quit);
None None
} }
(COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::Unsigned(1))) => { (COMPONENT_RADIO_QUIT, Msg::OnSubmit(Payload::One(Value::Usize(1)))) => {
// Quit // Quit
self.exit_reason = Some(super::ExitReason::Quit); self.exit_reason = Some(super::ExitReason::Quit);
self.umount_quit(); self.umount_quit();
@@ -142,7 +142,7 @@ impl SetupActivity {
None None
} }
// Delete key // Delete key
(COMPONENT_RADIO_DEL_SSH_KEY, Msg::OnSubmit(Payload::Unsigned(0))) => { (COMPONENT_RADIO_DEL_SSH_KEY, Msg::OnSubmit(Payload::One(Value::Usize(0)))) => {
// Delete key // Delete key
self.action_delete_ssh_key(); self.action_delete_ssh_key();
// Reload ssh keys // Reload ssh keys
@@ -157,7 +157,7 @@ impl SetupActivity {
None None
} }
// Save popup // Save popup
(COMPONENT_RADIO_SAVE, Msg::OnSubmit(Payload::Unsigned(0))) => { (COMPONENT_RADIO_SAVE, Msg::OnSubmit(Payload::One(Value::Usize(0)))) => {
// Save config // Save config
if let Err(err) = self.action_save_config() { if let Err(err) = self.action_save_config() {
self.mount_error(err.as_str()); self.mount_error(err.as_str());
@@ -226,7 +226,7 @@ impl SetupActivity {
None None
} }
// <ENTER> Edit key // <ENTER> Edit key
(COMPONENT_LIST_SSH_KEYS, Msg::OnSubmit(Payload::Unsigned(idx))) => { (COMPONENT_LIST_SSH_KEYS, Msg::OnSubmit(Payload::One(Value::Usize(idx)))) => {
// Edit ssh key // Edit ssh key
if let Err(err) = self.edit_ssh_key(*idx) { if let Err(err) = self.edit_ssh_key(*idx) {
self.mount_error(err.as_str()); self.mount_error(err.as_str());

View File

@@ -50,7 +50,7 @@ use tuirealm::tui::{
}; };
use tuirealm::{ use tuirealm::{
props::{PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder}, props::{PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder},
Payload, View, Payload, Value, View,
}; };
impl SetupActivity { impl SetupActivity {
@@ -729,12 +729,12 @@ impl SetupActivity {
/// Collect values from input and put them into the configuration /// Collect values from input and put them into the configuration
pub(super) fn collect_input_values(&mut self) { pub(super) fn collect_input_values(&mut self) {
if let Some(cli) = self.context.as_mut().unwrap().config_client.as_mut() { if let Some(cli) = self.context.as_mut().unwrap().config_client.as_mut() {
if let Some(Payload::Text(editor)) = if let Some(Payload::One(Value::Str(editor))) =
self.view.get_state(super::COMPONENT_INPUT_TEXT_EDITOR) self.view.get_state(super::COMPONENT_INPUT_TEXT_EDITOR)
{ {
cli.set_text_editor(PathBuf::from(editor.as_str())); cli.set_text_editor(PathBuf::from(editor.as_str()));
} }
if let Some(Payload::Unsigned(protocol)) = if let Some(Payload::One(Value::Usize(protocol))) =
self.view.get_state(super::COMPONENT_RADIO_DEFAULT_PROTOCOL) self.view.get_state(super::COMPONENT_RADIO_DEFAULT_PROTOCOL)
{ {
let protocol: FileTransferProtocol = match protocol { let protocol: FileTransferProtocol = match protocol {
@@ -745,29 +745,29 @@ impl SetupActivity {
}; };
cli.set_default_protocol(protocol); cli.set_default_protocol(protocol);
} }
if let Some(Payload::Unsigned(opt)) = if let Some(Payload::One(Value::Usize(opt))) =
self.view.get_state(super::COMPONENT_RADIO_HIDDEN_FILES) self.view.get_state(super::COMPONENT_RADIO_HIDDEN_FILES)
{ {
let show: bool = matches!(opt, 0); let show: bool = matches!(opt, 0);
cli.set_show_hidden_files(show); cli.set_show_hidden_files(show);
} }
if let Some(Payload::Unsigned(opt)) = if let Some(Payload::One(Value::Usize(opt))) =
self.view.get_state(super::COMPONENT_RADIO_UPDATES) self.view.get_state(super::COMPONENT_RADIO_UPDATES)
{ {
let check: bool = matches!(opt, 0); let check: bool = matches!(opt, 0);
cli.set_check_for_updates(check); cli.set_check_for_updates(check);
} }
if let Some(Payload::Text(fmt)) = if let Some(Payload::One(Value::Str(fmt))) =
self.view.get_state(super::COMPONENT_INPUT_LOCAL_FILE_FMT) self.view.get_state(super::COMPONENT_INPUT_LOCAL_FILE_FMT)
{ {
cli.set_local_file_fmt(fmt); cli.set_local_file_fmt(fmt);
} }
if let Some(Payload::Text(fmt)) = if let Some(Payload::One(Value::Str(fmt))) =
self.view.get_state(super::COMPONENT_INPUT_REMOTE_FILE_FMT) self.view.get_state(super::COMPONENT_INPUT_REMOTE_FILE_FMT)
{ {
cli.set_remote_file_fmt(fmt); cli.set_remote_file_fmt(fmt);
} }
if let Some(Payload::Unsigned(opt)) = if let Some(Payload::One(Value::Usize(opt))) =
self.view.get_state(super::COMPONENT_RADIO_GROUP_DIRS) self.view.get_state(super::COMPONENT_RADIO_GROUP_DIRS)
{ {
let dirs: Option<GroupDirs> = match opt { let dirs: Option<GroupDirs> = match opt {

View File

@@ -35,7 +35,7 @@ use tuirealm::tui::{
text::Span, text::Span,
widgets::{BorderType, Borders, List, ListItem, ListState}, widgets::{BorderType, Borders, List, ListItem, ListState},
}; };
use tuirealm::{Canvas, Component, Msg, Payload}; use tuirealm::{Canvas, Component, Msg, Payload, Value};
// -- props // -- props
@@ -317,7 +317,7 @@ impl Component for BookmarkList {
} }
fn get_state(&self) -> Payload { fn get_state(&self) -> Payload {
Payload::Unsigned(self.states.get_list_index()) Payload::One(Value::Usize(self.states.get_list_index()))
} }
fn blur(&mut self) { fn blur(&mut self) {
@@ -396,7 +396,7 @@ mod tests {
assert_eq!(component.states.list_index, 0); assert_eq!(component.states.list_index, 0);
assert_eq!(component.states.list_len, 3); assert_eq!(component.states.list_len, 3);
// get value // get value
assert_eq!(component.get_state(), Payload::Unsigned(0)); assert_eq!(component.get_state(), Payload::One(Value::Usize(0)));
// Render // Render
assert_eq!(component.states.list_index, 0); assert_eq!(component.states.list_index, 0);
// Handle inputs // Handle inputs
@@ -430,7 +430,7 @@ mod tests {
// Enter // Enter
assert_eq!( assert_eq!(
component.on(Event::Key(KeyEvent::from(KeyCode::Enter))), component.on(Event::Key(KeyEvent::from(KeyCode::Enter))),
Msg::OnSubmit(Payload::Unsigned(0)) Msg::OnSubmit(Payload::One(Value::Usize(0)))
); );
// On key // On key
assert_eq!( assert_eq!(

View File

@@ -35,7 +35,7 @@ use tuirealm::tui::{
text::Span, text::Span,
widgets::{BorderType, Borders, List, ListItem, ListState}, widgets::{BorderType, Borders, List, ListItem, ListState},
}; };
use tuirealm::{Canvas, Component, Msg, Payload}; use tuirealm::{Canvas, Component, Msg, Payload, Value};
// -- props // -- props
@@ -321,7 +321,7 @@ impl Component for FileList {
} }
fn get_state(&self) -> Payload { fn get_state(&self) -> Payload {
Payload::Unsigned(self.states.get_list_index()) Payload::One(Value::Usize(self.states.get_list_index()))
} }
// -- events // -- events
@@ -408,7 +408,7 @@ mod tests {
assert_eq!(component.states.list_index, 1); // Kept assert_eq!(component.states.list_index, 1); // Kept
assert_eq!(component.states.list_len, 3); assert_eq!(component.states.list_len, 3);
// get value // get value
assert_eq!(component.get_state(), Payload::Unsigned(1)); assert_eq!(component.get_state(), Payload::One(Value::Usize(1)));
// Render // Render
assert_eq!(component.states.list_index, 1); assert_eq!(component.states.list_index, 1);
// Handle inputs // Handle inputs
@@ -442,7 +442,7 @@ mod tests {
// Enter // Enter
assert_eq!( assert_eq!(
component.on(Event::Key(KeyEvent::from(KeyCode::Enter))), component.on(Event::Key(KeyEvent::from(KeyCode::Enter))),
Msg::OnSubmit(Payload::Unsigned(0)) Msg::OnSubmit(Payload::One(Value::Usize(0)))
); );
// On key // On key
assert_eq!( assert_eq!(

View File

@@ -34,7 +34,7 @@ use tuirealm::tui::{
style::{Color, Style}, style::{Color, Style},
widgets::{BorderType, Borders, List, ListItem, ListState}, widgets::{BorderType, Borders, List, ListItem, ListState},
}; };
use tuirealm::{Canvas, Component, Msg, Payload}; use tuirealm::{Canvas, Component, Msg, Payload, Value};
// -- props // -- props
@@ -281,7 +281,7 @@ impl Component for LogBox {
} }
fn get_state(&self) -> Payload { fn get_state(&self) -> Payload {
Payload::Unsigned(self.states.get_list_index()) Payload::One(Value::Usize(self.states.get_list_index()))
} }
fn blur(&mut self) { fn blur(&mut self) {
@@ -366,7 +366,7 @@ mod tests {
assert_eq!(component.states.list_index, 0); // Last item assert_eq!(component.states.list_index, 0); // Last item
assert_eq!(component.states.list_len, 3); assert_eq!(component.states.list_len, 3);
// get value // get value
assert_eq!(component.get_state(), Payload::Unsigned(0)); assert_eq!(component.get_state(), Payload::One(Value::Usize(0)));
// RenderData // RenderData
assert_eq!(component.states.list_index, 0); assert_eq!(component.states.list_index, 0);
// Set cursor to 0 // Set cursor to 0