marquee

package module
v0.0.0-...-6850f06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 9 Imported by: 0

README

Marquee Bubble

GoDoc

A simple BubbleTea bubble component to generate marquees.

Made with VHS

Usage

First, initialize a new marquee, then set the text to display, and optionally the width. If width is not defined, it's assumed from the text's length.

func NewMyModel() MyModel {
    m := marquee.New()
    m.SetText("Hello World")
    m.SetWidth(100) // optional
    return MyModel{marquee: m}
}

It supports two scrolling directions, left and right.

m.ScrollDirection = marquee.Right

You can also specify the scrolling speed (defaults to 250ms).

m.ScrollSpeed = 50 * time.Millisecond

And you can make it continuous:

m.SetContinuous(true)

Then, call scroll in your Init().

func(m MyModel) Init() tea.Cmd {
  return m.marquee.Scroll
}

That's it. Check the documentation and the example directory for more detailed usage.

License

See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int

Direction describes the direction for the marquee.

const (
	Left Direction = iota
	Right
)

Available directions.

type Model

type Model struct {
	ScrollSpeed time.Duration
	// Style for styling the marquee block.
	Style lipgloss.Style
	// The direction in which the text will scroll.
	ScrollDirection Direction
	// contains filtered or unexported fields
}

Model is the Bubble Tea model for the marquee.

func New

func New() Model

New creates a new model with default settings.

func (Model) Scroll

func (m Model) Scroll() tea.Msg

Scroll is a command used to initialize marquee scrolling.

func (*Model) ScrollCmd

func (m *Model) ScrollCmd() tea.Cmd

ScrollCmd is the command to control the marquee scrolling.

func (*Model) SetContinuous

func (m *Model) SetContinuous(continuous bool)

Sets if the text of the marquee should be continuous.

func (*Model) SetText

func (m *Model) SetText(text string)

Sets marquee text content.

func (*Model) SetWidth

func (m *Model) SetWidth(width int)

Sets marquee width.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update updates the marquee.

func (Model) View

func (m Model) View() string

View displays the marquee.

type ScrollMsg

type ScrollMsg struct {
	// contains filtered or unexported fields
}

ScrollMsg signals that the marquee should scroll.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL