use std::fmt::Debug;
use super::{main_event_loop_impl, BoxedSafeApp, GlobalData};
use crate::{get_size, CommonResult, FlexBoxId, InputDevice, InputEvent, OutputDevice};
pub struct TerminalWindow;
#[derive(Debug)]
pub enum TerminalWindowMainThreadSignal<AS>
where
AS: Debug + Default + Clone + Sync + Send,
{
Exit,
Render(Option<FlexBoxId>),
ApplyAppSignal(AS),
}
impl TerminalWindow {
pub async fn main_event_loop<S, AS>(
app: BoxedSafeApp<S, AS>,
exit_keys: &[InputEvent],
state: S,
) -> CommonResult<(
/* global_data */ GlobalData<S, AS>,
/* event stream */ InputDevice,
/* stdout */ OutputDevice,
)>
where
S: Debug + Default + Clone + Sync + Send,
AS: Debug + Default + Clone + Sync + Send + 'static,
{
let initial_size = get_size()?;
let input_device = InputDevice::new_event_stream();
let output_device = OutputDevice::new_stdout();
main_event_loop_impl(
app,
exit_keys,
state,
initial_size,
input_device,
output_device,
)
.await
}
}