vtcode_core/utils/
message_style.rs1use crate::ui::theme;
4use crate::ui::tui::InlineMessageKind;
5use anstyle::Style;
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum MessageStyle {
10 Info,
11 Error,
12 Output,
13 Response,
14 Tool,
15 ToolDetail,
16 ToolOutput,
17 ToolError,
18 Status,
19 McpStatus,
20 User,
21 Reasoning,
22 ReasoningEmphasis,
23 Warning,
24}
25
26impl MessageStyle {
27 pub fn style(self) -> Style {
29 let styles = theme::active_styles();
30 match self {
31 Self::Info => styles.info,
32 Self::Error => styles.error,
33 Self::Output => styles.output,
34 Self::Response => styles.response,
35 Self::Tool => styles.tool,
36 Self::ToolDetail => styles.tool_detail,
37 Self::ToolOutput => styles.pty_output, Self::ToolError => styles.error,
39 Self::Status => styles.status,
40 Self::McpStatus => styles.mcp,
41 Self::User => styles.user,
42 Self::Reasoning => styles.reasoning,
43 Self::ReasoningEmphasis => styles.reasoning.bold(),
44 Self::Warning => styles.error,
45 }
46 }
47
48 pub fn indent(self) -> &'static str {
50 match self {
51 Self::Response | Self::Tool => " ",
52 Self::Reasoning => " ❋ ",
53 Self::ReasoningEmphasis => " ▸ ",
54 Self::ToolDetail | Self::ToolOutput | Self::ToolError => " ",
55 _ => "",
56 }
57 }
58
59 pub fn message_kind(self) -> InlineMessageKind {
61 match self {
62 Self::Info => InlineMessageKind::Info,
63 Self::Error => InlineMessageKind::Error,
64 Self::Output | Self::ToolOutput => InlineMessageKind::Pty,
65 Self::Response => InlineMessageKind::Agent,
66 Self::Tool | Self::ToolDetail | Self::ToolError => InlineMessageKind::Tool,
67 Self::Status | Self::McpStatus => InlineMessageKind::Info,
68 Self::User => InlineMessageKind::User,
69 Self::Reasoning => InlineMessageKind::Policy,
70 Self::ReasoningEmphasis => InlineMessageKind::Policy,
71 Self::Warning => InlineMessageKind::Warning,
72 }
73 }
74}