From d73f50f272de210fe4957ff107e1ff88887f1c20 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 11 Jan 2023 14:33:11 +1100 Subject: spinner: add spinner-interval config option The default 200ms between each spinner frame can be unsuitable for spinners with many frames, so this adds a spinner-interval config option with type `time.Duration` to specify the interval between frames. The default is still the usual 200ms. Signed-off-by: Dean Acked-by: Moritz Poldrack --- config/ui.go | 2 ++ doc/aerc-config.5.scd | 5 +++++ widgets/spinner.go | 20 +++++++++++--------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/config/ui.go b/config/ui.go index 0994d993..e9b1a2b2 100644 --- a/config/ui.go +++ b/config/ui.go @@ -45,6 +45,7 @@ type UIConfig struct { NewMessageBell bool `ini:"new-message-bell"` Spinner string `ini:"spinner"` SpinnerDelimiter string `ini:"spinner-delimiter"` + SpinnerInterval time.Duration `ini:"spinner-interval"` IconUnencrypted string `ini:"icon-unencrypted"` IconEncrypted string `ini:"icon-encrypted"` IconSigned string `ini:"icon-signed"` @@ -150,6 +151,7 @@ func defaultUiConfig() *UIConfig { FuzzyComplete: false, Spinner: "[..] , [..] , [..] , [..] , [..], [..] , [..] , [..] ", SpinnerDelimiter: ",", + SpinnerInterval: 200 * time.Millisecond, IconUnencrypted: "", IconSigned: "[s]", IconEncrypted: "[e]", diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 410b40a3..cea7d2e7 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -183,6 +183,11 @@ These options are configured in the *[ui]* section of _aerc.conf_. Default: _,_ +*spinner-interval* = __ + The delay between each spinner frame + + Default: _200ms_ + *sort* = __ List of space-separated criteria to sort the messages by, see *:sort* command in *aerc*(1) for reference. Prefixing a criterion with _-r_ diff --git a/widgets/spinner.go b/widgets/spinner.go index 99365527..abbe1ae4 100644 --- a/widgets/spinner.go +++ b/widgets/spinner.go @@ -13,18 +13,20 @@ import ( ) type Spinner struct { - frame int64 // access via atomic - frames []string - stop chan struct{} - style tcell.Style + frame int64 // access via atomic + frames []string + interval time.Duration + stop chan struct{} + style tcell.Style } func NewSpinner(uiConf *config.UIConfig) *Spinner { spinner := Spinner{ - stop: make(chan struct{}), - frame: -1, - frames: strings.Split(uiConf.Spinner, uiConf.SpinnerDelimiter), - style: uiConf.GetStyle(config.STYLE_SPINNER), + stop: make(chan struct{}), + frame: -1, + interval: uiConf.SpinnerInterval, + frames: strings.Split(uiConf.Spinner, uiConf.SpinnerDelimiter), + style: uiConf.GetStyle(config.STYLE_SPINNER), } return &spinner } @@ -45,7 +47,7 @@ func (s *Spinner) Start() { atomic.StoreInt64(&s.frame, -1) s.stop <- struct{}{} return - case <-time.After(200 * time.Millisecond): + case <-time.After(s.interval): atomic.AddInt64(&s.frame, 1) ui.QueueRedraw() } -- cgit