Documentation
¶
Overview ¶
Package slider implements an interactive value slider widget.
Index ¶
- Constants
- Variables
- type ChangeFn
- type Direction
- type Option
- func AlignHorizontal(h align.Horizontal) Option
- func AlignVertical(v align.Vertical) Option
- func BarStyle() Option
- func DotsStyle() Option
- func FillCellOpts(cellOpts ...cell.Option) Option
- func FillRune(r rune) Option
- func FocusedKnobCellOpts(cellOpts ...cell.Option) Option
- func Height(cells int) Option
- func KnobCellOpts(cellOpts ...cell.Option) Option
- func KnobRune(r rune) Option
- func Length(cells int) Option
- func Max(v int) Option
- func Min(v int) Option
- func OnChange(fn ChangeFn) Option
- func Orientation(o Direction) Option
- func SegmentedBlocksStyle() Option
- func SegmentedDotsStyle() Option
- func SegmentedSquaresStyle() Option
- func SegmentedStyle() Option
- func SquaresStyle() Option
- func StarsStyle() Option
- func Step(v int) Option
- func Style(s Preset) Option
- func TrackCellOpts(cellOpts ...cell.Option) Option
- func TrackRune(r rune) Option
- func Value(v int) Option
- func Width(cells int) Option
- type Preset
- type Slider
- func (s *Slider) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (s *Slider) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (s *Slider) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (s *Slider) Options() widgetapi.Options
- func (s *Slider) SetValue(v int)
- func (s *Slider) Value() int
Constants ¶
const ( // DefaultWidth is the default slider length in terminal cells. DefaultWidth = 18 // DefaultStep is the default increment used for keyboard changes. DefaultStep = 1 )
Variables ¶
var ( DefaultFillColor = cell.ColorNumber(221) DefaultTrackColor = cell.ColorNumber(239) DefaultKnobColor = cell.ColorWhite DefaultFocusedKnobColor = cell.ColorCyan )
Default colors used by the slider widget.
Functions ¶
This section is empty.
Types ¶
type ChangeFn ¶
ChangeFn is called when the user changes the slider value.
The callback must be thread-safe because it is triggered from the keyboard and mouse event handling paths, which run in separate goroutines.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
func AlignHorizontal ¶
func AlignHorizontal(h align.Horizontal) Option
AlignHorizontal positions the slider horizontally inside a larger canvas.
func AlignVertical ¶
AlignVertical positions the slider vertically inside a larger canvas.
func FillCellOpts ¶
FillCellOpts sets the styling used for the filled portion of the slider.
func FocusedKnobCellOpts ¶
FocusedKnobCellOpts sets the styling used for the slider knob while the widget is focused.
func Height ¶
Height sets the slider length in terminal cells.
This is an alias for Length intended for vertical sliders.
func KnobCellOpts ¶
KnobCellOpts sets the styling used for the slider knob.
func OnChange ¶
OnChange sets the slider's value-change hook.
This is the widget's canonical callback surface. Callers that need delayed or asynchronous work should build that from this hook so the widget keeps a single stable event path.
func Orientation ¶
Orientation sets whether the slider is drawn horizontally or vertically.
func SegmentedBlocksStyle ¶
func SegmentedBlocksStyle() Option
SegmentedBlocksStyle applies the dense rectangular block style.
func SegmentedDotsStyle ¶
func SegmentedDotsStyle() Option
SegmentedDotsStyle applies the smaller dot segment style.
func SegmentedSquaresStyle ¶
func SegmentedSquaresStyle() Option
SegmentedSquaresStyle applies the smaller square segment style.
func SegmentedStyle ¶
func SegmentedStyle() Option
SegmentedStyle applies the thin segmented-line style.
func SquaresStyle ¶
func SquaresStyle() Option
SquaresStyle applies the filled and empty square style.
func TrackCellOpts ¶
TrackCellOpts sets the styling used for the unfilled portion of the slider.
type Preset ¶
type Preset int
Preset is a named visual preset for the slider track.
const ( // StyleBar is the default solid filled bar with a knob. StyleBar Preset = iota // StyleSegmented draws a thin segmented line. StyleSegmented // StyleSegmentedBlocks draws dense rectangular block segments. StyleSegmentedBlocks // StyleDots draws filled and empty circular dots. StyleDots // StyleSegmentedDots draws smaller dot segments. StyleSegmentedDots // StyleSquares draws filled and empty square blocks. StyleSquares // StyleSegmentedSquares draws smaller square segments. StyleSegmentedSquares // StyleStars draws filled and empty star segments. StyleStars )
type Slider ¶
type Slider struct {
// contains filtered or unexported fields
}
Slider lets the user select a numeric value within a fixed range.
Implements widgetapi.Widget. This object is thread-safe.
func (*Slider) Keyboard ¶
Keyboard processes keyboard events for the slider. Implements widgetapi.Widget.Keyboard.
func (*Slider) Mouse ¶
Mouse processes mouse events for the slider. Implements widgetapi.Widget.Mouse.
Directories
¶
| Path | Synopsis |
|---|---|
|
Binary sliderdemo shows the functionality of a slider widget.
|
Binary sliderdemo shows the functionality of a slider widget. |