refactor: redesigned help panel

This commit is contained in:
Jack Wills
2026-02-06 15:33:22 +00:00
parent bebb687c59
commit ae7f3f4a94
45 changed files with 3209 additions and 1160 deletions
+26 -20
View File
@@ -1,5 +1,5 @@
use std::{
io::{Read, Stdout, Write},
io::{Read, Write},
sync::{Arc, atomic::AtomicBool, mpsc::Sender},
};
@@ -10,7 +10,7 @@ use bollard::{
use crossterm::terminal::enable_raw_mode;
use futures_util::StreamExt;
use parking_lot::Mutex;
use ratatui::{Terminal, backend::CrosstermBackend};
use ratatui::layout::Size;
use tokio::{
fs::File,
io::{AsyncReadExt, AsyncWriteExt},
@@ -123,23 +123,29 @@ impl AsyncTTY {
}
}
/// This is used to set the terminal size when exec via the Internal method
#[derive(Debug, Clone)]
pub struct TerminalSize {
width: u16,
height: u16,
}
// impl TryFrom<&Terminal<CrosstermBackend<Stdout>>> for HWU16 {
// type Error = None;
// fn try_from(terminal: &Terminal<CrosstermBackend<Stdout>>) -> Option<Self> {
// terminal.size().map_or(None, |i| {
// Some(Self {
// width: i.width,
// height: i.height,
// })
// })
// }
impl TerminalSize {
pub fn new(terminal: &Terminal<CrosstermBackend<Stdout>>) -> Option<Self> {
terminal.size().map_or(None, |i| {
Some(Self {
width: i.width,
height: i.height,
})
})
}
}
// }
// impl TerminalSize {
// pub fn new(terminal: &Terminal<CrosstermBackend<Stdout>>) -> Option<Self> {
// terminal.size().map_or(None, |i| {
// Some(Self {
// width: i.width,
// height: i.height,
// })
// })
// }
// }
#[derive(Debug, Clone)]
pub enum ExecMode {
@@ -225,7 +231,7 @@ impl ExecMode {
&self,
id: &ContainerId,
docker: &Arc<Docker>,
terminal_size: Option<TerminalSize>,
terminal_size: Option<Size>,
) -> Result<(), AppError> {
let cancel_token = CancellationToken::new();
@@ -341,7 +347,7 @@ impl ExecMode {
}
}
pub async fn run(&self, tty_size: Option<TerminalSize>) -> Result<(), AppError> {
pub async fn run(&self, tty_size: Option<Size>) -> Result<(), AppError> {
match self {
Self::External(id) => {
Self::exec_external(id);