Skip to main content

raps_cli/shell/
prompt.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2024-2025 Dmytro Yemelianov
3
4use std::borrow::Cow;
5
6use reedline::{Prompt, PromptEditMode, PromptHistorySearch};
7
8/// RAPS interactive prompt with proper styled/raw separation.
9///
10/// The Prompt trait separates the raw text content from styling,
11/// so reedline can calculate cursor position from plain text width
12/// while still displaying a colored prompt.
13pub struct RapsPrompt;
14
15impl Prompt for RapsPrompt {
16    fn render_prompt_left(&self) -> Cow<'_, str> {
17        Cow::Borrowed("raps> ")
18    }
19
20    fn render_prompt_right(&self) -> Cow<'_, str> {
21        Cow::Borrowed("")
22    }
23
24    fn render_prompt_indicator(&self, _prompt_mode: PromptEditMode) -> Cow<'_, str> {
25        Cow::Borrowed("")
26    }
27
28    fn render_prompt_multiline_indicator(&self) -> Cow<'_, str> {
29        Cow::Borrowed("::: ")
30    }
31
32    fn render_prompt_history_search_indicator(
33        &self,
34        _history_search: PromptHistorySearch,
35    ) -> Cow<'_, str> {
36        Cow::Borrowed("(search) ")
37    }
38
39    fn get_prompt_color(&self) -> reedline::Color {
40        reedline::Color::Yellow
41    }
42}