diff options
| author | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-15 12:38:21 +0100 |
|---|---|---|
| committer | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-15 12:38:21 +0100 |
| commit | acc753e440fb6ce54342c1f4e4fc980c5e008448 (patch) | |
| tree | 89d1737d19b1db8d4082fa5fdbff1792150cefa0 /lua/pets/pet.lua | |
| parent | chore: renamed grey to gray (diff) | |
feat(commands): added hide and pause commands
Diffstat (limited to 'lua/pets/pet.lua')
| -rw-r--r-- | lua/pets/pet.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua index e13d9e0..2442eec 100644 --- a/lua/pets/pet.lua +++ b/lua/pets/pet.lua @@ -43,7 +43,7 @@ end -- start the animation of the pet function M.Pet:animate() self.popup:mount() - self.animation:start(self.popup.bufnr) + self.animation:start() end -- delete the pet :( @@ -56,4 +56,32 @@ function M.Pet:kill() end end +function M.Pet:toggle_pause() + if not self.paused then + self.animation:stop_timer() + self.paused = true + else + if self.animation.current_image then + self.animation.current_image:delete(0, { free = false }) + end + self.animation:start_timer() + self.paused = false + end +end + +function M.Pet:toggle_hide() + if not self.paused then + self.animation:stop_timer() + if self.animation.current_image then + self.animation.current_image:delete(0, { free = false }) + end + self.popup:unmount() + self.paused = true + else + self.popup:mount() + self.animation:start() + self.paused = false + end +end + return M |