sublime_lib icon indicating copy to clipboard operation
sublime_lib copied to clipboard

Compact ActivityIndicator animation

Open predragnikolic opened this issue 7 months ago • 1 comments

Currently the loading animation is a few characters long, [ = ]...

What do you think about a providing a way to have a more compact form like:

https://github.com/user-attachments/assets/6c872934-7916-45df-a41b-d2784f8cd070

The implementation from the video looks like this:

class ActivityIndicator:
    width = 10  # type: int
    interval = 100  # type: int

    _frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
    
    def render(self, ticks: int) -> str:
        frame = self._frames[ticks % len(self._frames)]

        return "{} {}".format(
            frame,
            self.label
        )

predragnikolic avatar May 21 '25 19:05 predragnikolic

Imo the ActivityIndicator class should take a frames: list[str] parameter that the render method will cycle through. We can then provide helper functions or constants with such frames that a user can choose from or create their own.

The current behavior could then for example be represented by a method that takes a width: int parameter and generates the respective frames .

Unsure if we'd also want to make the position of the label configurable alongside it.

FichteFoll avatar May 22 '25 14:05 FichteFoll