Migrate to ratatui
This commit is contained in:
parent
5e916e2b80
commit
dfac94b832
|
@ -10,4 +10,4 @@ clap = {version = "*", features = ["derive"]}
|
||||||
crossterm = "*"
|
crossterm = "*"
|
||||||
readmap = {version = "*", path = "readmap"}
|
readmap = {version = "*", path = "readmap"}
|
||||||
tool_helper = {version = "*", path = "../tool_helper"}
|
tool_helper = {version = "*", path = "../tool_helper"}
|
||||||
tui = "*"
|
ratatui = "*"
|
|
@ -3,16 +3,16 @@ use crossterm::event::KeyCode;
|
||||||
use readmap::types::MemoryMap;
|
use readmap::types::MemoryMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tool_helper::Error;
|
use tool_helper::Error;
|
||||||
use tui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Modifier, Style},
|
style::{Color, Modifier, Style},
|
||||||
text::{Span, Spans},
|
text::{Line, Span},
|
||||||
widgets::{Block, Borders, BorderType, Gauge, Paragraph, Tabs}
|
widgets::{Block, Borders, BorderType, Gauge, Paragraph, Tabs}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type EventReceiver = std::sync::mpsc::Receiver<Event<crossterm::event::KeyEvent>>;
|
pub type EventReceiver = std::sync::mpsc::Receiver<Event<crossterm::event::KeyEvent>>;
|
||||||
pub type Terminal = tui::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>;
|
pub type Terminal = ratatui::Terminal<ratatui::backend::CrosstermBackend<std::io::Stdout>>;
|
||||||
type ConsoleFrame<'a> = tui::Frame<'a, tui::backend::CrosstermBackend<std::io::Stdout>>;
|
type ConsoleFrame<'a> = ratatui::Frame<'a, ratatui::backend::CrosstermBackend<std::io::Stdout>>;
|
||||||
|
|
||||||
pub enum Event<I> {
|
pub enum Event<I> {
|
||||||
Input(I),
|
Input(I),
|
||||||
|
@ -138,12 +138,12 @@ impl ConsoleUI {
|
||||||
Constraint::Length(3),
|
Constraint::Length(3),
|
||||||
Constraint::Length(3),
|
Constraint::Length(3),
|
||||||
Constraint::Min(3)
|
Constraint::Min(3)
|
||||||
]).split(new_frame);
|
]).split(new_frame).to_vec();
|
||||||
|
|
||||||
*stats_frames = Layout::default().direction(Direction::Vertical).constraints([
|
*stats_frames = Layout::default().direction(Direction::Vertical).constraints([
|
||||||
Constraint::Min(3),
|
Constraint::Min(3),
|
||||||
Constraint::Length(3)
|
Constraint::Length(3)
|
||||||
]).split(sub_frames[2]);
|
]).split(sub_frames[2]).to_vec();
|
||||||
|
|
||||||
*frame = new_frame;
|
*frame = new_frame;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ impl ConsoleUI {
|
||||||
|
|
||||||
let menu = MENU_TITLES.iter().map(|t| {
|
let menu = MENU_TITLES.iter().map(|t| {
|
||||||
let (first, rest) = t.split_at(1);
|
let (first, rest) = t.split_at(1);
|
||||||
Spans::from(vec![
|
Line::from(vec![
|
||||||
Span::styled(first, Style::default().fg(Color::Yellow).add_modifier(Modifier::UNDERLINED),),
|
Span::styled(first, Style::default().fg(Color::Yellow).add_modifier(Modifier::UNDERLINED),),
|
||||||
Span::styled(rest, Style::default().fg(Color::White)),
|
Span::styled(rest, Style::default().fg(Color::White)),
|
||||||
])
|
])
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crossterm::{event::{self, Event as CEvent, KeyboardEnhancementFlags, KeyEven
|
||||||
use psxreadmap::{ConsoleUI, ConsoleUIData, Event, EventReceiver, Terminal, load_memory_map, UIState};
|
use psxreadmap::{ConsoleUI, ConsoleUIData, Event, EventReceiver, Terminal, load_memory_map, UIState};
|
||||||
use std::{io, path::PathBuf, sync::mpsc, thread, time::{Duration, Instant}};
|
use std::{io, path::PathBuf, sync::mpsc, thread, time::{Duration, Instant}};
|
||||||
use tool_helper::{Error, exit_with_error};
|
use tool_helper::{Error, exit_with_error};
|
||||||
use tui::backend::CrosstermBackend;
|
use ratatui::backend::CrosstermBackend;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(about = "Opens and scans a MAP file to print extended information", long_about = None)]
|
#[clap(about = "Opens and scans a MAP file to print extended information", long_about = None)]
|
||||||
|
|
Loading…
Reference in New Issue