/***********************************************************************

          Brief editor emulation for Borland/Turbo Pascal IDE.

	This file contains a Turbo Editor Macro Language (TEML) script 
which emulates the Brief programmer's editor in the Borland/Turbo Pascal 
IDE.  A complete description of the TEML language and the Turbo Editor 
Macro Compiler (TEMC) can be found in the file "TEMC.DOC".

	The TEMC compiler can be invoked from the DOS command line as
follows:
 
	  temc [-c] brief.tem <IDE configuration file><.CMD><.TP>

The optional -c switch can also be specified as /c, and can appear in
any argument position on the command line. If you use this option,
any existing command table in your configuration file is thrown away
before the script file is merged with those already defined. The
configuration file extension must be specified as TEMC will modify both DOS
and Windows IDEs config files.  Specify .CMD or .TP extentions for Windows
or DOS IDE, respectively. If the .CMD file does not exist, it will be 
created. The .TP file must exist, or an error is displayed.

Most of the simple Brief commands have been fully implemented.  Most
of the complex commands have been either partially implemented or not
implemented at all. Below is a list of the commands that have been
fully or partially implemented.

IDE Binding   Brief Command              Comments
-----------   ---------------	         -------------------------
F10           Command                    Activates system menu
Ins           Paste Scrap                Pastes current clipboard selection
Del           Delete                     Deletes current character only
PgDn          Page Down
PgUp          Page Up
UpAr          Cursor Up
DnAr          Cursor Down
Star          Undo
Plus          Copy to Scrap              Copies block to clipboard
Minus         Cut to Scrap               Cuts block to clipboard
Ctrl-D        Scroll Down
Ctrl-E        Scroll Up
Ctrl-G        Routines                   Activates the search menu
                                         Find function can be selected here
Ctrl-N        Next Error
Ctrl-P        Error list                 Moves to previous error
Ctrl-K        Delete To BOL              Deletes to beginning of line
Ctrl-U        Redo
Ctrl-W        Toggle Backup              Activates Options menu
                                         Backup files can be toggled here
Ctrl-F5       Case Sensitivity           Selects search dialog box
                                         Case sensitivity can be toggled here
Ctrl-F6       Toggle Regular Exp.        Selects search dialog box
                                         Regular expressions can be toggled here
Ctrl-bksp     Delete Prev Word
Alt-A         Drop anchor                Sets beginning of block
Alt-B         Buffer List                Lists ALL open windows
Alt-G         Goto line                  Activates the search menu
                                         Goto line can be selected here
Alt-H         Help                       Context sensitive help
Alt-I         Toggle Insert
Alt-J+0       Goto BookMark(0)           Only marks 0-5 are supported
Alt-J+1       Goto BookMark(1)             :
Alt-J+2       Goto BookMark(2)             :
Alt-J+3       Goto BookMark(3)             :
Alt-J+4       Goto BookMark(4)             :
Alt-J+5       Goto BookMark(5)           by this macro file
Alt-K         Delete To EOL
Alt-L         Mark Line
Alt-M         Mark                       Sets beginning of block
Alt-N         Next Buffer                Cycles to next open window
Alt-P         Print Block
Alt-Q         Quote                      Insert literal character
Alt-U         Undo
Alt-V         Version                    Activates system menu
                                         About can be selected here
Alt-X         Quit
Alt-Z         DOS Shell                  Activates the file menu
                                         OS Shell can be selected here
Alt-F2        Zoom Window
                                         IDE does not support inc. search
Alt-F6        Translate Backwards        Prompts for replace string
                                         Option to go backward can be selected

****************************************************************/

/******* Macros ********/

MACRO MacScrollUp
  ScrollScreenUp;
  FixCursorPos;
END;

MACRO MacScrollDown
  ScrollScreenDown;
  FixCursorPos;
END;

MACRO MacPageUp
  FixScreenPos;
  PageScreenDown;
  FixCursorPos;
END;

MACRO MacPageDown
  FixScreenPos;
  PageScreenUp;
  FixCursorPos;
END;

MACRO MacDeleteLine
  DeleteLine;
  LeftOfLine;
END;

MACRO MacTopOfScreen
  SetPrevPos;
  TopOfScreen;
END;

MACRO MacBottomOfScreen
  SetPrevPos;
  BottomOfScreen;
END;

MACRO MacHomeCursor
  SetPrevPos;
  HomeCursor;
END;

MACRO MacEndCursor
  SetPrevPos;
  EndCursor;
END;

MACRO MacOpenLine
  RightOfLine;
  LiteralChar(13);
END;


MACRO MacSetBlockBeg
  HideBlock;
  SetBlockBeg;
END;

MACRO MacSetBlockEnd
  HideBlock;
  SetBlockEnd;
  HighlightBlock;
END;

MACRO MacMarkLine
  HideBlock;
  SetTempPos;
  RightOfLine;
  CursorCharRight;
  SetBlockEnd;
  CursorCharLeft;
  LeftOfLine;
  SetBlockBeg;
  HighlightBlock;
  MoveToTempPos;
END;

MACRO MacMarkWord
  HideBlock;
  SetTempPos;
  CursorRight;
  WordLeft;
  RightOfWord;
  SetBlockEnd;
  WordLeft;
  SetBlockBeg;
  HighlightBlock;
  MoveToTempPos;
END;

MACRO MacMoveToBlockBeg
  SetPrevPos;
  MoveToBlockBeg;
  CenterFixScreenPos;
END;

MACRO MacMoveToBlockEnd
  SetPrevPos;
  MoveToBlockEnd;
  CenterFixScreenPos;
END;

MACRO MacMoveToPrevPos
  SwapPrevPos;
  CenterFixScreenPos;
END;

MACRO MacCopyBlock
  CopyBlock;
  HideBlock;
  CenterFixScreenPos;
END;

MACRO MacMoveBlock
  MoveBlock;
  HighlightBlock;
  CenterFixScreenPos;
END;

MACRO MacBreakLine
  LiteralChar(13);
  CursorCharLeft;
END;

MACRO MacDeleteNextWord
  WordRight;
  MacMarkWord;
  DeleteBlock;
  CenterFixScreenPos;
END;

MACRO MacDeletePrevWord
  WordLeft;
  MacMarkWord;
  DeleteBlock;
  CenterFixScreenPos;
END;

MACRO MacDeleteToBOL
  SetPrevPos;
  LeftOfLine;
  SetBlockBeg;
  MoveToPrevPos;
  SetBlockEnd;
  DeleteBlock;
  CenterFixScreenPos;
END;

/******* Brief Key Bindings  ******/

F10       : Menu;

Ins       : ClipPaste;
Del       : DeleteChar;
PgDn      : MacPageDown;
PgUp      : MacPageUp;
UpAr      : CursorUp;
DnAr      : CursorDown;
Star      : Undo;
Plus      : ClipCopy;
Minus     : ClipCut;

Ctrl-D    : MacScrollDown;
Ctrl-E    : MacScrollUp;
Ctrl-G    : SearchMenu;
Ctrl-N    : NextError;
Ctrl-P    : PrevError;
Ctrl-K    : MacDeleteToBOL;
Ctrl-U    : Redo;
Ctrl-W    : OptionsMenu;
Ctrl-F5   : GetFindString;
Ctrl-F6   : GetFindString;
Ctrl-bksp : MacDeletePrevWord;

Alt-A     : SetBlockBeg;
Alt-B     : WindowList;
Alt-G     : SearchMenu;
Alt-H     : Help;
Alt-I     : ToggleInsert;
Alt-J+0   : MoveToMark(0);
Alt-J+1   : MoveToMark(1);
Alt-J+2   : MoveToMark(2);
Alt-J+3   : MoveToMark(3);
Alt-J+4   : MoveToMark(4);
Alt-J+5   : MoveToMark(5);
Alt-K     : DeleteToEOL;
Alt-L     : MacMarkLine;
Alt-M     : SetBlockBeg;
Alt-N     : NextWindow;
Alt-P     : PrintBlock;
Alt-Q     : LiteralChar;
Alt-U     : Undo;
Alt-X     : Quit;
Alt-Z     : FileMenu;
Alt-F2    : ZoomWindow;
Alt-F6    : GetFindString;
