readme change

This commit is contained in:
2024-11-05 17:39:33 +01:00
parent 4f9a143008
commit a5de7f198e
2 changed files with 62 additions and 25 deletions
+61 -24
View File
@@ -1,38 +1,75 @@
# osui
# OSUI - A Terminal User Interface (TUI) Library
`osui` is a Text User Interface (TUI) library written in Rust.
# Please Read
OSUI is still in early development. Which means that the way you interact with OSUI will change.
Currently we are writing OSUI in Go and we will make a API that can be used by many popular languages like rust
Here is the OSUI Go version: https://github.com/orus-dev/osui
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.
## Features
- **React-Like**: Easily write components.
- **Cross-Platform Support**: Works on various operating systems.
- **Flexible Layout**: Easily create and manage complex UIs.
- **Efficient Performance**: Designed for high performance and low latency.
- Define and manage UI components.
- Handle keyboard input seamlessly.
- Create complex layouts using nested elements.
- Customizable element sizes and styles.
## Installation
## Getting Started
To use `osui` in your Rust project, run the following:
To use OSUI in your project, include it in your `Cargo.toml`:
`cargo add osui`
```toml
[dependencies]
osui = "0.2" # Replace with the latest version
```
## Example Usage
Here’s a simple example of how to create a basic UI with OSUI:
```rust
use osui::{
components::text,
oml, App
};
use osui::{rsx, app::run, ui::*};
fn main() {
let mut app = App::new();
app.set_component(oml!(
text("Hello, World!";)
));
app.run();
run(&mut rsx! {
text { "Hello, World!" }
});
}
```
## 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.
## Contributing
Contributions are welcome! If you have suggestions or improvements, feel free to submit a pull request or open an issue.
## License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.