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

Method scanner_state

crates/opencode-tui/src/components/spinner.rs:274–319  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

272 }
273
274 fn scanner_state(&self) -> ScannerState {
275 let frame = self.frame_index % self.knight_total_frames.max(1);
276 let width = self.width;
277 let forward_frames = width;
278 let hold_end_frames = self.hold_end;
279 let backward_frames = width.saturating_sub(1);
280 let hold_start_frames = self.hold_start;
281
282 if frame < forward_frames {
283 ScannerState {
284 active_position: frame,
285 is_holding: false,
286 hold_progress: 0,
287 is_moving_forward: true,
288 }
289 } else if frame < forward_frames + hold_end_frames {
290 ScannerState {
291 active_position: width.saturating_sub(1),
292 is_holding: true,
293 hold_progress: frame - forward_frames,
294 is_moving_forward: true,
295 }
296 } else if frame < forward_frames + hold_end_frames + backward_frames {
297 let backward_index = frame - forward_frames - hold_end_frames;
298 ScannerState {
299 active_position: width.saturating_sub(2).saturating_sub(backward_index),
300 is_holding: false,
301 hold_progress: 0,
302 is_moving_forward: false,
303 }
304 } else if frame < forward_frames + hold_end_frames + backward_frames + hold_start_frames {
305 ScannerState {
306 active_position: 0,
307 is_holding: true,
308 hold_progress: frame - forward_frames - hold_end_frames - backward_frames,
309 is_moving_forward: false,
310 }
311 } else {
312 ScannerState {
313 active_position: 0,
314 is_holding: true,
315 hold_progress: 0,
316 is_moving_forward: false,
317 }
318 }
319 }
320
321 fn color_index(&self, char_index: usize, scanner: ScannerState) -> Option<usize> {
322 let directional_distance = if scanner.is_moving_forward {

Callers 1

renderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected