DIRECTORY Atom USING [GetPName], Interminal USING [KeyName], IO USING [CreateViewerStreams, PutBlock, PutChar, Handle], TIPPrivate, TIPUser, TIPTables; TIPTableWriter: CEDAR PROGRAM IMPORTS IO, Atom, TIPUser EXPORTS TIPPrivate = BEGIN OPEN TIPPrivate, TIPTables, TIPUser; debug: BOOLEAN _ FALSE; debugStream: IO.Handle; WriteTIPTable: PUBLIC PROC [table: TIPTable, keyOption: KeyOption, s: IO.Handle] = { Char: PROC [c: CHAR] = { IO.PutChar[s,c]; IF debug THEN IO.PutChar[debugStream,c] }; String: PROC [str: REF READONLY TEXT] = { IO.PutBlock[s,str]; IF debug THEN IO.PutBlock[debugStream,str] }; Text: PROC [txt: REF READONLY TEXT] = { IF txt.length > 255 THEN ERROR; Char[LOOPHOLE[txt.length]]; String[txt] }; Flag: PROC [flag: BOOLEAN] = { Char[IF flag THEN 'T ELSE 'F] }; Key: PROC [k:Interminal.KeyName] = { Char[LOOPHOLE[k]] }; Int: PROC [x: INT] = { Bytes: TYPE = MACHINE DEPENDENT RECORD [ byte0(0:0..7), byte1(0:8..15), byte2(1:0..7), byte3(1:8..15): [0..255] _ 0]; b: Bytes _ LOOPHOLE[x]; Char[LOOPHOLE[b.byte0]]; Char[LOOPHOLE[b.byte1]]; Char[LOOPHOLE[b.byte2]]; Char[LOOPHOLE[b.byte3]] }; ChoiceItem: PROC [k:Interminal.KeyName, c: TIPChoice] = { IF c=NIL THEN RETURN; Char['(]; Key[k]; Choice[c]; Char[')] }; ChoiceSeries: PROC [cs: TIPChoiceSeries] = { Char['(]; FOR x: TIPChoiceSeries _ cs, x.rest UNTIL x=NIL DO Choice[x.first]; ENDLOOP; Char[')] }; Choice: PROC [c: TIPChoice] = { Char['(]; FOR x: TIPChoice _ c, x.rest UNTIL x=NIL DO Term[x.first]; ENDLOOP; Char[')] }; KeyState: PROC [keyState: TIPKeyState] = { Key[keyState.key]; Char[SELECT keyState.state FROM up => 'U, down => 'D, ENDCASE => ERROR] }; Term: PROC [t: TIPTerm] = TRUSTED { WITH x:t SELECT FROM keyTrigger => { Char['1]; Key[x.keyState.key]; Char[SELECT x.keyState.state FROM up => 'U, down => 'D, ENDCASE => ERROR] }; mouseTrigger => Char['2]; timeTrigger => { Char['3]; Char[SELECT x.flavor FROM gt => 'G, lt => 'L, ENDCASE => ERROR]; Char[LOOPHOLE[x.mSecs / 256]]; Char[LOOPHOLE[x.mSecs MOD 256]] }; keyEnable => { Char['4]; KeyState[x.keyState] }; predEnable => { Char['5]; Text[LOOPHOLE[Atom.GetPName[x.predicate]]] }; char => Char['6]; coords => Char['7]; nested => { Char['8]; ChoiceSeries[x.statement] }; result => { Char['9]; Results[x.list] }; key2Enable => { Char['A]; KeyState[x.keyState1]; KeyState[x.keyState2] }; keyEnableList => { Char['B]; Char['(]; FOR lst: LIST OF TIPKeyState _ x.lst, lst.rest UNTIL lst=NIL DO KeyState[lst.first]; ENDLOOP; Char[')] }; time => Char['C]; ENDCASE => ERROR; }; Results: PROC [c: TIPResults] = { Char['(]; FOR x: TIPResults _ c, x.rest UNTIL x=NIL DO Result[x.first]; ENDLOOP; Char[')] }; Result: PROC [r: REF ANY] = TRUSTED { IF r=stdCoords THEN Char['5] ELSE IF r=stdChar THEN Char['2] ELSE IF r=stdTime THEN Char['6] ELSE WITH r SELECT FROM x: ATOM => { Char['1]; Text[LOOPHOLE[Atom.GetPName[x]]] }; x: REF INT => { Char['3]; Int[x^] }; x: REF TEXT => { Char['4]; Text[x] }; ENDCASE => ERROR }; IF debug THEN debugStream _ IO.CreateViewerStreams["TIPTableWriterDebugLog"].out; String["TIPTABLE"]; Char[version]; Flag[table.opaque]; Char[SELECT keyOption FROM none => 'N, printKeys => 'P, defaultKeys => 'D, ENDCASE => ERROR]; Flag[table.ignore.up]; Flag[table.ignore.down]; Flag[table.ignore.move]; TRUSTED { WITH x:table SELECT FROM small => { Char['S]; ChoiceSeries[x.all] }; fast => { Char['F]; Choice[x.mouse]; Char['U]; Char['(]; FOR k:Interminal.KeyName IN Interminal.KeyName DO ChoiceItem[k,x.keyUp[k]]; ENDLOOP; Char[')]; Char['D]; Char['(]; FOR k:Interminal.KeyName IN Interminal.KeyName DO ChoiceItem[k,x.keyDown[k]]; ENDLOOP; Char[')]; Choice[x.time] }; ENDCASE => ERROR}; }; END. „TIPTableWriter.mesa; Last Edited by McGregor, September 10, 1982 10:16 am Last Edited by: Maxwell, January 3, 1983 11:36 am ΚH– "Mesa" style˜JšΟcJ™JJ™1J˜šΟk ˜ Jšœžœ ˜Jšœ žœ ˜Jšžœžœ2˜:J˜ J˜J˜ J˜—Jšœž ˜˜Jšžœžœ˜Jšžœ˜J˜—šžœ˜Jšžœ ˜$J˜—Jšœžœžœ˜Jšœ žœ˜J˜šΟn œžœžœ,žœ ˜TšŸœžœžœ˜Jšžœ˜Jšžœžœžœ˜*—š Ÿœžœžœžœžœ˜)Jšžœ˜Jšžœžœžœ˜-—š Ÿœžœžœžœžœ˜'Jšžœžœžœ˜Jšœžœ˜J˜—Jš Ÿœžœžœ žœžœžœ˜?JšŸœžœ!žœ˜9šŸœžœžœ˜š œžœžœž œžœ˜(J˜J˜-—Jšœ žœ˜Jšœžœ ˜Jšœžœ ˜Jšœžœ ˜Jšœžœ ˜—šŸ œžœ)˜9Jšžœžœžœžœ˜J˜(—šŸ œžœ˜,J˜ šžœ!žœžœž˜2Jšœžœ˜—J˜ —šŸœžœ˜J˜ šžœžœžœž˜+Jšœžœ˜—J˜ —šŸœžœ˜*J˜šœžœž˜Jšœžœžœ˜*——šŸœžœžœ˜#Jšžœžœž˜˜J˜ J˜šœžœž˜!Jšœžœžœ˜*——J˜˜J˜ Jš œžœ žœžœžœ˜@Jšœžœ˜Jšœžœ žœ ˜"—J˜3Jšœ!žœ ˜IJ˜J˜J˜8J˜-J˜L˜J˜š žœžœžœžœžœž˜?Jšœžœ˜—J˜ —J˜Jšžœ žœ˜J˜—šŸœžœ˜!J˜ šžœžœžœž˜,Jšœžœ˜—J˜ —š Ÿœžœžœžœžœ˜%Jšžœ žœ ˜Jšžœžœ žœ ˜Jšžœžœ žœ ˜Jšžœžœžœž˜Jšœžœžœ˜:Jšœžœžœ˜$Jšœžœžœ˜%Jšžœžœ˜J˜—Jšžœžœžœ3˜QJ˜J˜J˜šœžœ ž˜Jšœ0žœžœ˜B—J˜J˜J˜Jšžœ˜ Jšžœ žœž˜J˜+˜ J˜ J˜J˜ J˜ šžœžœž˜1Jšœžœ˜"—J˜ J˜ J˜ šžœžœž˜1Jšœžœ˜$—J˜ J˜—Jšžœžœ˜J˜J˜—Jšžœ˜J˜J˜—…—l8