Documentation ¶
Index ¶
- Constants
- Variables
- func Escape(text string) string
- func Print(screen tcell.Screen, text string, x, y, maxWidth, align int, color tcell.Color) (int, int)
- func PrintSimple(screen tcell.Screen, text string, x, y int)
- func TaggedStringWidth(text string) int
- func WordWrap(text string, width int) (lines []string)
- type App
- func (a *App) AreaList() (string, tview.Primitive, bool, bool)
- func (a *App) AreaListHelp() (string, tview.Primitive, bool, bool)
- func (a *App) AreaListQuit() (string, tview.Primitive, bool, bool)
- func (a *App) InsertMsg(area *msgapi.AreaPrimitive, msgType int) (string, tview.Primitive, bool, bool)
- func (a *App) InsertMsgMenu() (string, tview.Primitive, bool, bool)
- func (a *App) RefreshAreaList()
- func (a *App) Run() error
- func (a *App) SwitchToAreaListPage()
- func (a *App) ViewMsg(area *msgapi.AreaPrimitive, msgNum uint32) (string, tview.Primitive, bool, bool)
- func (a *App) ViewMsgHelp() (string, tview.Primitive, bool, bool)
- type EditHeader
- type IM
- type ModalAreaList
- func (m *ModalAreaList) Draw(screen tcell.Screen)
- func (m *ModalAreaList) Focus(delegate func(p tview.Primitive))
- func (m *ModalAreaList) HasFocus() bool
- func (m *ModalAreaList) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (m *ModalAreaList) SetDoneFunc(handler func(buttonIndex int)) *ModalAreaList
- func (m *ModalAreaList) SetText(text string) *ModalAreaList
- func (m *ModalAreaList) SetTextColor(color tcell.Color) *ModalAreaList
- type ModalHelp
- type ModalMenu
- func (m *ModalMenu) AddButtons(labels []string) *ModalMenu
- func (m *ModalMenu) Draw(screen tcell.Screen)
- func (m *ModalMenu) Focus(delegate func(p tview.Primitive))
- func (m *ModalMenu) HasFocus() bool
- func (m *ModalMenu) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (m *ModalMenu) SetDoneFunc(handler func(buttonIndex int)) *ModalMenu
- func (m *ModalMenu) SetText(text string) *ModalMenu
- func (m *ModalMenu) SetTextColor(color tcell.Color) *ModalMenu
- func (m *ModalMenu) SetY(y int) *ModalMenu
- type ModalMessageList
- func (m *ModalMessageList) Draw(screen tcell.Screen)
- func (m *ModalMessageList) Focus(delegate func(p tview.Primitive))
- func (m *ModalMessageList) HasFocus() bool
- func (m *ModalMessageList) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))
- func (m *ModalMessageList) SetDoneFunc(handler func(msgNum uint32)) *ModalMessageList
- func (m *ModalMessageList) SetTextColor(color tcell.Color) *ModalMessageList
- type SearchString
- type StatusBar
- type ViewHeader
Constants ¶
const ( AlignLeft = iota AlignCenter AlignRight )
Text alignment within a box.
Variables ¶
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 ¶
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 ¶
PrintSimple prints white text to the screen at the given position.
func TaggedStringWidth ¶
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 ¶
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 CurrentArea *msgapi.AreaPrimitive // contains filtered or unexported fields }
App ui struct
func (*App) AreaListHelp ¶
AreaListHelp Area List Help
func (*App) AreaListQuit ¶
AreaListQuit exit app
func (*App) InsertMsg ¶
func (a *App) InsertMsg(area *msgapi.AreaPrimitive, msgType int) (string, tview.Primitive, bool, bool)
InsertMsg widget
func (*App) InsertMsgMenu ¶
InsertMsgMenu modal menu
func (*App) RefreshAreaList ¶
func (a *App) RefreshAreaList()
func (*App) SwitchToAreaListPage ¶
func (a *App) SwitchToAreaListPage()
type EditHeader ¶
EditHeader widget
func NewEditHeader ¶
func NewEditHeader(msg *msgapi.Message) *EditHeader
NewEditHeader create new EditHeader
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 ModalAreaList ¶
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 ¶
ModalHelp widget
func (*ModalHelp) InputHandler ¶
InputHandler Input Handler
func (*ModalHelp) SetDoneFunc ¶
SetDoneFunc Set Done Function
type ModalMenu ¶
ModalMenu is a centered message window used to inform the user or prompt them
func (*ModalMenu) AddButtons ¶
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) InputHandler ¶
InputHandler handle input
func (*ModalMenu) SetDoneFunc ¶
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 ¶
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 ¶
SetTextColor sets the color of the message text.
type ModalMessageList ¶
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(area *msgapi.AreaPrimitive) *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 ¶
SearchString struct
func (*SearchString) GetText ¶
func (e *SearchString) GetText() string
GetText return searchString text
type ViewHeader ¶
ViewHeader widget
func NewViewHeader ¶
func NewViewHeader(msg *msgapi.Message) *ViewHeader
NewViewHeader create new ViewHeader
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