diff --git a/Cargo.lock b/Cargo.lock
index 548acf1..cddb2d5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -290,6 +290,7 @@ name = "nyanit"
version = "0.1.0"
dependencies = [
"ratatui",
+ "ratatui-textarea",
"regex",
"termion",
]
@@ -394,6 +395,19 @@ dependencies = [
"termion",
]
+[[package]]
+name = "ratatui-textarea"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c78d5ba0f26f97baed69a4c479f268a31c7b5b89d68ab939842152e383d6e73"
+dependencies = [
+ "ratatui-core",
+ "ratatui-termion",
+ "ratatui-widgets",
+ "unicode-segmentation",
+ "unicode-width",
+]
+
[[package]]
name = "ratatui-widgets"
version = "0.3.1"
diff --git a/Cargo.toml b/Cargo.toml
index 038bdfd..d22c2d2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ edition = "2024"
[dependencies]
ratatui = { version = "0.30", default-features = false, features = ["termion"] }
+ratatui-textarea = { version = "0.9", default-features = false, features = ["termion"] }
regex = "1.12.4"
termion = "4"
@@ -14,5 +15,5 @@ lto = true
debug = false
incremental = false
codegen-units = 1
-opt-level = 3
+opt-level = 2
strip = true
diff --git a/src/main.rs b/src/main.rs
index 44364c0..b90153d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,25 +14,27 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use ratatui::widgets::Borders;
-use ratatui::{Frame, Terminal, backend::TermionBackend, widgets::Paragraph};
+use ratatui::{Frame, Terminal, backend::TermionBackend};
use ratatui::{
layout::{Constraint, Layout},
- style::{Style, Stylize},
- text::{Line},
- widgets::{Block, List, ListState},
+ style::{Color, Style, Stylize},
+ text::Line,
+ widgets::{Block, Borders, List, ListState, Paragraph},
};
+
+use ratatui_textarea::TextArea;
+
use std::io::{self, Read, stdout};
use std::process::ExitCode;
use std::thread;
use std::time::Duration;
-use termion::event::{Event, Key};
+use termion::event::{self, Event};
use termion::raw::IntoRawMode;
mod nyan_system;
-use nyan_system::{ExecCommandError};
+use nyan_system::ExecCommandError;
const BEE_CAT: &str = include_str!("bee_cat.txt");
@@ -71,17 +73,8 @@ enum NyanitState {
HandOff(String),
}
-fn init_stage() -> Result {
- // mount sysfss
- nyan_system::prepare_env()?;
-
- // check if device is encrypted
- if nyan_system::bzzpss_dev_encrypted(ROOT_DEV)? {
- // if encrypted return EnterPassword so used get promted for pass
- return Ok(NyanitState::EnterPassword);
- }
-
- // if unencrypted
+/// Mounting bee-root and chiking if there any snapshots
+fn mount_and_check_snaps() -> Result {
// mount bee-root
nyan_system::mount_bee_root(TMP_ROOT, ROOT_DEV)?;
@@ -93,24 +86,40 @@ fn init_stage() -> Result {
return Ok(NyanitState::WaitForF2(snaps_list));
}
- // tell to finish boot
+ // else tell to finish boot
Ok(NyanitState::HandOff(TMP_ROOT.into()))
}
-pub struct NyanitTUI {
+fn init_stage() -> Result {
+ // mount sysfss
+ nyan_system::prepare_env()?;
+
+ // check if device is encrypted
+ if nyan_system::bzzpss_dev_encrypted(ROOT_DEV)? {
+ // if encrypted return EnterPassword so used get promted for pass
+ return Ok(NyanitState::EnterPassword);
+ }
+
+ // if unencrypted
+ mount_and_check_snaps()
+}
+
+struct NyanitTUI<'a> {
exit: bool,
state: NyanitState,
list_state: ListState,
time_counter: u32,
+ textarea: Option