app

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package app wires the view tree to a backend Screen and runs the main event loop: read events, dispatch them down the tree, draw, flush. v0.1 hosts an Application with a MenuBar, Desktop, and StatusLine and quits on Alt-X or the CmdQuit broadcast.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	*view.Group
	// contains filtered or unexported fields
}

Application is the root Group of the view tree. It holds the screen, the composition surface, and the channels that feed the main loop.

func New

func New(screen vio.Screen) *Application

New constructs an Application backed by screen. It sizes itself to the screen, attaches the standard MenuBar/Desktop/StatusLine triplet, and installs the BorlandClassic palette.

func (*Application) ClearModal added in v0.2.0

func (a *Application) ClearModal()

ClearModal removes any active modal slot.

func (*Application) Desktop

func (a *Application) Desktop() *Desktop

Desktop returns the desktop child for tests and host applications that want to insert windows into it.

func (*Application) ExecView added in v0.2.0

func (a *Application) ExecView(v ModalView) event.CommandID

ExecView shows v as a modal sub-loop and blocks until it closes. The view is inserted into the desktop, set as the modal slot, and drawn on every iteration. The loop exits when v.Result() returns a non-zero command, when the screen channel closes, or when Quit is called; it returns the close command (CmdCancel as a fall-back).

func (*Application) Finished

func (a *Application) Finished() <-chan struct{}

Finished returns a channel that is closed when Run exits.

func (*Application) HelpRegistry added in v0.2.0

func (a *Application) HelpRegistry() *help.Registry

HelpRegistry returns the help topic registry. Hosts register their own contexts on it before Run; v0.2 only seeds CtxAbout.

func (*Application) MenuBar

func (a *Application) MenuBar() *menu.Bar

MenuBar returns the menu bar child.

func (*Application) Modal added in v0.2.0

func (a *Application) Modal() view.Viewer

Modal returns the currently active modal view, or nil.

func (*Application) PutEvent

func (a *Application) PutEvent(e event.Event)

PutEvent posts an event into the application from any goroutine. It is the only thread-safe entry point into the UI; everything else expects to run on the main loop goroutine.

func (*Application) Quit

func (a *Application) Quit()

Quit asks the loop to stop after the current iteration.

func (*Application) Run

func (a *Application) Run() error

Run drives the event loop until Quit is called or the screen channel closes. It returns the error returned by Screen.Show, or nil.

func (*Application) SetModal added in v0.2.0

func (a *Application) SetModal(v view.Viewer)

SetModal pushes v as the currently active modal view. While set, only v receives non-system events; the rest of the tree (menu bar, desktop, status line) sees ClassNothing. Pass nil to clear the modal.

The host is responsible for inserting v into a Group (typically the desktop) before calling SetModal, and removing it after ClearModal. Phase 2 ships this minimal slot; Dialog/MessageBox in phase 3 will wrap it in an ExecView convenience.

func (*Application) ShowAbout added in v0.2.0

func (a *Application) ShowAbout() event.CommandID

ShowAbout opens the About dialog as a modal sub-loop.

func (*Application) StatusLine

func (a *Application) StatusLine() *menu.Line

StatusLine returns the status line child.

func (*Application) Surface

func (a *Application) Surface() *vio.Surface

Surface returns the composition surface, primarily for tests.

type Background

type Background struct {
	*view.View

	Pattern rune
}

Background is the dotted-fill view that shows behind every window. It is the visual layer of the desktop: the recognizable Borland blue speckle.

func NewBackground

func NewBackground(r vio.Rect, pattern rune) *Background

NewBackground returns a Background sized to r, drawing pattern as its fill rune. Pass 0 for the Turbo Vision default (a light shade block).

func (*Background) Draw

func (b *Background) Draw(s *vio.Surface)

Draw fills the bounds with the desktop pattern in the desktop color.

type Desktop

type Desktop struct {
	*view.Group
	// contains filtered or unexported fields
}

Desktop is the Group that hosts windows. It owns a Background child that fills its bounds and stays behind every other child.

func NewDesktop

func NewDesktop(r vio.Rect) *Desktop

NewDesktop returns an empty desktop sized to r, with the standard dotted background already attached.

func (*Desktop) HandleEvent

func (d *Desktop) HandleEvent(e *event.Event)

HandleEvent intercepts F6 (cycle windows), Ctrl-F4 close commands and mouse-down focus changes, then defers to the standard Group dispatch.

type ModalView added in v0.2.0

type ModalView interface {
	view.Viewer
	Result() event.CommandID
}

ModalView is implemented by views ExecView can drive: each iteration the loop checks Result; a non-zero value ends the sub-loop and is returned. Dialog satisfies this interface.

Jump to

Keyboard shortcuts

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