ui

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: 11 Imported by: 0

Documentation

Overview

Package ui provides the user interface for the LazyPost application. It implements a TUI (Text User Interface) using the Bubble Tea framework.

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyMap = KeyMap{
	FocusMethod: key.NewBinding(
		key.WithKeys("alt+1"),
		key.WithHelp("alt+1", "focus method"),
	),
	FocusURL: key.NewBinding(
		key.WithKeys("alt+2"),
		key.WithHelp("alt+2", "focus url"),
	),
	FocusQuery: key.NewBinding(
		key.WithKeys("alt+3"),
		key.WithHelp("alt+3", "switch to query tab"),
	),
	FocusResult: key.NewBinding(
		key.WithKeys("alt+4"),
		key.WithHelp("alt+5", "switch to result tab"),
	),
	FocusSubmit: key.NewBinding(
		key.WithKeys("alt+5"),
		key.WithHelp("alt+5", "submit request"),
	),
	Next: key.NewBinding(
		key.WithKeys("tab"),
		key.WithHelp("tab", "next inner tab"),
	),
	Prev: key.NewBinding(
		key.WithKeys("shift+tab"),
		key.WithHelp("shift+tab", "prev inner tab"),
	),
	Quit: key.NewBinding(
		key.WithKeys("ctrl+c", "esc"),
		key.WithHelp("ctrl+c/esc", "quit"),
	),
}

DefaultKeyMap returns the default keybindings for the application. This defines the key mappings that will be used across the app.

Functions

func IsValidJSON

func IsValidJSON(s string) bool

IsValidJSON checks if the provided string is valid JSON.

Types

type App

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

App represents the main application model. It embeds all UI components and manages the application state and logic.

func NewApp

func NewApp() App

NewApp initializes and returns a new App model. It sets up all the necessary UI components, loads the banner, and prepares the initial state.

func (App) Init

func (a App) Init() tea.Cmd

Init is the first command that is run when the application starts. It satisfies the tea.Model interface.

func (App) Update

func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles incoming messages and updates the App model accordingly. It is a central part of the Bubble Tea event loop and satisfies the tea.Model interface.

func (App) View

func (a App) View() string

View renders the current state of the application as a string. It satisfies the tea.Model interface.

type KeyMap

type KeyMap struct {
	FocusMethod key.Binding // Alt+1: Focus the method selector
	FocusURL    key.Binding // Alt+2: Focus the URL input
	FocusSubmit key.Binding // Alt+5: Submit the request
	FocusQuery  key.Binding // Alt+3: Switch to query tab
	FocusResult key.Binding // Alt+4: Switch to result tab
	Next        key.Binding // Tab: Navigate to next inner tab
	Prev        key.Binding // Shift+Tab: Navigate to previous inner tab
	Quit        key.Binding // Ctrl+C/Esc: Quit the application
}

KeyMap defines the keybindings for the application. It maps actions to specific key combinations.

type RequestCompleteMsg

type RequestCompleteMsg struct {
	Headers string // Formatted headers string
	Body    string // Response body text
	Error   error  // Any error that occurred during the request
}

RequestCompleteMsg is sent when an HTTP request has completed. It contains the response data from the request.

Directories

Path Synopsis
Package components defines various UI components for the LazyPost application.
Package components defines various UI components for the LazyPost application.
Package styles provides consistent styling for the LazyPost application.
Package styles provides consistent styling for the LazyPost application.

Jump to

Keyboard shortcuts

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