ui

package
v0.0.0-...-c186bf4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetApplication

func GetApplication() *tview.Application

GetApplication returns the shared instance of tview.Application.

Types

type AlertModal

type AlertModal struct {
	*BaseInputModal
	// contains filtered or unexported fields
}

AlertModal is a modal that shows a message with a single button to take an action.

func NewAlertModal

func NewAlertModal(title string, text string, buttonText string, accept ModalNoArgAcceptHandler) *AlertModal

NewAlertModal returns a new modal with text and button handler.

type AuthModal

type AuthModal struct {
	*BaseInputModal
	// contains filtered or unexported fields
}

AuthModal presents a modal for configuring authentication schemes.

func NewAuthModal

func NewAuthModal(accept AuthModalAcceptHandler, reject ModalRejectHandler) *AuthModal

NewAuthModal returns a new AuthModal instance.

func (*AuthModal) Widget

func (m *AuthModal) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type AuthModalAcceptHandler

type AuthModalAcceptHandler func(auth auth.RequestAuthentication)

type AuthView

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

AuthView shows various authentication schemes that can be configured for requests.

func NewAuthView

func NewAuthView(handler AuthViewChangeHandler) *AuthView

NewAuthView returns a new AuthModal instance configured with a change handler function.

func (*AuthView) Data

Data returns the parameters for the current authentication scheme.

func (*AuthView) FocusPrimitives

func (a *AuthView) FocusPrimitives() []tview.Primitive

FocusPrimitives returns a slice of primitives that should receive focus.

func (*AuthView) Set

func (a *AuthView) Set(item *state.CollectionItem)

Set applies the values from the CollectionItem to the view.

func (*AuthView) Widget

func (a *AuthView) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type AuthViewChangeHandler

type AuthViewChangeHandler func(data auth.RequestAuthentication)

type BaseInputModal

type BaseInputModal struct {
	*Modal
	// contains filtered or unexported fields
}

BaseInputModal is a scaffold that provides the basis for building more complex input modals. You should not use this component directly. Instead, use it as a base for embedding in more functional modals.

func NewBaseInputModal

func NewBaseInputModal() *BaseInputModal

NewBaseInputModal returns a new BaseInputModal instance with default dimensions.

func (*BaseInputModal) ButtonHeight

func (m *BaseInputModal) ButtonHeight() int

ButtonHeight returns the height (in cells) of the buttons in the modal.

func (*BaseInputModal) ContentRect

func (m *BaseInputModal) ContentRect() (int, int)

ContentRect returns the width and height of the rectangle containing the modal's content.

func (*BaseInputModal) SetText

func (m *BaseInputModal) SetText(text string)

SetText sets the informational text to show in the modal.

func (*BaseInputModal) Widget

func (m *BaseInputModal) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type BaseInputModalButton

type BaseInputModalButton byte
const (
	BaseInputModalButtonAccept BaseInputModalButton = 1 << iota
	BaseInputModalButtonReject
	BaseInputModalButtonAll = BaseInputModalButtonAccept | BaseInputModalButtonReject
)

type BasicAuthChangeHandler

type BasicAuthChangeHandler func(data *auth.BasicAuthentication)

type BasicAuthView

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

BasicAuthView contains form fields that represent HTTP basic authentication parameters.

func NewBasicAuthView

func NewBasicAuthView(handler BasicAuthChangeHandler, manager *util.FocusManager) *BasicAuthView

NewBasicAuthView returns a new BasicAuthView instance configured with a change handler function.

func (*BasicAuthView) Data

Data returns the authentication data provided in the view.

func (*BasicAuthView) FocusPrimitives

func (a *BasicAuthView) FocusPrimitives() []tview.Primitive

FocusPrimitives returns a slice of primitives that should receive focus.

func (*BasicAuthView) Set

func (a *BasicAuthView) Set(data *auth.BasicAuthentication)

Set applies the values for the basic authentication scheme.

func (*BasicAuthView) SetFocus

func (a *BasicAuthView) SetFocus()

SetFocus sets the focus on this component.

func (*BasicAuthView) Widget

func (a *BasicAuthView) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type Collection

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

Collection is a view that shows saved API requests.

func NewCollection

func NewCollection(state *state.Manager) *Collection

NewCollection returns a new instance of Collection.

func (*Collection) Reload

func (p *Collection) Reload()

Reload clears all nodes from the collection and rebuilds them from current app state. The currently selected item will be selected once again after reloading data if it still exists. If it doesn't exist anymore, the root item will be selected.

func (*Collection) SetFocus

func (p *Collection) SetFocus()

SetFocus sets the focus on this component.

func (*Collection) SetItemActivatedHandler

func (p *Collection) SetItemActivatedHandler(handler CollectionItemActionHandler)

SetItemActivatedHandler sets the callback to invoke when an action is performed on an item.

func (*Collection) Widget

func (p *Collection) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type CollectionItemAction

type CollectionItemAction int
const (
	CollectionItemOpen CollectionItemAction = iota
	CollectionItemAdd
	CollectionItemRename
	CollectionItemDelete
	CollectionItemClone
)

type CollectionItemActionHandler

type CollectionItemActionHandler func(action CollectionItemAction, item *state.CollectionItem)

type Component

type Component interface {
	// SetFocus sets the focus on this component.
	SetFocus()

	// Widget returns the tview.Primitive at the root of the component.
	Widget() tview.Primitive
}

Component is a higher level view that is composed of primitives.

type Content

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

Content provides a view that shows a request, response and URL input box.

func NewContent

func NewContent(state *state.Manager) *Content

NewContent returns a new Content instance.

func (*Content) HandleEvent

func (c *Content) HandleEvent(code events.Code, payload events.Payload)

func (*Content) HasFocus

func (c *Content) HasFocus(widget ContentWidget) bool

HasFocus returns if a child primitives has focus.

func (*Content) Reload

func (c *Content) Reload()

Reload refreshes the state of the component with current app state.

func (*Content) SetFocus

func (c *Content) SetFocus(widget ContentWidget)

SetFocus sets one of the content primitives to have focus.

func (*Content) Widget

func (c *Content) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type ContentWidget

type ContentWidget int16
const (
	ContentRequestBody ContentWidget = iota
	ContentResponseBody
	ContentURLBox
)

type KeyValueModal

type KeyValueModal struct {
	*BaseInputModal
	// contains filtered or unexported fields
}

KeyValueModal is a modal that allows inputting a key-value quantity.

func NewKeyValueModal

func NewKeyValueModal(title, keyLabel, valueLabel string, accept KeyValueModalAcceptHandler, reject ModalRejectHandler) *KeyValueModal

NewKeyValueModal returns a new instance of KeyValueModal.

func (*KeyValueModal) SetFocus

func (m *KeyValueModal) SetFocus()

SetFocus sets the focus on this component.

func (*KeyValueModal) SetKey

func (m *KeyValueModal) SetKey(text string)

SetKey sets the text for the key.

func (*KeyValueModal) SetValue

func (m *KeyValueModal) SetValue(text string)

SetValue sets the text for the value.

type KeyValueModalAcceptHandler

type KeyValueModalAcceptHandler func(key string, value string)
type Modal struct {
	// contains filtered or unexported fields
}

Modal is a container that presents components in a modal window.

func NewModal

func NewModal(content tview.Primitive, width, height int) *Modal

NewModal returns a new Modal with a tview.Primitive as content. The modal will be sized according to the given width and height units.

type ModalNoArgAcceptHandler

type ModalNoArgAcceptHandler func()

type ModalRejectHandler

type ModalRejectHandler func()

ModalRejectHandler is a standard callback for when a modal is cancelled.

type ModalTextAcceptHandler

type ModalTextAcceptHandler func(text string)

ModalTextAcceptHandler is a standard callback for a modal that accepts a line of text as input.

type OAuth2ChangeHandler

type OAuth2ChangeHandler func(data *auth.OAuth2RequestAuthentication)

type OAuth2View

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

OAuth2View contains form fields that represent an OAuth2 client credentials configuration.

func NewOAuth2View

func NewOAuth2View(handler OAuth2ChangeHandler, manager *util.FocusManager) *OAuth2View

NewOAuth2View returns a new OAuth2View instance configured with a change handler function.

func (*OAuth2View) Data

Data returns the authentication data provided in the view.

func (*OAuth2View) FocusPrimitives

func (a *OAuth2View) FocusPrimitives() []tview.Primitive

FocusPrimitives returns a slice of primitives that should receive focus.

func (*OAuth2View) Set

Set applies the values for the OAuth2 authentication scheme.

func (*OAuth2View) SetFocus

func (a *OAuth2View) SetFocus()

SetFocus sets the focus on this component.

func (*OAuth2View) Widget

func (a *OAuth2View) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type PromptModal

type PromptModal struct {
	*BaseInputModal
	// contains filtered or unexported fields
}

PromptModal is a modal that prompts the user to confirm or reject an action.

func NewPromptModal

func NewPromptModal(title string, text string, accept ModalNoArgAcceptHandler, reject ModalRejectHandler) *PromptModal

NewPromptModal returns a new modal with text and button handlers.

type RequestView

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

RequestView is a view that allows viewing and editing request/response components.

func NewRequestView

func NewRequestView(state *state.Manager) *RequestView

NewRequestView returns a new instance of RequestView.

func (*RequestView) Reload

func (p *RequestView) Reload()

Reload refreshes the state of the component with current app state.

func (*RequestView) SetFocus

func (p *RequestView) SetFocus()

SetFocus sets the focus on this component.

func (*RequestView) Widget

func (p *RequestView) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type ResponseView

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

ResponseView is a component that allows viewing HTTP response attributes.

func NewResponseView

func NewResponseView(state *state.Manager) *ResponseView

NewResponseView returns a new instance of ResponseView.

func (*ResponseView) Reload

func (p *ResponseView) Reload()

Reload refreshes the state of the component with current app state.

func (*ResponseView) SetFocus

func (p *ResponseView) SetFocus()

SetFocus sets the focus on this component.

func (*ResponseView) Widget

func (p *ResponseView) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type Root

type Root struct {
	StatusBar *StatusBar
	// contains filtered or unexported fields
}

Root is a top-level container for all application UI components.

func NewRoot

func NewRoot(app *tview.Application, stateManager *state.Manager, buildMeta *util.BuildMeta) *Root

NewRoot returns a new Root instance.

func (*Root) HandleEvent

func (r *Root) HandleEvent(code events.Code, payload events.Payload)

func (*Root) Widget

func (r *Root) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type StatusBar

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

StatusBar presents informational components.

func NewStatusBar

func NewStatusBar() *StatusBar

NewStatusBar returns an instance of StatusBar.

func (*StatusBar) HandleEvent

func (s *StatusBar) HandleEvent(code events.Code, payload events.Payload)

func (*StatusBar) Widget

func (s *StatusBar) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

type TextInputModal

type TextInputModal struct {
	*BaseInputModal
	// contains filtered or unexported fields
}

TextInputModal is a modal window that prompts a user to input text.

func NewTextInputModal

func NewTextInputModal(title string, text string, label string, accept ModalTextAcceptHandler, reject ModalRejectHandler) *TextInputModal

NewTextInputModal returns a new modal with a title, information text, label and button handlers.

type URLBox

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

URLBox is a view that contains an HTTP method, URL and other input components.

func NewURLBox

func NewURLBox(state *state.Manager) *URLBox

NewURLBox returns a new instance of URLBox.

func (*URLBox) Reload

func (u *URLBox) Reload()

Reload refreshes the state of the URL box component with current app state.

func (*URLBox) SetFocus

func (u *URLBox) SetFocus()

SetFocus sets the focus on this component.

func (*URLBox) Widget

func (u *URLBox) Widget() tview.Primitive

Widget returns a primitive widget containing this component.

Jump to

Keyboard shortcuts

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