diff options
| author | theprimeagain <the.primeagen@gmail.com> | 2026-02-08 19:48:58 -0700 |
|---|---|---|
| committer | theprimeagain <the.primeagen@gmail.com> | 2026-02-08 19:48:58 -0700 |
| commit | a303021d63507e3949d43a41d77d80c3e74fdbd1 (patch) | |
| tree | cf7b57ca1368581410e9b6170e7be6b6e32f72d5 /lua/99/ops | |
| parent | 7ac6779cade4b6bb6a7e01f0101df799113e9b05 (diff) | |
| download | a4-a303021d63507e3949d43a41d77d80c3e74fdbd1.tar.xz a4-a303021d63507e3949d43a41d77d80c3e74fdbd1.zip | |
search
Diffstat (limited to 'lua/99/ops')
| -rw-r--r-- | lua/99/ops/throbber.lua | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lua/99/ops/throbber.lua b/lua/99/ops/throbber.lua index a686ebb..b08302a 100644 --- a/lua/99/ops/throbber.lua +++ b/lua/99/ops/throbber.lua @@ -56,24 +56,37 @@ local function ease_in_ease_out_cubic(percent) end local throb_time = 1200 -local cooldown_time = 200 +local cooldown_time = 100 +local tick_time = 100 --- @class _99.Throbber --- @field start_time number --- @field section_time number --- @field state "init" | "throbbing" | "cooldown" | "stopped" --- @field throb_fn _99.Throbber.ThrobFN +--- @field opts _99.Throbber.Opts --- @field cb fun(str: string): nil local Throbber = {} Throbber.__index = Throbber +--- @class _99.Throbber.Opts +--- @field throb_time number +--- @field cooldown_time number + --- @param cb fun(str: string): nil +--- @param opts _99.Throbber.Opts? --- @return _99.Throbber -function Throbber.new(cb) +function Throbber.new(cb, opts) + opts = opts + or { + throb_time = throb_time, + cooldown_time = cooldown_time, + } return setmetatable({ state = "init", start_time = 0, section_time = 0, + opts = opts, cb = cb, throb_fn = create_throbber(linear), }, Throbber) @@ -91,18 +104,19 @@ function Throbber:_run() if percent == 1 then self.state = self.state == "cooldown" and "throbbing" or "cooldown" self.start_time = time.now() - self.section_time = self.state == "cooldown" and cooldown_time or throb_time + self.section_time = self.state == "cooldown" and self.opts.cooldown_time + or self.opts.throb_time end self.cb(icon) vim.defer_fn(function() self:_run() - end, 75) + end, tick_time) end function Throbber:start() self.start_time = time.now() - self.section_time = throb_time + self.section_time = self.opts.throb_time self.state = "throbbing" self:_run() end |
