Module patterns

Module patterns 

Source
Expand description

Common patterns for TUI applications

This module provides reusable patterns discovered while building multiple TUI apps (jira-revue, jenkins-tui, sshfs-tui, todo-tui). These patterns follow Clean Code and Single Responsibility Principle.

§Modules

ModuleDescription
colorsGitHub Dark theme color constants
messageMessage display with auto-timeout
confirmConfirmation dialog state
async_opsAsync polling patterns with mpsc channels
configTOML config loading utilities
keysLayered key handling pattern

§Example

use revue::patterns::*;

struct App {
    message: MessageState,
    confirm: ConfirmState,
    async_task: Option<AsyncTask<Vec<Item>>>,
}

impl App {
    fn poll(&mut self) -> bool {
        let mut needs_redraw = false;

        // Check message timeout
        needs_redraw |= self.message.check_timeout();

        // Poll async task
        if let Some(task) = &mut self.async_task {
            if let Some(result) = task.try_recv() {
                self.handle_result(result);
                self.async_task = None;
                needs_redraw = true;
            }
        }

        needs_redraw
    }
}

Re-exports§

pub use async_ops::spinner_char;
pub use async_ops::AsyncTask;
pub use async_ops::SPINNER_FRAMES;
pub use config::AppConfig;
pub use config::ConfigError;
pub use confirm::ConfirmAction;
pub use confirm::ConfirmState;
pub use form::FieldType;
pub use form::FormField;
pub use form::FormState;
pub use form::ValidationError;
pub use form::Validators;
pub use lazy::lazy;
pub use lazy::lazy_reloadable;
pub use lazy::lazy_sync;
pub use lazy::paged;
pub use lazy::progressive;
pub use lazy::LazyData;
pub use lazy::LazyList;
pub use lazy::LazyReloadable;
pub use lazy::LazySync;
pub use lazy::LoadState;
pub use lazy::PagedData;
pub use lazy::ProgressiveLoader;
pub use message::MessageState;
pub use navigation::build_breadcrumbs;
pub use navigation::BreadcrumbItem;
pub use navigation::NavigationEvent;
pub use navigation::NavigationState;
pub use navigation::Route;
pub use search::SearchMode;
pub use search::SearchState;
pub use colors::*;

Modules§

async_ops
Async operation patterns using mpsc channels
colors
GitHub Dark theme color constants
config
Configuration loading utilities
confirm
Confirmation dialog pattern
form
Form validation pattern with reactive state
keys
Layered key handling pattern
lazy
Lazy loading patterns for deferred data and UI rendering
message
Message display with automatic timeout
navigation
Navigation state pattern
search
Search and filter pattern