ui

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ui holds the browser chrome state independent of terminal I/O.

Index

Constants

View Source
const ChromeRows = 2

ChromeRows is the number of terminal rows reserved for browser chrome.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Kind            ActionKind
	URL             string
	Label           string
	Hint            *browser.Hint
	Index           int
	PauseGeneration uint64
	InstanceEpoch   string
}

Action is the result of one key event.

type ActionKind

type ActionKind int

ActionKind is a command the caller should run against the browser.

const (
	ActionNone ActionKind = iota
	ActionNavigate
	ActionBack
	ActionForward
	ActionReload
	ActionShowHints
	ActionHint
	ActionClearHints
	ActionOpenHistory
	ActionOpenBookmarks
	ActionToggleBookmark
	ActionOverlaySelect
	ActionOverlayClose
	ActionToggleText
	ActionTextScroll
	ActionScreenshot
	ActionScreenshotFull
	ActionNewTab
	ActionSelectTab
	ActionCloseTab
	ActionEditAddress
	ActionQuit
	ActionResumeAutomation
	ActionKeepPaused
)

type Model

type Model struct {
	URL          string
	Address      string
	Editing      bool
	Status       string
	Tabs         []TabInfo
	ActiveTab    int
	CanGoBack    bool
	CanGoForward bool
	Private      bool
	AgentActive  bool
	Interaction  host.InteractionState

	ResumeBusy    bool
	ResumeUnknown bool

	HintMode   bool
	HintBuffer string
	Hints      []browser.Hint

	Overlay      OverlayKind
	OverlayItems []string
	OverlayIndex int
	HistoryURLs  []string
	BookmarkURLs []string

	TextMode  bool
	TextLines []string
	TextTop   int
	// contains filtered or unexported fields
}

Model is the address bar and status state.

func New

func New(url string) *Model

New returns a browse-mode model for url.

func (*Model) AddressTrimmed

func (m *Model) AddressTrimmed() string

AddressTrimmed returns the address without surrounding whitespace.

func (*Model) CancelFooterPress added in v0.2.12

func (m *Model) CancelFooterPress()

func (*Model) Chrome added in v0.2.0

func (m *Model) Chrome(cols int) []string

Chrome renders the tab strip and toolbar. Untrusted text is sanitized, but Unicode is preserved; layout and mouse hitboxes use display cells, not bytes.

func (*Model) ClearHints

func (m *Model) ClearHints()

ClearHints leaves hint mode.

func (*Model) CloseOverlay

func (m *Model) CloseOverlay()

CloseOverlay leaves any picker.

func (*Model) FocusPage added in v0.2.19

func (m *Model) FocusPage()

FocusPage clears any recovery button focus before addressing page controls. Selecting a page never changes the automation pause itself.

func (*Model) Footer

func (m *Model) Footer(bookmarked bool) string

Footer renders the persistent status/help line.

func (*Model) FooterMouseActive added in v0.2.12

func (m *Model) FooterMouseActive() bool

func (*Model) Handle

func (m *Model) Handle(ev term.Event) Action

Handle consumes one key event.

func (*Model) HandleFooterKey added in v0.2.12

func (m *Model) HandleFooterKey(ev term.Event) (Action, bool)

Footer focus is bound when Tab is pressed, not reinterpreted for a later pause. Enter/Space never become an extra page key after selecting a button.

func (*Model) HandleFooterMouse added in v0.2.12

func (m *Model) HandleFooterMouse(cols, rows int, mouse term.MouseEvent) Action

HandleFooterMouse always consumes the footer outside the webpage. A click completes only on release over the same button and pause generation.

func (*Model) HandleMouse added in v0.2.0

func (m *Model) HandleMouse(cols int, mouse term.MouseEvent) Action

HandleMouse maps a press to the same parts used by Chrome. Mouse positions are one-based SGR terminal coordinates. A page press releases address editing so the newly focused page input, not the toolbar, receives the next key.

func (*Model) Header

func (m *Model) Header() string

Header renders the one-line chrome.

func (*Model) OpenOverlay

func (m *Model) OpenOverlay(kind OverlayKind, items []string)

OpenOverlay shows one picker.

func (*Model) SetHints

func (m *Model) SetHints(hints []browser.Hint)

SetHints installs a fresh page overlay and enters hint mode.

func (*Model) SetLists

func (m *Model) SetLists(history, bookmarks []string)

SetLists refreshes the persisted history and bookmark lists.

func (*Model) SetText

func (m *Model) SetText(text string)

SetText installs the extracted page text and enters text mode.

func (*Model) SetURL

func (m *Model) SetURL(url string)

SetURL updates the displayed URL after navigation.

func (*Model) TextView

func (m *Model) TextView(rows, width int) []string

TextView returns the visible window of extracted text.

type OverlayKind

type OverlayKind int

OverlayKind selects the one-line picker.

const (
	OverlayNone OverlayKind = iota
	OverlayHistory
	OverlayBookmarks
)

type TabInfo added in v0.2.0

type TabInfo struct {
	Title string
	URL   string
}

TabInfo is the display information for one browser tab.

Jump to

Keyboard shortcuts

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