refactor: extract mod exit, task; Thread -> Task

This commit is contained in:
same mf who else 2026-03-28 14:11:23 +02:00
parent bea88ac58d
commit dae4d5a140
8 changed files with 114 additions and 74 deletions

View file

@ -1,4 +1,4 @@
use crate::{*, lang::*, play::*, draw::*, space::{*, Split::*}, color::*, text::*};
use crate::{*, lang::*, play::*, draw::*, space::{*, Split::*}, color::*, text::*, task::*};
use unicode_width::{UnicodeWidthStr, UnicodeWidthChar};
use rand::distributions::uniform::UniformSampler;
use ::{
@ -509,14 +509,14 @@ pub fn tui_output <W: Write + Send + Sync + 'static, T: Draw<Tui> + Send + Sync
exited: &Arc<AtomicBool>,
state: &Arc<RwLock<T>>,
sleep: Duration
) -> Usually<Thread> {
) -> Usually<Task> {
let state = state.clone();
tui_setup()?;
let mut backend = CrosstermBackend::new(output);
let Size { width, height } = backend.size().expect("get size failed");
let mut buffer_a = Buffer::empty(Rect { x: 0, y: 0, width, height });
let mut buffer_b = Buffer::empty(Rect { x: 0, y: 0, width, height });
Ok(Thread::new_sleep(exited.clone(), sleep, move |perf| {
Ok(Task::new_sleep(exited.clone(), sleep, move |perf| {
let Size { width, height } = backend.size().expect("get size failed");
if let Ok(state) = state.try_read() {
tui_resize(&mut backend, &mut buffer_a, Rect { x: 0, y: 0, width, height });