messagebox

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OK         = Type(MB_OK)
	OK_CANCEL  = Type(MB_OK | MB_CANCEL)
	YES_NO     = Type(MB_YES | MB_NO)
	YES_NO_ALL = Type(MB_YES | MB_NO | MB_ALL)
)

Available message box types

Functions

func PlaceOverlay

func PlaceOverlay(x, y int, fg, bg string, opts ...WhitespaceOption) string

PlaceOverlay places fg on top of bg.

func WithPosition

func WithPosition(x, y int) optionFunc

WithPosition sets the position of the top left of the messagebox in columns from the left (x), and rows from the top (y).

func WithWidth

func WithWidth(w int) optionFunc

WithWidth sets the width of the message box. This will not be narrower than the space required to render the buttons. Height is computed from the message text.

Types

type Button

type Button int

Button represents a button in the message box

const (
	MB_OK Button = 1 << (iota + 1)
	MB_CANCEL
	MB_YES
	MB_NO
	MB_ALL
)

type Model

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

Model is the bubbletea model for message box.

func (Model) Init

func (m Model) Init() tea.Cmd

Init satisfies the BubbleTea Model interface. Does nothing here.

func (Model) IsActive

func (m Model) IsActive() bool

IsActive returns true if a message box is currently being displayed

func (Model) New

func (m Model) New(message string, boxType Type, opts ...optionFunc) Model

New creates a new modal message box with the given options. You would normally do this in the parent control's Update method in response to a key message.

While the message box in in an active state, you should direct all UI messages to its update method.

func (Model) Render

func (m Model) Render(content string) string

Render takes in the main view content and overlays the model's active message box. This function expects you to build the entirety of your view's content before calling this function. It's recommended for this to be the final call of your model's View(). Returns a string representation of the content with overlayed message box.

func (Model) Update

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

Update satisfies the BubbleTea Model interface. Processes key messages.

func (Model) View

func (m Model) View() string

View doesn't do anything, and it should never be called directly Implemented as part of BubbleTea Model interface

type Type

type Type int

Type defines the type of message box to display

type WhitespaceOption

type WhitespaceOption func(*whitespace)

WhitespaceOption sets a styling rule for rendering whitespace.

Jump to

Keyboard shortcuts

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