Replaced deprecated tui with ratatui and updated to current version.

This commit is contained in:
scoobybejesus 2023-10-23 13:36:28 -04:00
parent 823f83d5c6
commit e983fb2234
5 changed files with 135 additions and 56 deletions

149
Cargo.lock generated
View File

@ -24,6 +24,12 @@ dependencies = [
"version_check",
]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "android-tzdata"
version = "0.1.1"
@ -250,11 +256,11 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
[[package]]
name = "crossterm"
version = "0.25.0"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.4.1",
"crossterm_winapi",
"libc",
"mio",
@ -288,18 +294,18 @@ dependencies = [
[[package]]
name = "cryptools"
version = "0.12.5"
version = "0.12.6"
dependencies = [
"chrono",
"crptls",
"csv",
"dotenv",
"ratatui",
"rust_decimal",
"rust_decimal_macros",
"rustyline",
"structopt",
"termion 2.0.1",
"tui",
"termion",
]
[[package]]
@ -338,6 +344,12 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "either"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "endian-type"
version = "0.1.2"
@ -410,6 +422,16 @@ dependencies = [
"ahash 0.8.3",
]
[[package]]
name = "hashbrown"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
dependencies = [
"ahash 0.8.3",
"allocator-api2",
]
[[package]]
name = "heck"
version = "0.3.1"
@ -419,6 +441,12 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.17"
@ -460,6 +488,21 @@ dependencies = [
"cc",
]
[[package]]
name = "indoc"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
[[package]]
name = "itertools"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.9"
@ -506,6 +549,15 @@ dependencies = [
"cfg-if 0.1.10",
]
[[package]]
name = "lru"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
dependencies = [
"hashbrown 0.14.2",
]
[[package]]
name = "memchr"
version = "2.3.4"
@ -588,6 +640,12 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "paste"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "powerfmt"
version = "0.2.0"
@ -711,6 +769,25 @@ dependencies = [
"getrandom",
]
[[package]]
name = "ratatui"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425"
dependencies = [
"bitflags 2.4.1",
"cassowary",
"crossterm",
"indoc",
"itertools",
"lru",
"paste",
"strum",
"termion",
"unicode-segmentation",
"unicode-width",
]
[[package]]
name = "redox_syscall"
version = "0.1.57"
@ -820,6 +897,12 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "rustversion"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "rustyline"
version = "12.0.0"
@ -962,12 +1045,34 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107"
dependencies = [
"heck",
"heck 0.3.1",
"proc-macro2 0.4.30",
"quote 0.6.13",
"syn 0.15.44",
]
[[package]]
name = "strum"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
dependencies = [
"heck 0.4.1",
"proc-macro2 1.0.69",
"quote 1.0.33",
"rustversion",
"syn 2.0.38",
]
[[package]]
name = "syn"
version = "0.15.44"
@ -1007,18 +1112,6 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "termion"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905"
dependencies = [
"libc",
"numtoa",
"redox_syscall 0.1.57",
"redox_termios",
]
[[package]]
name = "termion"
version = "2.0.1"
@ -1082,20 +1175,6 @@ dependencies = [
"serde",
]
[[package]]
name = "tui"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
dependencies = [
"bitflags 1.3.2",
"cassowary",
"crossterm",
"termion 1.5.5",
"unicode-segmentation",
"unicode-width",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
@ -1104,9 +1183,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-segmentation"
version = "1.7.1"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"

View File

@ -1,6 +1,6 @@
[package]
name = "cryptools"
version = "0.12.5"
version = "0.12.6"
authors = ["scoobybejesus <scoobybejesus@users.noreply.github.com>"]
edition = "2021"
description = "Command-line utility for processing cryptocurrency transactions into 'lots' and 'movements'."
@ -10,7 +10,7 @@ description = "Command-line utility for processing cryptocurrency transactions i
# but it is optional because Windows doesn't support it.
default = ["print_menu"]
print_menu = ["tui", "termion"]
print_menu = ["ratatui", "termion"]
[[bin]]
name = "cryptools"
@ -26,7 +26,7 @@ rust_decimal_macros = "1.32.0"
chrono = { version = "0.4.31", features = ["serde"] }
structopt = "0.2.10"
rustyline = "12.0.0"
tui = { version = "0.19", optional = true, features = ['termion'] }
ratatui = { version = "0.24.0", optional = true, features = ['termion'] }
termion = { version = "2.0.1", optional = true }
dotenv = "0.15.0"

View File

@ -7,7 +7,7 @@ use std::collections::HashMap;
use crptls::transaction::{Transaction, ActionRecord};
use crptls::account::{Account, RawAccount};
use crptls::core_functions::ImportProcessParameters;
use tui::widgets::ListState;
use ratatui::widgets::ListState;
use crate::export::{export_csv, export_je, export_txt};

View File

@ -6,8 +6,8 @@ use std::time::Duration;
use std::collections::HashMap;
use std::error::Error;
use tui::Terminal;
use tui::backend::TermionBackend;
use ratatui::Terminal;
use ratatui::backend::TermionBackend;
use termion::raw::IntoRawMode;
use termion::screen::IntoAlternateScreen;
use termion::input::MouseTerminal;

View File

@ -3,13 +3,13 @@
use std::error::Error;
use ::tui::Terminal;
use ::tui::style::{Color, Modifier, Style};
use ::tui::text::{Text, Span, Spans};
use tui::widgets::{Wrap, ListItem};
use ::tui::widgets::{Block, Borders, Paragraph, List};
use ::tui::layout::{Layout, Constraint, Direction};
use ::tui::backend::Backend;
use ::ratatui::Terminal;
use ::ratatui::style::{Color, Modifier, Style};
use ::ratatui::text::{Text, Span, Line};
use ratatui::widgets::{Wrap, ListItem};
use ::ratatui::widgets::{Block, Borders, Paragraph, List};
use ::ratatui::layout::{Layout, Constraint, Direction};
use ::ratatui::backend::Backend;
use crate::mytui::app::{PrintWindow, REPORTS};
@ -19,33 +19,33 @@ pub fn draw<B: Backend>(terminal: &mut Terminal<B>, app: &mut PrintWindow) -> Re
terminal.draw(|f| {
let instructions = vec![
Spans::from(vec![Span::raw("")]),
Line::from(vec![Span::raw("")]),
Spans::from(vec![
Line::from(vec![
Span::raw(" Press '"),
Span::styled("x", Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD)),
Span::raw("' to add the selected report to the list of reports to print/export."),
]),
Spans::from(vec![Span::raw("")]),
Line::from(vec![Span::raw("")]),
Spans::from(vec![
Line::from(vec![
Span::raw(" Press '"),
Span::styled("d", Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD)),
Span::raw("' to delete the selected report from the list of reports to print/export."),
]),
Spans::from(vec![Span::raw("")]),
Line::from(vec![Span::raw("")]),
Spans::from(vec![
Line::from(vec![
Span::raw(" Press '"),
Span::styled("p", Style::default().fg(Color::Green).add_modifier(Modifier::BOLD)),
Span::raw("' to print/export the selected reports."),
]),
Spans::from(vec![Span::raw("")]),
Line::from(vec![Span::raw("")]),
Spans::from(vec![
Line::from(vec![
Span::raw(" Press '"),
Span::styled("q", Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)),
Span::raw("' to quit without printing."),