<<>> <> <> <> <> <<>> DIRECTORY ColorizeViewPoint, ColorizeViewPointBackdoor, IO, IPScan, Rope; ColorizeViewPointRoundEndsImpl: CEDAR PROGRAM IMPORTS ColorizeViewPoint, ColorizeViewPointBackdoor, IO, IPScan, Rope ~ BEGIN ROPE: TYPE ~ Rope.ROPE; ColorizeRoundEnds: ColorizeViewPointBackdoor.Colorization = { <<[ip: ROPE, palette: Profiles.Profile, checkSystemSetting: ColorizeViewPoint.CheckSystemSettingProc, mapData: MapData] RETURNS [newIP: ROPE]>> prefixes: LIST OF ROPE ~ ColorizeViewPointBackdoor.SubpaletteSearchList[prefixesIn: NIL, profile: palette]; tokens: LIST OF ROPE; levelsExceeded: BOOL; [tokens, levelsExceeded] _ ColorizeViewPointBackdoor.GetRecursiveValue[key: "RoundEnds", palette: palette, subpaletteList: prefixes, mapData: mapData]; SELECT TRUE FROM tokens=NIL => RETURN [ip]; --Don't colorize! levelsExceeded => { SIGNAL ColorizeViewPoint.Warning[class: $MalformedPaletteEntry, explanation: IO.PutFR[format: "RoundEnds color is part of a recursive color definition beyond allowable levels; ignoring it."]]; RETURN; }; ENDCASE => NULL; WITH ColorizeViewPointBackdoor.IPFragmentForColorSetting[def: tokens, palette: palette] SELECT FROM replacement: ROPE => { ScanForISET: IPScan.ScanProc = { <<[min: INT, max: INT, op: IPMaster.Op _ nil, seq: IPScan.Seq _ nil, num: INTEGER _ 0, punt: BOOL _ FALSE]>> IF ~punt AND max-min=searchLen AND ip.Substr[min, searchLen].Equal[search] THEN { newIP _ Rope.Cat[r1: newIP, r2: ip.Substr[flushedTo, min-flushedTo], r3: replacement]; flushedTo _ max; }; }; search: ROPE ~ "\017\242\017\260\223"; --2 16 ISET = round strokeEnd ISET searchLen: INT ~ search.Size; flushedTo: INT _ 0; newIP _ NIL; IPScan.ScanRope[ip: ip, ops: LIST[iset], action: ScanForISET]; newIP _ newIP.Concat[ip.Substr[flushedTo]]; }; ENDCASE => ERROR ColorizeViewPoint.Error[$MalformedPaletteEntry, "Round ends can only be colorized to constant colors"]; }; ColorizeViewPointBackdoor.InstallNewColorization[colorization: ColorizeRoundEnds, setting: [key: "ColorizeRoundEnds", description: "Lines with two round ends will be colorized according to the palette entry \"RoundEnds\". THIS FEATURE IS EXPERIMENTAL, and may conflict with the use of points.", default: TRUE]]; --but won't colorize if it finds no color defined ColorizeViewPointBackdoor.RegisterKeywords[keywordsList: LIST["RoundEnds"]]; --each Colorization reserves its colorizing keywords. END.