[comp.sources.apple2] v001SRC048: Texter -- text editor

jac@yoko.rutgers.edu (Jonathan A. Chandross) (05/11/91)

Submitted-by: Joel Sumner (q4kx@cornella.ccs.cornell.edu)
Posting-number: Volume 1, Source:48
Archive-name: editor/texter/part02
Architecture: ONLY_2gs
Version-number: 1.1.1


=texter.pas
-{$keep 'Texter'}
-{$optimize -1}
-Program Texter;
-
-Uses     Common,
-         ControlMgr,
-         ResourceMgr,
-         MemoryMgr,
-         IntegerMath,
-         DeskMgr,
-         ToolLocator,
-         WindowMgr,
-         FontMgr,
-         QuickDrawII,
-         PrintMgr,
-         MenuMgr,
-         GSOS,
-         DialogMgr,
-         SFToolSet,
-         TextEdit,
-         {$LibPrefix '0/'}
-         MessUnit,       {Dave Lyon's Unit for Message Center}
-         MyStuff,
-         Texter2;
-
-
-const
-    Application_Menu_Bar = 1;
-         Apple_Menu = 1;
-              About_Menu_Item = 256;
-
-         File_Menu = 2;
-              New_Menu_Item   = 258;
-              Open_Menu_Item  = 259;
-              Close_Menu_Item = 255;
-              Save_Menu_Item  = 260;
-              SaveAs_Menu_Item = 261;
-              Page_Setup_Item = 263;
-              Print_Item      = 264;
-              Quit_Menu_Item  = 257;
-
-         Edit_Menu = 3;
-              Undo_Menu_Item  = 250;
-              Cut_Menu_Item   = 251;
-              Copy_Menu_Item  = 252;
-              Paste_Menu_Item = 253;
-              Clear_Menu_Item = 254;
-
-         Window_Menu = 4;
-              Window1_Item = 265;
-              Window2_Item = 266;
-              Window3_Item = 267;
-              Window4_Item = 268;
-              Window5_Item = 269;
-
-         Goodies_Menu = 5;
-              Word_Wrap_Item = 270;
-              Choose_Font_Item=271;
-
-   Text_Window          = 4090;
-   Text_Window_wColor   = 1;
-   Text_Edit_Control    = 1;
-   Tool_Startup_Table   = 1;
-
-   Printing_Alert       = 1;
-   Tool_Error_Alert     = 2;
-   Save_Alert           = 3;
-
-
-
-var
-         MyMemoryID:    Integer;
-         OldWindow:     integer;
-         StartStopRef:  longint;
-         Done:          Boolean;
-         PrintRecHandle:PrHandle;
-         theGSString:   GSOSInString;
-         WindowMenuStr: String[255];
-         WindowItems:   Array[1..5] of String[25];
-         OpenWindows:   Integer;            {Max of 5 Open Windows}
-         OPTable:       OpenOSDCB;
-         WindFront:     boolean;
-         FormatDlog,
-         ApplicPort:    GrafPortPtr;
-
-
-procedure DoPageSetup;
-var Good,
-    Dummy:boolean;
-begin
-dummy:=PrValidate(PrintRecHandle);
-If ToolError<>0 then ErrorBox(ToolError,$1301)
-    else begin
-    Good:=PrStlDialog(PrintRecHandle);
-    If ToolError<>0 then ErrorBox(ToolError,$1301);
-    end;
-end;
-
-
-procedure DoPrintDoc;
-var PrintPort,
-    theWindow:     GrafPortPtr;
-    LineNum,
-    memsize:       longint;
-    hTECtl:        TEHandle;
-    Error,
-    Where:         integer;
-    pageRect:      rect;
-    dummy:         boolean;
-begin
-theWindow := FrontWindow;
-hTECtl := TEHandle(GetCtlHandleFromID(theWindow, Text_Edit_Control));
-If ToolError<>0 then ErrorBox(ToolError,$1101);
-dummy:=PrValidate(PrintRecHandle);
-If PrJobDialog(PrintRecHandle)>0 then
-    begin
-    PrintPort:=PrOpenDoc(PrintRecHandle,nil);
-    If ToolError<>0 then begin
-         PrSetError(prAbort);
-         Where:=2;
-         end;
-    pageRect := PrintRecHandle^^.prInfo.rPage;
-    LineNum:=0;
-    Repeat
-         PrOpenPage(PrintPort,nil);
-         If ToolError<>0 then begin
-              PrSetError(prAbort);
-              Where:=3;
-              end;
-         LineNum:=TEPaintText(PrintPort,LineNum,PageRect,0,hTECtl);
-         If ToolError<>0 then begin
-              PrSetError(prAbort);
-              Where:=4;
-              end;
-         PrClosePage(PrintPort);
-         If ToolError<>0 then begin
-              PrSetError(prAbort);
-              Where:=5;
-              end;
-    Until LineNum=-1;
-    PrCloseDoc(PrintPort);
-    Error:=PrError;
-    If Error<>0 then
-         begin
-         ErrorBox(Error,$1100+Where);
-         result:=AlertWindow(5,nil,pointer(Printing_Alert));
-         end
-       else
-         PrPicFile(PrintRecHandle,nil,nil);
-    end;
-end;
-
-
-Function GetAWindow(WindNum:Integer):GrafPortPtr;
-var tmpWindow:     GrafPortPtr;
-begin
-tmpWindow:=NewWindow2(@Windows[windNum].WindowTitle,
-           @Windows[windnum],
-           @DrawWindow,
-           nil,
-           refIsResource,
-           Text_Window,
-           $800E);
-If ToolError<>0 then ErrorBox(ToolError,$1001);
-SetPort(tmpWindow);
-GetAWindow:=tmpWindow;
-end;
-
-Function MakeWindow(theWindnum:integer):Boolean;
-begin
-Windows[theWindNum].DocWindow:=GetAWindow(theWindNum);
-if Windows[theWindNum].DocWindow<>nil then
-    Begin
-    With Windows[theWindNum] do begin
-         MakeWindow:=true;
-         If Length(WindowTitle)>15 then
-           WindowItems[theWindNum]:=concat('...',
-                                  copy(WindowTitle,Length(WindowTitle)-15,17),
-                                  '  ')
-            else
-           WindowItems[theWindNum]:= WindowTitle;
-         SetMItemName(@WindowItems[theWindNum],theWindNum+264);
-         EnableMItem(theWindNum+264);
-         CalcMenuSize(0,0,4);
-         end;  {of With Windows}
-    end
-    else MakeWindow:=false;
-end;
-
-Procedure SetWindArr(i:integer);
-begin
-Windows[i].index:=i;
-Windows[i].InUse:=True;
-Windows[i].Wrap:=true;
-EnableMItem(Close_Menu_Item);
-EnableMItem(Print_Item);
-EnableMItem(Save_Menu_Item);
-EnableMItem(SaveAs_Menu_Item);
-EnableMItem(Page_Setup_Item);
-EnableMItem(Choose_Font_Item);
-EnableMItem(Word_Wrap_Item);
-WindFront:=true;
-end;
-
-Procedure DoNew;
-var i,
-    MyWindNum:Integer;
-    OpenOK,
-    Success:  Boolean;
-    tempStr:  Str255;
-begin
-myWindNum:=0;
-For i:=5 downto 1 do
-    If Windows[i].InUse=False then mywindnum:=i;
-if mywindnum=0 then ErrorBox(-2,$F01);
-tempStr:=' Untitled ';
-For I:=1 to length(tempstr) do
-     Windows[mywindnum].DocGSString.thestring[i]:=tempstr[i];
-Windows[mywindnum].DocGSString.size:=Length(tempstr);
-Windows[myWindNum].WindowTitle:=tempstr;
-Windows[mywindnum].DocRef:=0;
-OpenOK:=True;
-Success:=True;
-If Success then OpenOK:=MakeWindow(MyWindNum);
-If not OpenOK then ErrorBox(-3,$F02)
-    else begin
-    OpenWindows:=OpenWindows+1;
-    SetWindArr(mywindnum);
-    Windows[mywindnum].New:=True;
-    Windows[mywindnum].Saved:=False;
-    end;
-If OpenWindows>4 then begin
-    DisableMItem(Open_Menu_Item);
-    DisableMItem(New_Menu_Item);
-    end;
-end; {of DoNew}
-
-Procedure FormDlog;
-var  r:        rect;
-begin
-ApplicPort:=GetPort;
-WaitCursor;
-SetRect(r,200,40,440,65);
-FormatDlog :=NewModalDialog(r,true,0);
-If ToolError<>0 then ErrorBox(ToolError,$E07);
-SetPort(FormatDlog);
-MoveTo(10,15);DrawString(@'Please Wait. Formatting Text...');
-end;
-
-Function ReadIt(thedocnum:integer):Boolean;
-var eofparm:  eofOSDCB;
-    temp:     boolean;
-    TextHandle:Handle;
-    readparm: readWriteOSDCB;
-    TEControl:TEHandle;
-
-begin
-FormDlog;
-temp:=true;
-eofparm.pcount:=2;
-eofparm.refnum:=Windows[thedocnum].Docref;
-GetEOFGS(eofparm);
-if ToolError<>0 then begin
-    ErrorBox(ToolError,$E01);
-    temp:=false;
-    end
-  else begin
-    TextHandle:=NewHandle(eofparm.eofEOF,MyMemoryID,0,pointer(0));
-    If ToolError<>0 then begin
-         ErrorBox(ToolError,$E02);
-         temp:=False;
-         end;
-    end;
-If Temp then
-    begin
-    Hlock(TextHandle);
-    readparm.pcount:=4;
-    readparm.refnum:=Windows[thedocnum].Docref;
-    readparm.databuffer:=TextHandle^;
-    readparm.requestcount:=eofparm.eofEOF;
-    ReadGS(readparm);
-    If ToolError<>0 then begin
-         ErrorBox(ToolError,$E03);
-         temp:=false;
-         end;
-    end;
-If Temp then
-    begin
-    TEControl:=TEHandle(GetCtlHandleFromID(Windows[thedocnum].DocWindow,
-                                  Text_Edit_Control));
-    If ToolError<>0 then
-         ErrorBox(ToolError,$E03);
-
-    TESetText(8+5, {Data is in Handle in Unformatted text block}
-              teTextRef(TextHandle),
-              eofparm.eofEOF,  {Should be ignored}
-              $0000,
-              $00000000,
-              TEControl);
-    If ToolError<>0 then
-         ErrorBox(ToolError,$E04);
-    HUnlock(TextHandle);
-    If ToolError<>0 then
-         ErrorBox(ToolError,$E05);
-    DisposeHandle(TextHandle);
-    If ToolError<>0 then ErrorBox(ToolError,$E06);
-    end;
-ReadIt:=temp;
-InitCursor;
-CloseDialog(FormatDlog);
-If ToolError<>0 then ErrorBox(ToolError,$E08);
-SetPort(ApplicPort);
-end;
-
-Procedure CloseFile(theref:integer);
-var CloseRec:CloseOSDCB;
-begin
-CloseRec.pCount:=1;
-CloseRec.refNum:=theref;
-CloseGS(CloseRec);
-If ToolError<>0 then ErrorBox(ToolError,$1401);
-end;
-
-Procedure OpenStartUp(theFile:Str255);
-var
-    i,Error:  integer;
-    OpenOK,
-    Success:  Boolean;
-    temptext: Str255;
-begin
-For I:=1 to Length(thefile) do
-    Windows[openWindows+1].DocGSString.thestring[i]:=thefile[i];
-Windows[openWindows+1].DocGSString.size:=Length(thefile);
-Windows[OpenWindows+1].WindowTitle:=concat(' ',thefile,' ');
-With OPtable do begin
-    pCount:=       15;
-    refnum:=       0;
-    pathname:=     @Windows[openWindows+1].DocGSString;
-    requestAccess:=1;
-    ResourceNumber:=0;
-    end;
-OpenGS(OPtable);
-Error:=ToolError;
-If (OPTable.filetype<>$04) and (OPTable.Filetype<>$B0) then Error:=-1;
-Windows[OpenWindows+1].DocRef:=OPtable.refnum;
-OpenOK:=True;
-Success:=True;
-If Error<>0 then
-    begin
-    ErrorBox(Error,$D01);
-    Success:=False;
-    end;
-If Success then OpenOK:=MakeWindow(OpenWindows+1);
-If not OpenOK then begin
-    ErrorBox(-3,$D03);
-    CloseFile(Windows[openwindows+1].DocRef);
-    end
-    else
-    begin
-    OpenWindows:=OpenWindows+1;
-    SetWindArr(OpenWindows);
-    Windows[OpenWindows].New:=False;
-    Windows[OpenWindows].Saved:=True;
-    OpenOK:=ReadIt(OpenWindows);
-    CloseFile(Windows[openwindows].DocRef);
-    end;
-end; {of OpenStartUp}
-
-
-Procedure OpenIt(SfRecord:ReplyRecord);
-var
-    i,Error,
-    MyWindNum:integer;
-    OpenOK,
-    Success:  Boolean;
-    temptext: Str255;
-begin
-mywindnum:=0;
-For i:=5 downto 1 do
-    If Windows[i].InUse=False then mywindnum:=i;
-if mywindnum=0 then ErrorBox(-2,$C01);
-For I:=1 to Length(SFRecord.Fullpathname) do
-    Windows[mywindnum].DocGSString.thestring[i]:=SFRecord.Fullpathname[i];
-Windows[mywindnum].DocGSString.size:=Length(SFRecord.Fullpathname);
-Windows[myWindNum].WindowTitle:=SFRecord.Fullpathname;
-With OPtable do begin
-    pCount:=       15;
-    refnum:=       0;
-    pathname:=     @Windows[mywindnum].DocGSString;
-    requestAccess:=1;
-    ResourceNumber:=0;
-    end;
-OpenGS(OPtable);
-Error:=ToolError;
-Windows[mywindnum].DocRef:=OPtable.refnum;
-OpenOK:=True;
-Success:=True;
-if Error<>0 then
-    begin
-    ErrorBox(Error,$C02);
-    Success:=False;
-    end;
-If Success then OpenOK:=MakeWindow(MyWindNum);
-If not OpenOK then begin
-    ErrorBox(Error,$C03);
-    CloseFile(Windows[mywindnum].DocRef);
-    end
-    else begin
-    OpenWindows:=OpenWindows+1;
-    SetWindArr(mywindnum);
-    Windows[mywindnum].New:=False;
-    Windows[mywindnum].Saved:=True;
-    OpenOK:=ReadIt(mywindnum);
-    CloseFile(Windows[mywindnum].DocRef);
-    end;
-If OpenWindows>4 then begin
-    DisableMItem(Open_Menu_Item);
-    DisableMItem(New_Menu_Item);
-    end;
-end; {of OpenIt}
-
-Function OpenFile(i:integer):boolean;
-var OCtable:OpenOSDCB;
-    error:    integer;
-begin
-With OCtable do begin
-    pCount:=       15;
-    refnum:=       0;
-    pathname:=     @Windows[i].DocGSString;
-    requestAccess:=3;
-    ResourceNumber:=0
-    end;
-OpenGS(OCtable);
-Error:=ToolError;
-Windows[i].Docref:=OCTable.refnum;
-if Error<>0 then
-    begin
-    ErrorBox(Error,$B01);
-    OpenFile:=False;
-    end
-    else OpenFile:=True;
-end;
-
-Procedure DoOpen;
-var      prompt:        str255;
-         replyrec:      ReplyRecord;
-         TheTypeList:   TypeList;
-begin
-prompt := 'File to Open:';
-with TheTypeList do begin
-    numEntries     := 2;
-    fileType[1]    := $0004;
-    fileType[2]    := $00B0;
-    end;
-SFGetFile(100,50,@prompt,nil,@TheTypeList,replyrec);
-If toolError>0 then ErrorBox(ToolError,$A01);
-if not(replyrec.good=false) then OpenIt(replyRec);
-end;
-
-Function DeleteFile(var CreateTable:CreateOSDCB):boolean;
-var DPTable:  DestroyOSDCB;
-    I,
-    error:    Integer;
-begin
-DPTable.pcount:=1;
-DPTable.Pathname:=CreateTable.PathName;
-DestroyGS(DPTable);
-If ToolError>0 then
-    begin
-    ErrorBox(Error,$901);
-    DeleteFile:=False;
-    end
-else begin
-    CreateGS(CreateTable);
-    If ToolError>0 then begin
-         ErrorBox(ToolError,$902);
-         DeleteFile:=False;
-         end
-    else DeleteFile:=True;
-    end;
-end; {of DeleteFile}
-
-Function CreateNewFile(index:integer):Boolean;
-var CPtable:  CreateOSDCB;
-    i,
-    error:    integer;
-    prompt,
-    origname: String;
-    reply:    ReplyRecord;
-begin
-prompt:='Save conversion as:';
-origname:='Untitled';
-SFPutFile(100,50,@prompt,@origname,15,reply);
-If ToolError> 0 then ErrorBox(ToolError,$801);
-if integer(reply.good)=0 then
-    CreateNewFile:=False
-    else
-    begin
-    For I:=1 to Length(reply.fullpathname) do
-         theGSString.thestring[i]:=reply.fullpathname[i];
-    theGSString.size:=Length(reply.fullpathname);
-    With CPtable do
-         begin
-         pCount:=       7;
-         Pathname:=     @theGSString;
-         access:=       227;
-         filetype:=     4;
-         auxType:=      0;
-         StorageType:=  1;
-         DataEOF:=      1;
-         resourceEOF:=  0;
-         end;
-    CreateGS(CPtable);
-    Error:=ToolError;
-    Windows[index].DocGSString:=theGSString;
-    Windows[index].WindowTitle:=reply.Fullpathname;
-    CreateNewFile:=True;
-    If Error>0 then begin
-         If Error = 71 then CreateNewFile:=DeleteFile(CPTable)
-              else begin
-              ErrorBox(ToolError,$802);
-              CreateNewFile:=False;
-              end; {If ToolError}
-         End; {If IsToolError}
-    end; {of If not reply.good}
-end; {of CreateNewFile}
-
-Function WriteDocWindow(i:integer):boolean;
-var eofparm:  SetMarkOSDCB;
-    writeparms:readwriteOSDCB;
-    uhoh:     boolean;
-    TECtlHand:TEHandle;
-    TextHandle:Handle;
-    length:   longint;
-begin
-Uhoh:=false;
-with eofparm do
-    begin
-    pcount:=       3;
-    refnum:=       Windows[i].DocRef;
-    base:=         0;
-    displacement:= 0;
-    end;
-SetEOFGS(eofParm);           {Set EOF to zero to prepare for write}
-TECtlHand:=TEHandle(GetCtlHandleFromID(Windows[i].DocWindow,
-                                      Text_Edit_Control));
-If ToolError<>0 then ErrorBox(ToolError,$701);
-TextHandle:=NewHandle(TECtlHand^^.textlength,MyMemoryID,0,pointer(0));
-If ToolError<>0 then
-    begin
-    ErrorBox(ToolError,$702);
-    uhoh:=true;
-    end;
-If not(uhoh) then
-    begin
-    HLock(TextHandle);
-    length:=TEGetText(8+5, {Data to Handle in Unformatted text block}
-                   TextHandle,
-                   $00000000,  {ignored}
-                   $0000,
-                   $00000000,{No style info}
-                   TECtlHand);
-    If ToolError<>0 then
-         begin
-         ErrorBox(ToolError,$703);
-         uhoh:=true;
-         end;
-    end;
-if not(uhoh) then
-    begin
-    With writeparms do
-         begin
-         pcount:=       5;
-         refnum:=       Windows[i].DocRef;
-         databuffer:=   TextHandle^;
-         requestcount:=length;
-         cachePriority:=0;
-         end;
-    WriteGS(writeparms);
-    If ToolError<>0 then
-         begin
-         ErrorBox(ToolError,$704);
-         uhoh:=true;
-         end;
-     end;
-WriteDocWindow:=not(uhoh);
-HUnlock(TextHandle);
-DisposeHandle(TextHandle);
-end;
-
-Procedure DoSaveAs;
-var i:        integer;
-    theDocptr:DocumentPtr;
-    theDoc:   Document;
-    success:  boolean;
-    TEControl:TEHandle;
-    dirty:    byte;
-begin
-theDocPtr:=DocumentPtr(GetWRefCon(FrontWindow));
-theDoc:=theDocPtr^;
-i:=theDoc.Index;
-If CreateNewFile(i) then
-    begin
-    if OpenFile(i) then success:=writeDocWindow(i);
-    CloseFile(Windows[i].DocRef);
-    end;
-If Success then
-    With Windows[i] do begin
-         If Length(WindowTitle)>15 then
-           WindowItems[i]:=concat('...',
-                                  copy(WindowTitle,Length(WindowTitle)-15,17),
-                                  '  ')
-            else
-           WindowItems[i]:= WindowTitle;
-         SetWTitle(@WindowTitle,DocWindow);
-         SetMItemName(@WindowItems[i],i+264);
-         EnableMItem(i+264);
-         CalcMenuSize(0,0,4);
-         saved:=true;
-         new:=false;
-         TEControl:=TEHandle(GetCtlHandleFromID(DocWindow,
-                                                Text_Edit_Control));
-         If ToolError<>0 then ErrorBox(ToolError,$601);
-         TEControl^^.ctlFlag:=TEControl^^.ctlFlag & $bf;
-         end; {of with windows}
-end;
-
-procedure DoSave;
-var i:   integer;
-    theDocptr:DocumentPtr;
-    theDoc:   Document;
-    success:  boolean;
-    TEControl:TEHandle;
-    dirty:    byte;
-begin
-theDocPtr:=DocumentPtr(GetWRefCon(FrontWindow));
-theDoc:=theDocPtr^;
-i:=theDoc.Index;
-success:=false;
-if windows[i].new then DoSaveAs
-    else
-    begin
-    if OpenFile(i) then success:=WriteDocWindow(i);
-    CloseFile(windows[i].DocRef);
-    end;
-If success then begin
-    windows[i].saved:=true;
-    TEControl:=TEHandle(GetCtlHandleFromID(Windows[i].DocWindow,
-                                                Text_Edit_Control));
-    If ToolError<>0 then ErrorBox(ToolError,$501);
-    TEControl^^.ctlFlag:=TEControl^^.ctlFlag & $bf;
-    end;
-end;
-
-procedure ContinueClose(i:integer);
-begin
-CloseWindow(Windows[i].DocWindow);     {close it}
-Windows[i].DocWindow := nil;
-Windows[i].InUse:=False;
-OpenWindows:=OpenWindows-1;
-EnableMItem(Open_Menu_Item);
-EnableMItem(New_Menu_Item);
-WindowItems[i]:=concat('Window',cnvis(i));
-SetMItemName(@WindowItems[i],i+264);
-CalcMenuSize(0,0,4);
-DisableMItem(264+i);
-If OpenWindows=0 then
-    begin
-    Windfront:=false;
-    DisableMItem(Close_Menu_Item);
-    DisableMItem(Print_Item);
-    DisableMItem(Save_Menu_Item);
-    DisableMItem(SaveAs_Menu_Item);
-    DisableMItem(Page_Setup_Item);
-    DisableMItem(Word_Wrap_Item);
-    DisableMITem(Choose_Font_Item);
-    end;
-end;
-
-procedure DoClose;
-var i:        integer;
-    theDocptr:DocumentPtr;
-    theDoc:   Document;
-    TEControl:TEHandle;
-    dirty:    byte;
-    button:   integer;
-begin
-if FrontWindow <> nil then
-    begin
-    if GetWKind(FrontWindow)=0 then
-         begin
-         theDocPtr:=DocumentPtr(GetWRefCon(FrontWindow));
-         theDoc:=theDocPtr^;
-         i:=theDoc.Index;
-         TEControl:=TEHandle(GetCtlHandleFromID(Windows[i].DocWindow,
-                                                Text_Edit_Control));
-         If ToolError<>0 then ErrorBox(ToolError,$401);
-         dirty:=TEControl^^.ctlFlag;
-         if (dirty & $0040) <> 0 then
-              Windows[i].saved:=false;
-         if not (Windows[i].saved) then
-              begin
-              button:=AlertWindow(5,nil,pointer(Save_Alert));
-              if button=2 then DoSave;
-              if button>0 then ContinueClose(i);
-              end
-              else ContinueClose(i);
-         end
-    end
-  else begin
-  CloseNDAByWinPtr(FrontWindow);
-  If ToolError<>0 then ErrorBox(ToolError,$402);
-  end;
-end; {DoClose}
-
-Procedure GoGetBuffer;
-var any:      integer;
-    PathPtr:  StringPtr;
-    NotDone:  Boolean;
-    PPtable:  PrefsOSDCB;
-begin
-PPtable.pcount:=1;
-PPtable.preferences:=$8000;
-SetSysPrefsGS(PPTable);
-If ToolError<>0 then ErrorBox(ToolError,$301);
-
-new(PathPtr);
-Any:=InitReadMc(MyMemoryID);
-OpenWindows:=0;
-If Any>-1 then 
-    Repeat
-    NotDone:=ReadNextMc(PathPtr);
-    if (NotDone) and (OpenWindows<5) then OpenStartUp(PathPtr^);
-    Until NotDone=False;
-If OpenWindows>4 then begin
-    DisableMItem(Open_Menu_Item);
-    DisableMItem(New_Menu_Item);
-    end;
-end;
-
-Procedure DoChooseFont;
-var i:        integer;
-    theDocptr:DocumentPtr;
-    theDoc:   Document;
-    TECtlHand:TEHandle;
-    theid:    longint;
-    thestyle: TEStyle;
-begin
-thestyle.teFont.fid:=ChooseFont(FMGetCurFID,0);
-If ToolError<>0 then ErrorBox(ToolError,$1601);
-theDocPtr:=DocumentPtr(GetWRefCon(FrontWindow));
-theDoc:=theDocPtr^;
-i:=theDoc.Index;
-TECtlHand:=TEHandle(GetCtlHandleFromID(Windows[i].DocWindow,
-                                      Text_Edit_Control));
-FormDlog;
-If ToolError<>0 then ErrorBox(ToolError,$1602);
-TESetSelection(0,TECtlHand^^.textlength,TECtlHand);
-If ToolError<>0 then ErrorBox(ToolError,$1603);
-TEStyleChange($62,theStyle,TECtlHand);
-If ToolError<>0 then ErrorBox(ToolError,$1604);
-InitCursor;
-CloseDialog(FormatDlog);
-If ToolError<>0 then ErrorBox(ToolError,$1605);
-SetPort(ApplicPort);
-end;
-
-Procedure ChangeWrap;
-var i:        integer;
-    theDocptr:DocumentPtr;
-    theDoc:   Document;
-    TEControl:TEHandle;
-    flag:     longint;
-    theruler: Handle;
-begin
-theDocPtr:=DocumentPtr(GetWRefCon(FrontWindow));
-theDoc:=theDocPtr^;
-i:=theDoc.Index;
-TEControl:=TEHandle(GetCtlHandleFromID(Windows[i].DocWindow,
-                                       Text_Edit_Control));
-If ToolError<>0 then ErrorBox(ToolError,$1501);
-FormDlog;
-flag:=TEControl^^.textflags;
-flag:=(flag ! $10000000);
-if (flag & $10000000)=0 then begin
-    Windows[i].Wrap:=True;
-    CheckMItem(true,Word_Wrap_Item);
-    end
-    else begin
-    CheckMItem(false,Word_Wrap_Item);
-    Windows[i].Wrap:=False;
-    end;
-TEControl^^.textflags:=flag;
-theRuler:=NewHandle(80,MyMemoryID,
-                   attrLocked+attrFixed+attrNoCross,
-                   Pointer(0));
-If ToolError<>0 then ErrorBox(ToolError,$1502);
-TEGetRuler(terefIsHandle,theruler,TEControl);
-If ToolError<>0 then ErrorBox(ToolError,$1503)
-    else begin
-    TESetRuler(teRefIsHandle,theruler,TEControl);
-    If ToolError<>0 then ErrorBox(ToolError,$1504);
-    end;
-DisposeHandle(theRuler);
-InitCursor;
-CloseDialog(FormatDlog);
-If ToolError<>0 then ErrorBox(ToolError,$1605);
-SetPort(ApplicPort);
-end;
-
-procedure ProcessMenu(Code: longint);
-var menuNum : integer;
-    itemNum : integer;
-begin
-    menuNum := HiWord(Code);
-    itemNum := LoWord(Code);
- 
-    case itemNum of
-         {Apple Menu}
-        About_Menu_Item :    DoAbout;
-         {File Menu}
-         New_Menu_Item:      DoNew;
-         Open_Menu_Item:     DoOpen;
-         Close_Menu_Item:    DoClose;
-         Save_Menu_Item:     DoSave;
-         SaveAs_Menu_Item:   DoSaveAs;
-         Page_Setup_Item:    DoPageSetup;
-         Print_Item:         DoPrintDoc;
-        Quit_Menu_Item  :    Done := true;
-         {Edit Menu}
-         Undo_Menu_Item:;
-         Cut_Menu_Item:;
-         Copy_Menu_Item:;
-         Paste_Menu_Item:;
-         Clear_Menu_Item:;
-         Window1_Item:   DoToFront(1);
-         Window2_Item:   DoToFront(2);
-         Window3_Item:   DoToFront(3);
-         Window4_Item:   DoToFront(4);
-         Window5_Item:   DoToFront(5);
-         Word_Wrap_Item: ChangeWrap;
-         Choose_Font_Item:DoChooseFont;
-        otherwise ;
-    end; {case}
- 
-    HiliteMenu(false,menuNum);
-end;
-
-Procedure modifymenus(i:integer);
-begin
-if i=0 then
-    begin          {Back to Texter windows}
-    If windfront=true then
-         begin
-         enableMItem(Save_Menu_Item);
-         enableMitem(SaveAs_Menu_Item);
-         enableMItem(Page_Setup_Item);
-         enableMItem(Print_Item);
-         enableMItem(Choose_Font_Item);
-         enableMItem(Word_Wrap_Item);
-         end;
-    end
-    else
-    begin
-    If windfront=true then
-         begin
-         disableMItem(Save_Menu_Item);
-         disableMitem(SaveAs_Menu_Item);
-         disableMItem(Page_Setup_Item);
-         disableMItem(Print_Item);
-         disableMItem(Choose_Font_Item);
-         disableMItem(Word_Wrap_Item);
-         end;
-    end;
-end;
-
-procedure CheckFront;
-var currwindow:    integer;
-    fwind:         GrafPortPtr;
-    i:             integer;
-    theDocptr:     DocumentPtr;
-    theDoc:        Document;
-begin
-fWind:=FrontWindow;
-currwindow:=GetWKind(Fwind);
-if currwindow<>oldwindow then
-    Modifymenus(currwindow);
-theDocPtr:=DocumentPtr(GetWRefCon(FWind));
-theDoc:=theDocPtr^;
-i:=theDoc.Index;
-If Windows[i].Wrap then CheckMItem(true,Word_Wrap_Item)
-    else CheckMItem(false,Word_Wrap_Item);
-end;
-
-procedure MainEventLoop;
-var Event     : EventRecord;
-    EventCode : integer;
-begin
-    Event.TaskMask := $FFFFF;
-    while not done do begin
-        CheckFront;
-        EventCode := TaskMaster($076E,Event);
-        case EventCode of
-            wInSpecial,
-            wInMenuBar : ProcessMenu(Event.TaskData);
-            wInContent :;
-            wInGoAway  : DoClose;
-            otherwise ;
-        end; {case}
-    end; {while}
-end;
-
-procedure SetUpMenus;
-var
-    height: Integer;
-
-begin
-SetSysBar(CtlRecHndl(NewMenubar2(refIsResource,Application_Menu_Bar, nil)));
-SetMenuBar(nil);
-FixAppleMenu(Apple_Menu);        { Add DAs to apple menu }
-If ToolError<>0 then ErrorBox(ToolError,$201);
-height := FixMenuBar;             { Set sizes of menus }
-DrawMenuBar;        { and draw the menu bar! }
-end; { of SetUpMenus }
-
-
-Procedure Initialize;
-begin
-OldWindow:=1;
-ErrStringPtr:=@ErrStringArr;
-PrintRecHandle:=PrHandle(NewHandle($8C,         {Size of Printer Job Rec}
-                          MyMemoryID,
-                          attrnocross+attrfixed+attrlocked,
-                          Pointer(0)));
-If ToolError<>0 then ErrorBox(ToolError,$101);
-PrDefault(PrintRecHandle);
-If ToolError<>0 then ErrorBox(ToolError,$102);
-Windfront:=false;
-end;
-
-
-begin
-TLStartUp;
-MyMemoryID := MMStartUp;
-
-StartStopRef := StartupTools(MyMemoryID,refIsResource,Tool_StartUp_Table);
-result:=ToolError;
-If result=0 then
-    begin
-    Initialize;
-    SetUpMenus;
-    GoGetBuffer;
-    InitCursor;
-    MainEventLoop;
-    end
-    else
-    NoRun(result);
-
-ShutDownTools(refIsHandle, StartStopRef);
-end.
-
=texter.r.src
-// --------------------------------------------------------------------
-// Genesys created REZ data code
-// Simple Software Systems International, Inc.
-// APWREZ.SCG 1.2
-// --------------------------------------------------------------------
-
-#include "types.rez"
-
-// --- Control Templates
-
-resource rControlTemplate (Text_Edit_Control, $0000) {
-       $00000001,              // ID
-       {  0,  0,170,590},      // rect
-       editTextControl {{
-               $0000,          // flag
-               $7C00,          // moreFlags
-               $00000000,      // refCon
-               $22280000,      // textFlags
-               {65535,65535,65535,65535},  // indentRect
-               $FFFFFFFF,      // vertBar
-               $0000,          // vertAmount
-               $00000000,      // horzBar
-               $0000,          // horzAmount
-               $00000000,      // styleRef
-               $0015,          // textDescriptor
-               Edit_pString,  // textRef
-               $00000000,      // textLength
-               $00000000,      // maxChars
-               $00000000,      // maxLines
-               $0000,          // maxCharsPerLine
-               $0000,          // maxHeight
-               0,              // colorTableRef
-               $0000,          // drawMode
-               $00000000       // filterProcPtr
-       }};
-};
-
-// --- rPString Templates
-
-resource rPString (Apple_pString, $C018) {
-       "@"
-};
-
-resource rPString (File_pString, $C018) {
-       "  File  "
-};
-
-resource rPString (Edit_pString, $C018) {
-       "  Edit  "
-};
-
-resource rPString (Windows_pString, $C018) {
-       "  Windows  "
-};
-
-resource rPString (Goodies_pString, $C018) {
-       "  Goodies  "
-};
-
-resource rPString (Undo_pString, $C018) {
-       "Undo"
-};
-
-resource rPString (Cut_pString, $C018) {
-       "Cut"
-};
-
-resource rPString (Copy_pString, $C018) {
-       "Copy"
-};
-
-resource rPString (Paste_pString, $C018) {
-       "Paste"
-};
-
-resource rPString (Clear_pString, $C018) {
-       "Clear"
-};
-
-resource rPString (Close_pString, $C018) {
-       "Close"
-};
-
-resource rPString (About_pString, $C018) {
-       "About..."
-};
-
-resource rPString (Quit_pString, $C018) {
-       "Quit"
-};
-
-resource rPString (New_pString, $C018) {
-       "New"
-};
-
-resource rPString (Open_pString, $C018) {
-       "Open..."
-};
-
-resource rPString (Save_pString, $C018) {
-       "Save"
-};
-
-resource rPString (SaveAs_pString, $C018) {
-       "Save as..."
-};
-
-resource rPString (Page_Setup_pString, $C018) {
-       "Page Setup..."
-};
-
-resource rPString (Print_pString, $C018) {
-       "Print..."
-};
-
-resource rPString (Window1_pString, $C018) {
-       "Window1"
-};
-
-resource rPString (Window2_pString, $C018) {
-       "Window2"
-};
-
-resource rPString (Window3_pString, $C018) {
-       "Window3"
-};
-
-resource rPString (Window4_pString, $C018) {
-       "Window4"
-};
-
-resource rPString (Window5_pString, $C018) {
-       "Window5"
-};
-
-resource rPString (Word_Wrap_pString, $C018) {
-       "Word Wrap On"
-};
-
-resource rPString (Choose_Font_pString, $C018) {
-       "Choose Font"
-};
-
-resource rPString (Text_Window_Title, $0000) {
-       " Title "
-};
-
-// --- Menu Bar Definitions
-
-resource rMenuBar (Application_Menu_Bar, $C018) {
-       {
-       Apple_Menu,
-       File_Menu,
-       Edit_Menu,
-       Window_Menu,
-       Goodies_Menu
-       };
-};
-
-// --- Menu Definitions
-
-resource rMenu (Apple_Menu, $C018) {
-       $0001,                  // menuID
-       $A008,                  // menuFlag
-       Apple_pString, {        // menuTitleRef
-               About_Menu_Item
-       };
-};
-
-resource rMenu (File_Menu, $C018) {
-       $0002,                  // menuID
-       $A008,                  // menuFlag
-       File_pString, {        // menuTitleRef
-               New_Menu_Item,
-               Open_Menu_Item,
-               Close_Menu_Item,
-               Save_Menu_Item,
-               SaveAs_Menu_Item,
-               Page_Setup_Item,
-               Print_Item,
-               Quit_Menu_Item
-       };
-};
-
-resource rMenu (Edit_Menu, $C018) {
-       $0003,                  // menuID
-       $A008,                  // menuFlag
-       Edit_pString, {        // menuTitleRef
-               Undo_Menu_Item,
-               Cut_Menu_Item,
-               Copy_Menu_Item,
-               Paste_Menu_Item,
-               Clear_Menu_Item
-       };
-};
-
-resource rMenu (Window_Menu, $C018) {
-       $0004,                  // menuID
-       $A008,                  // menuFlag
-       Windows_pString, {        // menuTitleRef
-               Window1_Item,
-               Window2_Item,
-               Window3_Item,
-               Window4_Item,
-               Window5_Item
-       };
-};
-
-resource rMenu (Goodies_Menu, $C018) {
-       $0005,                  // menuID
-       $A008,                  // menuFlag
-       Goodies_pString, {        // menuTitleRef
-               Word_Wrap_Item,
-               Choose_Font_Item
-       };
-};
-
-// --- Menu Item Definitions
-
-resource rMenuItem (Undo_Menu_Item, $C018) {
-       $00FA,                  // itemID
-       "Z","z",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8040,                  // itemFlag
-       Undo_pString           // itemTitleRef
-};
-
-resource rMenuItem (Cut_Menu_Item, $C018) {
-       $00FB,                  // itemID
-       "X","x",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8000,                  // itemFlag
-       Cut_pString           // itemTitleRef
-};
-
-resource rMenuItem (Copy_Menu_Item, $C018) {
-       $00FC,                  // itemID
-       "C","c",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8000,                  // itemFlag
-       Copy_pString           // itemTitleRef
-};
-
-resource rMenuItem (Paste_Menu_Item, $C018) {
-       $00FD,                  // itemID
-       "V","v",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8000,                  // itemFlag
-       Paste_pString           // itemTitleRef
-};
-
-resource rMenuItem (Clear_Menu_Item, $C018) {
-       $00FE,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8000,                  // itemFlag
-       Clear_pString           // itemTitleRef
-};
-
-resource rMenuItem (Close_Menu_Item, $C018) {
-       $00FF,                  // itemID
-       "W","w",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Close_pString           // itemTitleRef
-};
-
-resource rMenuItem (About_Menu_Item, $0018) {
-       $0100,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8040,                  // itemFlag
-       About_pString           // itemTitleRef
-};
-
-resource rMenuItem (Quit_Menu_Item, $0018) {
-       $0101,                  // itemID
-       "Q","q",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8000,                  // itemFlag
-       Quit_pString           // itemTitleRef
-};
-
-resource rMenuItem (New_Menu_Item, $C018) {
-       $0102,                  // itemID
-       "N","n",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8000,                  // itemFlag
-       New_pString           // itemTitleRef
-};
-
-resource rMenuItem (Open_Menu_Item, $0018) {
-       $0103,                  // itemID
-       "O","o",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8040,                  // itemFlag
-       Open_pString           // itemTitleRef
-};
-
-resource rMenuItem (Save_Menu_Item, $C018) {
-       $0104,                  // itemID
-       "S","s",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Save_pString           // itemTitleRef
-};
-
-resource rMenuItem (SaveAs_Menu_Item, $C018) {
-       $0105,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $80C0,                  // itemFlag
-       SaveAs_pString           // itemTitleRef
-};
-
-resource rMenuItem (Page_Setup_Item, $0018) {
-       $0107,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Page_Setup_pString           // itemTitleRef
-};
-
-resource rMenuItem (Print_Item, $C018) {
-       $0108,                  // itemID
-       "P","p",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $80C0,                  // itemFlag
-       Print_pString           // itemTitleRef
-};
-
-resource rMenuItem (Window1_Item, $C018) {
-       $0109,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Window1_pString           // itemTitleRef
-};
-
-resource rMenuItem (Window2_Item, $C018) {
-       $010A,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Window2_pString           // itemTitleRef
-};
-
-resource rMenuItem (Window3_Item, $C018) {
-       $010B,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Window3_pString           // itemTitleRef
-};
-
-resource rMenuItem (Window4_Item, $C018) {
-       $010C,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Window4_pString           // itemTitleRef
-};
-
-resource rMenuItem (Window5_Item, $C018) {
-       $010D,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Window5_pString           // itemTitleRef
-};
-
-resource rMenuItem (Word_Wrap_Item, $C018) {
-       $010E,                  // itemID
-       "","",                  // itemChar, itemAltChar
-       $0012,                  // itemCheck
-       $8080,                  // itemFlag
-       Word_Wrap_pString           // itemTitleRef
-};
-
-resource rMenuItem (Choose_Font_Item, $C018) {
-       $010F,                  // itemID
-       "F","f",                // itemChar, itemAltChar
-       NIL,                    // itemCheck
-       $8080,                  // itemFlag
-       Choose_Font_pString           // itemTitleRef
-};
-
-// --- Window Templates
-
-resource rWindParam1 (Text_Window, $0000) {
-       $C1A0,                  // plFrame (frame bits)
-       Text_Window_Title,          // plTitle (title ID)
-       $00000000,              // plRefCon
-       {  0,  0,  0,  0},      // plZoomRect
-       Text_Window_wColor,        // plColorTable
-       {$0000, $0000},         // plYOrigin, plXOrigin
-       {$0000, $0000},         // plDataHeight, plDataWidth
-       {$0000, $0000},         // plMaxHeight, plMaxWidth
-       {$0000, $0000},         // plVerScroll, plHorScroll
-       {$0000, $0000},         // plVerPage, plHorPage
-       $00000000,              // plInfoText (info RefCon)
-       $0000,                  // plInfoHeight
-       { 27, 24,197,614},      // plPosition
-       infront,                // plPlane
-       Text_Edit_Control,        // plControlList
-       $0A02                   // plInDesc
-};
-
-// --- Window Color Templates
-
-resource rWindColor (Text_Window_wColor, $0000) {
-       $0000,                  // frameColor
-       $0F00,                  // titleColor
-       $0207,                  // tBarColor
-       $F0FF,                  // growColor
-       $F0F0                   // infoColor
-};
-
-// --- Tool Startup Table Templates
-
-resource rToolStartup (Tool_Startup_Table, $0000) {
-       $C080, {                // videoMode
-                3, $0300,      // Miscellaneous Tools 
-                4, $0301,      // QuickDraw II 
-                5, $0302,      // Desk Manager 
-                6, $0300,      // Event Manager 
-               11, $0200,      // Integer Math 
-               14, $0301,      // Window Manager 
-               15, $0301,      // Menu Manager 
-               16, $0301,      // Control Manager 
-               18, $0301,      // QuickDraw II Aux. 
-               19, $0300,      // Print Manager 
-               20, $0301,      // LineEdit Tools 
-               21, $0301,      // Dialog Manager 
-               22, $0300,      // Scrap Manager 
-               23, $0301,      // Standard File Tools 
-               27, $0301,      // Font Manager 
-               28, $0301,      // List Manager 
-               30, $0100,      // Resource Manager 
-               34, $0101       // TextEdit Manager 
-       }
-};
-
-// --- rAlertString Templates
-
-resource rAlertString (Printing_Alert, $0000) {
-       "53~A Printing Error Has Occurred!~^#6"
-       "\$00"
-};
-
-resource rAlertString (Tool_Error_Alert, $0000) {
-       "54~Tool Error *0 Has Occurred at *1!~^#6"
-       "\$00"
-};
-
-resource rAlertString (Save_Alert, $0000) {
-       "23~"
-       "\$0D"
-       " Save Changes?~#1~#3~^#2"
-       "\$00"
-};
-
-// --- rText Templates
-
-resource rText (Window_Text, $0000) {
-       " "
-};
-
+ END OF ARCHIVE