corty_tui/
lib.rs

1//! Corty TUI - Terminal User Interface for Corty
2//!
3//! This crate provides a terminal-based user interface for interacting with
4//! the Corty AI assistant. It features:
5//!
6//! - Interactive chat interface with message history
7//! - Mouse and keyboard navigation support
8//! - Configurable mouse capture for scrolling vs text selection
9//! - Responsive layout with welcome screen
10//! - Real-time message updates and AI responses
11
12use color_eyre::eyre::Result;
13
14mod app;
15mod event;
16pub mod slash_command;
17mod tui;
18mod utils;
19
20//pub so that it can be imported in test modules
21pub mod widgets;
22
23/// Run the terminal user interface application
24///
25/// This is the main entry point for the TUI. It initializes the terminal,
26/// sets up the application state, and runs the main event loop.
27///
28/// # Errors
29///
30/// Returns an error if:
31/// - Terminal initialization fails
32/// - The event loop encounters an unrecoverable error
33/// - Terminal restoration fails
34pub async fn run_tui() -> Result<()> {
35    // Initialize terminal and mouse capture
36    let (mut terminal, mut mouse_capture) = tui::init()?;
37
38    // Create and run the application
39    let mut app = app::App::new();
40    app.run(&mut terminal, &mut mouse_capture).await?;
41
42    Ok(())
43}