Spinner doc comments

This commit is contained in:
Christian Rocha 2020-05-13 16:06:15 -04:00
parent 82a40119b9
commit 251f944f12
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
2 changed files with 27 additions and 5 deletions

View File

@ -38,6 +38,14 @@ type Model struct {
lines []string lines []string
} }
func (m *Model) PageUp() {
m.Y = max(0, m.Y-m.Height)
}
func (m *Model) PageDown() {
m.Y = min(len(m.lines)-m.Height, m.Y+m.Height)
}
// Content adds text content to the model // Content adds text content to the model
func (m *Model) Content(s string) { func (m *Model) Content(s string) {
s = strings.TrimSpace(s) s = strings.TrimSpace(s)

View File

@ -7,7 +7,7 @@ import (
"github.com/muesli/termenv" "github.com/muesli/termenv"
) )
// Spinner denotes a type of spinner // Spinner is a set of frames used in animating the spinner.
type Spinner = int type Spinner = int
// Available types of spinners // Available types of spinners
@ -29,15 +29,29 @@ var (
// Model contains the state for the spinner. Use NewModel to create new models // Model contains the state for the spinner. Use NewModel to create new models
// rather than using Model as a struct literal. // rather than using Model as a struct literal.
type Model struct { type Model struct {
// Type is the set of frames to use. See Spinner.
Type Spinner Type Spinner
// FPS is the speed at which the ticker should tick
FPS int FPS int
// ForegroundColor sets the background color of the spinner. It can be a
// hex code or one of the 256 ANSI colors. If the terminal emulator can't
// doesn't support the color specified it will automatically degrade
// (per github.com/muesli/termenv).
ForegroundColor string ForegroundColor string
// BackgroundColor sets the background color of the spinner. It can be a
// hex code or one of the 256 ANSI colors. If the terminal emulator can't
// doesn't support the color specified it will automatically degrade
// (per github.com/muesli/termenv).
BackgroundColor string BackgroundColor string
// CustomMsgFunc can be used to a custom message on tick. This can be // CustomMsgFunc can be used to a custom message on tick. This can be
// useful when you have spinners in different parts of your application and // useful when you have spinners in different parts of your application and
// want to differentiate the messages for clarity. If nil this setting is // want to differentiate between the messages for clarity and simplicity.
// ignored. // If nil, this setting is ignored.
CustomMsgFunc func() boba.Msg CustomMsgFunc func() boba.Msg
frame int frame int