MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / render

Method render

crates/opencode-tui/src/components/spinner.rs:179–243  ·  view source on GitHub ↗
(
        &self,
        frame: &mut Frame,
        area: Rect,
        animations_enabled: bool,
        background: Color,
    )

Source from the content-addressed store, hash-verified

177 }
178
179 pub fn render(
180 &self,
181 frame: &mut Frame,
182 area: Rect,
183 animations_enabled: bool,
184 background: Color,
185 ) {
186 if area.width == 0 || area.height == 0 {
187 return;
188 }
189
190 let base_style = Style::default().bg(background);
191
192 if matches!(self.mode, SpinnerMode::Braille) {
193 self.render_braille(frame, area, animations_enabled, base_style);
194 return;
195 }
196
197 if !self.active {
198 let mut spans = Vec::with_capacity(self.width);
199 for idx in 0..self.width {
200 let symbol = if idx % 2 == 0 {
201 TaskKind::inactive_shape()
202 } else {
203 "◦"
204 };
205 spans.push(Span::styled(
206 symbol,
207 Style::default().fg(self.inactive_color),
208 ));
209 }
210 frame.render_widget(Paragraph::new(Line::from(spans)).style(base_style), area);
211 return;
212 }
213
214 if !animations_enabled {
215 let fallback = format!("{:<width$}", "[⋯]", width = self.width);
216 frame.render_widget(Paragraph::new(fallback).style(base_style), area);
217 return;
218 }
219
220 let scanner = self.scanner_state();
221 let mut spans = Vec::with_capacity(self.width);
222 for char_index in 0..self.width {
223 let color_index = self.color_index(char_index, scanner);
224 if let Some(index) = color_index {
225 let color = self
226 .trail_colors
227 .get(index)
228 .copied()
229 .unwrap_or(self.inactive_color);
230 spans.push(Span::styled(
231 self.task_kind.shape(),
232 Style::default().fg(color),
233 ));
234 } else {
235 spans.push(Span::styled(
236 TaskKind::inactive_shape(),

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
render_brailleMethod · 0.80
scanner_stateMethod · 0.80
color_indexMethod · 0.80
shapeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected