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