-- EditToolPrivate.mesa
-- Edited by Paxton on  6-Feb-82 11:56:07

DIRECTORY
  Buttons,
  Convert,
  EditNotify,
  Inline,
  IOStream,
  Labels,
  List,
  Menus,
  MessageWindow,
  NodeAddrs,
  Rope,
  RopeEdit,
  RopeReader,
  RunReader,
  Runtime,
  TEditDocument,
  TEditInputOps,
  TEditOps,
  TextEdit,
  TextFind,
  TextLooks,
  TextLooksSupport,
  TextNode,
  TreeFind,
  UndoEvent,
  UserTerminal,
  ViewerClasses,
  ViewerMenus,
  ViewerOps;

EditToolPrivate: DEFINITIONS = {

-- command registration stuff

RegisterSort, RegisterSubs, RegisterSearch: PROC;

UnRegisterSort, UnRegisterSubs, UnRegisterSearch: PROC;

-- general stuff

mainEditTool: BOOLEAN;

interrupt: BOOLEAN;

Event: TYPE = UndoEvent.Ref;

entryHeight: CARDINAL = 15;
entryVSpace: CARDINAL = 5;
entryLeft: CARDINAL;
gapSize: CARDINAL = 5;
heightSoFar: CARDINAL;
container: ViewerClasses.Viewer;
tSel: TEditDocument.Selection;

ChangeState: PROC [label: Labels.Label, flag: BOOLEAN, trueAtom, falseAtom: ATOM];

BuildPair: PROC [proc: Buttons.ButtonProc, flag: BOOLEAN, l1, l2: Rope.Ref]
	RETURNS [label: Labels.Label, button: Buttons.Button];

CycleTriple: PROC [label: Labels.Label, state: [0..2], atom0, atom1, atom2: ATOM];

BuildTriple: PROC [proc: Buttons.ButtonProc, state: [0..2], l0, l1, l2: Rope.Ref]
	RETURNS [label: Labels.Label, button: Buttons.Button];

DataFieldButton: PROC [arg: ViewerClasses.Viewer];

BuildDataFieldPair: PROC [buttonRope: Rope.Ref, buttonProc: Buttons.ButtonProc, lines: CARDINAL ← 2]
	RETURNS [button: Buttons.Button, arg: ViewerClasses.Viewer];
	
GetDataNode: PROC [arg: ViewerClasses.Viewer] RETURNS [TextNode.RefTextNode];

GetDataLooks: PROC [arg: ViewerClasses.Viewer, name: Rope.Ref]
	RETURNS [looks: TextLooks.Looks];

-- Search related stuff

BuildSearchEntries, BuildSearchButtons, BuildTargetEntry: PROC;

word: BOOLEAN;
looksExact: BOOLEAN;
looksChoice: [0..2];
looksOnly: [0..2] = 0;
textOnly: [0..2] = 1;
textAndLooks: [0..2] = 2;
literal: BOOLEAN;
ignoreCase: BOOLEAN;
targetArg: ViewerClasses.Viewer;
SearchForward, SearchBackwards: Buttons.ButtonProc;

Search: PROC [forward: BOOLEAN];

CheckPSel: PROC [pSel: TEditDocument.Selection] RETURNS [ok: BOOLEAN];

GetPatternNode: PROC RETURNS [pattern: TextNode.RefTextNode];

Extend: PROC[forward: BOOLEAN, searchLooks: TextLooks.Looks,
	where: TextNode.RefTextNode, at, atEnd: TextNode.Offset,
	last: TextNode.Ref ← NIL, lastLen: TextNode.Offset ← TextNode.MaxLen]
	RETURNS [newAt, newAtEnd: TextNode.Offset];

-- Substitute related stuff

sourceArg: ViewerClasses.Viewer;
doReplace: BOOLEAN;
forceInitCap: BOOLEAN;
subsRange: [0..2];
withinSel: [0..2] = 0;
afterSel: [0..2] = 1;
entireDoc: [0..2] = 2;

GetLooksAndPatternInfo: PROC [pattern: TextNode.RefTextNode]
	RETURNS [pat: TextNode.RefTextNode,
		ignoreLooks, lit: BOOLEAN,
		searchLooks: TextLooks.Looks];

BuildSourceEntry, BuildDoItEntries, BuildOperationEntry, BuildInitCapEntry, BuildOperationField,
	BuildGetAndSetOpsEntries, BuildComNumField, BuildSubstituteEntry, BuildPatternDocEntry: PROC;

-- Sort related stuff

BuildSortButtons: PROC;

sortIncreasing: BOOLEAN;

sortKind: [0..2];
sortText: [0..2] = 0;
sortLines: [0..2] = 1;
sortBranches: [0..2] = 2;

}...