Cairn · module

Cairn.Runtime.Step

lean/Cairn/Runtime/Step.lean

The interaction runtime: turns host events into the Actions an app's update sees.

step is two halves. route reads the event against the laid tree on screen and produces the new interaction state and a list of actions, each naming a control of that tree. step then hands the actions to app.update in order, re-runs view and layout, and repairs focus, hover and press against the new tree. The semantics are written out in docs/runtime.md.

Imports Cairn.App, Cairn.UI.Hit, Cairn.VList, Cairn.Layout.Core, Cairn.Runtime.World

Order

Structures 5

structure

Cairn.Runtime.Config

lean/Cairn/Runtime/Step.lean:22
Config : Type

What the runtime needs besides the app: text metrics and the layout function. Layout is a parameter so the runtime and its theorems don't depend on one implementation.

Fields
metrics : TextMetrics
layout : Laid
panelHeight : Int

A panel's height for its content at a width: the content's own (hug) height, measured with that width offered (so paragraphs wrap to it).

structure

Cairn.Runtime.State

lean/Cairn/Runtime/Step.lean:70
State (S : Type) : Type
Fields
app : S
ui : UI

Window size, hover, pressed control, focus, window focus. view reads this.

clicks : Nat

Click count of the pointerDown that started the current press.

pointer : Option Point

Last pointer position in the window, none after it leaves. Hover follows it.

scale : Nat

Backing scale × 100.

laid : Laid

The laid tree on screen: what the person sees and what hit testing reads.

effects : Array Effect

Effects produced by the most recent stepBytes batch; the frame carries them.

world : World

The clock, timers, pending requests and subscriptions (docs/effects.md).

subCmds : Array SubCmd

Subscription commands of the most recent stepBytes batch; the frame carries them.

surfaces : List Shown

What each of the app's surfaces shows, in the app's order.

seen : List ControlRef

The controls marked Control.appear that had a visible part at the last Event.frame (appearRefs): an appear move is delivered for those that have one now and aren't here.

structure

Cairn.Runtime.Scroller

lean/Cairn/Runtime/Step.lean:160
Scroller : Type

A scroll box whose offset the runtime owns, as laid.

Fields
rect : Rect

The box's rect, and what of it shows (rect ∩ clip).

visible : Rect
horiz : Bool

A row scrolls sideways; a column or a stack up and down.

viewport : Int

The box's length along its axis.

content : Int

The content's length along the axis, from the box's start unscrolled to the furthest child's end plus the end padding (just the padding with no children).

offset : Int

The offset the view laid it at (Style.scroll).

Instances

Inhabited

structure

Cairn.Runtime.LaidList

lean/Cairn/Runtime/Step.lean:561
LaidList : Type

A virtual list as laid: its ref, what the view laid it by, its rect and padding, the offset it was laid at, how far that offset can go, and its children.

Fields
info : VList.Info
rect : Rect
pad : Insets
offset : Int
limit : Int
kids : List Laid
structure

Cairn.Runtime.Ctx

lean/Cairn/Runtime/Step.lean:782
Ctx (S : Type) : Type

An event's progress through the app: its state, the world, the effects that go on the frame, and whether anything was delivered.

Fields
app : S
world : World
effs : List Effect
delivered : Bool

Inductive types 1

inductive

Cairn.Runtime.Shown

lean/Cairn/Runtime/Step.lean:31
Shown : Type

What one surface shows now (docs/surfaces.md). The window's content is the state's ui and laid; a panel's is laid out here at its width and its own height; a status item's is its description, which menuSelect is checked against.

Constructors
window (place : ClaimId) (title : String) (minSize : Size) : Shown

The window: its place, title and the smallest content size the app asks for (App.minSize).

panel (place : ClaimId) (shown : Option (PanelView × Size × Laid)) :
  Shown

A shown panel: its view, its size (its width, its content's height) and its layout.

status (place : ClaimId) (item : Option StatusItem) : Shown
bar (place : ClaimId) (items : List MenuItem) : Shown

The app's items in the menu bar (Surface.menuBar), which menuSelect is checked against.

Instances

Inhabited

Definitions 101

def

Cairn.Runtime.Shown.place

lean/Cairn/Runtime/Step.lean:45
place : Shown → ClaimId
def

Cairn.Runtime.Shown.windowPlace

lean/Cairn/Runtime/Step.lean:49
windowPlace : List Shown → Option ClaimId

The first window's place: where bare local events go.

def

Cairn.Runtime.Shown.statusOf

lean/Cairn/Runtime/Step.lean:55
statusOf (p : ClaimId) : List Shown → Option StatusItem

What status item p shows, if it is shown.

def

Cairn.Runtime.Shown.menuOf

lean/Cairn/Runtime/Step.lean:62
menuOf (p : ClaimId) : List Shown → Option (List MenuItem)

The menu a selection for place p is checked against, other than the window's: a shown status item's menu, or the menu bar's items.

def

Cairn.Runtime.fieldInfo

lean/Cairn/Runtime/Step.lean:97
fieldInfo (t : Target) : Option (TextStyle × FieldView × Point)

A field's font, view and text origin.

def

Cairn.Runtime.nearest

lean/Cairn/Runtime/Step.lean:103
nearest (offs : List Int) (x : Int) : Nat

The index of the offset nearest x; the earlier one on a tie.

def

Cairn.Runtime.nearest.go

lean/Cairn/Runtime/Step.lean:106
go (x : Int) : List Int → Nat → Option (Nat × Nat) → Option Nat
def

Cairn.Runtime.caretAt

lean/Cairn/Runtime/Step.lean:116
caretAt (m : TextMetrics) (t : Target) (p : Point) : Nat

The caret boundary a click at p lands on: the nearest entry of the field's caret offsets, measured from its textOrigin.

def

Cairn.Runtime.fieldLength

lean/Cairn/Runtime/Step.lean:121
fieldLength (t : Target) : Nat
def

Cairn.Runtime.editOps

lean/Cairn/Runtime/Step.lean:128
editOps (k : Key) (mods : Mods) : List TextOp

Editing keys on a focused field. Single-line fields: up and page up go home, down and page down go to the end.

def

Cairn.Runtime.replaceOps

lean/Cairn/Runtime/Step.lean:148
replaceOps (t : Target) : Option (Nat × Nat) → List TextOp

Select [a, b) (clamped to the text) before an insert or composition that replaces it.

def

Cairn.Runtime.Scroller.limit

lean/Cairn/Runtime/Step.lean:177
limit (sc : Scroller) : Int

The furthest an offset can go: max 0 (content − viewport).

def

Cairn.Runtime.mainStart

lean/Cairn/Runtime/Step.lean:179
mainStart (h : Bool) (q : Rect) : Int
def

Cairn.Runtime.mainLen

lean/Cairn/Runtime/Step.lean:180
mainLen (h : Bool) (q : Rect) : Int
def

Cairn.Runtime.contentLen

lean/Cairn/Runtime/Step.lean:184
contentLen (h : Bool) (r : Rect) (pad : Insets) (o : Int) (kids : List Laid) :
  Int

The content's length of a box laid at r and scrolled by o (Scroller.content): its children's rects are moved back by o, so their ends unscrolled are their ends plus o.

def

Cairn.Runtime.scrollerOf

lean/Cairn/Runtime/Step.lean:191
scrollerOf : Laid → Option Scroller

The scroller a laid node is, if it is a scroll box with a scrollRef.

def

Cairn.Runtime.scrollersOf

lean/Cairn/Runtime/Step.lean:203
scrollersOf : Laid → List Scroller

Every scroller in the tree, in paint order (an outer box before the boxes inside it).

def

Cairn.Runtime.scrollersList

lean/Cairn/Runtime/Step.lean:206
scrollersList : List Laid → List Scroller
def

Cairn.Runtime.around

lean/Cairn/Runtime/Step.lean:214
around (r : ControlRef) : Laid → Option (List Scroller)

The scrollers around the first control r in paint order, outermost first; none when r isn't in the tree.

def

Cairn.Runtime.aroundList

lean/Cairn/Runtime/Step.lean:220
aroundList (r : ControlRef) : List Laid → Option (List Scroller)
def

Cairn.Runtime.scrollerAt

lean/Cairn/Runtime/Step.lean:226
scrollerAt (laid : Laid) (p : Point) : Option Scroller

The topmost scroller whose visible part holds p: the innermost one there.

def

Cairn.Runtime.clampOff

lean/Cairn/Runtime/Step.lean:229
clampOff (o lim : Int) : Int
def

Cairn.Runtime.clampScroll

lean/Cairn/Runtime/Step.lean:232
clampScroll (scs : List Scroller) (offs : List (ControlRef × Int)) :
  List (ControlRef × Int)

The offsets of offs whose box is in the tree, each clamped to its box; the rest dropped.

def

Cairn.UI.setScroll

lean/Cairn/Runtime/Step.lean:238
setScroll (ui : UI) (r : ControlRef) (o : Int) : UI

Set box r's offset to o; the same UI when it already is o.

def

Cairn.UI.scrollTo

lean/Cairn/Runtime/Step.lean:243
scrollTo (ui : UI) (sc : Runtime.Scroller) (o : Int) : UI

Move sc to o, clamped.

def

Cairn.Runtime.lineStep

lean/Cairn/Runtime/Step.lean:247
lineStep : Int

How far an arrow key scrolls, in points.

def

Cairn.Runtime.Scroller.page

lean/Cairn/Runtime/Step.lean:250
page (sc : Scroller) : Int

How far a page key scrolls: the viewport less a line, so a line stays in view.

def

Cairn.Runtime.keyScroll

lean/Cairn/Runtime/Step.lean:255
keyScroll (sc : Scroller) (cur : Int) (k : Key) (mods : Mods) : Option Int

Where a key moves sc from cur, if it is a scroll key for it: page up and down, space and shift-space by a page; home and end to the ends; the arrows along its axis by a line (with command, to the ends).

def

Cairn.Runtime.revealOff

lean/Cairn/Runtime/Step.lean:273
revealOff (sc : Scroller) (cur : Int) (q : Rect) : Int

The offset that brings q (a rect laid with sc at cur) into sc's view: the least move that puts its start and end inside the box, its start when it is longer than the box.

def

Cairn.Runtime.revealIn

lean/Cairn/Runtime/Step.lean:281
revealIn (chain : List Scroller) (ui : UI) (q : Rect) : UI

Bring q into view in each of chain (outermost first), innermost first: each box moves it, then the next box out sees it moved.

def

Cairn.Runtime.appearRefs

lean/Cairn/Runtime/Step.lean:294
appearRefs (laid : Laid) : List ControlRef

The controls marked Control.appear with a visible part, in paint order.

def

Cairn.Runtime.appearing

lean/Cairn/Runtime/Step.lean:299
appearing (laid : Laid) (seen : List ControlRef) : List Action

The appear moves of a frame: one for each control in appearRefs laid not in seen.

def

Cairn.Runtime.menuOf

lean/Cairn/Runtime/Step.lean:305
menuOf (laid : Laid) (r : ControlRef) : Option ControlMenu

The menu of the first control r in the tree, if it has one with items.

def

Cairn.Runtime.Target.menuButton

lean/Cairn/Runtime/Step.lean:309
menuButton (t : Target) : Bool

Whether t is a menu button: a primary press, Space or Return opens its menu.

def

Cairn.Runtime.menuHitsOf

lean/Cairn/Runtime/Step.lean:315
menuHitsOf (o : Option Target) : Laid → List Hit

Hit entries in paint order, each owned by the nearest control at or above it that has a menu (o, inherited from the ancestors): what a secondary click opens.

def

Cairn.Runtime.menuHitsList

lean/Cairn/Runtime/Step.lean:323
menuHitsList (o : Option Target) : List Laid → List Hit
def

Cairn.Runtime.menuTarget

lean/Cairn/Runtime/Step.lean:330
menuTarget (laid : Laid) (p : Point) : Option Target

The control whose menu a secondary click at p opens: of the topmost hit entry containing p (as hitTarget), the nearest control at or above it with a menu.

def

Cairn.Runtime.openMenu

lean/Cairn/Runtime/Step.lean:338
openMenu {S : Type} (s : State S) : Option (ControlRef × ControlMenu)

The control menu open now: UI.menu's control and its menu, in the tree on screen.

def

Cairn.Runtime.selectMenu

lean/Cairn/Runtime/Step.lean:343
selectMenu {S : Type} (s : State S) (p : ClaimId) : Option (List MenuItem)

The menu a menuSelect p _ is checked against: with the window's place, the control menu open now (openMenu); otherwise status item p's menu or the menu bar p's items.

def

Cairn.Runtime.openAt

lean/Cairn/Runtime/Step.lean:348
openAt {S : Type} (s : State S) (r : ControlRef) : State S

Open control r's menu.

def

Cairn.Runtime.focused

lean/Cairn/Runtime/Step.lean:353
focused {S : Type} (s : State S) : Option Target

The focused control, looked up in the tree on screen.

def

Cairn.Runtime.leave

lean/Cairn/Runtime/Step.lean:356
leave {S : Type} (s : State S) (next : Option ControlRef) : List Action

Leaving a focused field for next blurs it.

def

Cairn.Runtime.onField

lean/Cairn/Runtime/Step.lean:362
onField {S : Type} (s : State S) (ops : Target → List TextOp) : List Action

Edits to the focused field, if a field is focused.

def

Cairn.Runtime.keyActions

lean/Cairn/Runtime/Step.lean:367
keyActions {S : Type} (s : State S) (k : Key) (mods : Mods) : List Action
def

Cairn.Runtime.textActions

lean/Cairn/Runtime/Step.lean:381
textActions {S : Type} (s : State S) (str : String)
  (rep : Option (Nat × Nat)) : List Action
def

Cairn.Runtime.tabOrder

lean/Cairn/Runtime/Step.lean:389
tabOrder (laid : Laid) : List Target

Focusable controls in paint order.

def

Cairn.Runtime.tabTarget

lean/Cairn/Runtime/Step.lean:393
tabTarget {S : Type} (s : State S) (back : Bool) : Option Target

The next focusable control after the focused one (or before it, going back), wrapping; the first (or last) when nothing is focused.

def

Cairn.Runtime.tab

lean/Cairn/Runtime/Step.lean:401
tab {S : Type} (s : State S) (back : Bool) : State S × List Action

Tab and shift-Tab: focus the next (or previous) focusable control, scrolling every scroll box around it so that it is in view.

def

Cairn.Runtime.wheel

lean/Cairn/Runtime/Step.lean:411
wheel {S : Type} (s : State S) (p : Point) (dx dy : Int) : State S

A wheel or trackpad scroll at p: moves the innermost scroll box there along its axis (dx in a row, dy otherwise; positive toward the end, trusted ^1012), clamped.

def

Cairn.Runtime.keyScroller

lean/Cairn/Runtime/Step.lean:419
keyScroller {S : Type} (s : State S) : Option Scroller

The scroll box the keys move: the innermost one around the focused control, else the one under the pointer.

def

Cairn.Runtime.keyScrollState

lean/Cairn/Runtime/Step.lean:425
keyScrollState {S : Type} (s : State S) (k : Key) (mods : Mods) : State S

A key that no control takes (nothing focused, or a focused control that isn't a field and doesn't press on it) scrolls keyScroller, if it is a scroll key for it.

def

Cairn.Runtime.withPointer

lean/Cairn/Runtime/Step.lean:435
withPointer {S : Type} (s : State S) (p : Point) : State S
def

Cairn.Runtime.keyMenu

lean/Cairn/Runtime/Step.lean:440
keyMenu {S : Type} (s : State S) (k : Key) : Option ControlRef

The control whose menu a key opens: the focused control, if it has a menu and the key is the context-menu key, or it is a menu button and the key is Return or Space.

def

Cairn.Runtime.secondaryDown

lean/Cairn/Runtime/Step.lean:449
secondaryDown {S : Type} (s : State S) (p : Point) : State S

A secondary click at p: hover follows it, and the menu of the control there that has one (menuTarget) opens; nothing else.

def

Cairn.Runtime.keyRoute

lean/Cairn/Runtime/Step.lean:456
keyRoute {S : Type} (s : State S) (k : Key) (mods : Mods) :
  State S × List Action

A key other than Tab: it opens the focused control's menu (keyMenu), or scrolls and acts as keyScrollState and keyActions say.

def

Cairn.Runtime.textRoute

lean/Cairn/Runtime/Step.lean:463
textRoute {S : Type} (s : State S) (str : String) (rep : Option (Nat × Nat)) :
  State S × List Action

Committed text: a space on a focused menu button opens its menu (as the Space key does); anything else is textActions.

def

Cairn.Runtime.route

lean/Cairn/Runtime/Step.lean:470
route {S : Type} (m : TextMetrics) (s : State S) :
  Event → State S × List Action

Read one event against the tree on screen. Returns the new interaction state (app and laid untouched) and the actions to deliver, in order.

def

Cairn.Runtime.UI.same

lean/Cairn/Runtime/Step.lean:539
same (a b : UI) : Bool

Structural equality on UI, decided field by field (the derived BEq isn't lawful).

def

Cairn.Runtime.listsOf

lean/Cairn/Runtime/Step.lean:572
listsOf : Laid → List LaidList

Every virtual list in the tree, in paint order.

def

Cairn.Runtime.listsList

lean/Cairn/Runtime/Step.lean:581
listsList : List Laid → List LaidList
def

Cairn.Runtime.recordLists

lean/Cairn/Runtime/Step.lean:588
recordLists (laid : Laid) : List (ControlRef × VList.Known × Int)

The runtime's record of every virtual list in laid: what is now known of it, and its corrected offset.

def

Cairn.Runtime.setOff

lean/Cairn/Runtime/Step.lean:594
setOff (offs : List (ControlRef × Int)) (r : ControlRef) (o : Int) :
  List (ControlRef × Int)

offs with box r at o; the same list when it already is (as UI.setScroll).

def

Cairn.Runtime.relayout

lean/Cairn/Runtime/Step.lean:600
relayout {S : Type} (app : App S) (cfg : Config) (st : S) (ui : UI) : Laid
def

Cairn.Runtime.onScreen

lean/Cairn/Runtime/Step.lean:604
onScreen (scs : List Scroller) (r : ControlRef) : Bool

Whether r is a scroll box of scs.

def

Cairn.Runtime.keepOff

lean/Cairn/Runtime/Step.lean:608
keepOff {α : Type} (on : ControlRef → Bool) (keep : List ControlRef)
  (now old : List (ControlRef × α)) : List (ControlRef × α)

The entries of xs for boxes kept and not on screen, the ones in now first: what a box the app keeps (App.keepScroll) had when it left (docs/runtime.md, "Scrolling").

def

Cairn.Runtime.revive

lean/Cairn/Runtime/Step.lean:616
revive (scs : List Scroller) (ui : UI) : List (ControlRef × Int)

The kept offsets of boxes back on screen with no offset of their own: they resume where they were.

def

Cairn.Runtime.fixUI

lean/Cairn/Runtime/Step.lean:624
fixUI (laid : Laid) (pointer : Option Point) (ui : UI)
  (keep : List ControlRef) : UI

Repair interaction state against a new tree: hover is what the pointer is over, focus and press survive only if their control does, and scroll offsets only if their box does, clamped to its content, or the app keeps it (keep, from App.keepScroll), when it is kept as it was. A kept box that is back resumes its kept offset. Virtual lists are recorded (recordLists) and their offsets corrected before the clamp.

def

Cairn.Runtime.settle

lean/Cairn/Runtime/Step.lean:641
settle {S : Type} (app : App S) (cfg : Config) (st : S)
  (pointer : Option Point) (ui0 : UI) : Nat → UI → UI × Laid

View and lay out, repair ui0 against the result, and repeat while the repair changes what the view saw (hover reveals, focus rings), up to fuel more times. The result is always ui0 repaired against the tree returned with it.

def

Cairn.Runtime.settleFuel

lean/Cairn/Runtime/Step.lean:651
settleFuel : Nat

How many times settle may re-run the view after the first layout.

def

Cairn.Runtime.unsettled

lean/Cairn/Runtime/Step.lean:656
unsettled (laid : Laid) : Bool

Whether a virtual list in laid laid a row at a height other than the one the view laid it out by: a row the runtime hadn't recorded yet, or had recorded at another height. A frame like that shows heights the list no longer has, and the next layout lays it differently.

def

Cairn.Runtime.rowFuel

lean/Cairn/Runtime/Step.lean:665
rowFuel (laid : Laid) : Nat

How many more layouts resettle may take after settle: the rows of the virtual lists in laid. A list learns heights one window at a time, so when many rows it knows change at once (a filter hiding many rows), each layout brings the next window of them in at their old heights; the rows in the list bound how many windows there are, where a fixed fuel doesn't.

def

Cairn.Runtime.resettle

lean/Cairn/Runtime/Step.lean:670
resettle {S : Type} (app : App S) (cfg : Config) (st : S)
  (pointer : Option Point) (ui0 : UI) : Nat → UI × Laid → UI × Laid

Lay the view out again (one settle round) while a virtual list in the tree just laid is unsettled, up to fuel more times. Other changes (hover reveals, focus rings) don't extend it: settle alone bounds those.

def

Cairn.Runtime.settleAll

lean/Cairn/Runtime/Step.lean:679
settleAll {S : Type} (app : App S) (cfg : Config) (st : S)
  (pointer : Option Point) (ui0 ui : UI) : UI × Laid

settle, then resettle while a virtual list is unsettled, bounded by its rows (rowFuel): what every step lays out by.

def

Cairn.Runtime.requestedScrolls

lean/Cairn/Runtime/Step.lean:687
requestedScrolls (effs : List Effect) : List (ControlRef × ScrollTarget)

The scroll requests in effs, in order.

def

Cairn.Runtime.aimOff

lean/Cairn/Runtime/Step.lean:694
aimOff (laid : Laid) (ui : UI) (r : ControlRef) (to : ScrollTarget) :
  Option Int

The offset to asks of the box r in the tree laid, clamped as every offset is: start is 0, finish the box's limit, and key k the top of the row with key k in the heights the runtime now knows (ui.listOf, which the next layout lays the list by). none when r is no scroll box on screen, or to is a key and r no virtual list with that key.

def

Cairn.Runtime.aimScroll

lean/Cairn/Runtime/Step.lean:712
aimScroll (goals : List (ControlRef × ScrollTarget)) (laid : Laid) (ui : UI) :
  UI

Set each requested box's offset, in order (the last request for a box wins).

def

Cairn.Runtime.aim

lean/Cairn/Runtime/Step.lean:722
aim {S : Type} (app : App S) (cfg : Config) (st : S) (pointer : Option Point)
  (ui1 : UI) (goals : List (ControlRef × ScrollTarget)) : Nat → UI × Laid → UI × Laid

Aim the requested boxes against the tree just laid and settle again, while that moves an offset, up to fuel times: a virtual list laid at a new offset learns the heights of the rows there, which can move its end or a row's top, so the next round aims at the corrected place. Each round repairs ui1 (the routed UI) with the aimed offsets and what the last round recorded, so focus, press and hover are repaired as settle repairs them.

def

Cairn.Runtime.aimFuel

lean/Cairn/Runtime/Step.lean:733
aimFuel : Nat

How many rounds aim may take.

def

Cairn.Runtime.lay

lean/Cairn/Runtime/Step.lean:736
lay {S : Type} (app : App S) (cfg : Config) (st : S) (pointer : Option Point)
  (goals : List (ControlRef × ScrollTarget)) (ui1 : UI) : UI × Laid

Settle ui1 against the app's view, then run the scroll requests goals (aim).

def

Cairn.Runtime.panelSize

lean/Cairn/Runtime/Step.lean:742
panelSize (cfg : Config) (v : PanelView) : Size

A shown panel's size: its width and its content's height at that width.

def

Cairn.Runtime.layPanel

lean/Cairn/Runtime/Step.lean:747
layPanel (cfg : Config) (v : PanelView) : Size × Laid

Lay out a shown panel at its size.

def

Cairn.Runtime.Surface.show

lean/Cairn/Runtime/Step.lean:752
show {S : Type} (cfg : Config) (st : S) (min : Size) :
  Surface S → Shown

What one surface shows in app state st; a window keeps the app's smallest size min.

def

Cairn.Runtime.shows

lean/Cairn/Runtime/Step.lean:759
shows {S : Type} (app : App S) (cfg : Config) (st : S) : List Shown

What every surface shows in app state st.

def

Cairn.Runtime.deliver

lean/Cairn/Runtime/Step.lean:763
deliver {S : Type} (update : S → Action → S × List Effect) (st : S)
  (acts : List Action) : S × List Effect

Run update over the actions in order, collecting effects.

def

Cairn.Runtime.requestedFocus

lean/Cairn/Runtime/Step.lean:768
requestedFocus (effs : List Effect) : Option ControlRef

The focus the effects ask for: the last Effect.focus, if any.

def

Cairn.Runtime.applyFocus

lean/Cairn/Runtime/Step.lean:773
applyFocus (effs : List Effect) (ui : UI) : UI

Run the focus requests in effs on a UI. settle then keeps the focus only if its control is focusable in the new tree.

def

Cairn.Runtime.give

lean/Cairn/Runtime/Step.lean:789
give {S : Type} (app : App S) (c : Ctx S) (m : Msg) : Ctx S

Deliver a message to receive and take in its effects.

def

Cairn.Runtime.hear

lean/Cairn/Runtime/Step.lean:795
hear {S : Type} (app : App S) (c : Ctx S) : Ctx S

Tell the app the time, if it hasn't heard the current one.

def

Cairn.Runtime.fire

lean/Cairn/Runtime/Step.lean:800
fire {S : Type} (app : App S) (c : Ctx S) (n : String) : Ctx S

Fire n if it is still set and due: it leaves the table, then is delivered.

def

Cairn.Runtime.boot

lean/Cairn/Runtime/Step.lean:804
boot {S : Type} (app : App S) (c : Ctx S) : Ctx S

On the first clock: the app hears the time, then initEffects run.

def

Cairn.Runtime.release

lean/Cairn/Runtime/Step.lean:812
release {S : Type} (c : Ctx S) (w : World) : Ctx S

A slot or an id has freed (w is the world after a reply was taken): send what the queue can, oldest first, onto the frame.

def

Cairn.Runtime.ack

lean/Cairn/Runtime/Step.lean:818
ack {S : Type} (c : Ctx S) (id : Nat) : Ctx S

The host's reply to a request cancelled after it was sent: no one hears it; it frees the slot and the id.

def

Cairn.Runtime.admit

lean/Cairn/Runtime/Step.lean:827
admit {S : Type} (app : App S) (s : State S) : Event → Ctx S

What the world events deliver: a clock event fires due timers, a reply is delivered if its id is pending and it answers that kind, and a subscription event if its id is active. Other events deliver nothing here (their actions come from route). A reply that frees a slot sends what was queued before the app hears it (docs/effects.md, "Requests in flight").

def

Cairn.Runtime.act

lean/Cairn/Runtime/Step.lean:851
act {S : Type} (app : App S) (c : Ctx S) (acts : List Action) : Ctx S

Deliver the routed actions to update (after the time, if the app hasn't heard it) and take in their effects, in order.

def

Cairn.Runtime.step

lean/Cairn/Runtime/Step.lean:859
step {S : Type} (app : App S) (cfg : Config) (s : State S) (e : Event) :
  State S × List Effect

One event.

def

Cairn.Runtime.frameEvents

lean/Cairn/Runtime/Step.lean:876
frameEvents : List Event

What steps runs after a batch's events: two frame events, so that what an appear move's own delivery brings into view is heard in the same batch (docs/runtime.md, "Appear").

def

Cairn.UI.letGo

lean/Cairn/Runtime/Step.lean:882
letGo (ui : UI) : UI

What the runtime knows once a frame is shown: every virtual list's held anchor let go (VList.Known.letGo), so each list keeps its rows where this frame shows them. Within a batch the reader sees none of the frames between, so an anchor the clamp moved is held at the place the reader last saw it until then (VList.anchorAt).

def

Cairn.Runtime.State.shown

lean/Cairn/Runtime/Step.lean:887
shown {S : Type} (s : State S) : State S

A state whose frame has been shown (UI.letGo).

def

Cairn.Runtime.steps

lean/Cairn/Runtime/Step.lean:890
steps {S : Type} (app : App S) (cfg : Config) (s : State S)
  (es : List Event) : State S × List Effect

A batch of events, in order, then frameEvents; then the frame is shown (State.shown).

def

Cairn.Runtime.start

lean/Cairn/Runtime/Step.lean:897
start {S : Type} (app : App S) (cfg : Config) (size : Size)
  (scale : Nat := 100) : State S

The first state: the app's init at a window size, laid out, with the app's initFocus if that control is focusable.

def

Cairn.Runtime.cursor

lean/Cairn/Runtime/Step.lean:904
cursor {S : Type} (s : State S) : Cursor

The cursor the host shows: text over fields, a pointing hand over other controls.

Theorems 1

theorem

Cairn.Runtime.UI.same_eq

provedlean/Cairn/Runtime/Step.lean:545
same_eq {a b : UI} (h : same a b = true) : a = b

Instances 2

instance

Cairn.Runtime.instInhabitedShown

lean/Cairn/Runtime/Step.lean:41
instInhabitedShown : Inhabited Shown
instance

Cairn.Runtime.instInhabitedScroller

lean/Cairn/Runtime/Step.lean:174
instInhabitedScroller : Inhabited Scroller