menu

package
v0.1.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: 3 Imported by: 0

Documentation

Overview

Package menu implements vigo's top-of-screen menu bar and bottom-of-screen status line. v0.1 paints the bars with a fixed list of items; activation and pull-down menus arrive in v0.2.

Index

Constants

This section is empty.

Variables

View Source
var DefaultHints = []Hint{
	{Key: "F1", Action: "Help", Cmd: event.CmdHelp},
	{Key: "F10", Action: "Menu", Cmd: event.CmdMenu},
	{Key: "Alt-X", Action: "Exit", Cmd: event.CmdQuit},
}

DefaultHints is the v0.1 status line: F1 Help, F10 Menu, Alt-X Exit.

View Source
var DefaultItems = []Item{
	{Title: "≡", Hotkey: -1},
	{Title: "File", Hotkey: 0},
	{Title: "Edit", Hotkey: 0},
	{Title: "Search", Hotkey: 0},
	{Title: "Run", Hotkey: 0},
	{Title: "Compile", Hotkey: 0},
	{Title: "Debug", Hotkey: 0},
	{Title: "Project", Hotkey: 0},
	{Title: "Options", Hotkey: 0},
	{Title: "Window", Hotkey: 0},
	{Title: "Help", Hotkey: 0},
}

DefaultItems is the Turbo Vision IDE menu list: the system menu marker, followed by the nine top-level menus.

Functions

This section is empty.

Types

type Bar

type Bar struct {
	*view.View

	Items []Item
}

Bar is the horizontal strip of menu titles painted at the top of the screen. v0.1 only renders it; clicking and pull-downs come in v0.2.

func NewBar

func NewBar(w int, items []Item) *Bar

NewBar returns a one-row menu bar pinned to the top of an owner of width w, populated with the supplied items. Pass DefaultItems for the IDE list.

func (*Bar) Draw

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

Draw paints the bar background and each item separated by spaces. The hotkey character is drawn in the menu-shortcut palette color.

func (*Bar) HandleEvent

func (b *Bar) HandleEvent(e *event.Event)

HandleEvent is a no-op for v0.1.

type Hint

type Hint struct {
	Key    string
	Action string
	Cmd    event.CommandID
}

Hint is a single label on the status line: a key indicator (e.g. "F1") and the action it triggers ("Help"). The Cmd field is the command broadcast when the key is pressed; v0.1 paints the labels but does not fire commands yet (that ships with menu activation in v0.2).

type Item

type Item struct {
	Title  string
	Hotkey int
}

Item is a single label on the menu bar. Hotkey is the index of the highlighted character within Title, or -1 for none.

type Line

type Line struct {
	*view.View

	Hints []Hint
}

Line is the one-row status bar pinned to the bottom of the screen.

func NewLine

func NewLine(w, y int, hints []Hint) *Line

NewLine returns a status line of width w, anchored at row y, with the supplied hints. Pass DefaultHints for the IDE defaults.

func (*Line) Draw

func (l *Line) Draw(s *vio.Surface)

Draw paints the bar background and each hint as "<key> <action>".

func (*Line) HandleEvent

func (l *Line) HandleEvent(e *event.Event)

HandleEvent is a no-op for v0.1; the demo binary handles Alt-X directly.

Jump to

Keyboard shortcuts

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