ui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ui contains the primary application logic and user interface for ci.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateModal

func CreateModal(widget tview.Primitive, width, height int) tview.Primitive

CreateModal creates a modal dialog that contains a tview.Primitive.

func CreateTitleBox

func CreateTitleBox() *tview.TextView

CreateTitleBox creates and configures the title box of the application that displays the current navigated directory.

func GetHelpText

func GetHelpText(options *options.AppOptions) string

GetHelpText returns the text of the in-app help info.

func GetScrollBarDrawFunc

func GetScrollBarDrawFunc(
	s Scrollable,
	getScrollArea func() (width, height int),
	getScrollPosition func() (vScroll, hScroll int),
) func(screen tcell.Screen, x, y, width, height int) (int, int, int, int)

GetScrollBarDrawFunc returns a handler function responsible for drawing scroll bars on ui components. This handler satisfies the signature for the SetDrawFunc on the underlying tview.Box which most other components are composed of.

func Run

func Run(app *App, appOptions *options.AppOptions) error

Run initializes the App's components and runs its main process loop.

Types

type App

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

App is an abstraction of the tview.Application with additional functionality.

func NewApp

func NewApp(screen tcell.Screen, stream io.Writer, errStream io.Writer) *App

NewApp creates a new instance of an App.

func (*App) HandleError

func (a *App) HandleError(err error, logError bool)

HandleError logs errors and gracefully exits the program with a code of 1.

func (*App) PrintAndExit

func (a *App) PrintAndExit(data string)

PrintAndExit prints data to the App's configured output stream and exits the program.

func (*App) Start

func (a *App) Start()

Start starts the application by switching to an alternate screen buffer.

func (*App) Stop

func (a *App) Stop()

Stop stops the application and switches to the screen buffer of the host process.

type DetailsView

type DetailsView struct {
	*tview.TextView
	LongestLine int
	LineCount   int
	HasWrap     bool
	HasWordWrap bool
}

DetailsView is a wrapper for tview.TextView with better support for scrolling content. Overridden functions of this struct must be called before any inherited functions from tview.TextView.

func CreateDetailsView

func CreateDetailsView() *DetailsView

CreateDetailsView creates a new instance of DetailsView and initializes it with default settings.

func (*DetailsView) Clear

func (d *DetailsView) Clear() *DetailsView

Clear empties the DetailsView content and resets its title to the default value.

func (*DetailsView) GetText

func (d *DetailsView) GetText(stripAllTags bool) string

GetText returns the current text of this DetailsView. If stripAllTags is set to true, any region/color tags are stripped from the text.

func (*DetailsView) SetRect

func (d *DetailsView) SetRect(x, y, width, height int)

SetRect sets the bounds and screen location of the DetailsView.

func (*DetailsView) SetText

func (d *DetailsView) SetText(text string) *DetailsView

SetText sets the content of the DetailsView and recalculates the width and height of that content.

func (*DetailsView) SetWordWrap

func (d *DetailsView) SetWordWrap(wrapOnWords bool) *DetailsView

SetWordWrap sets the word wrap setting in the underlying tview.TextView and recalculates the content width and height.

func (*DetailsView) SetWrap

func (d *DetailsView) SetWrap(wrap bool) *DetailsView

SetWrap sets the wrap setting in the underlying tview.TextView and recalculates the content width and height.

type DirectoryList

type DirectoryList struct {
	*tview.List
	// contains filtered or unexported fields
}

DirectoryList is responsible for providing the user interface that enables users to quickly navigate directories and select other options.

func CreateDirectoryList

func CreateDirectoryList(
	app *App,
	titleBox *tview.TextView,
	filter *FilterForm,
	pages *tview.Pages,
	details *DetailsView,
	directoryController dirctrl.DirectoryController,
	appOptions *options.AppOptions,
) *DirectoryList

CreateDirectoryList creates a new instance of DirectoryList.

func (*DirectoryList) Init

func (d *DirectoryList) Init() *DirectoryList

Init prepares the DirectoryList for usage by initializing data and event handlers.

type FilterForm

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

FilterForm provides the user interface that enables the user to filter the list of directories in the DirectoryList.

func CreateFilterForm

func CreateFilterForm() *FilterForm

CreateFilterForm creates a new instance of FilterForm and initializes its form fields.

func (*FilterForm) Clear

func (f *FilterForm) Clear()

Clear resets the filterText field to empty.

func (*FilterForm) GetText

func (f *FilterForm) GetText() string

GetText returns the text that is in the FilterForm's filterText field.

func (*FilterForm) SetDoneHandler

func (f *FilterForm) SetDoneHandler(handler func(key tcell.Key)) *FilterForm

SetDoneHandler sets a key press event handler for external components to implement when input is completed on the FilterForm.

func (*FilterForm) SetText

func (f *FilterForm) SetText(text string) *FilterForm

SetText sets the text in the FilterForm's filterText field.

type Scrollable

type Scrollable interface {
	tview.Primitive
	GetInnerRect() (int, int, int, int)
}

Scrollable represents a tview Primitive that has the GetInnerRect function. The GetInnerRect function is crucial for calculations that draw scroll bars on Primitive components.

Jump to

Keyboard shortcuts

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