*
* File: MACROS.TXT  --  Miscellaneous useful macros for use with QEdit
*
* Last revised: 28-March-1990
*
* To use these macros, select the ones you like, copy them to your keyboard
* configuration file (QCONFIG.DAT), (editing the key assignment if need be)
* and then run the configuration program (QCONFIG) to install the new key
* assignments into your copy of QEdit.
*
* Most of these macros assume you are using QEdit 2.1 or greater.
* (Or the equivalent QEdit TSR 1.1 or QEdit for OS/2 1.5 or greater).
*

*
* Find and FindReplace with Centering
*
* QEdit tries not to move the cursor line when possible, so you don't have
* to glance around a lot on large screens.  Some people would prefer that
* it always center the cursor on the screen where possible, to best see
* context.  Here's a way to do it with Find and FindReplace:
*
^f7     MacroBegin Find Pause Return Pause Return JFalse end: MakeCtrOfScreen end:
^f8     MacroBegin FindReplace Pause Return Pause Return Pause Return JFalse end: MakeCtrOfScreen end:

*
* Find with Options prompt removed.
*
* The first one forces a forward case-insensitive search, the second backward.
*
f7      MacroBegin Find Pause Return 'i' Return
#f7     MacroBegin Find Pause Return 'ib' Return

*
* Find next occurence of the Word sitting at the cursor position
*
@=      MacroBegin MarkWord Copy Find Paste Return Return

*
* "Safer" WriteBlock
*
* All the file prompts come up with a default of the last file loaded.
* However, when using WriteBlock, accepting the default could overwrite
* a file you have in the editor.  Here's a macro to replace <Alt W> that
* makes sure the prompt comes up blank, and that the Overwrite/Append always
* comes up defaulted to Append no matter what.
*
@w      MacroBegin CursorRight CursorLeft WriteBlock " " Backspace Pause Return EndLine PrevPosition

*
* Block Cut with blank fill
*
* This does the same thing as Cut <Grey ->, but it fills the original block
* with spaces.  This is most useful with column blocks, where you don't want
* the text "around" the block to "fill in" where the removed text was.
* (Repeated here from READ.ME file).
*
^f10    MacroBegin GotoBlockBeg Cut Paste FillBlock ' ' Return UnmarkBlock

*
* Delete to beginning of line
*
^backspace MacroBegin begin: CursorLeft JFalse done: DelCh Jump begin: done:

*
* Duplicate "n" Lines
*
* The built in DupLine function duplicates the current line, and moves the
* cursor down onto the duplicate.  This macro does the same thing for X lines
* starting from the cursor line going "UP".  It will stop and prompt for the
* number of lines.  Press ESCAPE twice at the prompt to abort.
*
@d      MacroBegin UnmarkBlock MarkLine AddLine AddLine CursorUp RepeatCmd Pause Return MarkLine GotoBlockEnd CopyBlock GotoBlockEnd CursorDown DelLine DelLine CursorUp
*
* If "Insert line blocks ABOVE cursor line?" is set to YES, use this instead:
*
@d      MacroBegin UnmarkBlock MarkLine AddLine AddLine CursorUp RepeatCmd Pause Return MarkLine GotoBlockEnd CursorDown CopyBlock GotoBlockEnd CursorDown DelLine DelLine CursorUp

*
* Alternate Help File
*
* This allows you to have a help file much larger than one screen, by loading
* it into QEdit into an editing buffer.
*
* Change the directory & filename here to the help or doc file that you use.
*
f1      MacroBegin EditFile 'c:\qedit\help.dat' Return

*
* Load a file whose name is at the cursor
*
* This picks up a filename that is sitting at the cursor position in the
* editor, and loads it into another buffer.
*
^]      MacroBegin AltWordSet MarkWord Copy EditFile Paste Return DefaultWordSet

*
* Alternate WrapPara
*
* WrapPara assumes you have moved the cursor to the top of the paragraph
* you wish to wrap.  This macro removes this requirement by moving the
* cursor there for you.  This macro will re-wrap the current paragraph, no
* matter where the cursor is currently sitting in it.
*
@b      MacroBegin CursorDown PrevPara WrapPara NextPara

*
* Wrap entire file
*
* WrapPara only affects the current paragraph.  This macro repeats WrapPara
* from the cursor position to the end of the file, reformatting the entire
* file.  NOTE:  all paragraphs will be reformatted to the same margins, so
* be sure this is what you want.
*
^f10    MacroBegin EndFile AddLine BegFile BegLine again: WrapPara JTrue again: EndFile DelLine CursorUp

*
* Absolutely Quit the Editor
*
* This key, when hit, will absolutely discard all files from the editor,
* and exit to the DOS prompt, no questions asked.
*
* !WARNING!: Be careful with this one-- it will NOT prompt you to save your
*            work.   You will lose all your work if you haven't saved it!
*
^f12    MacroBegin again: Quit JTrue again: Escape

*
* Delete redundant blank lines in entire file
*
* This macro deletes all blank lines that are adjacent to another blank line.
* Useful for cleaning up files or screen captures that have too much excess
* white space in them.
*
^f11    MacroBegin findnext: EndPara CursorDown CursorDown JFalse end: blank: EndLine BegLine JTrue findnext: DelLine JTrue blank: end:

*
* Worry-free Sort
*
* Sort only works if there is a single, non-zoomed window on the screen.
* Well, rather than worry about that, how about have a macro take care of it:
*
#f3     MacroBegin GotoBlockBeg OneWindow Sort

*
* Case-Insensitive Sort
*
* This version of the sort is case-insensitive.  We copy the sort key block,
* upper case it, and sort on the copy.  Then we delete the copy, leaving the
* original lines as they were, except sorted:
*
#f3     MacroBegin GotoBlockBeg CopyBlock JFalse noblock: OneWindow Upper Sort DeleteBlock noblock:

*
* Reverse Sort
*
* This macro works just like Sort, but it sorts in descending order instead
* of ascending order.
*
* NOTE:  Since this macro uses the Kill Buffer to reverse the lines, it cannot
*        sort more lines than will fit in your Kill Buffer.  See (G)eneral
*        options in the configuration program for setting this value--it
*        defaults to only 30 lines so BE CAREFUL!
*
* You'll have to use QMAC to compile this macro.
*
^f3     MacroBegin
        GotoBlockBeg OneWindow Sort JFalse end:
        GotoBlockEnd MarkLine
        EditFile "$sort$.$$$" Return MoveBlock
        DelLine delall:   DelLine           JTrue delall:
        UnKill  undelall: CursorDown UnKill JTrue undelall:
        DelLine CursorUp DelLine CursorUp MarkLine BegFile PrevFile
        CursorUp MoveBlock NextFile Quit GotoBlockBeg UnMarkBlock
      end:

*
* Reload Current file
*
* QEdit normally never reloads a file from disk once in memory.  But
* sometimes the copy on disk might change while you are inside QEdit, and you
* may want to see the new copy.  (This could happen on a network, or if you
* run a utility that can modify files, from inside QEdit using "Dos").
*
* Hit this key, and no matter the state of the editing buffer, the
* original copy of this file will be reloaded into the editor.  This
* will LOSE any and all changes you haven't saved, so BE CAREFUL!
*
^f2  MacroBegin SplitLine EditFile CurrentFilename Return NewFile "N" Return

*  Here's a safer version:  this one stops to let you answer the
*  "Save Changes?" prompt.  You will have to hit RETURN to confirm the
*  reload of the file.
*
^f3  MacroBegin EditFile CurrentFilename Return NewFile

*
* EZSpell by Sam Smith
* (Tested with version 1.4)
*
* This macro invokes EZ-Spell to spell-check the current file.
*
* It is assumed that both EZS.EXE and the dictionary EZSPELL.DCT are in
* a directory named in your PATH= statement.
*
* EZSpell creates a backup file with the last letter of the name changed
* to a "$".  We delete that file in this macro after EZSpell is done.
*
^f9     MacroBegin SaveFile Dos "EZS " CurrentFilename Return Return Dos "DEL " CurrentFilename Backspace "$" Return Return EditFile CurrentFilename Return NewFile Return

*
* EZSpell: move to next marked word.  This allows you to jump to words that
*          EZSpell marked for you in the current file.
*
* Since EZSpell marks words with square brackets, this will actually find any
* pair of square brackets, and marks it as a block to highlight it.
*
^f10    MacroBegin Find "[" Return "N" Return UnMarkBlock DropAnchor Match DropAnchor GotoBlockBeg MakeCtrOfScreen

*
* ShareSpell by Acropolis Software
* (Tested with version 2.0.  Version 1.4 or greater is recommended)
*
* This macro invokes ShareSpell to spell-check the current file.
*
* It is assumed that both SS.EXE and the dictionary ACROP.DIC are in
* a directory named in your PATH= statement.
*
* There is no need to delete the backup file here, because SS stores it in
* ".BAK" just like QEdit does.
*
^f9     MacroBegin SaveFile Dos "SS " CurrentFilename Return Return EditFile CurrentFilename Return NewFile Return

*
* ShareSpell: move to next marked word.
*
* SS marks with an "@" ahead of each word.  We search for that, mark the
* word as a block to highlight it, and leave the cursor on the "@" so
* the user can delete it.
*
^f10    MacroBegin Find "@" Return "N" Return UnMarkBlock CursorRight MarkWord CursorLeft MakeCtrOfScreen

*
* An Editing Log macro
*
* This macro allows you to keep a "log" of the files you have edited with
* QEdit.  This could be useful to keep track of large multi-file projects.
*
* It keeps the log in the file C:\Q.LOG.  When you are "done" with a file,
* hit this key and it will be saved to disk, and the time and date recorded
* in the LOG file.  This macro is very near the maximum line limit of
* QCONFIG.DAT, so be careful when editing it.
*
^f5 MacroBegin HorizontalWindow EditFile "C:\Q.LOG" Return EndFile AddLine BegLine InsertDate InsertTime " @" BegLine PrevWindow FindReplace "@" Return CurrentFilename Return Escape NextWindow FindReplace Return Return "N" Return SaveFile CloseWindow File

*
* Run a Compiler Macro
*
* As written here, this macro will run the Turbo Pascal compiler (TPC) on the
* current file, and bring the resulting error messages into a window below
* the current one.  Edit where it says "TPC /Q >ERRS.LST " to invoke whichever
* language compiler you most often use.
*
^f9 MacroBegin OneWindow UnmarkBlock DropAnchor EditFile 'ERRS.LST' Return KillFile Quit GotoBlockBeg UnmarkBlock Dos 'TPC /Q >ERRS.LST ' CurrentFilename Return Return HorizontalWindow EditFile Return PrevWindow

*
* EOF: MACROS.TXT
*
