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
- [Issue 23](https://github.com/veeso/termscp/issues/23): Remove created file if transfer failed or was abrupted
- Dependencies:
- Added `tui-realm 0.1.0`
- Removed `tui`
- Added `tui-realm 0.2.1`
- Removed `tui` (as direct dependency)
- Updated `regex` to `1.5.3`
## 0.4.2

12
Cargo.lock generated
View File

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

View File

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

View File

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

View File

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

View File

@@ -47,7 +47,7 @@ use tuirealm::tui::{
};
use tuirealm::{
props::{InputType, PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder},
Msg, Payload,
Msg, Payload, Value,
};
impl AuthActivity {
@@ -689,16 +689,16 @@ impl AuthActivity {
/// Collect input values from view
pub(super) fn get_input(&self) -> (String, u16, FileTransferProtocol, String, String) {
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(),
};
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,
};
let protocol: FileTransferProtocol =
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,
2 => FileTransferProtocol::Ftp(false),
3 => FileTransferProtocol::Ftp(true),
@@ -707,11 +707,11 @@ impl AuthActivity {
_ => FileTransferProtocol::Sftp,
};
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(),
};
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(),
};
(addr, port, protocol, username, password)

View File

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

View File

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

View File

@@ -31,7 +31,7 @@ use super::SetupActivity;
// Ext
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use std::env;
use tuirealm::Payload;
use tuirealm::{Payload, Value};
impl SetupActivity {
/// ### action_save_config
@@ -64,7 +64,7 @@ impl SetupActivity {
if let Some(config_cli) = self.context.as_mut().unwrap().config_client.as_mut() {
// get index
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,
};
if let Some(idx) = idx {
@@ -100,11 +100,11 @@ impl SetupActivity {
if let Some(cli) = self.context.as_mut().unwrap().config_client.as_mut() {
// get parameters
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(),
};
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(),
};
// Prepare text editor

View File

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

View File

@@ -50,7 +50,7 @@ use tuirealm::tui::{
};
use tuirealm::{
props::{PropsBuilder, TableBuilder, TextSpan, TextSpanBuilder},
Payload, View,
Payload, Value, View,
};
impl SetupActivity {
@@ -729,12 +729,12 @@ impl SetupActivity {
/// Collect values from input and put them into the configuration
pub(super) fn collect_input_values(&mut self) {
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)
{
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)
{
let protocol: FileTransferProtocol = match protocol {
@@ -745,29 +745,29 @@ impl SetupActivity {
};
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)
{
let show: bool = matches!(opt, 0);
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)
{
let check: bool = matches!(opt, 0);
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)
{
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)
{
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)
{
let dirs: Option<GroupDirs> = match opt {

View File

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

View File

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

View File

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