ui

package
v0.0.0-...-4dc96f4 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlignLeft = iota
	AlignCenter
	AlignRight
)

Text alignment within a box.

Variables

View Source
var (
	// InputFieldInteger accepts integers.
	InputFieldInteger func(text string, ch rune) bool

	// InputFieldFloat accepts floating-point numbers.
	InputFieldFloat func(text string, ch rune) bool

	// InputFieldMaxLength returns an input field accept handler which accepts
	// input strings up to a given length. Use it like this:
	//
	//   inputField.SetAcceptanceFunc(InputFieldMaxLength(10)) // Accept up to 10 characters.
	InputFieldMaxLength func(maxLength int) func(text string, ch rune) bool
)

Predefined InputField acceptance functions.

Functions

func Escape

func Escape(text string) string

Escape escapes the given text such that color and/or region tags are not recognized and substituted by the print functions of this package. For example, to include a tag-like string in a box title or in a TextView:

box.SetTitle(tview.Escape("[squarebrackets]"))
fmt.Fprint(textView, tview.Escape(`["quoted"]`))

func Print

func Print(screen tcell.Screen, text string, x, y, maxWidth, align int, color tcell.Color) (int, int)

Print prints text onto the screen into the given box at (x,y,maxWidth,1), not exceeding that box. "align" is one of AlignLeft, AlignCenter, or AlignRight. The screen's background color will not be changed.

You can change the colors and text styles mid-text by inserting a color tag. See the package description for details.

Returns the number of actual bytes of the text printed (including color tags) and the actual width used for the printed runes.

func PrintSimple

func PrintSimple(screen tcell.Screen, text string, x, y int)

PrintSimple prints white text to the screen at the given position.

func TaggedStringWidth

func TaggedStringWidth(text string) int

TaggedStringWidth returns the width of the given string needed to print it on screen. The text may contain color tags which are not counted.

func WordWrap

func WordWrap(text string, width int) (lines []string)

WordWrap splits a text such that each resulting line does not exceed the given screen width. Possible split points are after any punctuation or whitespace. Whitespace after split points will be dropped.

This function considers color tags to have no width.

Text is always split at newline characters ('\n').

Types

type App

type App struct {
	App    *tview.Application
	Layout *tview.Flex
	Pages  *tview.Pages
	// contains filtered or unexported fields
}

App ui struct

func NewApp

func NewApp() *App

NewApp return new App

func (*App) AreaList

func (a *App) AreaList() (string, tview.Primitive, bool, bool)

AreaList - arealist widget

func (*App) AreaListHelp

func (a *App) AreaListHelp() (string, tview.Primitive, bool, bool)

AreaListHelp Area List Help

func (*App) AreaListQuit

func (a *App) AreaListQuit() (string, tview.Primitive, bool, bool)

AreaListQuit exit app

func (*App) InsertMsg

func (a *App) InsertMsg(areaID int, msgType int) (string, tview.Primitive, bool, bool)

InsertMsg widget

func (*App) InsertMsgMenu

func (a *App) InsertMsgMenu() (string, tview.Primitive, bool, bool)

InsertMsgMenu modal menu

func (*App) Run

func (a *App) Run() error

Run run App

func (*App) ViewMsg

func (a *App) ViewMsg(areaID int, msgNum uint32) (string, tview.Primitive, bool, bool)

ViewMsg widget

func (*App) ViewMsgHelp

func (a *App) ViewMsgHelp() (string, tview.Primitive, bool, bool)

ViewMsgHelp View Msg Help

type EditHeader

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

EditHeader widget

func NewEditHeader

func NewEditHeader(msg *msgapi.Message) *EditHeader

NewEditHeader create new EditHeader

func (*EditHeader) Draw

func (e *EditHeader) Draw(screen tcell.Screen)

Draw header

func (*EditHeader) InputHandler

func (e *EditHeader) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler event handler

func (*EditHeader) SetDoneFunc

func (e *EditHeader) SetDoneFunc(handler func([5][]rune)) *EditHeader

SetDoneFunc callback

type IM

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

IM struct

type ModalAreaList

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

ModalAreaList is a centered message window used to inform the user or prompt them

func NewModalAreaList

func NewModalAreaList() *ModalAreaList

NewModalAreaList returns a new modal message window.

func (*ModalAreaList) Draw

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

Draw draws this primitive onto the screen.

func (*ModalAreaList) Focus

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

Focus is called when this primitive receives focus.

func (*ModalAreaList) HasFocus

func (m *ModalAreaList) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*ModalAreaList) InputHandler

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

InputHandler handle input

func (*ModalAreaList) SetDoneFunc

func (m *ModalAreaList) SetDoneFunc(handler func(buttonIndex int)) *ModalAreaList

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 emptry string.

func (*ModalAreaList) SetText

func (m *ModalAreaList) SetText(text string) *ModalAreaList

SetText sets the message text of the window. The text may contain line breaks. Note that words are wrapped, too, based on the final size of the window.

func (*ModalAreaList) SetTextColor

func (m *ModalAreaList) SetTextColor(color tcell.Color) *ModalAreaList

SetTextColor sets the color of the message text.

type ModalHelp

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

ModalHelp widget

func NewModalHelp

func NewModalHelp() *ModalHelp

NewModalHelp return new ModalHelp

func (*ModalHelp) Draw

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

Draw draw

func (*ModalHelp) InputHandler

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

InputHandler Input Handler

func (*ModalHelp) SetDoneFunc

func (m *ModalHelp) SetDoneFunc(handler func()) *ModalHelp

SetDoneFunc Set Done Function

func (*ModalHelp) SetText

func (m *ModalHelp) SetText(txt string) *ModalHelp

SetText Set Text

type ModalMenu

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

ModalMenu is a centered message window used to inform the user or prompt them

func NewModalMenu

func NewModalMenu() *ModalMenu

NewModalMenu returns a new modal message window.

func (*ModalMenu) AddButtons

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

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 (*ModalMenu) Draw

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

Draw draws this primitive onto the screen.

func (*ModalMenu) Focus

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

Focus is called when this primitive receives focus.

func (*ModalMenu) HasFocus

func (m *ModalMenu) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*ModalMenu) InputHandler

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

InputHandler handle input

func (*ModalMenu) SetDoneFunc

func (m *ModalMenu) SetDoneFunc(handler func(buttonIndex int)) *ModalMenu

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 emptry string.

func (*ModalMenu) SetText

func (m *ModalMenu) SetText(text string) *ModalMenu

SetText sets the message text of the window. The text may contain line breaks. Note that words are wrapped, too, based on the final size of the window.

func (*ModalMenu) SetTextColor

func (m *ModalMenu) SetTextColor(color tcell.Color) *ModalMenu

SetTextColor sets the color of the message text.

func (*ModalMenu) SetY

func (m *ModalMenu) SetY(y int) *ModalMenu

SetY set Y

type ModalMessageList

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

ModalMessageList 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 AddButtons()) or it will never disappear.

See https://github.com/rivo/tview/wiki/Modal for an example.

func NewModalMessageList

func NewModalMessageList(areaID int) *ModalMessageList

NewModalMessageList returns a new modal message window.

func (*ModalMessageList) Draw

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

Draw draws this primitive onto the screen.

func (*ModalMessageList) Focus

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

Focus is called when this primitive receives focus.

func (*ModalMessageList) HasFocus

func (m *ModalMessageList) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*ModalMessageList) InputHandler

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

InputHandler handle input

func (*ModalMessageList) SetDoneFunc

func (m *ModalMessageList) SetDoneFunc(handler func(msgNum uint32)) *ModalMessageList

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 emptry string.

func (*ModalMessageList) SetTextColor

func (m *ModalMessageList) SetTextColor(color tcell.Color) *ModalMessageList

SetTextColor sets the color of the message text.

type SearchString

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

SearchString struct

func NewSearchString

func NewSearchString() *SearchString

NewSearchString create SearchString

func (*SearchString) AddChar

func (e *SearchString) AddChar(ch rune)

AddChar to searchString

func (*SearchString) Clear

func (e *SearchString) Clear()

Clear searchString

func (*SearchString) Draw

func (e *SearchString) Draw(screen tcell.Screen)

Draw searchString

func (*SearchString) GetText

func (e *SearchString) GetText() string

GetText return searchString text

type StatusBar

type StatusBar struct {
	SB *tview.Flex
	// contains filtered or unexported fields
}

StatusBar struct

func NewStatusBar

func NewStatusBar(app *App) *StatusBar

NewStatusBar func

func (StatusBar) Run

func (sb StatusBar) Run()

Run update timers

func (StatusBar) SetStatus

func (sb StatusBar) SetStatus(s string)

SetStatus set status

type ViewHeader

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

ViewHeader widget

func NewViewHeader

func NewViewHeader(msg *msgapi.Message) *ViewHeader

NewViewHeader create new ViewHeader

func (*ViewHeader) Draw

func (e *ViewHeader) Draw(screen tcell.Screen)

Draw header

func (*ViewHeader) InputHandler

func (e *ViewHeader) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler event handler

func (*ViewHeader) SetDoneFunc

func (e *ViewHeader) SetDoneFunc(handler func(string)) *ViewHeader

SetDoneFunc callback

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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