use crate::model::Model;
use crate::program::{Program, ProgramOptions};
use std::io;
pub struct App<M: Model> {
model: M,
options: ProgramOptions,
}
impl<M: Model + 'static> App<M> {
pub fn new(model: M) -> Self {
Self {
model,
options: ProgramOptions::default(),
}
}
#[must_use]
pub fn with_mouse(mut self) -> Self {
self.options.mouse = true;
self
}
#[must_use]
pub fn inline(mut self) -> Self {
self.options.alternate_screen = false;
self
}
#[must_use]
pub fn show_cursor(mut self) -> Self {
self.options.hide_cursor = false;
self
}
#[must_use]
pub fn with_bracketed_paste(mut self) -> Self {
self.options.bracketed_paste = true;
self
}
#[must_use]
pub fn with_options(mut self, options: ProgramOptions) -> Self {
self.options = options;
self
}
pub fn run(self) -> io::Result<()> {
Program::with_options(self.model, self.options).run()
}
}