init { screenTemplates := { "000": { "widgets": { "001": {"type": "textInput", "text": "", "state": 0, "visible": true}, "002": {"type": "table", "text": "testTeble", "state": 0, "visible": true, "data": {"_": {"name": "_", "age": 0}}, "rowHeight": 40, "colWidth": 100, "columns": append(append(nil, "name"), "age"), "primaryKeyName": "id", } }, "layout": true } } screen1 := "000" w002 := "002" } native channel ScreenUpdate { in screen(curSc: Json, update(curSc, nextSc)) = nextSc } native channel SetLayout { in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout } native channel SetVisible(wid: Str) { in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible } native channel SetText(wid: Str) { in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText } native channel SetX(wid: Str) { in screen.widgets.{wid}.x(curX: Int, setX(nextX)) = nextX } native channel SetY(wid: Str) { in screen.widgets.{wid}.y(curY: Int, setY(nextY)) = nextY } native channel SetWidth(wid: Str) { in screen.widgets.{wid}.width(curWidth: Int, setWidth(nextWidth)) = nextWidth } native channel SetHeight(wid: Str) { in screen.widgets.{wid}.height(curHeight: Int, setHeight(nextHeight)) = nextHeight } native channel MouseEvent(wid: Str) { out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState } native channel OnTableChanged(wid: Str) { in screen.widgets.{wid}.data(curData: Map, tableChanged(nextData)) = nextData } native channel TextEvent(wid: Str) { out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText } channel ChangeCurScreen { out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId } channel ScreenTransition { in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen)) out screen(curS, transScreen(nextScId, screen)) = screen } channel EventDispatch(wid: Str) { in screen.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState ref curScreen(curScId: Str, dispatchEvent(curScId, wid, nextState)) out screenTemplates.{curScId}.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState } channel EventHandler1(scId: Str, wid: Str) { in screenTemplates.{scId="000"}.widgets.{wid="002"}.state(curState: Int, handleEvent1(nextState)) = nextState out curScreen(curScId: Str, handleEvent1(nextState)) = if(nextState == 0, "001", curScId) } channel EventHandler2(scId: Str, wid: Str) { in screenTemplates.{scId="001"}.widgets.{wid="004"}.state(curState: Int, handleEvent2(nextState)) = nextState out curScreen(curScId: Str, handleEvent2(nextState)) = if(nextState == 0, "000", curScId) } channel EventHandler3(curScId: Str, wid: Str) { in screenTemplates.{curScId="000"}.widgets.{wid="002"}.data(curData: Map, handleEvent3(nextData, wid)) = nextData out screen.widgets.{wid}.data(curData: Map, handleEvent3(nextData, wid)) = nextData } channel addAccount { out accounts(accounts: Map, addAccount(id: Str, name: Str, age: Int)) = insert(accounts, id, {"name": name, "age": age}) } channel changeNameOfAccount(id: Str) { out accounts.{id}.name(curName: Str, changeName(nextName: Str)) = nextName } channel changeNameOfAccount(id: Str) { out accounts.{id}.age(curAge: Int, changeAge(nextAge: Int)) = nextAge } channel sendAccountToTable { in accounts(cur: Map, sendAccount(next: Map, scId:Str, wid:Str)) = next ref screen1(scId:Str, sendAccount(next, scId, wid)) ref w002(wid: Str, sendAccount(next, scId, wid)) out screenTemplates.{scId}.widgets.{wid}.data(cur: Map, sendAccount(next, scId, wid)) = next }