<> <> <> DIRECTORY CD, CDIO, CDOrient, CDImports, Parquet, Rope, TerminalIO; MGLabelWriter: CEDAR PROGRAM IMPORTS CDIO, CDImports, Parquet, Rope, TerminalIO = BEGIN cellName: Rope.ROPE; CellRef: TYPE = REF CellRec; CellRec: TYPE = RECORD[ name: Rope.ROPE _ "ASTERISK", tile: Parquet.Tile _ NIL, inTileSet: BOOLEAN _ TRUE ]; cellArray: ARRAY CHAR OF CellRef _ ALL[NEW[CellRec]] ; WriteLabelCommand: Parquet.ModuleGeneratorProc = <> BEGIN module: Parquet.Module; pc, startOfLine: Parquet.PlacedTile; objectName: Rope.ROPE; label: Rope.ROPE ; ch: CHAR; length: INT; [module: module, pc: pc] _ Parquet.NewModule[context]; <<>> <> { fontDesign: CD.Design; import: REF CDImports.Import _ NIL; fileName: Rope.ROPE _ TerminalIO.RequestRope["Input font file -> "]; importeeName: Rope.ROPE; TerminalIO.WriteRope["Reading font file\n"]; fontDesign _ CDIO.ReadDesign[from: fileName]; IF fontDesign = NIL THEN { TerminalIO.WriteRope["Could not find font file.\n"]; RETURN[NIL]; }; importeeName _ fontDesign.name; IF fontDesign.technology # context.eventualOwner.technology THEN { TerminalIO.WriteRope["Font is not of appropriate technology\n"]; RETURN[NIL]; }; TerminalIO.WriteRope["Importing font file\n"]; import _ CDImports.GetImport[design: context.eventualOwner, importeeName: importeeName, createIfNotFound: false]; IF import=NIL OR import.importee=NIL THEN { done: BOOL; done _ CDImports.DoImport[design: context.eventualOwner, importee: fontDesign, allowConflicts: interactive]; import _ CDImports.GetImport[design: context.eventualOwner, importeeName: importeeName, createIfNotFound: false] }; IF import=NIL OR import.importee=NIL THEN { TerminalIO.WriteRope["Had trouble reading the font file.\n"]; RETURN[NIL]; }; context.tiles _ import.importee; }; <<>> <> label _ TerminalIO.RequestRope[" Input label -> "]; length _ Rope.Length[label]; <> FOR i: INT _ 0, i+1 WHILE i < length DO ch _ Rope.Fetch[label, i]; objectName _ cellArray[ch].name; IF (cellArray[ch].tile = NIL) AND (cellArray[ch].inTileSet) THEN { cellArray[ch].tile _ Parquet.InstantiateTile[context: context, cellName: objectName]; IF cellArray[ch].tile = NIL THEN cellArray[ch].inTileSet _ FALSE; }; IF cellArray[ch].inTileSet THEN { pc _ Parquet.AdjacentTile[oldTile: pc, newTile: cellArray[ch].tile, dir: $rightOf]; IF i = 0 THEN startOfLine _ pc; } ELSE { TerminalIO.WriteRope[cellArray[ch].name]; TerminalIO.WriteRope[" not in tile set\n"]; }; ENDLOOP; <<>> DO label _ TerminalIO.RequestRope[" Input another label -> "]; length _ Rope.Length[label]; IF length = 0 THEN RETURN [module]; FOR i: INT _ 0, i+1 WHILE i < length DO ch _ Rope.Fetch[label, i]; objectName _ cellArray[ch].name; IF (cellArray[ch].tile = NIL) AND (cellArray[ch].inTileSet) THEN { cellArray[ch].tile _ Parquet.InstantiateTile[context: context, cellName: objectName]; IF cellArray[ch].tile = NIL THEN cellArray[ch].inTileSet _ FALSE; }; IF cellArray[ch].inTileSet AND i = 0 THEN { pc _ Parquet.AdjacentTile[oldTile: startOfLine, newTile: cellArray[ch].tile, dir: $below]; startOfLine _ pc; } ELSE IF cellArray[ch].inTileSet THEN pc _ Parquet.AdjacentTile[oldTile: pc, newTile: cellArray[ch].tile, dir: $rightOf] ELSE { TerminalIO.WriteRope[cellArray[ch].name]; TerminalIO.WriteRope[" not in tile set\n"]; }; ENDLOOP; ENDLOOP; END; Init: PROC[] = { cellName _ "LA"; cellArray['a] _ NEW[CellRec]; cellArray['a].name _ cellName; cellName _ "LB"; cellArray['b] _ NEW[CellRec]; cellArray['b].name _ cellName; cellName _ "LC"; cellArray['c] _ NEW[CellRec]; cellArray['c].name _ cellName; cellName _ "LD"; cellArray['d] _ NEW[CellRec]; cellArray['d].name _ cellName; cellName _ "LE"; cellArray['e] _ NEW[CellRec]; cellArray['e].name _ cellName; cellName _ "LF"; cellArray['f] _ NEW[CellRec]; cellArray['f].name _ cellName; cellName _ "LG"; cellArray['g] _ NEW[CellRec]; cellArray['g].name _ cellName; cellName _ "LH"; cellArray['h] _ NEW[CellRec]; cellArray['h].name _ cellName; cellName _ "LI"; cellArray['i] _ NEW[CellRec]; cellArray['i].name _ cellName; cellName _ "LJ"; cellArray['j] _ NEW[CellRec]; cellArray['j].name _ cellName; cellName _ "LK"; cellArray['k] _ NEW[CellRec]; cellArray['k].name _ cellName; cellName _ "LL"; cellArray['l] _ NEW[CellRec]; cellArray['l].name _ cellName; cellName _ "LM"; cellArray['m] _ NEW[CellRec]; cellArray['m].name _ cellName; cellName _ "LN"; cellArray['n] _ NEW[CellRec]; cellArray['n].name _ cellName; cellName _ "LO"; cellArray['o] _ NEW[CellRec]; cellArray['o].name _ cellName; cellName _ "LP"; cellArray['p] _ NEW[CellRec]; cellArray['p].name _ cellName; cellName _ "LQ"; cellArray['q] _ NEW[CellRec]; cellArray['q].name _ cellName; cellName _ "LR"; cellArray['r] _ NEW[CellRec]; cellArray['r].name _ cellName; cellName _ "LS"; cellArray['s] _ NEW[CellRec]; cellArray['s].name _ cellName; cellName _ "LT"; cellArray['t] _ NEW[CellRec]; cellArray['t].name _ cellName; cellName _ "LU"; cellArray['u] _ NEW[CellRec]; cellArray['u].name _ cellName; cellName _ "LV"; cellArray['v] _ NEW[CellRec]; cellArray['v].name _ cellName; cellName _ "LW"; cellArray['w] _ NEW[CellRec]; cellArray['w].name _ cellName; cellName _ "LX"; cellArray['x] _ NEW[CellRec]; cellArray['x].name _ cellName; cellName _ "LY"; cellArray['y] _ NEW[CellRec]; cellArray['y].name _ cellName; cellName _ "LZ"; cellArray['z] _ NEW[CellRec]; cellArray['z].name _ cellName; cellName _ "UA"; cellArray['A] _ NEW[CellRec]; cellArray['A].name _ cellName; cellName _ "UB"; cellArray['B] _ NEW[CellRec]; cellArray['B].name _ cellName; cellName _ "UC"; cellArray['C] _ NEW[CellRec]; cellArray['C].name _ cellName; cellName _ "UD"; cellArray['D] _ NEW[CellRec]; cellArray['D].name _ cellName; cellName _ "UE"; cellArray['E] _ NEW[CellRec]; cellArray['E].name _ cellName; cellName _ "UF"; cellArray['F] _ NEW[CellRec]; cellArray['F].name _ cellName; cellName _ "UG"; cellArray['G] _ NEW[CellRec]; cellArray['G].name _ cellName; cellName _ "UH"; cellArray['H] _ NEW[CellRec]; cellArray['H].name _ cellName; cellName _ "UI"; cellArray['I] _ NEW[CellRec]; cellArray['I].name _ cellName; cellName _ "UJ"; cellArray['J] _ NEW[CellRec]; cellArray['J].name _ cellName; cellName _ "UK"; cellArray['K] _ NEW[CellRec]; cellArray['K].name _ cellName; cellName _ "UL"; cellArray['L] _ NEW[CellRec]; cellArray['L].name _ cellName; cellName _ "UM"; cellArray['M] _ NEW[CellRec]; cellArray['M].name _ cellName; cellName _ "UN"; cellArray['N] _ NEW[CellRec]; cellArray['N].name _ cellName; cellName _ "UO"; cellArray['O] _ NEW[CellRec]; cellArray['O].name _ cellName; cellName _ "UP"; cellArray['P] _ NEW[CellRec]; cellArray['P].name _ cellName; cellName _ "UQ"; cellArray['Q] _ NEW[CellRec]; cellArray['Q].name _ cellName; cellName _ "UR"; cellArray['R] _ NEW[CellRec]; cellArray['R].name _ cellName; cellName _ "US"; cellArray['S] _ NEW[CellRec]; cellArray['S].name _ cellName; cellName _ "UT"; cellArray['T] _ NEW[CellRec]; cellArray['T].name _ cellName; cellName _ "UU"; cellArray['U] _ NEW[CellRec]; cellArray['U].name _ cellName; cellName _ "UV"; cellArray['V] _ NEW[CellRec]; cellArray['V].name _ cellName; cellName _ "UW"; cellArray['W] _ NEW[CellRec]; cellArray['W].name _ cellName; cellName _ "UX"; cellArray['X] _ NEW[CellRec]; cellArray['X].name _ cellName; cellName _ "UY"; cellArray['Y] _ NEW[CellRec]; cellArray['Y].name _ cellName; cellName _ "UZ"; cellArray['Z] _ NEW[CellRec]; cellArray['Z].name _ cellName; cellName _ "N1"; cellArray['1] _ NEW[CellRec]; cellArray['1].name _ cellName; cellName _ "N2"; cellArray['2] _ NEW[CellRec]; cellArray['2].name _ cellName; cellName _ "N3"; cellArray['3] _ NEW[CellRec]; cellArray['3].name _ cellName; cellName _ "N4"; cellArray['4] _ NEW[CellRec]; cellArray['4].name _ cellName; cellName _ "N5"; cellArray['5] _ NEW[CellRec]; cellArray['5].name _ cellName; cellName _ "N6"; cellArray['6] _ NEW[CellRec]; cellArray['6].name _ cellName; cellName _ "N7"; cellArray['7] _ NEW[CellRec]; cellArray['7].name _ cellName; cellName _ "N8"; cellArray['8] _ NEW[CellRec]; cellArray['8].name _ cellName; cellName _ "N9"; cellArray['9] _ NEW[CellRec]; cellArray['9].name _ cellName; cellName _ "N0"; cellArray['0] _ NEW[CellRec]; cellArray['0].name _ cellName; cellName _ "SLASH"; cellArray['/ ] _ NEW[CellRec]; cellArray['/].name _ cellName; cellName _ "LEFTPAREN"; cellArray['(] _ NEW[CellRec]; cellArray['(].name _ cellName; cellName _ "COLON"; cellArray[':] _ NEW[CellRec]; cellArray[':].name _ cellName; cellName _ "RIGHTPAREN"; cellArray[')] _ NEW[CellRec]; cellArray[')].name _ cellName; cellName _ "COMMA"; cellArray[',] _ NEW[CellRec]; cellArray[',].name _ cellName; cellName _ "PERIOD"; cellArray['.] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "SPLAT"; cellArray['#] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "DOLLARSIGN"; cellArray['$] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "EXCLMARK"; cellArray['!] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "PERCENT"; cellArray['%] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "AMPERSAND"; cellArray['&] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "ASTERISK"; cellArray['*] _ NEW[CellRec]; cellArray['.].name _ cellName; cellName _ "QUESTIONMARK"; cellArray['?] _ NEW[CellRec]; cellArray['.].name _ cellName; [] _ Parquet.RegisterGenerator[generatorName: "WriteLabel", proc: WriteLabelCommand, needsTiles: FALSE]; }; Init[]; END.