home *** CD-ROM | disk | FTP | other *** search
- {$S5} { set stack space to 5k... }
-
- { -----------------------------------------------------------------------------
-
- NOTICE:
-
- THESE MATERIALS are UNSUPPORTED by OSS! If you do not understand how to
- use them do not contact OSS for help! We will not teach you how to
- program in Pascal. If you find an error in these materials, feel free
- to SEND US A LETTER explaining the error, and how to fix it.
-
- THE BOTTOM LINE:
-
- Use it, enjoy it, but you are on your own when using these materials!
-
-
- DISCLAIMER:
-
- OSS makes no representations or warranties with respect to the contents
- hereof and specifically disclaim all warranties of merchantability or
- fitness for any particular purpose. This document is subject to change
- without notice.
-
- OSS provides these materials for use with Personal Pascal. Use them in
- any way you wish.
-
-
- -------------------------------------------------------------------------- }
-
-
- PROGRAM Newedit;
-
- {**************************************************************************
-
- PROGRAM COPYRIGHT 1986 OSS. ALL COMMERCIAL RIGHTS RESERVED.
-
- This program is in the public domain. You may give away copies of
- this program and/or source code to anyone willing to take it!
-
- Program sets up mouse in cursor key mode then chains original
- editor, passing original command-line args to program. On exit,
- restore mouse to mouse mode.
-
- Written 10-28-86 M. Curry
-
- To use this program:
-
- 1. Compile this program. Compile and link for TOS!
-
- 2. Rename EDITOR.PRG to OLDEDIT.PRG.
-
- 3. Rename this program to EDITOR.PRG.
-
- 4. Edit any program and move the mouse! The cursor should
- follow the mouse movements.
-
-
- ***************************************************************************}
-
- CONST
-
- IKBD = 4; { device number of Keyboard processor }
- LoadAndGo = 0;
-
- TYPE
-
- Cstring = PACKED ARRAY [ 1..80 ] OF CHAR;
-
- VAR
-
- RetCode : Integer; { returned value from editor }
-
- FUNCTION Bcostat( Dev : Integer ) : Boolean; Bios( 8 );
- PROCEDURE Bconout( Dev : Integer; C : Char ); Bios( 3 );
- PROCEDURE Pterm( Retval : Integer ); Gemdos( $4c );
-
- FUNCTION Pexec( Mode : Integer;
- VAR Prog : Cstring;
- VAR Tail : STRING;
- Env : Long_Integer ) : Integer;
- Gemdos( $4b );
-
-
- {**************************************************************************
-
- Make a C string from a Pascal string
-
- ***************************************************************************}
-
- PROCEDURE Make_Cstr( ps : STRING; VAR cs : Cstring);
- { convert pascal string ps to C string cs }
-
- VAR i : Integer;
-
- BEGIN
-
- cs[ 1 ] := Chr( 0 ); { set to null for safety }
-
- FOR i := 1 to Length( ps ) DO
- cs[ i ] := ps[ i ];
-
- cs[ Length( ps )+1 ] := Chr( 0 );
-
- END;
-
- {**************************************************************************
-
- Send a key to the keyboard processor
-
- ***************************************************************************}
-
- PROCEDURE KOUT( C : Char );
-
- BEGIN
-
- WHILE NOT Bcostat( IKBD ) DO; { wait till kbd is ready }
- Bconout( IKBD, C ); { send char to kbd }
-
- END;
-
-
- {**************************************************************************
-
- Set mouse in cursor key mode
-
- ***************************************************************************}
-
- PROCEDURE SetCurs;
-
- BEGIN
-
- KOUT( #$0A ); { set mouse cursor mode }
- KOUT( #05 ); { 5 pulses / x movement }
- KOUT( #10 ); { 10 pulses / y movement }
- { Change these to suit your taste! }
- END;
-
- {**************************************************************************
-
- Set mouse in mouse mode
-
- ***************************************************************************}
-
- PROCEDURE SetMous;
-
- BEGIN
-
- KOUT( #8 ); { set mouse mouse mode }
-
- END;
-
-
- {*************************************************************************
-
- chain to editor program
-
- **************************************************************************}
-
- FUNCTION RunProg : INTEGER;
-
- VAR
- I : Integer;
- Temp,
- CmdLine,
- Args : STRING;
-
- C_CmdLine : Cstring;
-
- BEGIN
-
- CmdLine := 'OLDEDIT.PRG'; { name of original editor program to run }
- Args := '';
-
-
- { grab original arguments from pascal manager... }
-
- FOR I := 1 to Cmd_Args DO
- BEGIN
- Cmd_GetArg( I, Temp );
- Args := Concat( Args, ' ', Temp )
- END;
-
- Make_Cstr( CmdLine, C_CmdLine ); { convert to c flavored string }
-
- Args := Concat( Args, ' ' );
- Args[ Length( Args ) ] := Chr( 0 );
-
- { use Pexec since
- RunProg := Pexec( LoadAndGo, C_Cmdline, Args, 0 ); { do the evil deed }
-
- END;
-
-
-
- BEGIN
-
- { introduce ourselves... }
-
- Writeln( 'MCursor V1.1 From OSS' );
- Writeln( 'Public Domain -- Free to all!' );
- Writeln( 'Mouse Cursor Active...' );
-
- SetCurs; { set mouse cursor-mode. }
- RetCode := RunProg; { run program, copying command line args to it }
- SetMous; { set mouse mouse-mode }
- Writeln( 'Mouse is Mouse...' );
- Pterm( RetCode ); { return value to manager }
-
- END.
-