Documentation ¶
Index ¶
- func ViewDown(m Model, lines []string) tea.Cmd
- func ViewUp(m Model, lines []string) tea.Cmd
- type KeyMap
- type Model
- func (this Model) AtBottom() bool
- func (this Model) AtTop() bool
- func (m *Model) GotoBottom() (lines []string)
- func (m *Model) GotoTop() (lines []string)
- func (m *Model) HalfViewDown() (lines []string)
- func (m *Model) HalfViewUp() (lines []string)
- func (this Model) Init() tea.Cmd
- func (m *Model) LineDown(n int) (lines []string)
- func (m *Model) LineUp(n int) (lines []string)
- func (this Model) PastBottom() bool
- func (this Model) ScrollPercent() float64
- func (this *Model) SetYOffset(n int)
- func (this Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (this Model) View() string
- func (this *Model) ViewDown() []string
- func (this *Model) ViewUp() []string
- func (this *Model) Write(p []byte) (n int, err error)
- func (this *Model) WriteString(s string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KeyMap ¶
type KeyMap struct { PageDown key.Binding PageUp key.Binding HalfPageUp key.Binding HalfPageDown key.Binding Down key.Binding Up key.Binding }
KeyMap defines the keybindings for the viewport. Note that you don't necessary need to use keybindings at all; the viewport can be controlled programmatically with methods like Model.LineDown(1). See the GoDocs for details.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap returns a set of pager-like default keybindings.
type Model ¶
type Model struct { Width int Height int KeyMap KeyMap // Whether or not to respond to the mouse. The mouse must be enabled in // Bubble Tea for this to work. For details, see the Bubble Tea docs. MouseWheelEnabled bool // The number of lines the mouse wheel will scroll. By default, this is 3. MouseWheelDelta int // YOffset is the vertical scroll position. YOffset int // YPosition is the position of the viewport in relation to the terminal // window. It's used in high performance rendering only. YPosition int // Style applies a lipgloss style to the viewport. Realistically, it's most // useful for setting borders, margins and padding. Style lipgloss.Style // contains filtered or unexported fields }
Model is the Bubble Tea model for this viewport element.
func New ¶
func New() (this Model)
New returns a new model with the given width and height as well as default key mappings.
func (Model) AtBottom ¶
AtBottom returns whether or not the viewport is at or past the very bottom position.
func (*Model) GotoBottom ¶
GotoBottom sets the viewport to the bottom position.
func (*Model) HalfViewDown ¶
HalfViewDown moves the view down by half the height of the viewport.
func (*Model) HalfViewUp ¶
HalfViewUp moves the view up by half the height of the viewport.
func (*Model) LineUp ¶
LineUp moves the view down by the given number of lines. Returns the new lines to show.
func (Model) PastBottom ¶
PastBottom returns whether or not the viewport is scrolled beyond the last line. This can happen when adjusting the viewport height.
func (Model) ScrollPercent ¶
ScrollPercent returns the amount scrolled as a float between 0 and 1.
func (*Model) ViewDown ¶
ViewDown moves the view down by the number of lines in the viewport. Basically, "page down".
func (*Model) ViewUp ¶
ViewUp moves the view up by one height of the viewport. Basically, "page up".