This commit is contained in:
2024-12-24 20:55:20 +01:00
parent ea7e9c1e1c
commit 7e2106cae5
5 changed files with 50 additions and 52 deletions
+16 -6
View File
@@ -55,10 +55,10 @@ pub mod utils;
pub mod prelude {
pub use crate::ui::Color::*;
pub use crate::ui::Font::*;
pub use crate::ui::Instruction::*;
pub use crate::ui::Number::{Auto, Center};
pub use crate::Instruction::*;
pub use crate::{self as osui, css, ersx, launch, rsx, ui::*, Handler};
pub use crate::{style, Component, Document, State};
pub use crate::{style, Component, Document, Instruction, State};
pub use crate::{Children, Element, ElementCore, ElementWidget};
pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
pub use osui_element::component;
@@ -197,17 +197,19 @@ impl Document {
}
}
pub fn run(&mut self) -> bool {
// Set up the screen
utils::hide_cursor();
crossterm::terminal::enable_raw_mode().unwrap();
utils::clear();
self.running = None;
let element = unsafe { &mut *self.element };
self.render();
element.initialize(self);
// Send initial event
element.event(crossterm::event::Event::FocusGained, self);
utils::hide_cursor();
crossterm::terminal::enable_raw_mode().unwrap();
utils::clear();
while self.running == None {
self.render();
element.event(crossterm::event::read().unwrap(), self);
@@ -509,3 +511,11 @@ impl<T: PartialEq> PartialEq<T> for State<T> {
self.use_state().ne(other)
}
}
#[derive(Debug)]
pub enum Instruction<'a> {
SetStyle(ui::Css),
SetChild(usize),
Ghost(usize),
Load(Handler<ui::Div<'a>>),
}