File: /ivy/stolfi/misc/ScrambleText.mesa
Last Edited by: Stolfi, June 14, 1984 2:52:36 pm PDT
Dhas kleclin locasdols i "Sglinpro" puddem dhid ikkraos i vazob irkhipodag supsdadudaem gwkhol de irr roddols imb bacads am dho gullomd daeci sorogdaem. Dho kolnudidaem yis ghesom se is de nito dho losurdamc dozd amsgludipro pud loridajorw klemumgoipro.
To use the program, just run /ivy/stolfi/misc/scrambletext.bcd, select some text in an editable viewer, and red-click the Scramble button on the herald window. Blue-click inverts the effect. Any funny behavior by this program is hereby blamed (rightly or wrongly) on undocumented "features" of Cedar. (NOTE: such behavior is observable, for example, if the selection is an entire node, or if it spans a node boundary.)
A yledo dhas kleclin niamrw de comolido cilpico varos usob am dosdamc DoZ nigles. Amgabomdirrw, dhas kleclin irse klejos dhid de be dho sankrosd dhamcs am Gobil weu hijo de ankeld i bexom klegobulos imb dwkos vlen vajo bavvolomd amdolvigos. Sibrw de siw, nimw ev dheso klegobulos bem'd be yhid dho begunomdidaem siws dhow be.
DIRECTORY
Buttons USING [ButtonProc, Create],
Rope USING [ROPE, Translate, TranslatorType, ActionType],
TiogaOps USING [Delete, InsertRope],
ViewerClasses USING [Viewer],
ViewerTools USING [SelPos, GetSelection, GetSelectedViewer, GetSelectionContents, SetSelection];
ScrambleText:
CEDAR
MONITOR
IMPORTS Buttons,ViewerTools, TiogaOps, Rope =
BEGIN
ROPE: TYPE = Rope.ROPE;
scramble, unscramble: ARRAY CHAR OF CHAR;
ScrambleButtonProc:
ENTRY Buttons.ButtonProc = {
[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL]
Scrambler: Rope.TranslatorType =
[old: CHAR] RETURNS [new: CHAR]
{new ← scramble[old]};
UnScrambler: Rope.TranslatorType =
[old: CHAR] RETURNS [new: CHAR]
{new ← unscramble[old]};
viewer: ViewerClasses.Viewer = ViewerTools.GetSelectedViewer[];
sel: ViewerTools.SelPos = ViewerTools.GetSelection[viewer];
IF sel # NIL AND (viewer.class.flavor =$Text OR viewer.class.flavor = $Typescript) THEN
BEGIN
rope: ROPE ← ViewerTools.GetSelectionContents[];
TiogaOps.Delete[];
TiogaOps.InsertRope[Rope.Translate[base: rope,
translator: IF mouseButton = blue THEN UnScrambler ELSE Scrambler]];
ViewerTools.SetSelection[viewer, sel];
END
};
InitScramble:
PROC = {
delta: INT = 'A - 'a;
FOR c:
CHAR
IN
CHAR
DO
scramble[c] ← c
ENDLOOP;
scramble['0] ← '3;
scramble['1] ← '8;
scramble['2] ← '4;
scramble['3] ← '5;
scramble['4] ← '9;
scramble['5] ← '2;
scramble['6] ← '6;
scramble['7] ← '0;
scramble['8] ← '1;
scramble['9] ← '7;
scramble['e] ← 'o;
scramble['o] ← 'e;
scramble['a] ← 'i;
scramble['i] ← 'a;
scramble['y] ← 'w;
scramble['w] ← 'y;
scramble['b] ← 'p;
scramble['p] ← 'k;
scramble['k] ← 't;
scramble['t] ← 'd;
scramble['d] ← 'b;
scramble['c] ← 'g;
scramble['g] ← 'c;
scramble['f] ← 'v;
scramble['v] ← 'j;
scramble['j] ← 'f;
scramble['x] ← 'z;
scramble['z] ← 'x;
scramble['l] ← 'r;
scramble['r] ← 'l;
scramble['m] ← 'n;
scramble['n] ← 'm;
FOR c:
CHAR
IN ['a..'z]
DO
scramble[c + delta] ← scramble[c] + delta
ENDLOOP;
FOR c:
CHAR
IN
CHAR
DO
unscramble[scramble[c]] ← c
ENDLOOP;
};
InitScramble[];
[] ← Buttons.Create[
info: [
name: "Scramble",
parent: NIL],
proc: ScrambleButtonProc,
documentation: "Translates the selection from English to Omcrash (blue-click to reverse)."];
END.
CHANGE LOG
Created by Stolfi on April 5, 1984 10:50:38 pm PST
Edited on June 14, 1984 2:37:09 pm PDT, by Stolfi
changes to: ScrambleButtonProc, InitScramble, DIRECTORY