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

Method render

crates/opencode-tui/src/components/dialogs/alert.rs:89–162  ·  view source on GitHub ↗
(&self, frame: &mut Frame, area: Rect, theme: &Theme)

Source from the content-addressed store, hash-verified

87 }
88
89 pub fn render(&self, frame: &mut Frame, area: Rect, theme: &Theme) {
90 if !self.open {
91 return;
92 }
93
94 let color = self.get_color(theme);
95 let icon = self.get_icon();
96
97 let line_count = self.message.lines().count().max(1);
98 let dialog_width = 50.min(area.width.saturating_sub(4));
99 let dialog_height = (line_count + 6).min(16) as u16;
100
101 let dialog_area = centered_rect(dialog_width, dialog_height, area);
102
103 frame.render_widget(Clear, dialog_area);
104
105 let block = Block::default()
106 .title(Span::styled(
107 format!(" {} {} ", icon, self.title),
108 Style::default().fg(color).add_modifier(Modifier::BOLD),
109 ))
110 .borders(Borders::ALL)
111 .border_style(Style::default().fg(color))
112 .style(Style::default().bg(theme.background_panel));
113
114 let inner = super::dialog_inner(block.inner(dialog_area));
115 frame.render_widget(block, dialog_area);
116
117 let paragraph = Paragraph::new(self.message.clone())
118 .style(Style::default().fg(theme.text))
119 .wrap(Wrap { trim: false })
120 .centered();
121
122 frame.render_widget(
123 paragraph,
124 Rect {
125 x: inner.x,
126 y: inner.y + 1,
127 width: inner.width,
128 height: inner.height.saturating_sub(4),
129 },
130 );
131
132 let hint = Line::from(vec![
133 Span::styled("[Enter] ", Style::default().fg(theme.text_muted)),
134 Span::styled("Close", Style::default().fg(theme.text)),
135 Span::styled(" [Ctrl+C] ", Style::default().fg(theme.text_muted)),
136 Span::styled("Copy", Style::default().fg(theme.text)),
137 ]);
138 frame.render_widget(
139 Paragraph::new(hint).centered(),
140 Rect {
141 x: inner.x,
142 y: inner.y + inner.height.saturating_sub(3),
143 width: inner.width,
144 height: 1,
145 },
146 );

Callers

nothing calls this directly

Calls 8

dialog_innerFunction · 0.85
newFunction · 0.85
get_colorMethod · 0.80
get_iconMethod · 0.80
countMethod · 0.80
centered_rectFunction · 0.70
titleMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected