command stage 1

This commit is contained in:
2024-11-22 05:59:14 +01:00
parent 533ec30597
commit 10c8f6d0ca
3 changed files with 95 additions and 30 deletions
+15 -1
View File
@@ -43,7 +43,7 @@ pub use app::run;
pub mod prelude {
pub use crate::ui::Color::*;
pub use crate::{self as osui, css, rsx, rsx_elem, ui::*, Handler};
pub use crate::{style, Element, Value};
pub use crate::{style, Command, Element, Value, Document};
// useful for Element making
pub use crate::{run_handler, Children, ElementCore, ElementWidget};
pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
@@ -194,4 +194,18 @@ impl Children {
/// Converts a `Element` into the struct
pub fn convert<T>(widget: &mut Box<dyn ElementWidget>) -> &mut Box<T> {
unsafe { &mut *(widget as *mut _ as *mut Box<T>) }
}
pub enum Command {
Exit,
}
pub struct Document {
cmd_sender: std::sync::mpsc::Sender<Command>,
}
impl Document {
pub fn exit(&self) {
self.cmd_sender.send(Command::Exit).unwrap();
}
}