diff --git a/README.md b/README.md index 54ba261..209acc8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ # OSUI - A Terminal User Interface (TUI) Library -OSUI is a customizable terminal user interface (TUI) library written in Rust. It provides a set of components to build interactive command-line interfaces with ease. +
+ OSUI +
+ OSUI is a customizable terminal user interface (TUI) library written in Rust. It provides a set of components and rsx to build interactive command-line interfaces with ease. + +
## Features +- Custom rsx syntax. - Define and manage UI components. - Handle keyboard input seamlessly. - Create complex layouts using nested elements. @@ -23,7 +29,7 @@ osui = "0.2" # Replace with the latest version Here’s a simple example of how to create a basic UI with OSUI: ```rust -use osui::{rsx, app::run, ui::*}; +use osui::prelude::*; fn main() { run(&mut rsx! { @@ -32,43 +38,9 @@ fn main() { } ``` -## Modules - -- **element**: Defines base elements and their behavior. -- **key**: Handles keyboard input and mapping. -- **utils**: Provides utility functions for common TUI tasks. -- **ui**: Contains user interface components and layout management. - -## Elements - -### ElementSize - -Defines the size of an element, either as a default size or a custom size. - -### Element Trait - -The core trait for all UI components, requiring the implementation of methods to retrieve data, update dimensions, render output, and handle updates based on user input. - -### Commands - -The library supports several commands that can be triggered during the application’s lifecycle: - -- **Render**: Re-render an element with the given state. -- **Update**: Update an element's state based on user input. -- **Sleep**: Pause execution for a specified duration. -- **Exit**: Terminate the application gracefully. - -## Macros - -OSUI provides several macros to simplify the definition and usage of elements: - -- **element!**: Define a new UI element with customizable properties and behaviors. -- **rsx!**: Create a nested structure of UI components easily. -- **command!**: Simplify command creation for updates. - -## Credits - -Credit to priz.js (discord) for the idea of using C +## How it works +Credit to priz.js (discord) for the idea of using C for multithreading + ## Contributing diff --git a/github/OSUI.png b/github/OSUI.png new file mode 100644 index 0000000..d5278b6 Binary files /dev/null and b/github/OSUI.png differ diff --git a/github/multithread.png b/github/multithread.png new file mode 100644 index 0000000..a556882 Binary files /dev/null and b/github/multithread.png differ diff --git a/src/lib.rs b/src/lib.rs index 82821f2..96c8f02 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! ```rust //! use osui::prelude::*; //! -//! osui::app::run(&mut rsx! { +//! run(&mut rsx! { //! text { "Hello, World!" } //! }); //! ``` @@ -39,17 +39,9 @@ pub mod utils; pub mod prelude { pub use crate::ui::Color::*; pub use crate::{app::run, css, rsx, rsx_elem, ui::*, Handler}; - pub use crate::{Children, Element, ElementCore, State, Value}; - pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind}; - pub fn sleep(ms: u64) { - std::thread::sleep(std::time::Duration::from_millis(ms)); - } -} - -pub mod prelude_extra{ - pub use crate::ui::Color::*; - pub use crate::{app::run, css, rsx, rsx_elem, ui::*, Handler, StateChanger}; - pub use crate::{Children, Component, Element, ElementCore, State, Value, run_handler}; + pub use crate::{Element, State, StateChanger, Value}; + // useful for Element making + pub use crate::{run_handler, Children, Component, ElementCore}; pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind}; pub fn sleep(ms: u64) { std::thread::sleep(std::time::Duration::from_millis(ms)); diff --git a/src/ui/mod.rs b/src/ui/mod.rs index db37aa1..e645ee9 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -5,7 +5,7 @@ pub mod styles; pub use styles::*; -use crate::prelude_extra::*; +use crate::prelude::*; use osui_element::{elem_fn, element}; /// The `Text` element represents a piece of static text in the terminal UI.