app

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMenu

func AddMenu(menuType keybinding.KeyContext)

AddMenu adds a menu to the menubar.

func ConditionalDraw added in v0.4.3

func ConditionalDraw(mustDraw func() bool)

ConditionalDraw redraws the screen according to the conditional mustDraw parameter.

func DrawMenu

func DrawMenu(x int, region string)

DrawMenu renders the menu.

func DrawPrimitives added in v0.3.8

func DrawPrimitives(primitives ...tview.Primitive)

DrawPrimitives draws the primitives onto the screen.

func FocusMenu

func FocusMenu()

FocusMenu activates the menu bar.

func FocusedTable

func FocusedTable() *tview.Table

FocusedTable returns the currently focused table.

func FocusedTableReference

func FocusedTableReference() (inv.SearchData, error)

FocusedTableReference returns the currently selected entry's information from the focused table.

func GetCurrentTab

func GetCurrentTab() string

GetCurrentTab returns the currently selected tab.

func HorizontalLine

func HorizontalLine(property theme.ThemeProperty) *tview.Box

HorizontalLine returns a box with a thick horizontal line.

func InitMenu

func InitMenu(data *MenuData)

InitMenu initializes the menu.

func MenuExit()

MenuExit closes the menu.

func MenuHighlightHandler(added, removed, remaining []string)

MenuHighlightHandler draws the menu based on which menu name is highlighted.

func MenuKeybindings(event *tcell.EventKey) *tcell.EventKey

MenuKeybindings describes the menu keybindings.

func ModifyReference

func ModifyReference(title string, add bool, info ...inv.SearchData) error

ModifyReference modifies the currently selected entry within the focused table.

func ResizeModal

func ResizeModal()

ResizeModal resizes the modal according to the current screen dimensions.

func SelectTab

func SelectTab(tab string)

SelectTab selects a tab.

func SetContextMenu

func SetContextMenu(menuType keybinding.KeyContext, item tview.Primitive)

SetContextMenu sets the context menu.

func SetGlobalKeybindings

func SetGlobalKeybindings(kb func(event *tcell.EventKey) *tcell.EventKey)

SetGlobalKeybindings sets the keybindings for the app.

func SetPrimaryFocus

func SetPrimaryFocus()

SetPrimaryFocus sets the focus to the appropriate primitive.

func SetResizeHandler

func SetResizeHandler(resize func(screen tcell.Screen))

SetResizeHandler sets the resize handler for the app.

func SetTab

func SetTab(tabInfo Tab, context theme.ThemeContext)

SetTab sets the tab.

func SetTableSelector added in v0.4.2

func SetTableSelector(t *tview.Table, prevrows int)

SetTableSelector sets the table's selector position.

func Setup

func Setup() error

Setup sets up the application

func ShowError

func ShowError(err error)

ShowError shows an error message.

func ShowInfo

func ShowInfo(text string, persist bool, print ...bool)

ShowInfo shows an information message.

func Stop

func Stop(skip ...struct{})

Stop stops the application.

func SwitchTab

func SwitchTab(reverse bool, tabs ...Tab) string

SwitchTab handles the tab selection. If reverse is set, the previous tab is selected and vice-versa.

func VerticalLine

func VerticalLine(property theme.ThemeProperty) *tview.Box

VerticalLine returns a box with a thick vertical line.

Types

type Application

type Application struct {
	MenuLayout *tview.Flex
	Menu, Tabs *tview.TextView

	Area           *tview.Pages
	Pages          *tview.Pages
	Layout, Region *tview.Flex

	Status      Status
	FileBrowser FileBrowser

	Suspend bool
	Closed  context.Context
	Exit    context.CancelFunc

	Screen tcell.Screen

	*tview.Application
	// contains filtered or unexported fields
}

Application describes the layout of the app.

var UI Application

UI stores the application data.

type FileBrowser

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

FileBrowser describes the layout of a file browser.

func (*FileBrowser) Hide

func (f *FileBrowser) Hide()

Hide hides the file browser.

func (*FileBrowser) IsOpen added in v0.4.3

func (f *FileBrowser) IsOpen() bool

IsOpen returns whether the filebrowser is open.

func (*FileBrowser) Keybindings

func (f *FileBrowser) Keybindings(event *tcell.EventKey) *tcell.EventKey

Keybindings define the keybindings for the file browser.

func (*FileBrowser) Query

func (f *FileBrowser) Query(
	prompt string,
	validate func(text string, reply chan string),
	max ...int,
) string

Query displays a confirmation message within the file browser.

func (*FileBrowser) SaveFile added in v0.3.6

func (f *FileBrowser) SaveFile(
	file string,
	entriesFunc func(flags int, appendToFile bool) (string, int, error),
)

SaveFile saves the generated entries into a file.

func (*FileBrowser) Show

func (f *FileBrowser) Show(prompt string, dofunc func(text string), options ...FileBrowserOptions)

Show displays the file browser.

func (*FileBrowser) ThemeProperty added in v0.3.8

func (f *FileBrowser) ThemeProperty() theme.ThemeProperty

ThemeProperty returns the filebrowser's theme property.

type FileBrowserOptions added in v0.3.3

type FileBrowserOptions struct {
	ShowDirOnly, ResetPath bool
	SetDir                 string
}

FileBrowserOptions describes the file browser options.

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

MenuArea stores the menu modal and the current context menu.

type MenuData struct {
	Visible map[keybinding.Key]func(menuType string) bool
	Items   map[keybinding.KeyContext][]keybinding.Key
}

MenuData stores the menu items and handlers.

type Modal struct {
	Name          string
	Open          bool
	Height, Width int

	Flex  *tview.Flex
	Table *tview.Table
	Title *tview.TextView
	// contains filtered or unexported fields
}

Modal stores a layout to display a floating modal.

func NewMenuModal

func NewMenuModal(name string, regionX, regionY int, property theme.ThemeProperty) *Modal

NewMenuModal returns a menu modal.

func NewModal

func NewModal(name, title string, item tview.Primitive, height, width int, property theme.ThemeProperty) *Modal

NewModal returns a modal. If a primitive is not provided, a table is attach to it.

func (*Modal) Exit

func (m *Modal) Exit(focusInput bool)

Exit exits the modal.

func (*Modal) Show

func (m *Modal) Show(attachToStatus bool)

Show shows the modal. If attachToStatus is true, the modal will attach to the top part of the status bar rather than float in the middle.

type Status

type Status struct {
	Message *tview.TextView

	Cancel context.CancelFunc

	*tview.Pages
	*tview.InputField
	// contains filtered or unexported fields
}

Status describes the layout for a status bar

func (*Status) ErrorMessage

func (s *Status) ErrorMessage(err error)

ErrorMessage sends an error message to the status bar.

func (*Status) InfoMessage

func (s *Status) InfoMessage(text string, persist bool)

InfoMessage sends an info message to the status bar.

func (*Status) SetFocusFunc

func (s *Status) SetFocusFunc(focus ...func())

SetFocusFunc sets the function to be executed when the input is focused.

func (*Status) SetInput

func (s *Status) SetInput(label string,
	max int,
	clearInput bool,
	dofunc func(text string),
	ifunc func(event *tcell.EventKey) *tcell.EventKey,
	chgfunc ...func(text string),
)

SetInput sets up the prompt and appropriate handlers for the input area within the status bar.

func (*Status) Setup

func (s *Status) Setup()

Setup sets up the status bar.

func (*Status) Tag added in v0.3.7

func (s *Status) Tag(tag string)

Tag sets a tag to the status bar.

func (*Status) ThemeProperty added in v0.3.8

func (s *Status) ThemeProperty() theme.ThemeProperty

type Tab

type Tab struct {
	Title, Selected string
	Info            []TabInfo

	Context theme.ThemeContext

	TabView *tview.TextView
}

Tab describes the layout for a tab.

type TabInfo

type TabInfo struct {
	ID, Title string
}

TabInfo stores the tab information.

Jump to

Keyboard shortcuts

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