browserapi

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTabNotFree is returned when a tab is being used in call to
	// SetContent but it's already owned by another Window.
	ErrTabNotFree = errors.New("tab already rendered in Window")
)

Functions

This section is empty.

Types

type BarConfig

type BarConfig struct {
	Orientation Orientation
	Size        int
	Frame       BarFrame
}

BarConfig defines the configuration for a Bar created bia WindowManager.Bar.

type BarFrame

type BarFrame uint8

BarFrame represents the different options for creating a bar.

const (
	// BarFrameDefault signals that the bar should use the default frame
	// configuration of the WindowManager.
	BarFrameDefault BarFrame = iota
	// BarFrameAlways signals that the bar should always be framed,
	// regardless of the WindowManager configuration.
	BarFrameAlways
	// BarFrameNever signals that the bar should never be framed,
	// regardless of the WindowManager configuration.
	BarFrameNever
)

type Browser

Browser is an interface that groups methods to manipulate the user interface of a browser.

type EventPublisher

type EventPublisher interface {
	// Interrupt will publish an interrupt event, which will force
	// redrawing all components in the terminal.
	Interrupt(context.Context) error

	// PublishEventNone will publish an EventNone event, which will force
	// calling Handle on the component currently in focus.
	//
	// There's no guarantee that caller will be the tui.Handler that will
	// receive this event.
	PublishEventNone() error
}

EventPublisher is the interface that wraps the method Interrupt.

type Floating

type Floating interface {
	Handler
	handler.Floating
}

Floating is a Handler used for Floating windows. See handler.Floating for more details.

func FuncFloating

func FuncFloating(h Handler, dimFn func() (int, int)) Floating

FuncFloating wraps a Handler and returns a Floating that calls dimFn when Dimensions is called.

func FuncFloatingHandler

func FuncFloatingHandler(h handler.Floating, closeFn func() error) Floating

FuncFloatingHandler wraps a handler.Floating and returns a Floating that calls calls closeFn when Close is called.

func NopFloatingHandler

func NopFloatingHandler(h handler.Floating) Floating

NopFloatingHandler wraps a handler.Floating and returns a Floating that does nothing when Close is called.

func StaticFloating

func StaticFloating(h Handler, width, height int) Floating

StaticFloating wraps a Handler and returns a Floating that always return the same Dimensions values.

type FloatingConfig

type FloatingConfig struct {
	// Sets the alignment of the window.
	component.Alignment
	// Offset is to be applied to the position of the window
	// after alignment has been determined.
	Offset term.Coordinates
}

FloatingConfig abstracts configuration for creating floating windows.

type Handler

type Handler interface {
	tui.Handler
	Close() error
}

Handler adds Close to a tui.Handler. Close must be idempotent.

func FuncHandler

func FuncHandler(h tui.Handler, doClose func() error) Handler

FuncHandler returns a Handler by wrapping a tui.Handler with an Close callback.

func NopHandler

func NopHandler(h tui.Handler) Handler

NopHandler returns a Handler by wrapping a tui.Handler with an nop Close callback.

func SyncHandler

func SyncHandler(locker sync.Locker, h Handler) Handler

SyncHandler wraps the given handler and adds synchronized access.

type NotificationLevel

type NotificationLevel uint8

NotificationLevel determines the severity of the notification.

const (
	// LevelError signals an unexpected error.
	LevelError NotificationLevel = iota
	// LevelWarn signals an expected error.
	LevelWarn
	// LevelInfo signals an informational message.
	LevelInfo
	// LevelSuccess signals a message of success.
	LevelSuccess
)

type Notifications

type Notifications interface {
	// Notify delivers the given message to the user, as a notification.
	Notify(level NotificationLevel, msg string, args ...any) (string, error)

	// NotifyOnce delivers the given notification once, and never again. A notification
	// is identified as the hash of the final message (with arguments).
	NotifyOnce(level NotificationLevel, msg string, args ...any) (string, error)

	// UpdateNotificationProgress updates the progress of a notification,
	// overriding the default timing and progress bar settings.
	//
	// After calling this once, caller is responsible for updating it
	// until progress == total.
	//
	// It's expected for progress to be smaller than or equal than total,
	// and total must never be 0. An error is returned if any of these conditions
	// are not met.
	//
	// The message argument can be empty, in which case the previous message
	// is used.
	UpdateNotificationProgress(id, message string, progress, total int64) error
}

Notifications is the interface that wraps methods to display messages to the user.

type Orientation

type Orientation uint8

Orientation represents a window orientation.

const (
	// OrientationDefault represents the default window orientation.
	OrientationDefault Orientation = iota
	// OrientationTop sets the component at the top.
	OrientationTop
	// OrientationBottom sets the component at the bottom.
	OrientationBottom
	// OrientationLeft sets the component on the left.
	OrientationLeft
	// OrientationRight sets the component on the right.
	OrientationRight
)

type ResourceOpener

type ResourceOpener interface {
	// Opens the resource with a given uri as a tab, using the underlying
	// workspaceapi.FileSystem, but doesn't switch the focus of the current
	// window in focus to it. That can be accomplished via WindowManager.SetWindowContent.
	Open(resource workspaceapi.URI) (Handler, error)
}

ResourceOpener is the interface that wraps the method Open.

type Window

type Window interface {
	WindowID() uint64
}

Window is the interface that represents a closeable window in a WindowManager.

type WindowManager

type WindowManager interface {
	// Focus returns the current Window in focus.
	Focus() (Window, error)

	// Split splits the current window in focus in two, and installs
	// Handler in the new window.
	Split(Orientation, Window, Handler) (Window, error)

	// Floating creates a new floating window at coordinates,
	// with static width and height.
	Floating(h Floating, cfg FloatingConfig) (Window, error)

	// Bar creates a status bar with Orientation and Handler.
	// Bars differ from Split and Floating windows in that they can't
	// be in focus and can only receive mouse events.
	Bar(BarConfig, tui.Handler) error

	// Tab creates a new tab with h and returns a handle that can be
	// used with the rest of methods that take a browser.Handler.
	// URI is used to uniquely identify a tab and name is used as a label
	// to display it in the tab bar.
	Tab(uri workspaceapi.URI, icon rune, name string, h Handler) (Handler, error)

	// SetWindowContent sets the content of the given window to the given handler.
	SetWindowContent(Window, Handler) error

	// Close closes the given window.
	CloseWindow(Window) error
}

WindowManager is the interface that groups tile window management methods.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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