-- TiogaFileOps.Mesa
-- written by Bill Paxton. June 1982
-- last written by Paxton. June 7, 1982 2:37 pm

-- This is for applications that are creating a Tioga file from some other source

-- The expected mode of operation is as follows:
	-- create a root node using CreateRoot
		-- set its style (if not default) using SetStyle
	-- for each node in tree, 
		-- (1) create it using InsertNode
		-- (2) set the text contents using SetContents
		-- (3) add looks if any using AddLooks
		-- (4) set the format (if not default) using SetFormat
	-- write the new Tioga file using Store

DIRECTORY
	Rope,
	TextNode;

TiogaFileOps: DEFINITIONS =
BEGIN

Ref: TYPE = TextNode.RefTextNode;

CreateRoot: PROC RETURNS [root: Ref];

InsertNode: PROC [x: Ref, child: BOOL ← FALSE] RETURNS [new: Ref];
	-- if ~child then new is immediate next sibling of x
	-- else new is first child of x

SetContents: PROC [x: Ref, txt: Rope.Ref];

AddLooks: PROC [x: Ref, start, len: INT, look: CHAR ['a..'z], root: Ref ← NIL];
	-- start is char index of first char to get looks added.  count from 0
	-- can omit root, but runs faster if you supply it
	-- must set contents before add looks
	-- can add several different looks for any given character
	-- can add looks for overlapping spans of text

SetFormat: PROC [x: Ref, format: Rope.Ref];
	-- e.g., SetStyle[node, "Title"];

SetStyle: PROC [x: Ref, style: Rope.Ref];
	-- e.g., SetStyle[root, "Mesa"];

Store: PROC [x: Ref, filename: Rope.Ref];
	-- x should be from call on CreateRoot
	-- e.g., Store[root, "Foo.Tioga"];

END...