Cairn · module

Cairn.Surface

lean/Cairn/Surface.lean

What an app shows besides a window (docs/surfaces.md): a menu bar status item with its native menu, and a non-activating, click-through overlay panel, both as data. Cairn.App collects an app's surfaces; the runtime keeps what each one shows (Cairn.Runtime.Shown) and the frame carries it (docs/frame.md, surface records).

The menu is a description, not a laid tree: the host builds a real NSMenu from it, and every actionable item is a Control naming a move, so presence, enablement and checkmarks are facts about this value (refs, enabledOf, checkedOf) with no layout in between.

MenuItem is a nested inductive, so every function over it is a structural pair (f on one item, fs on a list), per AGENTS.md.

Imports Cairn.UI.Node, Cairn.Input

Order

Structures 2

structure

Cairn.StatusItem

lean/Cairn/Surface.lean:125
StatusItem : Type

A menu bar status item and its menu.

Fields
symbol : String

An SF Symbol name, drawn as a template image so it follows the menu bar's appearance.

title : String

Optional text beside the symbol.

label : String

What VoiceOver says for the button.

control : ControlRef

Opening the menu is a press on this control.

menu : List MenuItem
Instances

Inhabited Repr

structure

Cairn.PanelView

lean/Cairn/Surface.lean:157
PanelView : Type

What a shown panel holds. The panel's window behaviour (never key, click-through, on every Space) is fixed by the host, not chosen here (docs/surfaces.md, docs/trusted.md).

Fields
width : Nat

Width in points; the height is the laid-out content's.

anchor : Anchor
screen : ScreenChoice
content : Node
Instances

Repr Inhabited

Inductive types 2

inductive

Cairn.Anchor

lean/Cairn/Surface.lean:138
Anchor : Type

Where the host puts a panel on its screen.

Constructors
bottomCenter (offset : Nat) : Anchor

Horizontally centred, offset points above the bottom of the screen's visible frame (above the Dock).

Instances

Inhabited Repr

inductive

Cairn.ScreenChoice

lean/Cairn/Surface.lean:149
ScreenChoice : Type

Which screen a panel is shown on.

Constructors
pointer : ScreenChoice

The screen the pointer is on when the panel is shown; it stays there until hidden.

Instances

Inhabited Repr

Definitions 11

def

Cairn.MenuItem.button

lean/Cairn/Surface.lean:25
button (r : ControlRef) (label : String) (enabled : Bool := true)
  (shortcut : Option Shortcut := none) : MenuItem

A plain item for r.

def

Cairn.MenuItem.check

lean/Cairn/Surface.lean:30
check (r : ControlRef) (label : String) (on : Bool)
  (enabled : Bool := true) : MenuItem

A checkbox item for r, ticked when on.

def

Cairn.MenuItem.refsOf

lean/Cairn/Surface.lean:35
refsOf : MenuItem → List ControlRef

The refs of an item's actionable items, depth first, in menu order.

def

Cairn.MenuItem.refs

lean/Cairn/Surface.lean:41
refs : List MenuItem → List ControlRef

The refs of every actionable item in a menu, depth first, in menu order.

def

Cairn.MenuItem.enabledRefsOf

lean/Cairn/Surface.lean:48
enabledRefsOf : MenuItem → List ControlRef

The refs of an item's enabled actionable items.

def

Cairn.MenuItem.enabledRefs

lean/Cairn/Surface.lean:55
enabledRefs : List MenuItem → List ControlRef

The refs of every enabled actionable item in a menu, in any submenu: what a selection may press (Cairn.Runtime.route, menuSelect).

def

Cairn.MenuItem.findOf

lean/Cairn/Surface.lean:62
findOf (r : ControlRef) : MenuItem → Option (Control × Bool)

The first actionable item with ref r in an item: its control and whether it is enabled.

def

Cairn.MenuItem.find

lean/Cairn/Surface.lean:68
find (r : ControlRef) : List MenuItem → Option (Control × Bool)

The first actionable item with ref r in a menu.

def

Cairn.MenuItem.enabledOf

lean/Cairn/Surface.lean:77
enabledOf (items : List MenuItem) (r : ControlRef) : Option Bool

Whether the item for r is enabled; none when the menu has no item for r.

def

Cairn.MenuItem.checkedOf

lean/Cairn/Surface.lean:80
checkedOf (items : List MenuItem) (r : ControlRef) : Option (Option Bool)

The item for r's checkmark (some none: not a checkbox); none when there is no item.

def

Cairn.Anchor.offset

lean/Cairn/Surface.lean:145
offset : Anchor → Nat

The anchor's distance in points.

Theorems 5

theorem

Cairn.MenuItem.enabledRefsOf_sub

provedlean/Cairn/Surface.lean:84
enabledRefsOf_sub (m : MenuItem) (r : ControlRef) :
  r ∈ m.enabledRefsOf → r ∈ m.refsOf
theorem

Cairn.MenuItem.enabledRefs_sub

provedlean/Cairn/Surface.lean:96
enabledRefs_sub (ms : List MenuItem) (r : ControlRef) :
  r ∈ enabledRefs ms → r ∈ refs ms
theorem

Cairn.MenuItem.refs_append

provedlean/Cairn/Surface.lean:107
refs_append (xs ys : List MenuItem) : refs (xs ++ ys) = refs xs ++ refs ys
theorem

Cairn.MenuItem.enabledRefs_append

provedlean/Cairn/Surface.lean:112
enabledRefs_append (xs ys : List MenuItem) :
  enabledRefs (xs ++ ys) = enabledRefs xs ++ enabledRefs ys
theorem

Cairn.MenuItem.mem_refs_of_enabled

provedlean/Cairn/Surface.lean:119
mem_refs_of_enabled {ms : List MenuItem} {r : ControlRef}
  (h : r ∈ enabledRefs ms) : r ∈ refs ms

An enabled item is an item.

Instances 10

instance

Cairn.instInhabitedStatusItem

lean/Cairn/Surface.lean:135
instInhabitedStatusItem : Inhabited StatusItem
instance

Cairn.instReprStatusItem

lean/Cairn/Surface.lean:135
instReprStatusItem : Repr StatusItem
instance

Cairn.instInhabitedAnchor

lean/Cairn/Surface.lean:142
instInhabitedAnchor : Inhabited Anchor
instance

Cairn.instDecidableEqAnchor

lean/Cairn/Surface.lean:142
instDecidableEqAnchor : DecidableEq Anchor
instance

Cairn.instReprAnchor

lean/Cairn/Surface.lean:142
instReprAnchor : Repr Anchor
instance

Cairn.instDecidableEqScreenChoice

lean/Cairn/Surface.lean:153
instDecidableEqScreenChoice : DecidableEq ScreenChoice
instance

Cairn.instInhabitedScreenChoice

lean/Cairn/Surface.lean:153
instInhabitedScreenChoice : Inhabited ScreenChoice
instance

Cairn.instReprScreenChoice

lean/Cairn/Surface.lean:153
instReprScreenChoice : Repr ScreenChoice
instance

Cairn.instReprPanelView

lean/Cairn/Surface.lean:163
instReprPanelView : Repr PanelView
instance

Cairn.instInhabitedPanelView

lean/Cairn/Surface.lean:163
instInhabitedPanelView : Inhabited PanelView