components

package
v0.0.0-...-04fbf5c Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package components defines various UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Package components defines various UI components for the LazyPost application.

Package components provides UI components for the LazyPost application.

Index

Constants

This section is empty.

Variables

View Source
var DefaultAuthSelectorKeyMap = AuthSelectorKeyMap{
	Open:   key.NewBinding(key.WithKeys("enter", " ")),
	Close:  key.NewBinding(key.WithKeys("esc")),
	Next:   key.NewBinding(key.WithKeys("down", "j")),
	Prev:   key.NewBinding(key.WithKeys("up", "k")),
	Select: key.NewBinding(key.WithKeys("enter")),
}

DefaultAuthSelectorKeyMap provides default keybindings for the AuthSelector. These are standard keys like Enter, Space, Escape, and arrow keys.

Functions

This section is empty.

Types

type APIKeyAuthDetailsComponent

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

APIKeyAuthDetailsComponent is a placeholder for API Key authentication details UI. It currently displays a simple message and will be implemented with actual input fields for API key, value, and type (header/query) in the future.

func NewAPIKeyAuthDetailsComponent

func NewAPIKeyAuthDetailsComponent() APIKeyAuthDetailsComponent

NewAPIKeyAuthDetailsComponent creates a new instance of APIKeyAuthDetailsComponent.

func (*APIKeyAuthDetailsComponent) SetActive

func (c *APIKeyAuthDetailsComponent) SetActive(active bool)

SetActive sets the active state of the component.

func (*APIKeyAuthDetailsComponent) SetSize

func (c *APIKeyAuthDetailsComponent) SetSize(width, height int)

SetSize sets the dimensions for the component's rendering area.

func (APIKeyAuthDetailsComponent) Update

func (c APIKeyAuthDetailsComponent) Update(msg tea.Msg) tea.Cmd

Update handles messages and updates the component's state. Currently, it's a no-op as the component is a placeholder.

func (APIKeyAuthDetailsComponent) View

View renders the APIKeyAuthDetailsComponent. It displays a placeholder message within a styled border. If width or height is zero or negative, it returns an empty string.

type AuthContainer

type AuthContainer struct {
	Width  int  // Width is the rendering width of the container.
	Height int  // Height is the rendering height of the container.
	Active bool // Active indicates if the container (and potentially its children) is focused.
	// contains filtered or unexported fields
}

AuthContainer encapsulates the AuthSelector and the various authentication detail components. It manages which auth detail view is shown based on the AuthSelector's choice and delegates updates and focus to the appropriate child component.

func NewAuthContainer

func NewAuthContainer() AuthContainer

NewAuthContainer creates and initializes a new AuthContainer. It creates an AuthSelector and instances of all auth detail components.

func (AuthContainer) GetAuthHeaders

func (ac AuthContainer) GetAuthHeaders() map[string]string

GetAuthHeaders constructs and returns a map of HTTP headers based on the selected authentication type and the values entered in the corresponding auth detail component. For "None", it returns an empty map. For other types, it retrieves credentials/tokens and formats them into the appropriate "Authorization" header (or other headers for API Key, if applicable). Placeholder comments indicate where logic for JWT, API Key, and OAuth2 needs to be fully implemented.

func (AuthContainer) IsFocused

func (ac AuthContainer) IsFocused() bool

IsFocused checks if the AuthContainer itself is considered to be in a focused state. Currently, this is equivalent to its Active state. (Placeholder for potentially more complex focus logic).

func (*AuthContainer) SetActive

func (ac *AuthContainer) SetActive(active bool)

SetActive sets the active state of the AuthContainer. It also propagates the active state to the AuthSelector and the currently selected auth detail component.

func (*AuthContainer) SetHeight

func (ac *AuthContainer) SetHeight(height int)

SetHeight sets the rendering height for the AuthContainer and its children. The height is distributed to the AuthSelector and the active auth detail component.

func (*AuthContainer) SetWidth

func (ac *AuthContainer) SetWidth(width int)

SetWidth sets the rendering width for the AuthContainer and its children. The width is distributed to the AuthSelector and the active auth detail component.

func (*AuthContainer) Update

func (ac *AuthContainer) Update(msg tea.Msg) tea.Cmd

Update handles messages for the AuthContainer. It delegates messages to the AuthSelector and the currently active auth detail component. It also re-evaluates which detail component should be active if the AuthSelector's selection changes. It only processes messages if the container itself is active.

func (AuthContainer) View

func (ac AuthContainer) View() string

View renders the AuthContainer. It displays the AuthSelector and the view of the currently selected auth detail component. The layout includes spacing between the selector and the detail view. The container is enclosed in a border styled according to its active state.

type AuthSelector

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

AuthSelector manages the dropdown UI for selecting an authentication type. It handles opening/closing the dropdown, navigating options, and displaying the current selection.

func NewAuthSelector

func NewAuthSelector() AuthSelector

NewAuthSelector creates and initializes a new AuthSelector component. It sets default options, styles, and keymap.

func (*AuthSelector) SetActive

func (as *AuthSelector) SetActive(active bool)

SetActive sets the active state of the AuthSelector. An active selector can be interacted with via keybindings.

func (*AuthSelector) SetWidth

func (as *AuthSelector) SetWidth(width int)

SetWidth sets the rendering width for the AuthSelector component.

func (*AuthSelector) Update

func (as *AuthSelector) Update(msg tea.Msg) tea.Cmd

Update handles messages for the AuthSelector, primarily key presses. It manages opening/closing the dropdown, navigating options, and selecting an item. It only processes messages if the selector is active.

func (AuthSelector) View

func (as AuthSelector) View() string

View renders the AuthSelector component. It displays either the currently selected option (if closed) or the list of options (if open). Styling is applied based on the active state and whether the dropdown is open.

type AuthSelectorKeyMap

type AuthSelectorKeyMap struct {
	Open   key.Binding // Key to open the dropdown.
	Close  key.Binding // Key to close the dropdown.
	Next   key.Binding // Key to navigate to the next option in the dropdown.
	Prev   key.Binding // Key to navigate to the previous option in the dropdown.
	Select key.Binding // Key to select the highlighted option in the dropdown.
}

AuthSelectorKeyMap defines keybindings for the AuthSelector component. These bindings are used when the AuthSelector is active and its dropdown is open or closed. (Placeholder for future more complex interactivity, currently uses simple string matching).

type BasicAuthDetailsComponent

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

BasicAuthDetailsComponent holds the UI for Basic Auth input fields (username and password). It manages focus between the two input fields and provides methods to get their values.

func NewBasicAuthDetailsComponent

func NewBasicAuthDetailsComponent() BasicAuthDetailsComponent

NewBasicAuthDetailsComponent creates a new instance of BasicAuthDetailsComponent. It initializes the username and password text input fields with placeholders and default settings.

func (*BasicAuthDetailsComponent) GetValues

func (c *BasicAuthDetailsComponent) GetValues() (username string, password string)

GetValues returns the current values of the username and password input fields.

func (*BasicAuthDetailsComponent) SetActive

func (c *BasicAuthDetailsComponent) SetActive(active bool)

SetActive sets the active state of the component. When active, it focuses the appropriate input field (username or password). When inactive, it blurs both input fields.

func (*BasicAuthDetailsComponent) SetSize

func (c *BasicAuthDetailsComponent) SetSize(width, height int)

SetSize sets the dimensions for the component's rendering area. This influences the overall width and height available for the component to render itself.

func (*BasicAuthDetailsComponent) Update

func (c *BasicAuthDetailsComponent) Update(msg tea.Msg) tea.Cmd

Update handles messages and updates the component's state. It manages focus switching between username and password fields using Tab/Shift+Tab or Up/Down keys. It delegates other messages to the currently focused input field. It only processes messages if the component is active.

func (BasicAuthDetailsComponent) View

View renders the BasicAuthDetailsComponent. It displays the username and password input fields, styled according to their active and focused state, along with help text, all within a bordered box. The border style also reflects the component's active state. If width or height is zero or negative, it returns an empty string.

type BodyContainer

type BodyContainer struct {
	Viewport viewport.Model // Viewport for scrollable content

	Width  int  // Width of the component in characters
	Height int  // Height of the component in characters
	Active bool // Whether the component is currently active/focused
	// contains filtered or unexported fields
}

BodyContainer represents a scrollable component for displaying HTTP response bodies. It uses a viewport for scrolling through large content.

func NewBodyContainer

func NewBodyContainer() BodyContainer

NewBodyContainer creates a new body container with a scrollable viewport.

func (*BodyContainer) SetActive

func (b *BodyContainer) SetActive(active bool)

SetActive sets the active state of the component.

func (*BodyContainer) SetContent

func (b *BodyContainer) SetContent(content string)

SetContent updates the body content to display and resets scroll position.

func (*BodyContainer) SetHeight

func (b *BodyContainer) SetHeight(height int)

SetHeight sets the height of the component in characters. Also adds 3 extra rows to extend the container's height.

func (*BodyContainer) SetWidth

func (b *BodyContainer) SetWidth(width int)

SetWidth sets the width of the component in characters.

func (*BodyContainer) Update

func (b *BodyContainer) Update(msg tea.Msg) tea.Cmd

Update handles viewport navigation and other messages.

func (BodyContainer) View

func (b BodyContainer) View() string

View renders the body container with scrolling.

type HeaderInput

type HeaderInput struct {
	HeaderSelect   []string        // HeaderSelect stores the list of available header names for the dropdown.
	SelectedHeader int             // SelectedHeader is the index of the currently selected header name in HeaderSelect.
	DropdownOpen   bool            // DropdownOpen indicates whether the header name dropdown is currently visible.
	ValueInput     textinput.Model // ValueInput is the text input field for the header value.
	// contains filtered or unexported fields
}

HeaderInput represents a single row in the HeadersInputContainer. It consists of a dropdown for selecting a header name and a text input for its value.

type HeadersContainer

type HeadersContainer struct {
	Content string // Content is the formatted header text to be displayed.

	Width  int  // Width is the width of the component in characters.
	Height int  // Height is the height of thecomponent in characters.
	Active bool // Active indicates whether the component is currently focused and can respond to key presses like 'y'.
	// contains filtered or unexported fields
}

HeadersContainer represents a component for displaying HTTP response headers. It formats and displays header information. If active, it also shows a hint for copying the content to the clipboard using the 'y' key.

func NewHeadersContainer

func NewHeadersContainer() HeadersContainer

NewHeadersContainer creates and initializes a new HeadersContainer. It starts with placeholder content and default dimensions.

func (*HeadersContainer) SetActive

func (h *HeadersContainer) SetActive(active bool)

SetActive sets the active state of the HeadersContainer. When active, it may display additional help text or respond to keys.

func (*HeadersContainer) SetContent

func (h *HeadersContainer) SetContent(content string)

SetContent updates the header content to be displayed and the raw content for copying.

func (*HeadersContainer) SetHeight

func (h *HeadersContainer) SetHeight(height int)

SetHeight sets the rendering height for the HeadersContainer.

func (*HeadersContainer) SetWidth

func (h *HeadersContainer) SetWidth(width int)

SetWidth sets the rendering width for the HeadersContainer.

func (*HeadersContainer) Update

func (h *HeadersContainer) Update(msg tea.Msg) tea.Cmd

Update handles messages for the HeadersContainer. If the container is active and the 'y' key is pressed, it attempts to copy the raw content to the clipboard.

func (HeadersContainer) View

func (h HeadersContainer) View() string

View renders the HeadersContainer. It displays the formatted header content. If active, it appends a help message for copying. The content is rendered within a styled box, respecting the component's width and height. If width or height is zero or negative, it returns an empty string.

type HeadersInputContainer

type HeadersInputContainer struct {
	Active bool // Active indicates if the container itself is focused and interactive.
	// contains filtered or unexported fields
}

HeadersInputContainer manages a list of HeaderInput rows, allowing users to input multiple HTTP headers. It handles focus navigation between rows and between the header name and value fields within a row. It also provides functionality to retrieve all entered headers as a map.

func NewHeadersInputContainer

func NewHeadersInputContainer() HeadersInputContainer

NewHeadersInputContainer creates and initializes a new HeadersInputContainer. It pre-populates a fixed number of HeaderInput rows with default values and styles.

func (HeadersInputContainer) GetHeaders

func (h HeadersInputContainer) GetHeaders() map[string]string

GetHeaders returns a map of all valid headers entered by the user. A header is considered valid if its name is not "Empty" and its value is not an empty string.

func (HeadersInputContainer) GetSelectedValues

func (h HeadersInputContainer) GetSelectedValues() (header string, value string)

GetSelectedValues returns the currently selected header name and its corresponding value for the currently focused row. This can be useful for context-aware operations.

func (HeadersInputContainer) Init

func (h HeadersInputContainer) Init() tea.Cmd

Init is the first command that will be run by Bubble Tea for this component. It typically returns textinput.Blink to enable cursor blinking for text inputs.

func (HeadersInputContainer) IsDropdownOpen

func (h HeadersInputContainer) IsDropdownOpen() bool

IsDropdownOpen checks if the header name dropdown for the currently focused row is open.

func (*HeadersInputContainer) SetActive

func (h *HeadersInputContainer) SetActive(active bool)

SetActive sets the active state of the HeadersInputContainer. When activated, it focuses the currently selected internal input field. When deactivated, it blurs all internal input fields.

func (*HeadersInputContainer) SetHeight

func (h *HeadersInputContainer) SetHeight(height int)

SetHeight sets the rendering height for the HeadersInputContainer.

func (*HeadersInputContainer) SetWidth

func (h *HeadersInputContainer) SetWidth(width int)

SetWidth sets the rendering width for the HeadersInputContainer and its child HeaderInput rows. It distributes the width between the header name and value input fields.

func (*HeadersInputContainer) Update

Update handles messages for the HeadersInputContainer, primarily key presses. It manages navigation (up/down rows, left/right between fields), opening/closing dropdowns, and delegating character input to the focused ValueInput field. It returns the updated HeadersInputContainer and any command to be executed (e.g., focus, blink).

func (HeadersInputContainer) View

func (h HeadersInputContainer) View() string

View renders the HeadersInputContainer. It displays labels for header and value, followed by each HeaderInput row. Each row shows the selected header name (or a dropdown if open) and the value input field. Styling is applied to indicate focus and active state. Help text is shown if enabled.

type JWTAuthDetailsComponent

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

JWTAuthDetailsComponent is a placeholder for JWT authentication details UI. It currently displays a simple message and will be implemented with actual input fields for the JWT in the future.

func NewJWTAuthDetailsComponent

func NewJWTAuthDetailsComponent() JWTAuthDetailsComponent

NewJWTAuthDetailsComponent creates a new instance of JWTAuthDetailsComponent.

func (*JWTAuthDetailsComponent) SetActive

func (c *JWTAuthDetailsComponent) SetActive(active bool)

SetActive sets the active state of the component.

func (*JWTAuthDetailsComponent) SetSize

func (c *JWTAuthDetailsComponent) SetSize(width, height int)

SetSize sets the dimensions for the component's rendering area.

func (JWTAuthDetailsComponent) Update

func (c JWTAuthDetailsComponent) Update(msg tea.Msg) tea.Cmd

Update handles messages and updates the component's state. Currently, it's a no-op as the component is a placeholder.

func (JWTAuthDetailsComponent) View

View renders the JWTAuthDetailsComponent. It displays a placeholder message within a styled border. If width or height is zero or negative, it returns an empty string.

type MethodSelector

type MethodSelector struct {
	Methods        []string // Methods is the list of available HTTP method strings.
	SelectedMethod int      // SelectedMethod is the index of the currently selected method in the Methods slice.
	Width          int      // Width is the rendering width of the component.
	Active         bool     // Active indicates whether the component is currently focused and interactive.
	DropdownOpen   bool     // DropdownOpen indicates whether the list of methods is currently displayed as a dropdown.
}

MethodSelector represents the HTTP method selection component. It allows the user to choose an HTTP method (e.g., GET, POST) from a predefined list. The component can display as a simple selection or an open dropdown list.

func NewMethodSelector

func NewMethodSelector() MethodSelector

NewMethodSelector creates and initializes a new MethodSelector component. It populates the list of HTTP methods and sets initial default values.

func (*MethodSelector) GetSelectedMethod

func (m *MethodSelector) GetSelectedMethod() string

GetSelectedMethod returns the string representation of the currently selected HTTP method. If no methods are available or selected (which is unlikely in normal operation), it might return an empty string or the default method.

func (*MethodSelector) Next

func (m *MethodSelector) Next()

Next selects the next HTTP method in the list, wrapping around to the beginning if necessary.

func (*MethodSelector) Prev

func (m *MethodSelector) Prev()

Prev selects the previous HTTP method in the list, wrapping around to the end if necessary.

func (*MethodSelector) SetActive

func (m *MethodSelector) SetActive(active bool)

SetActive sets the active state of the MethodSelector. An active selector responds to key presses and has distinct visual styling.

func (*MethodSelector) SetWidth

func (m *MethodSelector) SetWidth(width int)

SetWidth sets the rendering width for the MethodSelector component.

func (*MethodSelector) Update

func (m *MethodSelector) Update(msg tea.Msg)

Update handles messages for the MethodSelector, primarily key presses when it's active. It allows toggling the dropdown with Enter and navigating with Up/Down arrows when the dropdown is open.

func (MethodSelector) View

func (m MethodSelector) View() string

View renders the MethodSelector component. If the dropdown is open, it lists all methods with the current selection highlighted. If closed, it shows only the selected method with a dropdown indicator. The component includes a title and is bordered, with styles changing based on the active state.

type OAuth2AuthDetailsComponent

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

OAuth2AuthDetailsComponent is a placeholder for OAuth2 authentication details UI. It currently displays a simple message and will be implemented with actual input fields and logic for OAuth2 flows in the future.

func NewOAuth2AuthDetailsComponent

func NewOAuth2AuthDetailsComponent() OAuth2AuthDetailsComponent

NewOAuth2AuthDetailsComponent creates a new instance of OAuth2AuthDetailsComponent.

func (*OAuth2AuthDetailsComponent) SetActive

func (c *OAuth2AuthDetailsComponent) SetActive(active bool)

SetActive sets the active state of the component.

func (*OAuth2AuthDetailsComponent) SetSize

func (c *OAuth2AuthDetailsComponent) SetSize(width, height int)

SetSize sets the dimensions for the component's rendering area.

func (OAuth2AuthDetailsComponent) Update

func (c OAuth2AuthDetailsComponent) Update(msg tea.Msg) tea.Cmd

Update handles messages and updates the component's state. Currently, it's a no-op as the component is a placeholder.

func (OAuth2AuthDetailsComponent) View

View renders the OAuth2AuthDetailsComponent. It displays a placeholder message within a styled border. If width or height is zero or negative, it returns an empty string.

type ParamInput

type ParamInput struct {
	NameInput  textinput.Model
	ValueInput textinput.Model
}

ParamInput represents a single Name/Value input pair.

type ParamsContainer

type ParamsContainer struct {
	Inputs []ParamInput // Slice of parameter inputs
	Width  int          // Width of the container
	Height int          // Height of the container
	Active bool         // Whether the container is currently active/focused
	// contains filtered or unexported fields
}

ParamsContainer manages a list of parameter inputs (Name/Value pairs).

func NewParamsContainer

func NewParamsContainer() ParamsContainer

NewParamsContainer creates a new ParamsContainer with a predefined number of rows.

func (*ParamsContainer) Blur

func (pc *ParamsContainer) Blur()

Blur removes focus from all input fields in the container.

func (*ParamsContainer) ClearParams

func (pc *ParamsContainer) ClearParams()

ClearParams clears all input fields.

func (*ParamsContainer) Focus

func (pc *ParamsContainer) Focus()

Focus sets the focus to the first input field in the container.

func (*ParamsContainer) GetParams

func (pc *ParamsContainer) GetParams() map[string]string

GetParams returns the current parameters as a map.

func (*ParamsContainer) IsAnyInputFocused

func (pc *ParamsContainer) IsAnyInputFocused() bool

IsAnyInputFocused checks if any text input within the ParamsContainer is currently focused.

func (*ParamsContainer) SetActive

func (pc *ParamsContainer) SetActive(active bool)

SetActive sets the active state of the container.

func (*ParamsContainer) SetHeight

func (pc *ParamsContainer) SetHeight(height int)

SetHeight sets the height of the container.

func (*ParamsContainer) SetWidth

func (pc *ParamsContainer) SetWidth(width int)

SetWidth sets the width of the container and its child inputs.

func (*ParamsContainer) Update

func (pc *ParamsContainer) Update(msg tea.Msg) tea.Cmd

Update handles messages for the ParamsContainer.

func (*ParamsContainer) View

func (pc *ParamsContainer) View() string

View renders the ParamsContainer.

type QueryTab

type QueryTab struct {
	InnerTabs      []string              // InnerTabs stores the labels for the switchable inner sections (e.g., "Params", "Auth").
	ActiveInnerTab int                   // ActiveInnerTab is the index of the currently visible and interactive inner tab.
	Width          int                   // Width is the rendering width of the entire QueryTab component.
	Height         int                   // Height is the rendering height of the entire QueryTab component.
	Active         bool                  // Active indicates if the QueryTab itself (and thus its active inner tab) is focused.
	ParamsInput    ParamsContainer       // ParamsInput is the component for managing URL query parameters.
	AuthInput      AuthContainer         // AuthInput is the component for managing authentication settings.
	HeadersInput   HeadersInputContainer // HeadersInput is the component for managing request headers.
	QueryBodyInput textarea.Model        // QueryBodyInput is the text area for inputting the request body.
	// contains filtered or unexported fields
}

QueryTab represents the main interactive area for constructing an HTTP request. It contains several inner tabs (Params, Auth, Headers, Body) allowing the user to configure different parts of the request. It manages focus between these inner tabs and delegates interactions to the active inner component.

func NewQueryTab

func NewQueryTab() QueryTab

NewQueryTab creates and initializes a new QueryTab component. It sets up the inner tabs and their corresponding child components (ParamsContainer, AuthContainer, etc.).

func (*QueryTab) GetBodyContent

func (q *QueryTab) GetBodyContent() string

GetBodyContent returns the current content of the QueryBodyInput (request body text area).

func (*QueryTab) IsAnyInputFocused

func (q *QueryTab) IsAnyInputFocused() bool

IsAnyInputFocused checks if any interactive element within the currently active inner tab is focused. This is used to determine context for keybindings or help text.

func (*QueryTab) NextTab

func (q *QueryTab) NextTab()

NextTab cycles to the next inner tab in the sequence.

func (*QueryTab) PrevTab

func (q *QueryTab) PrevTab()

PrevTab cycles to the previous inner tab in the sequence.

func (*QueryTab) SetActive

func (q *QueryTab) SetActive(active bool)

SetActive sets the active state of the QueryTab. This also triggers an update to the focus state of its internal components.

func (*QueryTab) SetHeight

func (q *QueryTab) SetHeight(height int)

SetHeight sets the rendering height for the QueryTab and propagates it to its child components. The height is adjusted for the tab bar, borders, and padding before being passed to children.

func (*QueryTab) SetWidth

func (q *QueryTab) SetWidth(width int)

SetWidth sets the rendering width for the QueryTab and propagates it to its child components. The width is adjusted for borders and padding before being passed to children.

func (*QueryTab) SwitchToInnerTab

func (q *QueryTab) SwitchToInnerTab(tabIndex int)

SwitchToInnerTab changes the active inner tab to the one specified by tabIndex. It deactivates the previously active inner component and activates the new one.

func (*QueryTab) Update

func (q *QueryTab) Update(msg tea.Msg) tea.Cmd

Update handles messages for the QueryTab. It manages Tab/Shift+Tab navigation between inner tabs. For other messages, it delegates to the Update method of the currently active inner component. It ensures that components like the textarea receive necessary updates for cursor blinking even if not fully active.

func (QueryTab) View

func (q QueryTab) View() string

View renders the QueryTab component. It displays a bar with inner tab labels, with the active tab highlighted. Below the tab bar, it renders the View of the currently active inner component. Help text is displayed at the bottom, contextual to the active inner tab and its state.

type ResultTab

type ResultTab struct {
	InnerTabs      []string         // Labels for the inner tabs
	ActiveInnerTab int              // Index of the currently active inner tab
	Width          int              // Width of the component in characters
	Height         int              // Height of the component in characters
	Active         bool             // Whether the component is currently active/focused
	HeadersTab     HeadersContainer // Container for displaying response headers
	BodyTab        BodyContainer    // Container for displaying response body
}

ResultTab represents the inner tab component for the Result tab. It provides a tabbed interface for viewing different aspects of an HTTP response including headers and body content. The component handles tab navigation via Tab/Shift+Tab keys.

func NewResultTab

func NewResultTab() ResultTab

NewResultTab creates a new result tab component with predefined inner tabs. The component is initialized with the "Headers" tab selected, zero dimensions, and inactive state. Each inner tab has default placeholder content.

func (*ResultTab) NextTab

func (r *ResultTab) NextTab()

NextTab cycles to the next inner tab. It wraps around to the beginning if the end of the tabs is reached.

func (*ResultTab) PrevTab

func (r *ResultTab) PrevTab()

PrevTab cycles to the previous inner tab. It wraps around to the end if the beginning of the tabs is reached.

func (*ResultTab) SetActive

func (r *ResultTab) SetActive(active bool)

SetActive sets the active state of the component. When active, the component has visual styling to indicate focus and responds to key presses.

func (*ResultTab) SetBodyContent

func (r *ResultTab) SetBodyContent(content string)

SetBodyContent sets the content for the body tab.

func (*ResultTab) SetContent

func (r *ResultTab) SetContent(tabIndex int, content string)

SetContent sets the content for a specific inner tab by index. This method is for backward compatibility.

func (*ResultTab) SetHeadersContent

func (r *ResultTab) SetHeadersContent(content string)

SetHeadersContent sets the content for the headers tab.

func (*ResultTab) SetHeight

func (r *ResultTab) SetHeight(height int)

SetHeight sets the height of the component in characters.

func (*ResultTab) SetWidth

func (r *ResultTab) SetWidth(width int)

SetWidth sets the width of the component in characters.

func (*ResultTab) SwitchToInnerTab

func (r *ResultTab) SwitchToInnerTab(tabIndex int)

SwitchToInnerTab switches to the specified inner tab by index. If the index is out of range, no change is made.

func (*ResultTab) Update

func (r *ResultTab) Update(msg tea.Msg) tea.Cmd

Update processes input messages and updates the result tab state. It handles tab and shift+tab key presses for inner tab navigation.

func (ResultTab) View

func (r ResultTab) View() string

View renders the result tab component

type Spinner

type Spinner struct {
	Visible  bool     // Whether the spinner is currently visible
	Width    int      // Width of the spinner in characters
	Height   int      // Height of the spinner in characters
	Frames   []string // Animation frames
	FrameIdx int      // Current frame index
	Message  string   // Optional text message to display with the spinner
	X        int      // X position for placing the spinner (default 0)
	Y        int      // Y position for placing the spinner (default 0)
}

Spinner represents a loading spinner that overlays a specific UI component. It displays an animation to indicate ongoing processes like HTTP requests.

func NewSpinner

func NewSpinner() Spinner

NewSpinner creates a new spinner component with default values. The spinner is initially hidden until Show() is called.

func (*Spinner) Hide

func (s *Spinner) Hide()

Hide hides the spinner and stops its animation.

func (*Spinner) SetHeight

func (s *Spinner) SetHeight(height int)

SetHeight sets the height of the spinner component.

func (*Spinner) SetPosition

func (s *Spinner) SetPosition(x, y int)

SetPosition sets the position of the spinner. x is the horizontal position and y is the vertical position.

func (*Spinner) SetWidth

func (s *Spinner) SetWidth(width int)

SetWidth sets the width of the spinner component.

func (*Spinner) Show

func (s *Spinner) Show(message string) tea.Cmd

Show displays the spinner with an optional message. It returns a command to start the spinner animation.

func (*Spinner) Update

func (s *Spinner) Update(msg tea.Msg) tea.Cmd

Update handles messages and updates the spinner state. It advances the animation frame when a SpinnerTickMsg is received.

func (Spinner) View

func (s Spinner) View() string

View renders the spinner component. If the spinner is not visible, an empty string is returned.

type SpinnerTickMsg

type SpinnerTickMsg time.Time

SpinnerTickMsg is sent when the spinner animation should advance.

type SubmitButton

type SubmitButton struct {
	Label  string // Text displayed on the button
	Width  int    // Width of the button in characters
	Height int    // Height of the button in characters
	Active bool   // Whether the button is currently active/focused
}

SubmitButton represents a clickable button component that can be focused and activated. It provides a standard button interface with visual feedback for active state and handles key press events for interaction.

func NewButton

func NewButton(label string) SubmitButton

NewButton creates a new button component with the specified label. The button is initialized with zero width and height, and inactive state.

func (*SubmitButton) SetActive

func (b *SubmitButton) SetActive(active bool)

SetActive sets the active state of the button. When a button is active, it has visual styling to indicate focus.

func (*SubmitButton) SetHeight

func (b *SubmitButton) SetHeight(height int)

SetHeight sets the height of the button in characters.

func (*SubmitButton) SetWidth

func (b *SubmitButton) SetWidth(width int)

SetWidth sets the width of the button in characters.

func (*SubmitButton) Update

func (b *SubmitButton) Update(msg tea.Msg) (tea.Cmd, bool)

Update processes input messages and updates the button state. Returns a tea.Cmd (always nil for Button) and a boolean indicating if the button was activated. The boolean is true if Enter was pressed while the button was active.

func (SubmitButton) View

func (b SubmitButton) View() string

View renders the button component as a string for terminal display. The rendered button includes a border and content, with styling based on the active state. When active, the button has a highlighted border and background.

type TabsContainer

type TabsContainer struct {
	Tabs        []string  // Labels for the main tabs
	ActiveTab   int       // Index of the currently active main tab
	Width       int       // Width of the container in characters
	Height      int       // Height of the container in characters
	Active      bool      // Whether the component is currently active/focused
	TabContents []string  // Default content for each tab (used as fallback)
	QueryTab    QueryTab  // The query tab component with its inner tabs
	ResultTab   ResultTab // The result tab component with its inner tabs
}

TabsContainer represents a tabbed container with multiple tabs. It manages a main set of tabs (Query and Result) and renders the appropriate inner tab component based on the active tab selection.

func NewTabsContainer

func NewTabsContainer() TabsContainer

NewTabsContainer creates a new tab container with Query and Result tabs. It initializes both tabs with default content and proper configuration.

func (*TabsContainer) GetQueryTab

func (t *TabsContainer) GetQueryTab() *QueryTab

GetQueryTab returns a pointer to the query tab component.

func (*TabsContainer) GetResultTab

func (t *TabsContainer) GetResultTab() *ResultTab

GetResultTab returns a pointer to the result tab component.

func (*TabsContainer) SetActive

func (t *TabsContainer) SetActive(active bool)

SetActive sets the active state of the tab container and propagates the active state to the inner tab components.

func (*TabsContainer) SetHeight

func (t *TabsContainer) SetHeight(height int)

SetHeight sets the height of the tab container and propagates the height to the inner tab components, giving the QueryTab more vertical space.

func (*TabsContainer) SetWidth

func (t *TabsContainer) SetWidth(width int)

SetWidth sets the width of the tab container and propagates the appropriate width to the inner tab components, with reduced right margin.

func (*TabsContainer) SwitchToTab

func (t *TabsContainer) SwitchToTab(tabIndex int)

SwitchToTab switches to the specified tab by index. If the index is out of range, no change is made.

func (*TabsContainer) Update

func (t *TabsContainer) Update(msg tea.Msg)

Update processes input messages and updates the container state. It handles alt+key combinations for tab switching and delegates tab/shift+tab navigation to the appropriate inner tab component.

func (TabsContainer) View

func (t TabsContainer) View() string

View renders the tab container component with the active tab's content. It creates a tabbed interface with hotkey indicators and renders the appropriate inner tab component (QueryTab or ResultTab) based on which main tab is active.

type TickMsg

type TickMsg time.Time

TickMsg is sent when the timer ticks. It is used for automatic dismissal timing of toast notifications.

type Toast

type Toast struct {
	Message   string // The text message to display in the toast
	Visible   bool   // Whether the toast is currently visible
	Width     int    // Width of the toast in characters
	Height    int    // Height of the toast in characters
	Dismissed bool   // Whether the toast has been dismissed by the user
}

Toast represents a temporary notification that displays messages to the user. It can show success, warning, or error messages with a dismissal option.

func NewToast

func NewToast() Toast

NewToast creates a new toast notification with default values. The toast is initially hidden until Show() is called.

func (*Toast) Hide

func (t *Toast) Hide()

Hide hides the toast notification and resets its state. This clears the message and sets the dismissed flag to false.

func (*Toast) SetHeight

func (t *Toast) SetHeight(height int)

SetHeight sets the height of the toast notification in characters.

func (*Toast) SetWidth

func (t *Toast) SetWidth(width int)

SetWidth sets the width of the toast notification in characters.

func (*Toast) Show

func (t *Toast) Show(message string)

Show displays a toast message with the provided text. This makes the toast visible and updates its message content.

func (*Toast) Update

func (t *Toast) Update(msg tea.Msg) bool

Update processes input messages and updates the toast state. Returns a boolean indicating whether the update resulted in any state change. Note: Enter keypresses are now handled by the App's Update method.

func (Toast) View

func (t Toast) View() string

View renders the toast component as a styled notification box. The toast has a gold border, white text, and a brown-red background. If the toast is not visible, an empty string is returned.

type TokenAuthDetailsComponent

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

TokenAuthDetailsComponent holds the UI for Bearer Token input. It's specifically for Bearer tokens, but named generically as TokenAuthDetailsComponent for potential future reuse or extension if other simple token types arise.

func NewTokenAuthDetailsComponent

func NewTokenAuthDetailsComponent() TokenAuthDetailsComponent

NewTokenAuthDetailsComponent creates a new instance of TokenAuthDetailsComponent. It initializes the text input field for the Bearer token.

func (*TokenAuthDetailsComponent) GetToken

func (c *TokenAuthDetailsComponent) GetToken() string

GetToken returns the current value of the token input field.

func (*TokenAuthDetailsComponent) SetActive

func (c *TokenAuthDetailsComponent) SetActive(active bool)

SetActive sets the active state of the component. When active, the token input field gains focus. When inactive, it loses focus.

func (*TokenAuthDetailsComponent) SetSize

func (c *TokenAuthDetailsComponent) SetSize(width, height int)

SetSize sets the dimensions for the component's rendering area. This influences the overall width and height available for the component to render itself.

func (*TokenAuthDetailsComponent) Update

func (c *TokenAuthDetailsComponent) Update(msg tea.Msg) tea.Cmd

Update handles messages and updates the component's state. It only processes messages and updates the token input field if the component is active. It returns a tea.Cmd, which might be produced by the text input field's update.

func (TokenAuthDetailsComponent) View

View renders the TokenAuthDetailsComponent. It displays the token input field, styled according to its active and focused state, within a bordered box. The border style also reflects the component's active state. If width or height is zero or negative, it returns an empty string.

type URLInput

type URLInput struct {
	TextInput textinput.Model // The underlying text input model
	Width     int             // Width of the component in characters
	Active    bool            // Whether the component is currently active/focused
}

URLInput represents the URL input component where users can enter the target URL for HTTP requests. It wraps the textinput.Model from the Bubble Tea framework to provide specialized URL input functionality.

func NewURLInput

func NewURLInput() URLInput

NewURLInput creates a new URL input component with default configuration. The input is initially focused and has a placeholder text.

func (*URLInput) GetText

func (u *URLInput) GetText() string

GetText returns the current URL text entered by the user.

func (*URLInput) SelectAllText

func (u *URLInput) SelectAllText()

SelectAllText selects all text in the input field. This is used when focusing the input to allow quick replacement of the URL.

func (*URLInput) SetActive

func (u *URLInput) SetActive(active bool)

SetActive sets the active state of the URL input. When active, the input is focused and can receive keyboard input. When inactive, the input is blurred and displays with different styling.

func (*URLInput) SetWidth

func (u *URLInput) SetWidth(width int)

SetWidth sets the width of the URL input component. It adjusts the internal TextInput width to account for border and padding.

func (*URLInput) Update

func (u *URLInput) Update(msg tea.Msg) tea.Cmd

Update processes input messages and updates the URLInput component. It only processes messages when the component is active. Returns any commands that need to be executed.

func (URLInput) View

func (u URLInput) View() string

View renders the URLInput component with the appropriate styling. It displays a title with hotkey and the text input field with border.

Jump to

Keyboard shortcuts

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