← XeFM crftwr/xefm on GitHub · craftware

Progress Animation System

Module: xefm/progress_animator.py

A small, generalized engine for animated progress indicators (spinners and progress-bar-style effects) used wherever XeFM needs “something is happening” feedback — search, and, through ProgressManager, file operations. It is a pure frame generator: it computes which glyph to show based on elapsed time. Rendering and threading live in the callers.

Architecture

ProgressAnimator

ProgressAnimator(config, pattern_override=None, speed_override=None)

config supplies defaults PROGRESS_ANIMATION_PATTERN and PROGRESS_ANIMATION_SPEED; the two overrides let a single instance pick a different pattern or speed without touching config. Key methods:

Timing is purely elapsed-time based, so the animation is independent of how often the caller redraws — a caller can force smoothness by redrawing on a timer even without new progress data.

Patterns

The patterns table maps a name to a frame list. Available names: spinner (default, Braille), dots, progress (bar fill), bounce, pulse, wave, clock, arrow. An unknown name falls back to spinner. The exact frame lists are defined in the source; treat that as authoritative rather than duplicating them here.

ProgressAnimatorFactory

Static builders:

Usage

from xefm.progress_animator import ProgressAnimator, ProgressAnimatorFactory

search_animator = ProgressAnimatorFactory.create_search_animator(config)
status = search_animator.get_status_text("Searching", "42 found", is_active=True)

animator = ProgressAnimatorFactory.create_custom_animator(config, 'progress', 0.3)
animator.set_pattern('wave')   # change at runtime
animator.set_speed(0.1)

ProgressManager (xefm/progress_manager.py) constructs its own ProgressAnimator with pattern_override='spinner', speed_override=0.08 and calls get_current_frame() while formatting operation status — see Progress Manager System.

Configuration

# Defaults consumed from config
PROGRESS_ANIMATION_PATTERN = 'spinner'
PROGRESS_ANIMATION_SPEED   = 0.2   # seconds per frame; ~0.1–0.5 is reasonable

Notes

Tests

</content>