mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
72 lines
2.3 KiB
Rust
72 lines
2.3 KiB
Rust
#![feature(type_changing_struct_update)]
|
|
|
|
mod tui_engine; pub use self::tui_engine::*;
|
|
mod tui_content; pub use self::tui_content::*;
|
|
|
|
pub(crate) use ::tengri_core::*;
|
|
|
|
pub use ::tengri_input as input;
|
|
pub(crate) use ::tengri_input::*;
|
|
|
|
pub use ::tengri_output as output;
|
|
pub(crate) use ::tengri_output::*;
|
|
|
|
pub(crate) use atomic_float::AtomicF64;
|
|
|
|
pub use ::better_panic; pub(crate) use ::better_panic::{Settings, Verbosity};
|
|
|
|
pub use ::palette; pub(crate) use ::palette::{*, convert::*, okhsl::*};
|
|
|
|
pub use ::crossterm; pub(crate) use ::crossterm::{
|
|
ExecutableCommand,
|
|
terminal::{EnterAlternateScreen, LeaveAlternateScreen, enable_raw_mode, disable_raw_mode},
|
|
event::{Event, KeyEvent, KeyCode, KeyModifiers, KeyEventKind, KeyEventState},
|
|
};
|
|
|
|
pub use ::ratatui; pub(crate) use ratatui::{
|
|
prelude::{Color, Style, Buffer},
|
|
style::Modifier,
|
|
backend::{Backend, CrosstermBackend, ClearType},
|
|
layout::{Size, Rect},
|
|
buffer::Cell
|
|
};
|
|
|
|
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::*}};
|
|
pub(crate) use std::io::{stdout, Stdout};
|
|
|
|
#[cfg(test)] #[test] fn test_tui_engine () -> Usually<()> {
|
|
use crate::*;
|
|
use std::sync::{Arc, RwLock};
|
|
struct TestComponent(String);
|
|
impl Content<TuiOut> for TestComponent {
|
|
fn content (&self) -> impl Render<TuiOut> {
|
|
Some(self.0.as_str())
|
|
}
|
|
}
|
|
impl Handle<TuiIn> for TestComponent {
|
|
fn handle (&mut self, from: &TuiIn) -> Perhaps<bool> {
|
|
Ok(None)
|
|
}
|
|
}
|
|
let engine = Tui::new()?;
|
|
engine.read().unwrap().exited.store(true, std::sync::atomic::Ordering::Relaxed);
|
|
let state = TestComponent("hello world".into());
|
|
let state = std::sync::Arc::new(std::sync::RwLock::new(state));
|
|
//engine.run(&state)?;
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)] #[test] fn test_parse_key () {
|
|
use KeyModifiers as Mods;
|
|
let test = |x: &str, y|assert_eq!(KeyMatcher::new(x).build(), Some(Event::Key(y)));
|
|
//test(":x",
|
|
//KeyEvent::new(KeyCode::Char('x'), Mods::NONE));
|
|
//test(":ctrl-x",
|
|
//KeyEvent::new(KeyCode::Char('x'), Mods::CONTROL));
|
|
//test(":alt-x",
|
|
//KeyEvent::new(KeyCode::Char('x'), Mods::ALT));
|
|
//test(":shift-x",
|
|
//KeyEvent::new(KeyCode::Char('x'), Mods::SHIFT));
|
|
//test(":ctrl-alt-shift-x",
|
|
//KeyEvent::new(KeyCode::Char('x'), Mods::CONTROL | Mods::ALT | Mods::SHIFT ));
|
|
}
|