This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/default/config/config.go

42 lines
1.0 KiB
Go
Raw Normal View History

2023-02-02 13:19:56 -07:00
package config
2023-03-31 12:02:56 -06:00
import "time"
2023-03-30 23:06:29 -06:00
import "git.tebibyte.media/sashakoshka/tomo"
2023-02-02 16:20:02 -07:00
// Default specifies default configuration values.
type Default struct { }
2023-02-02 13:19:56 -07:00
2023-02-02 16:20:02 -07:00
// ScrollVelocity returns the default scroll velocity value.
func (Default) ScrollVelocity () int {
return 16
}
2023-03-31 12:02:56 -06:00
// DoubleClickDelay returns the default double click delay.
func (Default) DoubleClickDelay () time.Duration {
return time.Second / 2
}
2023-02-08 12:36:14 -07:00
// Wrapped wraps a configuration and uses Default if it is nil.
type Wrapped struct {
2023-03-30 23:06:29 -06:00
tomo.Config
2023-02-08 12:36:14 -07:00
}
2023-03-31 12:02:56 -06:00
// ScrollVelocity returns how many pixels should be scrolled every time a scroll
// button is pressed.
2023-02-08 12:36:14 -07:00
func (wrapped Wrapped) ScrollVelocity () int {
return wrapped.ensure().ScrollVelocity()
}
2023-03-31 12:02:56 -06:00
// DoubleClickDelay returns the maximum delay between two clicks for them to be
// registered as a double click.
func (wrapped Wrapped) DoubleClickDelay () time.Duration {
return wrapped.ensure().DoubleClickDelay()
}
2023-03-30 23:06:29 -06:00
func (wrapped Wrapped) ensure () (real tomo.Config) {
2023-02-08 12:36:14 -07:00
real = wrapped.Config
if real == nil { real = Default { } }
return
}