hitmap

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 2 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 hitmap is pure geometry: it maps a screen (row, col) to a Hit zone using the rectangles a layout publishes. It operates on integers and zone names only.

Go port of Ruby's lib/tui/hit_map.rb.

Index

Constants

This section is empty.

Variables

View Source
var Outside = Hit{Zone: ZoneOutside}

Outside is the never-nil answer for coordinates off the frame.

Functions

This section is empty.

Types

type FooterPayload

type FooterPayload struct {
	Index int
	Role  FooterRole
}

FooterPayload is the payload a footer hit carries.

type FooterRole

type FooterRole string

FooterRole classifies a footer line for routing purposes.

const (
	RoleChrome   FooterRole = "chrome"
	RoleResponse FooterRole = "response"
	RolePrompt   FooterRole = "prompt"
)

type Hit

type Hit struct {
	Zone   Zone
	Index  int
	Tab    string
	Footer FooterPayload
}

Hit is one resolved zone. Index carries the row/line payload for list, modal, popup and footer zones; Tab carries the tab key; Footer carries the footer index and role.

type HitMap

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

HitMap answers zone queries for one sampled frame.

func Build

func Build(opts Options) *HitMap

Build constructs a hit map.

func (*HitMap) At

func (m *HitMap) At(row, col int) Hit

At resolves a screen coordinate. It never fails: unknown coordinates are ZoneOutside.

type MarkerSpan

type MarkerSpan struct{ Start, End int }

MarkerSpan is the half-open column range of a row's collapse marker, measured inside the row text (after the two-cell cursor prefix).

type Options

type Options struct {
	Layout      *layout.Layout
	TabSpans    []TabSpan
	RowCount    int
	Modal       *layout.Modal
	Popup       *layout.Popup
	Panel       bool
	MarkerSpans map[int]MarkerSpan
	FooterRoles []FooterRole
}

Options builds a HitMap.

type TabSpan

type TabSpan struct {
	Key        string
	Start, End int
}

TabSpan is one clickable tab: a key and the half-open column range it paints.

type Zone

type Zone string

Zone names a clickable region of the frame.

const (
	ZoneOutside        Zone = "outside"
	ZoneBorder         Zone = "border"
	ZoneHeader         Zone = "header"
	ZoneTab            Zone = "tab"
	ZoneListRow        Zone = "list_row"
	ZoneCollapseMarker Zone = "collapse_marker"
	ZonePanel          Zone = "panel"
	ZonePanelDivider   Zone = "panel_divider"
	ZoneFooterRow      Zone = "footer_row"
	ZoneModalRow       Zone = "modal_row"
	ZonePopupRow       Zone = "popup_row"
)

Jump to

Keyboard shortcuts

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