MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / parse_logo_line

Function parse_logo_line

crates/opencode-tui/src/components/logo.rs:35–88  ·  view source on GitHub ↗

Parse a single logo line, replacing marker characters with styled shadow spans. `bold` controls whether non-marker characters get the BOLD modifier (used for the right half).

(line: &str, fg_color: Color, bg_color: Color, bold: bool)

Source from the content-addressed store, hash-verified

33/// Parse a single logo line, replacing marker characters with styled shadow spans.
34/// `bold` controls whether non-marker characters get the BOLD modifier (used for the right half).
35fn parse_logo_line(line: &str, fg_color: Color, bg_color: Color, bold: bool) -> Vec<Span<'_>> {
36 let shadow_color = blend_colors(fg_color, bg_color);
37 let base_style = if bold {
38 Style::default().fg(fg_color).add_modifier(Modifier::BOLD)
39 } else {
40 Style::default().fg(fg_color)
41 };
42 let mut spans = Vec::new();
43
44 for c in line.chars() {
45 let span = if MARKS.contains(c) {
46 match c {
47 '_' => Span::styled(
48 " ",
49 if bold {
50 Style::default()
51 .fg(fg_color)
52 .bg(shadow_color)
53 .add_modifier(Modifier::BOLD)
54 } else {
55 Style::default().fg(fg_color).bg(shadow_color)
56 },
57 ),
58 '^' => Span::styled(
59 "▀",
60 if bold {
61 Style::default()
62 .fg(fg_color)
63 .bg(shadow_color)
64 .add_modifier(Modifier::BOLD)
65 } else {
66 Style::default().fg(fg_color).bg(shadow_color)
67 },
68 ),
69 '~' => Span::styled(
70 "▀",
71 if bold {
72 Style::default()
73 .fg(shadow_color)
74 .add_modifier(Modifier::BOLD)
75 } else {
76 Style::default().fg(shadow_color)
77 },
78 ),
79 _ => Span::styled(c.to_string(), base_style),
80 }
81 } else {
82 Span::styled(c.to_string(), base_style)
83 };
84 spans.push(span);
85 }
86
87 spans
88}
89
90pub struct Logo {
91 primary_color: Color,

Callers 1

renderMethod · 0.85

Calls 3

newFunction · 0.85
containsMethod · 0.80
blend_colorsFunction · 0.70

Tested by

no test coverage detected