[comp.sources.apple2] v001SRC047: 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:47
Archive-name: editor/texter/part01
Architecture: ONLY_2gs
Version-number: 1.1.1

Texter is a text editor for the GS.

Enjoy.


=Read.Me
-
-Texter
-
-Version 1.1.1
-
-I am not perfect so please point out errors, suggestions, etc. to
-me.  I would appreciate knowing what I am doing right or wrong.
-
-This source is compiled with Orca/Pascal (tm Byteworks) and the
-Resource was created with Genesys (tm SSSI) though I created APW
-Rez (tm Apple Computer) source with Genesys so you could see what
-the resource fork was.
-
-Also included is a unit by Dave Lyons of Apple Computer to utilitize
-MessageCenter.  This unit is Public Domain.  I made 1 little change
-to it because of compiler type-checking and such.  His original code
-is still there, enclosed in comments.
-
-This code is for demonstration purposes only.  Please do not re-distribute
-without this header.
-
-If you have any questions, contact me at:
-
-	Joel Sumner
-	19 Fossen Way
-	Andover, MA 01810
-
-	GEnie: JOEL.SUMNER
-	Internet: q4kx@cornella.ccs.cornell.edu
-		  q4kx@vax5.cit.cornell.edu
-	Bitnet:   q4kx@CORNELLA
-		  q4kx@CRNLVAX5
-
-Release Notes:
-
-	Fixed bug in Version 1.1 where PrDefault() was called every
-	time the user selected "Page Setup" instead of calling
-	PrDefault() when Texter was started up and then PrValidate
-	after that.
-
=Manifest
-
-Read.Me
-icons.bsc
-messunit.pas
-mystuffintf.pas
-texter.doc
-texter.pas
-texter.r.equ
-texter.r.src
-texter2.pas
-
=texter.doc
-
-                        Texter v1.1
-                       By Joel Sumner
-
-Background
-----------
-     This is the next in a continuing series of little programs that
-I have made because I needed them.  This one in particular is
-just a text editor.  Simple enough.  But I couldn't find one
-that allowed you to double-click on the file from the finder
-and have it load the text editor and the file you double-
-clicked upon.  Appleworks GS does this but many other programs
-don't.  Therefore, I decided to write one.  I happened to write
-this the same week that I had two exams and a long paper due.
-I always seem to do that to myself.  Anyway, I hope you like it.
-
-Use
----
-     You can run Texter one of two ways.  Either run it as a regular
-application just as you would any other program, or you can
-double-click upon a text file in a finder window and Texter
-will automatically be run and the file you clicked upon will
-be run.  You can even select more than one file and double-
-click upon them.  A maximum of 5 files will be loaded though,
-even if you select more than that.
-
-Installation
-------------
-     Included in this archive is the program (Texter), the
-documentation file (Texter.Doc), and an Icon file (Texter.ICN).
-Place the Icon file in the ICONS folder of your boot disk
-and place Texter in the SYSTEM subdirectory of your boot
-disk.  It should now work just fine.
-     If you need to put Texter somewhere besides the SYSTEM
-subdirectory of your boot disk (due to space or preference),
-you will have to edit the attributes of the Icon file to
-reflect the new loaction of Texter.  This can be accomplished
-with one of the Icon Editors out there.  (I recommend DiCeD by
-Dave Lyons.)  Simply load the Icon file into the editor
-and change the attributes like that says:
-
-*/SYSTEM/TEXTER
-
-to whatever pathname that Texter currently resides in.
-(The '*' refers to your boot disk.  My hard drive title is '/js'
-and I boot off it so '*' is the same as '/js')
-
-Note, if you try to run the program and get a text dialog saying
-"Error $1E06", that means that the resource fork was not copied
-properly.  Make sure you extract the archive with GSHK and copy
-it to your destination with the Apple IIgs Finder.
-
-Features
---------
-     This is pretty no-frills.  You can open up to 5 files at a
-time.  Their full pathname will be displayed in the window
-title and part of their pathname can be seen in the 'Windows'
-menu.  If you have a bunch of windows open and you wish to
-view one of the bottom ones, you can either move all the top
-windows out of the way (slow way), or you can simply select
-that window in the 'Windows' menu (fast way).
-     You can cut and paste text between windows, but the Undo
-command does not function.
-
-Texter uses all of the standard Text Edit shortcuts:
-
-- The arrow keys can be used to move the cursor
-- Control-D or Delete will delete the current selection or the
-  character to the left of the cursor.
-- Clear clears the current selection
-- Control-F removes the current selection or deletes the
-  character to the right of the cursor
-- Control-Y removes all characters from the cursor to the
-  end of the line
-- Control-X cuts the selection like OA-X and Cut
-- Control-C copies the selection like OA-C and Copy
-- Control-V pastes from the clipboard like OA-V and Paste
-- A single click places the cursor where the click was
-- A double click selects the word under the arrow
-- A triple click selects the line under the arrow
-- Holding down shift selects everything from the cursor to the
-  mouse click
-
-You can also print your document.  I assure you that the default
-font (Shaston 8) looks pretty horrid on a printer.  Thus, simply
-select the Choose Font option from the Goodies menu and select
-a better font to print with.  Experiment until you find something
-that looks acceptable.
-
-Finally, you can choose if you want the document word-wrapped or
-not.  Simply select the toggle in the Goodies Menu.  If "Word Wrap On"
-is checked, then the current document has word wrap activated.
-This setting is dependent on the window so turning it on or off
-only affects the current window.
-
-None of the above settings are changed because, after all, this edits
-straight text files, not word processor files.
-
-Other Notes
------------
-- TextEdit automatically formats your files so they word wrap.
-This takes a certain amount of time.  Thus loading large files
-(200K or more) can take a good amount of time (20-25 seconds)
-to be formatted.  Please be patient.
-- Files cannot be loaded that are more than 1/2 of available
-memory.  This is because two copies of the file must temporarily
-be in memory simultaneously when loading or saving files and
-there would be no memory available to do this.
-
-Conclusion
-----------
-     Well, that's about it.  I hope you enjoy or use this program.
-As you may notice, I have said nothing about money.  That's
-because I don't want any.  This is Freeware.  As a request though,
-if you do actually install it and use it, please drop me a line
-and let me know what you think.  If you send it via E-Mail, even
-the response doesn't cost anything.  If you have any questions,
-comments, or responses, I can be reached at the following
-addresses:
-
-Joel Sumner
-19 Fossen Way
-Andover, MA 01810
-
-GEnie: JOEL.SUMNER
-Internet:
-q4kx@cornella.ccs.cornell.edu
-q4kx@vax5.cit.cornell.edu
-Bitnet:
-q4kx@cornella
-q4kx@crnlvax5
-
-Updates
---------
-(Version 1.1)
-- Fixed bug that caused an error $206 on startup and prevented printing
-  with anything but the ImageWriter driver.
-- Added Goodies Menu with Word Wrap selection and Font selection.
-- Added 'Formatting Text' dialogs.
-- Better Tool Error dialogs to determine where errors have occurred.
-- New (and improved) icon file.
-
=icons.bsc
-FiLeStArTfIlEsTaRt
-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()
-IICONS.BSC      AMQuAAAAAYwwDIAA2qKAq(AHPUhtAMQuAcj0
-GVvTlzW6BcbYAAAAO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bNCSHrGHsj5fh4gBrpwniumy5mGr49ALvwq0tJ9b
-hnCzroKWMaKe7a6CGRoegTgJBkCz6TlvEA6JLokh8KaAq42AC6u70666pppUolpP
-OtuqMiDpFYiSHwv5YE8TmQ9oV4zx(bD60pg7MBrvAAYBLdhQ)EQNvJ42IKbMqyme
-qb5H4m5jAgHYAWOmwsYIii85KvMrUIDrYPKrZXtgF4Jgpp9CgWQpAAwHAAAAAAAA
-AE2e
=messunit.pas
-{$Keep 'MessUnit'}
-UNIT MessUnit;
-{
-  PUBLIC DOMAIN      20-Sep-89      v1.1
- 
-  Easy-to-use interface for reading a list of pathnames
-  passed to an application by the Finder or another
-  program selector.  This list is passed in the Message
-  Center as described in the Tool Locator chapter of
-  the Toolbox Reference, Volume 2.
- 
-  Modified September 1989 for TML Pascal II.
- 
-  To use:
-    Call InitReadMC with a valid memory ID.  If it returns
-    -1, no message was available.  If InitReadMC returns 0
-     or 1, then a list of pathnames is available.  0 means
-     the application should OPEN the files, and 1 means it
-     should PRINT them.
- 
-     Repeatedly call ReadNextMC to get a pathname. It
-     returns FALSE when there are no more pathnames to
-     get.  (To clarify, False means the PREVIOUS call gave
-     you the last available pathname.)
- 
-     Even if you are going to accept only one pathname from
-     the MessageCenter (not recommended), you should still
-     call ReadNextMC until it returns FALSE.  Otherwise some
-     memory will needlessly be left allocated.
- 
-     Tip:  Be sure to allow for people fiddling with their
-     icon files!  Do NOT assume that any pathname given to
-     you by the MessageCenter will specify a file of the
-     type you expect--check.
- 
-     Also, don't assume that the volumes containing the files
-     are necessarily online when your application is launched.
-     You may need to ask the user to insert the correct disk.
- 
-  by David A. Lyons a.k.a. DAL Systems
-  P.O. Box 287
-  North Liberty, IA 52317
- 
-  CompuServe 72177,3233
-  GEnie D.LYONS2
-  AppleLink--PE Dave Lyons
-}
- 
-INTERFACE
- 
-USES Common, ToolLocator, MemoryMgr;
-
-Type     Str255 = string[255];   {My Additions to TYPE}
-         StringPtr = ^Str255;
-
-function  InitReadMC(id: integer): integer;
-function  ReadNextMC(s: StringPtr): boolean;
- 
-IMPLEMENTATION
-type
-  myMessageRec = RECORD
-    messageNext: longint;
-    messageType: integer;
-    messageData: integer;
-    fileNames: packed array[1..32000] of char;
-  END;
-  MessagePtr = ^myMessageRec;
-  MessageH = ^MessagePtr;
- 
-var
-  MsgHand:  MessageH;
-  MsgIndex: integer;
- 
-function InitReadMC;
-var
-  err: integer;
-begin
-  InitReadMC := -1;
-  MsgIndex := 1;
-  MsgHand := MessageH(NewHandle(0,id,attrNoCross,nil));
-  MessageCenter(getMessage,1,Handle(MsgHand));
-  err := ToolError;
-  MessageCenter(deleteMessage,1,nil);
-  if err=0 then
-    InitReadMC := MsgHand^^.messageData
-  else
-    DisposeHandle(handle(MsgHand));
-end;
- 
-function ReadNextMC;
-var
-  len,i: integer;
-  tempStr: Str255;
-begin
-  s^ := '**********';
-  ReadNextMC := false;
-  len := ord(MsgHand^^.FileNames[MsgIndex]);
-  if len<>0 then begin
-    ReadNextMC := true;
-    {BlockMove(@MsgHand^^.FileNames[MsgIndex],ptr(s),len+1);} {Dave's}
-    For i:=0 to len do
-     tempStr[i]:=MsgHand^^.FileNames[MsgIndex+i];    {My [Joel's] Routine}
-    MsgIndex := MsgIndex + len + 1;
-  end else
-    DisposeHandle(handle(MsgHand));
-s^:=TempStr;
-end;
- 
-END.
=mystuffintf.pas
-{$Keep 'MyStuff'}
-Unit MyStuff;
-Interface
-
-Uses     Common,
-         DialogMgr,
-         MscToolSet,
-         WindowMgr,
-         QuickDrawII,
-         {$LibPrefix '0/'}
-         MessUnit;       {Dave Lyon's Unit for Message Center}
-
-
-type
-         SubstArray = Array [0..1] of StringPtr;
-
-var
-         TempTextString:     Str255;
-         result:        Integer;
-         errString:     StringPtr;
-         errStringArr:  SubstArray;
-         errStringPtr:  ^SubstArray;
-
-
-PROCEDURE SystemError (ErrNum : Integer);
-Function cnvihs(theint:integer):StringPtr;
-Procedure ErrorBox(error,where:integer);
-
-Implementation
-PROCEDURE SystemError;
-
-    BEGIN    { This is to save code - we don't need Pascal's Run-Time errors }
-    END;
-
-Function cnvihs;      {converts integer to hex string}
-var tmpStrPtr    :StringPtr;
-    TmpStr       :String;
-    i:        integer;
-begin
-tmpstr[0]:=char(5);
-i:=integer((theint & $F)+48);
-if I<58 then tmpstr[5]:=char(i)
-    else tmpstr[5]:=char(i+7);
-i:=integer((theint & $F0) div $10 +48);
-if I<58 then tmpstr[4]:=char(i)
-    else tmpstr[4]:=char(i+7);
-i:=integer((theint & $F00)div $100 + 48);
-if I<58 then tmpstr[3]:=char(i)
-    else tmpstr[3]:=char(i+7);
-i:=integer((theint & $F000)div $1000 + 48);
-if (I<56) and (I>47) then tmpstr[2]:=char(i)
-    else if (I=40) or (I=41) then tmpstr[2]:=char(I+16)
-    else if I>41 then tmpstr[2]:=char(i+23);
-tmpstr[1]:=char('$');
-TempTextString:=tmpstr;
-tmpstrPtr:=@TempTextString;
-cnvihs:=tmpstrPtr;
-end;
-
-Procedure ErrorBox;   {put error dialog on screen}
-begin
-SysBeep;
-errString:=cnvihs(Error);
-new(ErrStringArr[0]);
-errStringArr[0]^:=errString^;
-errString:=cnvihs(where);
-new(ErrStringArr[1]);
-errStringArr[1]^:=errString^;
-result:=AlertWindow(5,ptr(ErrStringPtr),pointer(2));
-end;
-
-
-END.
=texter.r.equ
-// --------------------------------------------------------------------
-// Genesys created REZ defines
-// Simple Software Systems International, Inc.
-// APWREZ.SCG 1.2
-// --------------------------------------------------------------------
-
-
-// --- type $8004 defines
-
-#define Text_Edit_Control $00000001
-
-// --- type $8006 defines
-
-#define Apple_pString $00000001
-#define File_pString $00000002
-#define Edit_pString $00000003
-#define Windows_pString $00000004
-#define Goodies_pString $00000005
-#define Undo_pString $000000FA
-#define Cut_pString $000000FB
-#define Copy_pString $000000FC
-#define Paste_pString $000000FD
-#define Clear_pString $000000FE
-#define Close_pString $000000FF
-#define About_pString $00000100
-#define Quit_pString $00000101
-#define New_pString $00000102
-#define Open_pString $00000103
-#define Save_pString $00000104
-#define SaveAs_pString $00000105
-#define Page_Setup_pString $00000107
-#define Print_pString $00000108
-#define Window1_pString $00000109
-#define Window2_pString $0000010A
-#define Window3_pString $0000010B
-#define Window4_pString $0000010C
-#define Window5_pString $0000010D
-#define Word_Wrap_pString $0000010E
-#define Choose_Font_pString $0000010F
-#define Text_Window_Title $00010005
-
-// --- type $8008 defines
-
-#define Application_Menu_Bar $00000001
-
-// --- type $8009 defines
-
-#define Apple_Menu $00000001
-#define File_Menu $00000002
-#define Edit_Menu $00000003
-#define Window_Menu $00000004
-#define Goodies_Menu $00000005
-
-// --- type $800A defines
-
-#define Undo_Menu_Item $000000FA
-#define Cut_Menu_Item $000000FB
-#define Copy_Menu_Item $000000FC
-#define Paste_Menu_Item $000000FD
-#define Clear_Menu_Item $000000FE
-#define Close_Menu_Item $000000FF
-#define About_Menu_Item $00000100
-#define Quit_Menu_Item $00000101
-#define New_Menu_Item $00000102
-#define Open_Menu_Item $00000103
-#define Save_Menu_Item $00000104
-#define SaveAs_Menu_Item $00000105
-#define Page_Setup_Item $00000107
-#define Print_Item $00000108
-#define Window1_Item $00000109
-#define Window2_Item $0000010A
-#define Window3_Item $0000010B
-#define Window4_Item $0000010C
-#define Window5_Item $0000010D
-#define Word_Wrap_Item $0000010E
-#define Choose_Font_Item $0000010F
-
-// --- type $800E defines
-
-#define Text_Window $00000FFA
-
-// --- type $8010 defines
-
-#define Text_Window_wColor $00000001
-
-// --- type $8013 defines
-
-#define Tool_Startup_Table $00000001
-
-// --- type $8015 defines
-
-#define Printing_Alert $00000001
-#define Tool_Error_Alert $00000002
-#define Save_Alert $00000003
-
-// --- type $8016 defines
-
-#define Window_Text $00000003
=texter2.pas
-{$Keep 'Texter2'}
-Unit Texter2;
-Interface
-
-Uses     Common,
-         ToolLocator,
-         DialogMgr,
-         ControlMgr,
-         WindowMgr,
-         QuickDrawII,
-         {$LibPrefix '0/'}
-         MessUnit,       {Dave Lyon's Unit for Message Center}
-         MyStuff;
-
-type
-         Document       =
-              RECORD
-                   index:         integer;
-                   InUse:         Boolean;
-                   New:           Boolean;
-                   Saved:         Boolean;
-                   Wrap:          boolean;
-                   DocGSString:   GSOSInString;
-                   DocRef:        Integer;
-                   DocWindow:     GrafPortPtr;
-                   WindowTitle:   Str255;
-              end;
-
-         DocumentPtr    = ^Document;
-
-var      Windows:       Array[1..5] of Document;
-
-Procedure DoAbout;
-procedure NoRun(i:integer);
-Procedure DoToFront(thewind:Integer);
-procedure DrawWindow;
-
-Implementation
-
-
-procedure DrawWindow;
-begin
-DrawControls(GetPort);
-end; { of DrawWindow }
-
-Procedure DoToFront;
-begin
-SelectWindow(Windows[thewind].DocWindow);
-end;
-
-Procedure NoRun;
-var    string2ptr:pStringPtr;
-begin
-string2ptr:=pStringPtr(cnvihs(i));
-result:=TLTextMountVolume(@'Unable to run due to Tool Error #',
-                          string2ptr,
-                          @'Quit',
-                          @'Quit');
-end;
-
-Procedure DoAbout;
-var AboutDlog,
-    ApplicPort:     GrafPortPtr;
-    r:             Rect;
-    itemHit:       Integer;
-
-begin
-ApplicPort:=GetPort;
-   SetRect(r,20,40,320,170);
-   AboutDlog :=NewModalDialog(r,true,0);
-If ToolError<>0 then ErrorBox(ToolError,$1201);
-   SetPort(AboutDlog);
- 
-   SetRect(r,230,18,290,30);
-   NewDItem(AboutDlog,1,r,10,@'Ok',0,0,nil);
-If ToolError<>0 then ErrorBox(ToolError,$1202);
-
-SetForeColor(1);
-MoveTo(65,20);DrawString(@'Texter v1.1');
-SetForeColor(0);
-Moveto(20,35);DrawString(@'Another little Utility by:');
-MoveTo(30,50);DrawString(@'Joel Sumner');
-MoveTo(30,60);DrawString(@'19 Fossen Way');
-MoveTo(30,70);DrawString(@'Andover, MA 01810');
-MoveTo(30,80);DrawString(@'q4kx@cornella.ccs.cornell.edu');
-MoveTo(30,90);DrawString(@'q4kx@CORNELLA.BITNET');
- 
-MoveTo(15,110);DrawString(@'Some code property of ByteWorks and');
-MoveTo(25,120);DrawString(@'Apple Computer Inc. 1986-1989');
-
-   itemHit := ModalDialog(nil);
-If ToolError<>0 then ErrorBox(ToolError,$1203);
-   CloseDialog(AboutDlog);
-If ToolError<>0 then ErrorBox(ToolError,$1204);
-SetPort(ApplicPort);
-end; { of AboutDlog }
-
-END.
-
+ END OF ARCHIVE