added the ability to swap the scrolling runes

This commit is contained in:
dank 2020-10-13 00:40:58 -04:00 committed by GitHub
parent 2a7dafa3a8
commit 8a316e6c1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -32,6 +32,8 @@ type Option interface {
// options stores the provided options.
type options struct {
scrollUp rune
scrollDown rune
wrapMode wrap.Mode
rollContent bool
disableScrolling bool
@ -46,6 +48,8 @@ type options struct {
// newOptions returns a new options instance.
func newOptions(opts ...Option) *options {
opt := &options{
scrollUp: DefaultScrollUpRune,
scrollDown: DefaultScrollDownRune,
mouseUpButton: DefaultScrollMouseButtonUp,
mouseDownButton: DefaultScrollMouseButtonDown,
keyUp: DefaultScrollKeyUp,
@ -84,6 +88,22 @@ func (o option) set(opts *options) {
o(opts)
}
// ScrollRunes configures the text widgets scroll runes, shown at the top and
// bottom of a scrollable text widget. If not provided, the default scroll
// runes will be used.
func ScrollRunes(up, down rune) Option {
return option(func(opts *options) {
opts.scrollUp = up
opts.scrollDown = down
})
}
// The default scroll runes for content scrolling
const (
DefaultScrollUpRune = '⇧'
DefaultScrollDownRune = '⇩'
)
// WrapAtWords configures the text widget so that it automatically wraps lines
// that are longer than the width of the widget at word boundaries. If not
// provided, long lines are trimmed instead.