Module prompt

Module prompt 

Source
Expand description

Prompt widget for displaying the command prompt

This module provides the PromptWidget for displaying a beautiful, styled command prompt with context information. The prompt displays:

  • Git branch information
  • Project name
  • Current application mode (Chat, Command, Diff, Help)
  • Active AI provider and model

§Features

  • Context indicators: Display git branch, project name, mode, and provider
  • Multi-line input: Support for multi-line command input with text wrapping
  • Input history: Navigate through previous commands with up/down arrows
  • Customizable styling: Configure colors and appearance via PromptConfig
  • Cursor positioning: Full cursor control and text editing

§Examples

Creating a prompt widget with context:

use ricecoder_tui::{PromptWidget, ContextIndicators, AppMode};

let mut context = ContextIndicators::new();
context.git_branch = Some("main".to_string());
context.project_name = Some("ricecoder".to_string());
context.mode = AppMode::Chat;
context.provider = Some("OpenAI".to_string());
context.model = Some("gpt-4".to_string());

let mut prompt = PromptWidget::new(context);

Customizing the prompt appearance:

use ricecoder_tui::PromptConfig;

let config = PromptConfig {
    prefix: "❯ ".to_string(),
    show_git_branch: true,
    show_mode: true,
    ..Default::default()
};

Structs§

ContextIndicators
Context indicators for the prompt
PromptConfig
Prompt configuration
PromptWidget
Prompt widget