KeyboardScan:
CEDAR
PROGRAM
IMPORTS TEditInputOps, TEditRefresh, TEditSelection, TextEdit, TextNode, TiogaOps
={
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
Location: TYPE = TiogaOps.Location;
Selection: TYPE = TEditDocument.Selection;
CommandProc: TYPE = TiogaOps.CommandProc;
ScanTo000: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\000]};
ScanTo001: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\001]};
ScanTo002: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\002]};
ScanTo003: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\003]};
ScanTo004: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\004]};
ScanTo005: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\005]};
ScanTo006: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\006]};
ScanTo007: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\007]};
ScanTo010: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\010]};
ScanTo011: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\011]};
ScanTo012: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\012]};
ScanTo013: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\013]};
ScanTo014: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\014]};
ScanTo015: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\015]};
ScanTo016: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\016]};
ScanTo017: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\017]};
ScanTo020: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\020]};
ScanTo021: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\021]};
ScanTo022: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\022]};
ScanTo023: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\023]};
ScanTo024: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\024]};
ScanTo025: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\025]};
ScanTo026: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\026]};
ScanTo027: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\027]};
ScanTo030: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\030]};
ScanTo031: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\031]};
ScanTo032: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\032]};
ScanTo033: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\033]};
ScanTo034: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\034]};
ScanTo035: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\035]};
ScanTo036: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\036]};
ScanTo037: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\037]};
ScanTo040: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\040]};
ScanTo041: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\041]};
ScanTo042: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\042]};
ScanTo043: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\043]};
ScanTo044: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\044]};
ScanTo045: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\045]};
ScanTo046: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\046]};
ScanTo047: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\047]};
ScanTo050: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\050]};
ScanTo051: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\051]};
ScanTo052: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\052]};
ScanTo053: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\053]};
ScanTo054: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\054]};
ScanTo055: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\055]};
ScanTo056: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\056]};
ScanTo057: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\057]};
ScanTo060: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\060]};
ScanTo061: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\061]};
ScanTo062: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\062]};
ScanTo063: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\063]};
ScanTo064: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\064]};
ScanTo065: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\065]};
ScanTo066: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\066]};
ScanTo067: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\067]};
ScanTo070: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\070]};
ScanTo071: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\071]};
ScanTo072: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\072]};
ScanTo073: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\073]};
ScanTo074: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\074]};
ScanTo075: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\075]};
ScanTo076: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\076]};
ScanTo077: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\077]};
ScanTo100: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\100]};
ScanTo101: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\101]};
ScanTo102: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\102]};
ScanTo103: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\103]};
ScanTo104: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\104]};
ScanTo105: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\105]};
ScanTo106: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\106]};
ScanTo107: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\107]};
ScanTo110: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\110]};
ScanTo111: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\111]};
ScanTo112: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\112]};
ScanTo113: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\113]};
ScanTo114: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\114]};
ScanTo115: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\115]};
ScanTo116: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\116]};
ScanTo117: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\117]};
ScanTo120: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\120]};
ScanTo121: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\121]};
ScanTo122: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\122]};
ScanTo123: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\123]};
ScanTo124: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\124]};
ScanTo125: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\125]};
ScanTo126: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\126]};
ScanTo127: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\127]};
ScanTo130: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\130]};
ScanTo131: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\131]};
ScanTo132: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\132]};
ScanTo133: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\133]};
ScanTo134: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\134]};
ScanTo135: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\135]};
ScanTo136: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\136]};
ScanTo137: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\137]};
ScanTo140: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\140]};
ScanTo173: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\173]};
ScanTo174: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\174]};
ScanTo175: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\175]};
ScanTo176: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\176]};
ScanTo177: CommandProc = {[recordAtom, quit] ← ScanTo[viewer, '\177]};
ScanNull:
PROC [viewer: Viewer ←
NIL]
RETURNS [recordAtom:
BOOL ←
TRUE, quit:
BOOL ←
FALSE]
--TiogaOps.CommandProc-- =
{NULL};
ScanUpper:
PROC [viewer: Viewer ←
NIL]
RETURNS [recordAtom:
BOOL ←
TRUE, quit:
BOOL ←
FALSE]
--TiogaOps.CommandProc-- =
{case ← Upper};
ScanLower:
PROC [viewer: Viewer ←
NIL]
RETURNS [recordAtom:
BOOL ←
TRUE, quit:
BOOL ←
FALSE]
--TiogaOps.CommandProc-- =
{case ← Lower};
ScanForward:
PROC [viewer: Viewer ←
NIL]
RETURNS [recordAtom:
BOOL ←
TRUE, quit:
BOOL ←
FALSE]
--TiogaOps.CommandProc-- =
{direction ← Forward};
ScanBackward:
PROC [viewer: Viewer ←
NIL]
RETURNS [recordAtom:
BOOL ←
TRUE, quit:
BOOL ←
FALSE]
--TiogaOps.CommandProc-- =
{direction ← Backward};
Case: TYPE = {Upper, Lower};
case: Case;
Direction: TYPE = {Forward, Backward};
direction: Direction;
delta: ARRAY Direction OF INT = [Forward: 1, Backward: -1];
ScanTo:
PROC [viewer: Viewer, goal:
CHAR]
RETURNS [recordAtom:
BOOL ←
TRUE, quit:
BOOL ←
FALSE] = {
myDir: Direction ← direction;
visible: BOOL ← TRUE;
Doit:
PROC [root: TextNode.Ref, tSel: Selection] = {
loc: TextNode.Location ←
SELECT tSel.insertion
FROM
before => tSel.start.pos,
after => tSel.end.pos,
ENDCASE => ERROR;
node: TextNode.RefTextNode ← TextNode.NarrowToTextNode[loc.node];
offset: TextNode.Offset;
nodeSize: INT;
IF node=NIL THEN GOTO Bad;
nodeSize ← TextEdit.Size[node];
offset ←
IF loc.where # TextNode.NodeItself
THEN
loc.where +
(
SELECT tSel.insertion
FROM
before => 0,
after => 1,
ENDCASE => ERROR)
ELSE
SELECT tSel.insertion
FROM
before => 0,
after => nodeSize,
ENDCASE => ERROR;
offset ← offset + (
SELECT myDir
FROM
Backward => -1,
Forward => 0,
ENDCASE => ERROR);
DO
SELECT myDir
FROM
Forward =>
WHILE offset
NOT
IN [0 .. nodeSize)
DO
node ← TextNode.StepForward[node];
IF node = NIL THEN GOTO Bad;
nodeSize ← TextEdit.Size[node];
offset ← 0;
ENDLOOP;
Backward =>
WHILE offset
NOT
IN [0 .. nodeSize)
DO
node ← TextNode.StepBackward[node];
IF node = NIL THEN GOTO Bad;
nodeSize ← TextEdit.Size[node];
offset ← nodeSize-1;
ENDLOOP;
ENDCASE => ERROR;
IF TextEdit.FetchChar[node, offset].char = goal
THEN {
TEditSelection.Deselect[primary];
tSel.start.pos ← [node, offset];
tSel.end.pos ← [node, offset];
tSel.granularity ← char;
tSel.pendingDelete ← FALSE;
tSel.insertion ←
SELECT myDir
FROM
Backward => before,
Forward => after,
ENDCASE => ERROR;
TEditSelection.MakeSelection[selection: primary, new: tSel];
TEditSelection.FixupSelection[TEditSelection.pSel, viewer];
TEditSelection.FixupCaret[TEditSelection.pSel];
TEditRefresh.ScrollToEndOfSel[viewer, FALSE, primary];
visible ← TEditSelection.CaretVisible[];
EXIT;
};
offset ← offset + delta[myDir];
ENDLOOP;
EXITS Bad => TEditInputOps.EditFailed[]
};
IF goal
IN ['A .. 'Z]
THEN
SELECT case
FROM
Upper => NULL;
Lower => goal ← goal - 'A + 'a;
ENDCASE => ERROR;
quit ← TRUE;
TEditInputOps.CallWithLocks[Doit, read];
IF NOT visible THEN [] ← TEditInput.Normalize[viewer];
};
Start:
PROC = {
TiogaOps.RegisterCommand[$ScanNull, ScanNull];
TiogaOps.RegisterCommand[$ScanUpper, ScanUpper];
TiogaOps.RegisterCommand[$ScanLower, ScanLower];
TiogaOps.RegisterCommand[$ScanForward, ScanForward];
TiogaOps.RegisterCommand[$ScanBackward, ScanBackward];
TiogaOps.RegisterCommand[$ScanTo000, ScanTo000];
TiogaOps.RegisterCommand[$ScanTo001, ScanTo001];
TiogaOps.RegisterCommand[$ScanTo002, ScanTo002];
TiogaOps.RegisterCommand[$ScanTo003, ScanTo003];
TiogaOps.RegisterCommand[$ScanTo004, ScanTo004];
TiogaOps.RegisterCommand[$ScanTo005, ScanTo005];
TiogaOps.RegisterCommand[$ScanTo006, ScanTo006];
TiogaOps.RegisterCommand[$ScanTo007, ScanTo007];
TiogaOps.RegisterCommand[$ScanTo010, ScanTo010];
TiogaOps.RegisterCommand[$ScanTo011, ScanTo011];
TiogaOps.RegisterCommand[$ScanTo012, ScanTo012];
TiogaOps.RegisterCommand[$ScanTo013, ScanTo013];
TiogaOps.RegisterCommand[$ScanTo014, ScanTo014];
TiogaOps.RegisterCommand[$ScanTo015, ScanTo015];
TiogaOps.RegisterCommand[$ScanTo016, ScanTo016];
TiogaOps.RegisterCommand[$ScanTo017, ScanTo017];
TiogaOps.RegisterCommand[$ScanTo020, ScanTo020];
TiogaOps.RegisterCommand[$ScanTo021, ScanTo021];
TiogaOps.RegisterCommand[$ScanTo022, ScanTo022];
TiogaOps.RegisterCommand[$ScanTo023, ScanTo023];
TiogaOps.RegisterCommand[$ScanTo024, ScanTo024];
TiogaOps.RegisterCommand[$ScanTo025, ScanTo025];
TiogaOps.RegisterCommand[$ScanTo026, ScanTo026];
TiogaOps.RegisterCommand[$ScanTo027, ScanTo027];
TiogaOps.RegisterCommand[$ScanTo030, ScanTo030];
TiogaOps.RegisterCommand[$ScanTo031, ScanTo031];
TiogaOps.RegisterCommand[$ScanTo032, ScanTo032];
TiogaOps.RegisterCommand[$ScanTo033, ScanTo033];
TiogaOps.RegisterCommand[$ScanTo034, ScanTo034];
TiogaOps.RegisterCommand[$ScanTo035, ScanTo035];
TiogaOps.RegisterCommand[$ScanTo036, ScanTo036];
TiogaOps.RegisterCommand[$ScanTo037, ScanTo037];
TiogaOps.RegisterCommand[$ScanTo040, ScanTo040];
TiogaOps.RegisterCommand[$ScanTo041, ScanTo041];
TiogaOps.RegisterCommand[$ScanTo042, ScanTo042];
TiogaOps.RegisterCommand[$ScanTo043, ScanTo043];
TiogaOps.RegisterCommand[$ScanTo044, ScanTo044];
TiogaOps.RegisterCommand[$ScanTo045, ScanTo045];
TiogaOps.RegisterCommand[$ScanTo046, ScanTo046];
TiogaOps.RegisterCommand[$ScanTo047, ScanTo047];
TiogaOps.RegisterCommand[$ScanTo050, ScanTo050];
TiogaOps.RegisterCommand[$ScanTo051, ScanTo051];
TiogaOps.RegisterCommand[$ScanTo052, ScanTo052];
TiogaOps.RegisterCommand[$ScanTo053, ScanTo053];
TiogaOps.RegisterCommand[$ScanTo054, ScanTo054];
TiogaOps.RegisterCommand[$ScanTo055, ScanTo055];
TiogaOps.RegisterCommand[$ScanTo056, ScanTo056];
TiogaOps.RegisterCommand[$ScanTo057, ScanTo057];
TiogaOps.RegisterCommand[$ScanTo060, ScanTo060];
TiogaOps.RegisterCommand[$ScanTo061, ScanTo061];
TiogaOps.RegisterCommand[$ScanTo062, ScanTo062];
TiogaOps.RegisterCommand[$ScanTo063, ScanTo063];
TiogaOps.RegisterCommand[$ScanTo064, ScanTo064];
TiogaOps.RegisterCommand[$ScanTo065, ScanTo065];
TiogaOps.RegisterCommand[$ScanTo066, ScanTo066];
TiogaOps.RegisterCommand[$ScanTo067, ScanTo067];
TiogaOps.RegisterCommand[$ScanTo070, ScanTo070];
TiogaOps.RegisterCommand[$ScanTo071, ScanTo071];
TiogaOps.RegisterCommand[$ScanTo072, ScanTo072];
TiogaOps.RegisterCommand[$ScanTo073, ScanTo073];
TiogaOps.RegisterCommand[$ScanTo074, ScanTo074];
TiogaOps.RegisterCommand[$ScanTo075, ScanTo075];
TiogaOps.RegisterCommand[$ScanTo076, ScanTo076];
TiogaOps.RegisterCommand[$ScanTo077, ScanTo077];
TiogaOps.RegisterCommand[$ScanTo100, ScanTo100];
TiogaOps.RegisterCommand[$ScanTo101, ScanTo101];
TiogaOps.RegisterCommand[$ScanTo102, ScanTo102];
TiogaOps.RegisterCommand[$ScanTo103, ScanTo103];
TiogaOps.RegisterCommand[$ScanTo104, ScanTo104];
TiogaOps.RegisterCommand[$ScanTo105, ScanTo105];
TiogaOps.RegisterCommand[$ScanTo106, ScanTo106];
TiogaOps.RegisterCommand[$ScanTo107, ScanTo107];
TiogaOps.RegisterCommand[$ScanTo110, ScanTo110];
TiogaOps.RegisterCommand[$ScanTo111, ScanTo111];
TiogaOps.RegisterCommand[$ScanTo112, ScanTo112];
TiogaOps.RegisterCommand[$ScanTo113, ScanTo113];
TiogaOps.RegisterCommand[$ScanTo114, ScanTo114];
TiogaOps.RegisterCommand[$ScanTo115, ScanTo115];
TiogaOps.RegisterCommand[$ScanTo116, ScanTo116];
TiogaOps.RegisterCommand[$ScanTo117, ScanTo117];
TiogaOps.RegisterCommand[$ScanTo120, ScanTo120];
TiogaOps.RegisterCommand[$ScanTo121, ScanTo121];
TiogaOps.RegisterCommand[$ScanTo122, ScanTo122];
TiogaOps.RegisterCommand[$ScanTo123, ScanTo123];
TiogaOps.RegisterCommand[$ScanTo124, ScanTo124];
TiogaOps.RegisterCommand[$ScanTo125, ScanTo125];
TiogaOps.RegisterCommand[$ScanTo126, ScanTo126];
TiogaOps.RegisterCommand[$ScanTo127, ScanTo127];
TiogaOps.RegisterCommand[$ScanTo130, ScanTo130];
TiogaOps.RegisterCommand[$ScanTo131, ScanTo131];
TiogaOps.RegisterCommand[$ScanTo132, ScanTo132];
TiogaOps.RegisterCommand[$ScanTo133, ScanTo133];
TiogaOps.RegisterCommand[$ScanTo134, ScanTo134];
TiogaOps.RegisterCommand[$ScanTo135, ScanTo135];
TiogaOps.RegisterCommand[$ScanTo136, ScanTo136];
TiogaOps.RegisterCommand[$ScanTo137, ScanTo137];
TiogaOps.RegisterCommand[$ScanTo140, ScanTo140];
TiogaOps.RegisterCommand[$ScanTo173, ScanTo173];
TiogaOps.RegisterCommand[$ScanTo174, ScanTo174];
TiogaOps.RegisterCommand[$ScanTo175, ScanTo175];
TiogaOps.RegisterCommand[$ScanTo176, ScanTo176];
TiogaOps.RegisterCommand[$ScanTo177, ScanTo177];
};
Start[];
}.