primitives

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FormModal added in v0.1.10

type FormModal struct {
	*tview.Box
	Form *tview.Form
	// contains filtered or unexported fields
}

FormModal is a modal window that contains a form.

func NewFormModal added in v0.1.10

func NewFormModal() *FormModal

NewFormModal returns a new form modal.

func (*FormModal) Draw added in v0.1.10

func (m *FormModal) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*FormModal) Focus added in v0.1.10

func (m *FormModal) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*FormModal) GetForm added in v0.1.10

func (m *FormModal) GetForm() *tview.Form

GetForm returns the form.

func (*FormModal) HasFocus added in v0.1.10

func (m *FormModal) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*FormModal) InputHandler added in v0.1.10

func (m *FormModal) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*FormModal) MouseHandler added in v0.1.10

func (m *FormModal) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*FormModal) SetCancelFunc added in v0.1.10

func (m *FormModal) SetCancelFunc(handler func()) *FormModal

SetCancelFunc sets a handler which is called when the user cancels the modal.

func (*FormModal) SetDoneFunc added in v0.1.10

func (m *FormModal) SetDoneFunc(handler func(buttonIndex int, buttonLabel string)) *FormModal

SetDoneFunc sets a handler which is called when one of the buttons was pressed. It receives the index of the button as well as its label text.

type InputModal

type InputModal struct {
	*tview.Box
	// contains filtered or unexported fields
}

InputModal is a simple input field primitive that is displayed as a modal

func NewInputModal

func NewInputModal() *InputModal

NewInputModal returns a new input field.

func (*InputModal) Draw

func (mi *InputModal) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*InputModal) GetText

func (mi *InputModal) GetText() string

func (*InputModal) InputHandler

func (mi *InputModal) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

func (*InputModal) SetBackgroundColor

func (mi *InputModal) SetBackgroundColor(color tcell.Color) *InputModal

func (*InputModal) SetFieldBackgroundColor

func (mi *InputModal) SetFieldBackgroundColor(color tcell.Color) *InputModal

func (*InputModal) SetFieldTextColor

func (mi *InputModal) SetFieldTextColor(color tcell.Color) *InputModal

func (*InputModal) SetInputLabel

func (mi *InputModal) SetInputLabel(label string) *InputModal

func (*InputModal) SetLabel

func (mi *InputModal) SetLabel(label string) *InputModal

func (*InputModal) SetLabelColor

func (mi *InputModal) SetLabelColor(color tcell.Color) *InputModal

func (*InputModal) SetText

func (mi *InputModal) SetText(text string) *InputModal

type ListModal

type ListModal struct {
	*tview.Box
	// contains filtered or unexported fields
}

ListModal is a simple list primitive that is displayed as a modal

func NewListModal

func NewListModal() *ListModal

func (*ListModal) AddItem

func (lm *ListModal) AddItem(text string, secondaryText string, shortcut rune, selected func()) *ListModal

AddItem adds item to the list

func (*ListModal) Clear

func (lm *ListModal) Clear() *ListModal

Clear removes all items from the list

func (*ListModal) Draw

func (lm *ListModal) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*ListModal) GetCurrentItem

func (lm *ListModal) GetCurrentItem() int

GetCurrentItem returns the index of the currently selected item

func (*ListModal) GetText

func (lm *ListModal) GetText() string

GetText returns text of the selected item

func (*ListModal) InputHandler

func (lm *ListModal) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*ListModal) RemoveItem

func (lm *ListModal) RemoveItem(index int) *ListModal

RemoveItem removes item from the list

func (*ListModal) SetBorderPadding added in v0.1.10

func (lm *ListModal) SetBorderPadding(top, right, bottom, left int) *ListModal

SetBorderPadding sets the border padding of the modal

func (*ListModal) SetMainTextStyle

func (lm *ListModal) SetMainTextStyle(style tcell.Style) *ListModal

SetMainTextStyle sets the text style of main text.

func (*ListModal) SetSecondaryTextStyle

func (lm *ListModal) SetSecondaryTextStyle(style tcell.Style) *ListModal

SetSecondaryTextStyle sets the text style of secondary text.

func (*ListModal) SetSelectedStyle

func (lm *ListModal) SetSelectedStyle(style tcell.Style) *ListModal

SetSelectedTextColor sets the color of the selected item's text.

func (*ListModal) ShowSecondaryText

func (lm *ListModal) ShowSecondaryText(show bool) *ListModal

ShowSecondaryText sets whether or not secondary text is shown

type Text

type Text struct {
	Content string
	Color   tcell.Color
	Align   int
}

Text is the text to be displayed in the modal.

type ViewModal

type ViewModal struct {
	*tview.Box
	// contains filtered or unexported fields
}

ViewModal is a centered message window used to inform the user or prompt them for an immediate decision. It needs to have at least one button (added via ViewModal.AddButtons) or it will never disappear.

func NewViewModal

func NewViewModal() *ViewModal

NewViewModal returns a new modal message window.

func (*ViewModal) AddButtons

func (m *ViewModal) AddButtons(labels []string) *ViewModal

AddButtons adds buttons to the window. There must be at least one button and a "done" handler so the window can be closed again.

func (*ViewModal) ClearButtons

func (m *ViewModal) ClearButtons() *ViewModal

ClearButtons removes all buttons from the window.

func (*ViewModal) CopySelectedLine

func (m *ViewModal) CopySelectedLine(copyFunc func(text string) error, copyType string) error

CopySelectedLine copies the selected line to the clipboard. copyType can be "full" or "value". "full" will copy the entire highlighted lines, while "value" will copy only the value of the highlighted line.

func (*ViewModal) Draw

func (m *ViewModal) Draw(screen tcell.Screen)

func (*ViewModal) Focus

func (m *ViewModal) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*ViewModal) HasFocus

func (m *ViewModal) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*ViewModal) InputHandler

func (m *ViewModal) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*ViewModal) IsFullScreen added in v0.1.8

func (m *ViewModal) IsFullScreen() bool

IsFullScreen returns true if the modal is in full-screen mode

func (*ViewModal) MouseHandler

func (m *ViewModal) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*ViewModal) MoveDown

func (m *ViewModal) MoveDown()

func (*ViewModal) MoveToBottom

func (m *ViewModal) MoveToBottom()

func (*ViewModal) MoveToTop

func (m *ViewModal) MoveToTop()

func (*ViewModal) MoveUp

func (m *ViewModal) MoveUp()

func (*ViewModal) SetBackgroundColor

func (m *ViewModal) SetBackgroundColor(color tcell.Color) *tview.Box

SetBackgroundColor sets the color of the modal frame background.

func (*ViewModal) SetBorderColor

func (m *ViewModal) SetBorderColor(color tcell.Color) *tview.Box

SetBorderColor sets the color of the modal frame border.

func (*ViewModal) SetButtonActivatedStyle

func (m *ViewModal) SetButtonActivatedStyle(style tcell.Style) *ViewModal

SetButtonActivatedStyle sets the style of the buttons when they are focused.

func (*ViewModal) SetButtonBackgroundColor

func (m *ViewModal) SetButtonBackgroundColor(color tcell.Color) *ViewModal

SetButtonBackgroundColor sets the background color of the buttons.

func (*ViewModal) SetButtonStyle

func (m *ViewModal) SetButtonStyle(style tcell.Style) *ViewModal

SetButtonStyle sets the style of the buttons when they are not focused.

func (*ViewModal) SetButtonTextColor

func (m *ViewModal) SetButtonTextColor(color tcell.Color) *ViewModal

SetButtonTextColor sets the color of the button texts.

func (*ViewModal) SetDocumentColors

func (m *ViewModal) SetDocumentColors(keyColor, valueColor, bracketColor tcell.Color) *ViewModal

SetDocumentColors sets the colors for document elements.

func (*ViewModal) SetDoneFunc

func (m *ViewModal) SetDoneFunc(handler func(buttonIndex int, buttonLabel string)) *ViewModal

SetDoneFunc sets a handler which is called when one of the buttons was pressed. It receives the index of the button as well as its label text. The handler is also called when the user presses the Escape key. The index will then be negative and the label text an empty string.

func (*ViewModal) SetFocus

func (m *ViewModal) SetFocus(index int) *ViewModal

SetFocus shifts the focus to the button with the given index.

func (*ViewModal) SetFocusStyle

func (m *ViewModal) SetFocusStyle(style tcell.Style) *tview.Box

SetFocusStyle sets the style of the modal when it is focused.

func (*ViewModal) SetFullScreen added in v0.1.8

func (m *ViewModal) SetFullScreen(fullScreen bool) *ViewModal

SetFullScreen toggles between full-screen and modal view

func (*ViewModal) SetHighlightColor

func (m *ViewModal) SetHighlightColor(color tcell.Color) *ViewModal

SetHighlightColor sets the color of the highlighted text.

func (*ViewModal) SetScrollable

func (m *ViewModal) SetScrollable(scrollable bool) *ViewModal

func (*ViewModal) SetText

func (m *ViewModal) SetText(text Text) *ViewModal

TextAlignment sets the text alignment within the modal. This must be one of

func (*ViewModal) SetTextColor

func (m *ViewModal) SetTextColor(color tcell.Color) *tview.Box

SetTextColor sets the color of the message text.

func (*ViewModal) SetTitleColor

func (m *ViewModal) SetTitleColor(color tcell.Color) *tview.Box

SetTitleColor sets the color of the modal frame title.

func (*ViewModal) TextAlignment

func (m *ViewModal) TextAlignment(align int) *ViewModal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳