diff --git a/.ignore b/.ignore new file mode 100644 index 0000000..ee88966 --- /dev/null +++ b/.ignore @@ -0,0 +1 @@ +assets/ diff --git a/Cargo.toml b/Cargo.toml index 3681cac..f52a8b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ memchr = "2.7.4" once_cell = "1.19.0" packed_struct = "0.10.1" ratatui = "0.28.1" +ratatui-splash-screen = "0.1.4" serde = { version = "1.0.210", features = ["derive"] } serialport = "4.5.0" strum = { version = "0.26.3", features = ["derive"] } diff --git a/assets/icon.png b/assets/icon.png new file mode 100644 index 0000000..6aa6a3f Binary files /dev/null and b/assets/icon.png differ diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000..04ebd7b Binary files /dev/null and b/assets/logo.png differ diff --git a/src/main.rs b/src/main.rs index 20bc9a8..58ff4dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,14 +4,12 @@ //! and will not offer any scripting capabilities #![warn(missing_docs, clippy::missing_docs_in_private_items)] -// #![allow(dead_code)] mod scan; mod structs; mod ui; mod ui_struct; use color_eyre::Result; -// use human_panic::setup_panic; use structs::TinyError; use ui_struct::AppInfo; @@ -28,7 +26,7 @@ fn main() -> Result<(), TinyError> { log::info!(target:"info","Logging started"); color_eyre::install()?; let terminal = ratatui::init(); - // setup_panic!(); + let ports = serialport::available_ports()?; let app_r = AppInfo::new(ports).run(terminal); diff --git a/src/scan.rs b/src/scan.rs index 96bb226..0b85167 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -40,7 +40,6 @@ pub struct DataPoint { static EOF: OnceLock> = OnceLock::new(); /// Scan a specific range and returns the scan result -#[allow(clippy::too_many_arguments)] pub(crate) fn scan_with_progress(connection_info: ConnectionInfo) -> Result<(), TinyError> { let mode = mode_from(connection_info.start, connection_info.stop)?; let mut port = acquire_port(&connection_info)?; diff --git a/src/ui.rs b/src/ui.rs index 5f42fe7..13787ce 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,43 +1,16 @@ //! The (minimal) user interface to control the program -#![allow(unused_imports)] -use clap::builder::Resettable; -use color_eyre::{eyre::Context, owo_colors::OwoColorize, Section}; -use core::{panic, time}; use log::info; use ratatui::{ - buffer::Buffer, - crossterm::{ - event::{self, Event, KeyCode, KeyEvent, KeyEventKind}, - style::Print, - }, - layout::{Alignment, Constraint, Direction, Layout, Rect}, - prelude::BlockExt, - style::{ - palette::tailwind::{BLUE, GREEN, SLATE}, - Color, Modifier, Style, Styled, Stylize, - }, - symbols::{self, Marker}, - text::Line, - widgets::{ - block::Title, Axis, Block, Borders, Chart, Dataset, GraphType, HighlightSpacing, LineGauge, - List, ListDirection, ListItem, ListState, Padding, Paragraph, ScrollDirection, - StatefulWidget, Widget, Wrap, - }, + crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind}, + layout::{Constraint, Layout, Rect}, + style::{Color, Modifier, Style, Stylize}, + symbols::Marker, + widgets::{Axis, Block, Chart, Dataset, GraphType, LineGauge, List, Paragraph, Wrap}, DefaultTerminal, Frame, }; use serialport::SerialPortInfo; -use std::{ - borrow::{Borrow, BorrowMut}, - cmp::min, - fmt::Pointer, - iter::Iterator, - sync::{Arc, Mutex}, - thread, - time::{Duration, Instant}, -}; -use strum::{EnumCount, EnumIter, EnumProperty}; -use strum::{FromRepr, IntoEnumIterator}; -use tui_textarea::{Input, Key, TextArea}; +use std::{thread, time::Duration}; +use strum::EnumCount; use crate::{ mleft, mright, scan, @@ -251,7 +224,9 @@ impl<'a> AppInfo<'a> { self.update_color()?; frame.render_widget( - Paragraph::new(self.status_message.clone()).block(Block::bordered()), + Paragraph::new(self.status_message.clone()) + .wrap(Wrap { trim: true }) + .block(Block::bordered()), title_area, ); self.render_footer(frame, status_area); @@ -312,7 +287,9 @@ impl<'a> AppInfo<'a> { frame.render_stateful_widget(list_ports, area_ports, &mut self.port_list.state); frame.render_stateful_widget(list_baudrates, area_baud, &mut self.baudrate.state); frame.render_widget( - Paragraph::new(self.status_message.clone()).block(Block::bordered()), + Paragraph::new(self.status_message.clone()) + .wrap(Wrap { trim: true }) + .block(Block::bordered()), title_area, ); self.render_footer(frame, status_area); @@ -349,6 +326,7 @@ impl<'a> AppInfo<'a> { .style(SELECTED_COLOR); let message = self.get_connection_info()?.get_scan_info(); let message = Paragraph::new(message.clone()) + .wrap(Wrap { trim: true }) .block(Block::bordered().title("TinySA Info")) .style(SELECTED_COLOR); let pb = self @@ -411,6 +389,7 @@ impl<'a> AppInfo<'a> { let conn_status = self.get_connection_info()?.get_connection_status(); let status_message = self.error_message_from_current_error()?; let status = Paragraph::new(status_message) + .wrap(Wrap { trim: true }) .block(Block::bordered().title("Status")) .style(Color::Red); let mut additional = String::new(); @@ -429,6 +408,7 @@ impl<'a> AppInfo<'a> { self.get_connection_info()?.get_scan_message(), additional )) + .wrap(Wrap { trim: true }) .block(Block::bordered().title("Status")); let footer = Paragraph::new("Press ↲ or q to exit".to_string()).centered(); frame.render_widget(status, title_area); diff --git a/src/ui_struct.rs b/src/ui_struct.rs index e09c3a5..8a9239a 100644 --- a/src/ui_struct.rs +++ b/src/ui_struct.rs @@ -133,7 +133,7 @@ impl Default for AppState { macro_rules! mright { ($v:ident, $cname:ident,$fname:ident) => { Some(AppState::$cname( - $fname::from_repr(min(($v + 1), $fname::COUNT - 1)) + $fname::from_repr(std::cmp::min(($v + 1), $fname::COUNT - 1)) .ok_or(TinyUIError::MenuSelectionError)?, )) };