readme change
This commit is contained in:
@@ -1,38 +1,75 @@
|
|||||||
# osui
|
# OSUI - A Terminal User Interface (TUI) Library
|
||||||
|
|
||||||
`osui` is a Text User Interface (TUI) library written in Rust.
|
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.
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **React-Like**: Easily write components.
|
- Define and manage UI components.
|
||||||
- **Cross-Platform Support**: Works on various operating systems.
|
- Handle keyboard input seamlessly.
|
||||||
- **Flexible Layout**: Easily create and manage complex UIs.
|
- Create complex layouts using nested elements.
|
||||||
- **Efficient Performance**: Designed for high performance and low latency.
|
- 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
|
```rust
|
||||||
use osui::{
|
use osui::{rsx, app::run, ui::*};
|
||||||
components::text,
|
|
||||||
oml, App
|
|
||||||
};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut app = App::new();
|
run(&mut rsx! {
|
||||||
app.set_component(oml!(
|
text { "Hello, World!" }
|
||||||
text("Hello, World!";)
|
});
|
||||||
));
|
|
||||||
app.run();
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
//! ## Example Usage
|
//! ## Example Usage
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use osui::{parse_rsx_param, rsx, ui::*};
|
//! use osui::{self, rsx, ui::*};
|
||||||
//!
|
//!
|
||||||
//! osui::app::run(&mut rsx! {
|
//! osui::app::run(&mut rsx! {
|
||||||
//! text { "Hello, World!" }
|
//! text { "Hello, World!" }
|
||||||
|
|||||||
Reference in New Issue
Block a user