readme changes
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
# OSUI - A Terminal User Interface (TUI) Library
|
# 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.
|
<div style="text-align:center">
|
||||||
|
<img src="github/OSUI.png" alt="OSUI" width="200px"/>
|
||||||
|
<br/>
|
||||||
|
<b>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.
|
||||||
|
</b>
|
||||||
|
</div>
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
- Custom rsx syntax.
|
||||||
- Define and manage UI components.
|
- Define and manage UI components.
|
||||||
- Handle keyboard input seamlessly.
|
- Handle keyboard input seamlessly.
|
||||||
- Create complex layouts using nested elements.
|
- 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:
|
Here’s a simple example of how to create a basic UI with OSUI:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use osui::{rsx, app::run, ui::*};
|
use osui::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
run(&mut rsx! {
|
run(&mut rsx! {
|
||||||
@@ -32,43 +38,9 @@ fn main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Modules
|
## How it works
|
||||||
|
Credit to priz.js (discord) for the idea of using C for multithreading
|
||||||
- **element**: Defines base elements and their behavior.
|
<img src="github/multithread.png"/>
|
||||||
- **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
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
+4
-12
@@ -10,7 +10,7 @@
|
|||||||
//! ```rust
|
//! ```rust
|
||||||
//! use osui::prelude::*;
|
//! use osui::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! osui::app::run(&mut rsx! {
|
//! run(&mut rsx! {
|
||||||
//! text { "Hello, World!" }
|
//! text { "Hello, World!" }
|
||||||
//! });
|
//! });
|
||||||
//! ```
|
//! ```
|
||||||
@@ -39,17 +39,9 @@ pub mod utils;
|
|||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::ui::Color::*;
|
pub use crate::ui::Color::*;
|
||||||
pub use crate::{app::run, css, rsx, rsx_elem, ui::*, Handler};
|
pub use crate::{app::run, css, rsx, rsx_elem, ui::*, Handler};
|
||||||
pub use crate::{Children, Element, ElementCore, State, Value};
|
pub use crate::{Element, State, StateChanger, Value};
|
||||||
pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
|
// useful for Element making
|
||||||
pub fn sleep(ms: u64) {
|
pub use crate::{run_handler, Children, Component, ElementCore};
|
||||||
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 crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
|
pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};
|
||||||
pub fn sleep(ms: u64) {
|
pub fn sleep(ms: u64) {
|
||||||
std::thread::sleep(std::time::Duration::from_millis(ms));
|
std::thread::sleep(std::time::Duration::from_millis(ms));
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
pub mod styles;
|
pub mod styles;
|
||||||
pub use styles::*;
|
pub use styles::*;
|
||||||
|
|
||||||
use crate::prelude_extra::*;
|
use crate::prelude::*;
|
||||||
use osui_element::{elem_fn, element};
|
use osui_element::{elem_fn, element};
|
||||||
|
|
||||||
/// The `Text` element represents a piece of static text in the terminal UI.
|
/// The `Text` element represents a piece of static text in the terminal UI.
|
||||||
|
|||||||
Reference in New Issue
Block a user