;   Sample TOOLS.INI file for:
;
;   Microsoft Programmer's WorkBench Version 2.00
;   Copyright (c), 1989-1992  Microsoft Corp.
;
;----------------------------------------------------------------------
;   To use the macros or settings in this file, copy or merge this file
;   with your TOOLS.INI file.
;
;   Once in TOOLS.INI, the macros and editor settings in this file can
;   be defined by initializing the appropriate tagged section. A tagged
;   section for PWB begins with a tag, which has the form:
;
;       [PWB-name]
;
;   Where <name> is the name of the tagged section.
;
;   To initialize a named section of TOOLS.INI, execute Arg <name>
;   Initialize, as follows:
;
;   1.  Execute the Arg function (press ALT+A).
;   2.  Type the name of the tagged section.
;   3.  Execute the Initialize function (press SHIFT+F8).
;
;   If you want certain settings to be your default settings, copy the
;   contents of that section to the main PWB section.

;----------------------------------------------------------------------
;   Contents
;
;   Tag                 Description
;   --------------      -----------------------------------------------
;   [pwb pwb-main]      Main PWB section
;   [pwb-4.0]           Settings for MS-DOS 4.0 and 4.1
;   [pwb-5.0]           Settings for MS-DOS 5.0
;   [pwb-..]            Default file-extension settings
;   [pwb-.bak]          Settings for .BAK files
;   [pwb-utility]       Miscellaneous utility macros
;   [pwb-emulations]    Selected editor emulations
;   [pwb-visible]       Settings for visisble whitespace characters
;   [pwb-invisible]     Settings for invisisble whitespace characters
;   [pwb-wptab]         Settings for word-processor-like tab handling
;   [pwb-notab]         Settings for no tab characters
;   [pwb-CTPL]          C templates
;   [pwb-ckeys]         Key assignments for C templates
;   [pwb-samples]       Sample macros from Help
;   [pwb-tutor]         Sample macros from the PWB tutorial
;   [pwb-abbr]          Abbreviation facility

;----------------------------------------------------------------------
;   Note  - Some macros in this file assume certain conditions.
;
;   All macros in this file that use regular expressions assume that the
;   Unixre switch is set to yes, the default value for Unixre.
;
;   Many macros assume that the current selection mode is stream or box
;   mode. These macros may not work correctly in line selection mode.

;----------------------------------------------------------------------
[pwb pwb-main]
;   Main section of TOOLS.INI
;
;   Only this section, operating-system-specific, and file extension
;   sections are initialized at startup. For more information on these
;   sections, see the PWB Help under TOOLS.INI.

;   Autostart is executed automatically at startup.
Autostart :=

;----------------------------------------------------------------------
;   Sample operating system tagged sections

[pwb-4.0]
;   Settings when running on MS-DOS version 4.0 or 4.1

[pwb-5.0]
;   Settings when running on MS-DOS version 5.0

;----------------------------------------------------------------------
;   Sample file extension tagged sections

[pwb-..]
;   Default settings for any file extension that is not otherwise
;   defined.

color:text 17

[pwb-.asm]
;	Change tab settings for .ASM files

tabstops      :8
filetab       :8

[pwb-.bak]
;   It's easy to open a .BAK file by mistake, so this section defines
;   the text color to something noticeable.

color:text 4e

;----------------------------------------------------------------------
[pwb-utility]
;   Utility macros

;   Window and file management

;   Close all files in the active window except the current file.
;   When multiple files have been opened in a single window, this
;   macro removes the extra files.
AllBut1File  := cancel :>s setfile -> closefile < =>s

;   Close all windows except for the active window.
AllBut1Window:= cancel :>s openfile -> meta window < =>s

;   Minimize all windows.
MinimizeAll := cancel arg minimize

;   Restore all windows.
RestoreAll  := cancel arg minimize :>s selwindow minimize ->s  \
               selwindow minimize

;   Change directory to directory of current file.
;   Requires an editable file.
ccd  := linsert curfile arg curfilenam msearch arg meta ldelete  \
        begline arg right right setfile begline arg setfile undo

;   Change directory to directory of current file.
;   Requires an editable file.
;   This version is slower, but does not change the current search
;   pattern.
ccd2 := linsert curfile savecur curfilenam curfileext restcur  \
        :>s delete cdelete left right +>s  \
        begline arg right right setfile begline arg setfile undo


;   Synchronized error traversal: Build Results, source, and Help.
;
;   Traverses messages in the build results, showing the message, the
;   location of the message in the source file, and help for the message
;   in arranged windows.
;
;psync  - Synchronize to next message
;msync  - Synchronize to previous message
;setsync- Synchronize to message at the cursor in Build Results.

syncmsg := nextmsg -> pwbhelperr openfile arg arrangewindow

psync   := cancel syncmsg
msync   := cancel arg "-1" syncmsg
setsync := cancel arg "<COMPILE>" pwbwindow arg arg syncmsg

psync   :Alt+Down
msync   :Alt+Up
setsync :Alt+Goto

;----------------------------------------------------------------------
[pwb-emulations]
;   These macros approximate selected behaviors of other editors.

;   Successively go to beginning of line, top left window corner,
;   beginning of file.
BRIEFHome := begline +> home +> begfile

;   Successively go to end of line, end of last line in the window,
;   end of file.
BRIEFEnd  := endline +> meta down endline +> endfile

;   Emulate an emacs-style character delete. When at the end of a line,
;   delete the line break. Otherwise delete the character at the cursor.
;   Note that this macro includes the line break when deleting the last
;   character on a line.

EmacsDel  := delete "-" left right ->eol emacscdel => :>eol left  \
             arg meta sdelete

;----------------------------------------------------------------------
[pwb-visible]
;   Settings to make tabs, trailing spaces, and trailing lines visible.

tabdisp       :250
traildisp     :177
traillinesdisp:7

;----------------------------------------------------------------------
[pwb-invisible]
;   Settings to make tabs, trailing spaces, and trailing lines invisible.

tabdisp       :32
traildisp     :32
traillinesdisp:32

;----------------------------------------------------------------------
[pwb-wptab]
;   Word-processor-like settings.
;   Because tab characters and trailing spaces are allowed, the visible
;   whitespace settings above are recommended.

;   You can change tabstops and filetab to your preference, but should
;   have the same value for proper emulation.
tabstops  :8
filetab   :8

realtabs  :yes
tabalign  :yes
entab     :0
trailspace:yes

;   Insert a tab character in insert mode.
;   Move the cursor right one tab stop in overtype mode.
tabio := insertmode +>over insertmode "\t" =>  \
      :>over insertmode tab
tabio : Tab

;   Move right one tab stop in both insert mode and overtype mode.
;   To insert a tab in all modes, use Quote TAB (CTRL+P, TAB)
tab   :ctrl+tab

;----------------------------------------------------------------------
[pwb-notab]
;   Settings so that no new tab characters are added to the file.
;

Filetab :8          ;Tabs expand to 8 spaces
Realtabs:no         ;Do not preserve tabs
Entab   :0          ;Translate whitespace to spaces

;   Note that tab characters on unmodified lines are preserved.
;
;   To strip all tabs from the file, execute the TouchAll macro with
;   these settings. To also strip trailing spaces, uncomment the next
;   line.
;trailspace:no

;  TouchAll - Modify all nonblank lines
TouchAll:= savecur  \
           begfile arg arg replace "^." newline "\\0" newline restcur
TouchAll:Alt+D      ;Press Alt+D to touch all nonempty lines in the file

;----------------------------------------------------------------------
[pwb-CTPL]
;   C template macro set for Microsoft Programmer's WorkBench
;   Copyright (c), 1989-1992  Microsoft Corp.
;
;   CTPL is a useful example of an extended system of macros to
;   customize the PWB. You can change this set to implement your own C
;   programming style.
;
;   To install CTPL, add this section to your TOOLS.INI. When you want
;   to activate the macros, type:
;
;       Arg "ctpl" Initialize
;
;   Or define the following macro in the main section of TOOLS.INI:
;
;       CTPL:=arg "Ctpl" initialize
;       CTPL:Alt+F10
;
;   and press ALT+F10 to initialize the C templates.
;
;   Most templates are activated by typing a C keyword and executing the
;   DoTpl macro (Alt+T). Templates usually insert some text, then select
;   an active area--a "tag".
;
;   To fill out a tag, type the replacement text.
;
;   To skip the tag, execute Cancel (Press ESC).
;
;   To move back and forth among tags use the Mrec (ALT+PGUP) and Prec
;   (ALT+PGDN) macros.
;
;   Since tags are C comments, you can compile code with incompletely
;   filled-in templates.
;
;   For templates that do not have a keyword--a function or prototype,
;   for example--CTPL defines a key assignment. This command structure
;   minimizes the number of key bindings necessary to support the CTPL
;   macro set.
;
;   For example, the switch template uses the macro AddCase (ALT+F9) to
;   insert a case just before the default case provided by the switch
;   template.
;
;   HINT: Sometimes you don't want the semicolon that CTPL often places
;   after a tag. In these situations press RIGHT to extend the selection
;   to include the semicolon as well as the tag, and it is replaced by
;   what you type.
;
;   NOTE: CTPL macros assume that the current selection mode is box or
;   stream mode. If this becomes troublesome for you, use the mode-safe
;   versions of the SelTag and DoTpl macros. The CTPL macros also work
;   correctly in stream-selection mode. If you prefer stream selection,
;   change the mode-safe versions to use the _pwbstreammode macro.
;
;   NOTE: Because PWB rereads a file-extension tagged section each time
;   you move to the file, It is not recommend to rename the CTPL section
;   as [pwb-.C]. This works, but slows down switching to .C files.


;   Select word
selword    :=pword ->eof mword arg meta pword =>  \
           :>eof mword pword arg meta pword

;-- The core macro for CTPL
;   select the current word and execute it
DoTpl      :=selword execute

;   selection-mode safe DoTpl
;DoTpl     :=_pwbboxmode selword execute

;-- simple 'pairs'
parens     :="()" left
subscript  :="[]" left
angles     :="<>" left
quotes     :="\"\"" left

;-- messages
notag      :=arg "No more tags" message
nobrace    :=arg "Missing right brace" message
nodefault  :=arg "No \"default:\" found" message

;-- tag & utilities
tag        :="/*%*/"
stmt       :="/*%*/;"

seltag     :=arg right right right right right
;   selection-mode safe seltag
;seltag    :=_pwbboxmode arg right right right right right

;   Tag movement - Move to and select the position to be filled in.
;mrec      - Move to and select previous tag
;prec      - Move to and select next tag
mrec       :=cancel left  arg tag msearch ->f seltag => :>f notag
prec       :=cancel right arg tag psearch ->f seltag => :>f notag

;-- Utilities -- redefine to change indentation styles
;test      - condition in parentheses
;plist     - parameter list
;testbreak - type of break (if any) after a test
test       :="( " tag " )"
plist      :="( " tag " )"
testbreak  :=addline

;-- utilities for adding components of C constructs
;
;addline  - Add a line, with same indentation as this line
;addstmt  - Add a statement after this line
;addstmti - Add an indented statement after this line
;block    - Add a statement block after this line
;
addline  :=cancel begline down linsert
addstmt  :=addline tag mrec
addstmti :=addline tab tag mrec
block    :="{" addline "}" begline linsert tab tag down endline

;-- function, prototype and utilities
;
;func    - Parameter list and body
;proto   - Semicolon-terminated parameter list
;main    - Alias of func
;additem - Add item to the current parameter list or 'for' control
;
func     :=endline savecur plist addline block restcur prec
proto    :=endline plist ";" mrec
main     :=func
additem  :=cancel left arg arg "[;:)}]" psearch ->   \
           arg arg "[^ \t]" msearch right ", " tag right mrec

;printf, fprintf, sprintf  - Handy templates
;
printf   :=proto quotes tag "\\n"  mrec
fprintf  :=proto "std" tag ", " quotes tag "\\n" begline prec
sprintf  :=proto tag ", " tag ", " tag mrec mrec quotes tag  \
           endline mrec mrec

;-- conditional constructs
;
;if      - Add a condition and statement block
;else    - You usually use addelse, but this is still useful
;addelse - Add an else clause to the current if statement
;addelif - Add an else-if clause to the current if statement
;while   - While loop
;for     - For loop template. Use additem for comma-op items
;do      - Do  loop template
;queryop - "() ? : " template for the ternary operator
;
if      :=endline savecur  test testbreak block  restcur prec
else    :=testbreak block  mrec
addelse :=cancel arg "}" psearch ->f testbreak "else" else => :>f nobrace
addelif :=cancel arg "}" psearch ->f testbreak "else if" if => :>f nobrace
while   :=if
for     :=if stmt " " stmt " " tag  begline prec
do      :=testbreak block " while" test endline ";" mrec
queryop :=savecur test " ? " tag " : " tag restcur prec

_asm    :=testbreak block mrec

;-- declarations
;
enum    :=endline " " tag " { " tag " } " stmt begline prec
typedef :=endline " " tag " " stmt begline prec
struct  :=endline savecur " " tag testbreak block " " stmt restcur prec
class   :=struct

;-- switch statement and components
;   Use add-case to build the cases of the switch.
;   Use addbreak to terminate a statement section.
;
;case     - Colon-terminated placeholder
;addbreak - Insert a break statement after the current statement
;addcase  - Insert case just before the next or default case
;switch   - Condition, block, and default case.
;swiback  - By default case labels appear at the same indentation level
;           as the opening 'case' For indented case labels, define it
;           as 'swiback:='
swiback :=backtab
case    :=endline " " tag ":" mrec
addbreak:=addstmt "break;"  begline
addcase :=cancel arg arg "\\{default:\\!case\\}" psearch ->f   \
          linsert "case" case => :>f nodefault
switch  :=endline test testbreak block mrec right meta delete swiback   \
          "default:" addstmti "break" mrec

;-- preprocessor utilities
;inc     - #include <x>
;def     - #define x x
;pragma  - #pragma x( x )
inc   :=begline "#" endline "lude <>"  left
def   :=begline "#" endline "ine " tag " " tag  begline prec
pragma:=begline "#" endline " " tag plist begline prec

;   The OpenInclude macro opens an include file named in the next
;   #include directive. The macro demonstrates a technique using the
;   Lasttext function to pick up text from the file and modify it
;   without modifying the file or the clipboard.
OpenInclude :=  \
    up meta begline arg arg "^[ \t]*#[ \t]*include" psearch ->  \
    arg arg "[<>\"]" psearch -> right savecur psearch ->        \
    selcur lasttext begline "$INCLUDE:" openfile <n +>          \
    lastselect openfile <

;   Key Assignments
mrec      :Alt+PgUp
prec      :Alt+PgDn
addcase   :Alt+F9
addbreak  :Alt+F10
addelse   :Shift+Ctrl+E
addelif   :Shift+Ctrl+I
additem   :Alt+,
queryop   :Alt+/
parens    :Ctrl+0
subscript :Alt+]
quotes    :alt+'
angles    :Alt+>
addstmt   :Ctrl+;
addstmti  :Shift+Ctrl+:
proto     :Shift+Ctrl+P
func      :Shift+Ctrl+F
dotpl     :Alt+T

;-------------------
[pwb-ckeys]
;   Initialize this section if you've switched to another type of file
;   and need to recover your CTPL keys.
mrec :=cancel left  arg tag msearch ->f seltag => :>f notag
prec :=cancel right arg tag psearch ->f seltag => :>f notag
mrec        :Alt+PgUp
prec        :Alt+PgDn
addcase     :Alt+F9
addbreak    :Alt+F10
addelse     :Shift+Ctrl+E
addelif     :Shift+Ctrl+I
additem     :Alt+,
queryop     :Alt+/
parens      :Ctrl+0
subscript   :Alt+]
quotes      :alt+'
angles      :Alt+>
addstmt     :Ctrl+;
addstmti    :Shift+Ctrl+:
proto       :Shift+Ctrl+P
func        :Shift+Ctrl+F
dotpl       :Alt+T

;----------------------------------------------------------------------
[pwb-samples]
;   This section contains example macros from help.
;

;   Run the program for current PWB project
Run  :=arg "run" compile

;   Debug the program for current PWB project
Debug:=arg "debug" compile


;   Insert spaces to next tab stop.
InsertTab := arg tab sinsert

;   Indent a paragraph to the next tab stop:
para_indent:=_pwbboxmode meta mpara down begline arg   \
             meta ppara up begline tab insert

;    Move the cursor to column one, then toggle between column one and
;    the first nonblank character on the line.
ToggleBegline := left ->x meta :>x begline

;   Put parts of current filename on the clipboard.
Path2clip     := Arg Curfile Copy
Name2clip     := Arg Curfilenam Copy
Filename2clip := Arg Curfilenam Curfileext Copy

;-------------------
;   Macro utilities
;   Macro writing and debugging tools, plus convenient shorthands

;   Set True return value. Side effect: cancels active arguments
True := cancel

;   Set False return value. Side effect: turns off Meta
False := meta +>off meta :>off meta

;   The following macros test common conditions.
;
;   At beginning of line?
bol? := savecur begline +>no True => :>no restcur False

;   Any text at cursor?
text? := right +>yes left False => :>yes left True

;   Is the current line an empty line?
empty? := meta begline endline ->yes False => :>yes True


;   Display the current macro return value on the status bar, then
;   reset return value. Use this macro when debugging loops and
;   conditional flow control.
? := +>t arg "FALSE" message => :>t arg "TRUE" message

;   Refresh - force a full screen redraw
! := meta message


;   These two utilities make readable find/replace macros. For example,
;   use the phrase:
;       replace "<junk text>" with nothing
;   to delete <junk text> from the file.
With    := newline
Nothing := " " cdelete newline


;   Position the window so that the next tagged section of TOOLS.INI
;   starts at the top of the window.
FindTag:=arg arg "^\\[[^\\]]+\\]" psearch ->none  \
         arg setwindow => :>none arg "no tag" message

;   Adjust each line continuation (backslash at the end of a line) so
;   that it appears in column 73.
SlashJust:=savecur begfile arg arg replace    \
           "^\\(.*[^ ]\\)  +\\\\$" newline    \
           "\\(-70,1)  \\\\" newline restcur


;   Prompt for help topic to look up.
QueryHelp := arg "Get Help On:" prompt ->no pwbhelp =>  \
          :>no arg "Query Cancelled" message

;-------------------
;   Iterations on the file.
;   All... - Macros that iterate over the file, one line at a time.
;   Act    - Define as the action to be performed on each line.
Act :=

;   Perform Act on all lines of the file, starting from the end.
AllBackward := endfile :>s act up +>s

;   Perform Act on all lines from start, including a page of blank lines
;   at the end of the file.
AllForward  := begfile :>s act down +>s

;   Perform Act on all lines from start, testing for end-of-file at each
;   step. Solves 'extra lines' problem of AllForward at the cost of
;   speed.
AllForward2 := begfile savecur :>s restcur act   \
               down savecur begline endfile +>s

;-------------------
;   Perform Act at each occurrence of a regular expression in the file.
Act :=

;   Regular expression to match (example is for blank line)
RE   := "^$"

;   Perform Act at each occurrence of RE.
For1 := begfile :>s arg arg RE psearch -> act =>s

;   Like For1, but iterates much faster with the restriction that Act
;   cannot perform a search.
For2 := begfile arg arg RE :>s psearch -> act =>s

;-------------------
;GetMac - Load a separate file of macros or assignments.
;
;Usage: Arg 'file' getMac where <file> is the base name of
;       a file in the INIT directory
;
GetMac := cancel lasttext begline "$INIT:" endline ".MAC"  \
          setfile <n +>Ok lasttext begline               \
          "Can't find \"" endline "\"" message =>          \
       :>Ok begfile arg endfile assign ->  arg refresh

;----------------------------------------------------------------------
[pwb-tutor]
;   PWB Tutorial macro examples
CloseWindows := :>Loop Openfile -> Meta Window Window =>Loop
CloseWindows : SHIFT+CTRL+W

LineComment := "//  "
RevHead     := "** Revision History **"
RevComment  :=  \
  Arg Arg "Start" Mark                 \
  Begfile Arg RevHead Psearch +>Found  \
  Linsert LineComment RevHead          \
:>Found  \
  Down Linsert Begline LineComment Curdate " ("    \
  Arg "Initials" Prompt ->Quit Paste Endline ") "  \
  Arg "Comment"  Prompt ->Quit Paste =>End         \
:>Quit Meta Ldelete  \
:>End Arg "Start" Mark
RevComment:CTRL+H


;----------------------------------------------------------------------
[pwb-abbr]
;   Abbreviations - Define and expand abbreviations.

;  Select the current word
SelWord:= pword ->eof mword arg meta pword =>  \
                :>eof mword pword arg meta pword

;  Delete the current word and execute it
Expand := selword lasttext cancel lastselect meta sdelete lasttext execute
Expand :Alt+T

;  Simple text expansion
prog   := "program"
ex     := "example"

;  Expand 'cmd' once to get 'command', Expand twice to get 'command line'
cmd    := "command"
command:= "command line"

;   Expand to the contents of the file HEADER.TPL in the INIT
;   directory--a good technique for large boilerplate text.
Header := arg arg "$INIT:header.TPL" paste


[end]
