Adds some Icons, an .ignore file and wrap for paragraphs
This commit is contained in:
parent
eccca9eb1c
commit
39e09e4363
|
|
@ -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"] }
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ pub struct DataPoint {
|
|||
static EOF: OnceLock<memmem::Finder<'_>> = 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)?;
|
||||
|
|
|
|||
52
src/ui.rs
52
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);
|
||||
|
|
|
|||
|
|
@ -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)?,
|
||||
))
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue