Cairn.Frame.Menu
lean/Cairn/Frame/Menu.lean
Frame.ofMenu: a status item's menu description becomes the flat list of menu records the
frame carries (docs/frame.md, "Menu records"), parents before children, as the accessibility
list is.
Theorems: controls_ofMenu (the records' controls are exactly the description's actionable
items, in order: what the host's NSMenu is built from is what the presence and enablement
proofs are about), enabled_ofMenu (likewise for the enabled ones) and parent_lt_ofMenu
(every parent index points at an earlier record, and at a submenu).
Imports Cairn.Frame
Definitions 9
ofMenu (items : List MenuItem) : Array MenuRecord
A menu description, flattened.
ofStatus (it : StatusItem) : StatusFrame
What a status item puts on the frame.
ctl (r : MenuRecord) : Option ControlRef
The control of an actionable record.
enabledCtl (r : MenuRecord) : Option ControlRef
The control of an enabled actionable record.
MenuParentsOk (ms : Array MenuRecord) : Prop
Every record's parent is an earlier record, and a submenu.
MenuParentBelow (ms : Array MenuRecord) (parent : Option Nat) : Prop
Theorems 14
controls_ofMenu (items : List MenuItem) : List.filterMap MenuRecord.ctl (ofMenu items).toList = MenuItem.refs items
The menu on the frame is the menu described. The controls of the frame's menu records are exactly the description's actionable items, in order.
enabled_ofMenu (items : List MenuItem) : List.filterMap MenuRecord.enabledCtl (ofMenu items).toList = MenuItem.enabledRefs items
The enabled records' controls are exactly the description's enabled items: what the host
greys out is what Lean will refuse (Runtime.menu_select_stale).
push {ms : Array MenuRecord} {parent : Option Nat}
(h : MenuParentBelow ms parent) (x : MenuRecord) : MenuParentBelow (ms.push x) parent
push {ms : Array MenuRecord} {x : MenuRecord}
(h : MenuParentsOk ms) (hx : MenuParentBelow ms x.parent) : MenuParentsOk (ms.push x)
mono {ms ms' : Array MenuRecord} {parent : Option Nat}
(h : MenuParentBelow ms parent) (hs : ms.size ≤ ms'.size)
(he : ∀ (i : Nat) (hi : i < ms.size), ms'[i] = ms[i]) : MenuParentBelow ms' parent
parent_lt_ofMenu (items : List MenuItem) : MenuParentsOk (ofMenu items)
Parents first. Every menu record's parent is an earlier record and a submenu, so the
host builds the NSMenu tree in one pass.