Skip to main content

Crate osui

Crate osui 

Source
Expand description

§OSUI - A TUI Library for Advanced UIs

OSUI is a Rust library for building sophisticated Terminal User Interfaces (TUIs). It provides a component-based architecture with state management, event handling, and rendering capabilities for creating interactive console applications.

§Key Features

  • Component System: Build UIs using composable components
  • State Management: React-like hooks for managing component state
  • Event Handling: Type-safe event system with reactive updates
  • RSX Syntax: Macro-based DSL for defining component hierarchies
  • Console Engine: Terminal rendering with crossterm support

§Architecture

  • component - Component system and context management
  • state - State management with hooks (useState, useEffect, etc.)
  • engine - Rendering engine and command execution
  • frontend - RSX (React-like Syntax) for component definitions
  • render - Low-level rendering primitives

§Example

use osui::prelude::*;
use std::sync::Arc;

#[component]
pub fn Counter(cx: &Arc<Context>) -> View {
    let count = use_state(0);
     
    Arc::new(move |ctx| {
        ctx.draw_text(Point { x: 0, y: 0 }, &format!("Count: {}", count.get_dl()));
    })
}

Modules§

component
Component Module
engine
Engine Module
frontend
Frontend Module
prelude
Prelude module - Re-exports commonly used items for convenience
render
Rendering Module
state
State Management Module

Enums§

Error
Error type for OSUI operations

Functions§

sleep
Sleep for the specified duration in milliseconds. Useful for controlling render frame rate or delays.

Type Aliases§

Result
Result type for OSUI operations
View
A View is an async function that renders content to a DrawContext. It takes a mutable DrawContext and produces drawing instructions.
ViewWrapper
A ViewWrapper is a higher-order function that wraps views. It can modify or enhance how a view is rendered.