home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / tse2jr4.zip / MACROS.TXT < prev    next >
Text File  |  1997-02-21  |  13KB  |  387 lines

  1. *
  2. * File: MACROS.TXT  --  Miscellaneous useful macros for use with TSE Jr.
  3. *
  4. * Last revised: 27-February-1995
  5. *
  6. * To use these macros, select the ones you like, copy them to your keyboard
  7. * configuration file (QCONFIG.DAT), (editing the key assignment if need be)
  8. * and then run the configuration program (QCONFIG) to install the new key
  9. * assignments into your copy of TSE Jr.
  10. *
  11. * These macros assume you are using TSE Jr. 4.0 or greater.
  12. * (Or the equivalent Mem-Res or OS/2 version 4.0).
  13. *
  14.  
  15. *
  16. *  Title: Fancy home macro.
  17. *
  18. *  If already at the start of a line, go to the first non-white character
  19. *  on the line; otherwise, if not already at the start of a line, go to the
  20. *  start of the line.
  21. *
  22. Home        BegLine MacroQuitTrue FirstNonWhite
  23.  
  24. *
  25. *  Title: Block Cut with blank fill
  26. *
  27. *  This does the same thing as Cut <Grey ->, but it fills the original block
  28. *  with spaces.  This is most useful with column blocks, when you don't want
  29. *  the text "around" the block to "fill in" where the removed text was. The
  30. *  macro assumes a block is already marked.  The block will be [Cut] to the
  31. *  clipboard or system scrap buffer. You can then insert the block where you
  32. *  like by pressing the [Paste] key <Grey *>.
  33. *
  34. *  Note: the block must be closed before this macro will work.
  35. *
  36. f10         GotoBlockBeg MacroQuitFalse
  37.             Cut Paste
  38.             FillBlock ' ' Return
  39.             UnmarkBlock
  40.  
  41. *
  42. * Title: Find with Options prompt removed.
  43. *
  44. * The first one forces a forward case-insensitive search, the second backward.
  45. *
  46. f7          Find Pause Return 'i' Return
  47.  
  48. #f7         Find Pause Return 'ib' Return
  49.  
  50. *
  51. * Title: Find next occurence of the Word sitting at the cursor position
  52. * Note: if cursor is not in a word, we check left and right for a word,
  53. * if we still can't find a word, we quit.
  54. *
  55. @=          MarkWord MacroQuitFalse Copy
  56.             Find Paste Return Return
  57. *
  58. * Title: Find Word at cursor backwards
  59. *
  60. ^f1         MarkWord MacroQuitFalse Copy
  61.             Find Paste Return "ib" Return
  62.  
  63. *
  64. * Title: "Safer" WriteBlock
  65. *
  66. * All the file prompts come up with a default of the last file loaded.
  67. * However, when using WriteBlock, accepting the default could overwrite
  68. * a file you have in the editor.  Here's a macro to replace <Alt W> that
  69. * makes sure the prompt comes up blank, and that the Overwrite/Append always
  70. * comes up defaulted to Append no matter what.
  71. *
  72. @w          WriteBlock DelLine Pause Return
  73.             Jump done:
  74.             EndLine
  75.             done:
  76.  
  77. *
  78. * Title: Delete to beginning of line
  79. *
  80. ^backspace  SplitLine DelLine BegLine
  81.  
  82. *
  83. * Title: Duplicate "n" Lines
  84. *
  85. * The built in DupLine function duplicates the current line, and moves the
  86. * cursor down onto the duplicate.  This macro does the same thing for X lines
  87. * starting from the cursor line going "UP".  It will stop and prompt for the
  88. * number of lines.  Press ESCAPE twice at the prompt to abort.
  89. *
  90. @d          UnmarkBlock MarkLine AddLine 2 CursorUp
  91.             RepeatCmd Pause Return
  92.             MarkLine GotoBlockEnd CopyBlock GotoBlockEnd
  93.             CursorDown DelLine 2 CursorUp
  94. *
  95. * If "Insert line blocks ABOVE cursor line?" is set to YES, use this instead:
  96. *
  97. *@d         UnmarkBlock MarkLine AddLine 2 CursorUp
  98.             RepeatCmd Pause Return
  99.             MarkLine GotoBlockEnd CursorDown CopyBlock GotoBlockEnd
  100.             CursorDown DelLine 2 CursorUp
  101.  
  102. *
  103. * Title: Alternate Help File
  104. *
  105. * This allows you to have a help file much larger than one screen, by loading
  106. * it into TSE Jr. into an editing buffer.
  107. *
  108. * Change the directory & filename here to the help or doc file that you use.
  109. *
  110. f1          EditFile 'c:\tsejr\help.dat' Return
  111.  
  112. *
  113. * Title: Load a file whose name is at the cursor
  114. *
  115. * This picks up a filename that is sitting at the cursor position in the
  116. * editor, and loads it into another buffer.
  117. *
  118. ^]          AltWordSet MarkWord jFalse done: Copy
  119.             EditFile Paste Return
  120.     done:   DefaultWordSet
  121.  
  122. *
  123. * Title: Alternate WrapPara I
  124. *
  125. * WrapPara assumes you have moved the cursor to the top of the paragraph
  126. * you wish to wrap.  This macro removes this requirement by moving the
  127. * cursor there for you.  This macro will re-wrap the current paragraph, no
  128. * matter where the cursor is currently sitting in it, even if it is the
  129. * line after the paragraph.
  130. *
  131. @b          CursorDown PrevPara WrapPara NextPara
  132.  
  133. *
  134. * Title: Alternate WrapPara II
  135. *
  136. * This is an alternate version of the WrapPara macro that treats blank
  137. * lines between paragraphs as part of the next paragraph, instead of
  138. * treating them as part of the previous paragraph.
  139. *
  140. @b          EndPara CursorDown PrevPara WrapPara NextPara
  141.  
  142.  
  143. *
  144. * Title: Wrap entire file
  145. *
  146. * WrapPara only affects the current paragraph.  This macro repeats WrapPara
  147. * from the cursor position to the end of the file, reformatting the entire
  148. * file.  NOTE:  all paragraphs will be reformatted to the same margins, so
  149. * be sure this is what you want.
  150. *
  151. ^f6         EndFile
  152.             AddLine
  153.             BegFile
  154.             BegLine
  155.      again: WrapPara    JTrue again:
  156.             EndFile
  157.             DelLine
  158.             CursorUp
  159.  
  160. *
  161. * Title: Absolutely Quit the Editor
  162. *
  163. * This key, when hit, will absolutely discard all files from the editor,
  164. * and exit to the DOS prompt, no questions asked.
  165. *
  166. * !WARNING!: Be careful with this one-- it will NOT prompt you to save your
  167. *            work.   You will lose all your work if you haven't saved it!
  168. *
  169. ^f12 again: Quit        JTrue again:
  170.             Escape
  171.  
  172. *
  173. * Title: Delete redundant blank lines in entire file
  174. *
  175. * This macro deletes all blank lines that are adjacent to another blank line.
  176. * Useful for cleaning up files or screen captures that have too much excess
  177. * white space in them.
  178. *
  179. ^f11  next: EndPara
  180.             CursorDown 2 MacroQuitFalse
  181.      blank: EndLine
  182.             BegLine JTrue next:
  183.             DelLine JTrue blank:
  184.  
  185. *
  186. * Title: Worry-free Sort
  187. *
  188. * Sort only works if there is a single, non-zoomed window on the screen.
  189. * Well, rather than worry about that, how about have a macro take care of it:
  190. *
  191. #f3         GotoBlockBeg OneWindow Sort
  192.  
  193. *
  194. * Title: Reload Current file
  195. *
  196. * TSE Jr. normally never reloads a file from disk once in memory.  But
  197. * sometimes the copy on disk might change while you are inside TSE Jr., and you
  198. * may want to see the new copy.  (This could happen on a network, or if you
  199. * run a utility that can modify files, from inside TSE Jr. using "Dos").
  200. *
  201. * Hit this key, and no matter the state of the editing buffer, the
  202. * original copy of this file will be reloaded into the editor.  This
  203. * will LOSE any and all changes you haven't saved, so BE CAREFUL!
  204. *
  205. ^f2         SplitLine
  206.             EditFile CurrentFilename Return
  207.             NewFile "N" Return
  208.  
  209. *  Here's a safer version:  this one stops to let you answer the
  210. *  "Save Changes?" prompt.  You will have to hit RETURN to confirm the
  211. *  reload of the file.
  212. *
  213. ^f3         EditFile CurrentFilename Return
  214.             NewFile
  215.  
  216. *
  217. * Title: An Editing Log macro
  218. *
  219. * This macro allows you to keep a "log" of the files you have edited.
  220. * This could be useful to keep track of large multi-file projects.
  221. *
  222. * It keeps the log in the file C:\Q.LOG.  When you are "done" with a file,
  223. * hit this key and it will be saved to disk, and the time and date recorded
  224. * in the LOG file.
  225. *
  226. ^f5         HorizontalWindow
  227.             EditFile "C:\Q.LOG" Return
  228.             EndFile AddLine BegLine
  229.             InsertDate InsertTime " @" BegLine
  230.             PrevWindow
  231.             FindReplace "@" Return CurrentFilename Return Escape
  232.             NextWindow
  233.             FindReplace Return Return "N" Return
  234.             SaveFile
  235.             CloseWindow
  236.             File
  237.  
  238. *
  239. * Title: Run a Compiler Macro
  240. *
  241. * As written here, this macro will run the Turbo Pascal compiler (TPC) on the
  242. * current file, and bring the resulting error messages into a window below
  243. * the current one.  Edit where it says "TPC /Q >ERRS.LST " to invoke whichever
  244. * language compiler you most often use.
  245. *
  246. @f9         OneWindow UnmarkBlock DropAnchor
  247.             EditFile 'ERRS.LST' Return
  248.             KillFile Quit
  249.             GotoBlockBeg UnmarkBlock
  250.             Dos 'TPC /Q >ERRS.LST ' CurrentFilename Return Return
  251.             HorizontalWindow
  252.             EditFile Return
  253.             PrevWindow
  254.  
  255. * Title: Delete all blank lines in a marked block
  256. *
  257. * The cursor should be at the beginning of the block when the macro is
  258. * invoked.
  259. *
  260. #f9         SetScreenOff                    * turn off screen for speed
  261.     begin:  isCursorInBlock                 *
  262.             MacroQuitFalse                  * exit if not in block
  263.             isEmptyLine     jFalse next:    * skip if not empty line
  264.             isLastLine      jTrue  last:    * special handling for last line
  265.             DelLine         jump  begin:    * delete empty lines
  266.     next:   CursorDown      jTrue begin:    * try next line
  267.             MacroQuit                       * thats all, folks!
  268.     last:   DelLine                         * delete the last line
  269.  
  270. *
  271. * Title: WordStar-like cursor left/right
  272. *
  273. * Left and Right cursor definitions that wrap to previous/next line
  274. * like WordStar does
  275. *
  276. cursorleft  CursorLeft                       * try to go left
  277.             MacroQuitTrue                    * succeed!  then we are done
  278.             CursorUp                         * else try to go to prev line
  279.             MacroQuitFalse                   * if fail, then at top of file. done
  280.             EndLine                          * jump to end of previous line.
  281.  
  282. cursorright isEndLine       jTrue Down:      * are we at end of line? Go down
  283.             CursorRight                      * else right one
  284.             MacroQuit                        * Quit macro
  285.       Down: CursorDown                       * try to go to next line
  286.             MacroQuitFalse                   * if not goto end
  287.             BegLine                          * else goto beginning of line
  288.  
  289. *
  290. * Title: repeat GetPrev down
  291. *
  292. * A very useful TSE Jr. command, GetPrev, copies a character from the line
  293. * immediately above the cursor line, onto the cursor line.  Often it is
  294. * necessary to copy this character to several succeeding lines in the
  295. * same column.  The GetPrev command, used in a macro, makes this
  296. * function easy.  Assign this macro to the <Alt 4> key (for example) in
  297. * QCONFIG.DAT as follows:
  298. *
  299. @4          GetPrev CursorLeft CursorDown
  300.  
  301. *
  302. * Title: enhanced AddLine/DelLine
  303. *
  304. * AddLine and DelLine commands do not change the cursor position.
  305. * Many would prefer that the cursor move to column one when these
  306. * commands are executed.  A solution is to change the QCONFIG.DAT
  307. * file as follows:
  308. *
  309. * Default QCONFIG.DAT file:
  310. *
  311. * f2    AddLine
  312. * ^y    DelLine
  313. *
  314. * Customized QCONFIG.DAT file:
  315. *
  316. f2          AddLine BegLine
  317.  
  318. ^y          DelLine BegLine
  319.  
  320. *
  321. * Title: Enhanced Copy/Move block
  322. *
  323. * CopyBlock and MoveBlock commands leave the copied or moved Block marked.
  324. * Many would prefer the Block to be unmarked.  A solution is to change
  325. * the QCONFIG.DAT file as follows:
  326. *
  327. * Default QCONFIG.DAT file:
  328. *
  329. * @c    CopyBlock
  330. * @m    MoveBlock
  331. *
  332. * Customized QCONFIG.DAT file:
  333. *
  334. @c          CopyBlock UnmarkBlock
  335.  
  336. @m          MoveBlock UnmarkBlock
  337.  
  338. * Title: Alternate DropAnchor
  339. *
  340. * The DropAnchor command ends or extends a Block if executed after a
  341. * Block has been initially or entirely marked.  Some editors have a
  342. * similar command, except that it acts as a toggle.  That is, if you are
  343. * already marking a Block, and you press DropAnchor again, the Block is
  344. * unmarked and marking begins again at the current cursor position.  To
  345. * implement this behavior, change the QCONFIG.DAT file as follows:
  346. *
  347. * Default QCONFIG.DAT file:
  348. *
  349. * @a    DropAnchor
  350. *
  351. * Customized QCONFIG.DAT file:
  352. *
  353. @a          UnmarkBlock DropAnchor
  354.  
  355.  
  356. * Title: Load sorted list of files in the current directory.
  357. *
  358. * This macro allows you to edit a sorted list of files of the current
  359. * directory.  Assign this macro to the <Alt 5> key (for example) in
  360. * QCONFIG.DAT as follows:
  361. *
  362. @5          Dos "dir *.* | sort>filedir.tmp" Return Return
  363.             EditFile "filedir.tmp" Return
  364.             DelLine 4
  365.  
  366. *
  367. * Title: PE2 like joinline
  368. *
  369. * Macro to make joinline act line PE's joinline, e.g., force
  370. * joinline to always concat the next line to the end of the
  371. * current line, regardless of the current cursor position.
  372. * Must be on one line if processed by qconfig.exe.
  373. * Works better if "removing trailing spaces=yes" (our default) in qconfig.exe
  374. *
  375. @j          isLastLine       * force blank removal, and check for eof
  376.             MacroQuitTrue    * if at eof, we can get out now
  377.             CursorRight      * force some movement that we can easily undo
  378.             EndLine          *
  379.             JoinLine         * concat the lines
  380.             PrevPosition     * back to where we were before the endline
  381.             CursorLeft       * and undo the cursorright
  382.  
  383. *
  384. * Title: Copy line above to EOL
  385. *
  386. @f1   top:  GetPrev     JTrue top:
  387.