home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / uedit-stuff_429.lzh / Uedit-Stuff / Paging < prev    next >
Text File  |  1991-01-10  |  10KB  |  228 lines

  1.  
  2. These here are new versions of the paging commands lAmiga-v (insert numbered
  3. page break at cursor), lAmiga-d (delete page break), lAmiga-r (insert
  4. numbered page breaks from cursor to end of file), and lAmiga-y (delete next
  5. page number, leaving formfeed).
  6.  
  7. L-r has two significant changes.  One is that you can put formfeeds into the
  8. file with L-f before running it, and it will put numbered page breaks at
  9. those points, padding out the short pages above them with blank lines.  It
  10. will refuse to work if it finds a numbered page break, or any formfeed which
  11. is not at the beginning of a line.  The other change is that it puts a top
  12. margin at the top of the first page (the page the cursor is on when you use
  13. it).  It also no longer has a tendency to add an extra entirely blank page
  14. at the end.
  15.  
  16. L-d is different in that it leaves a blank line where the page break was, if
  17. the page before it has any blank lines at the bottom above the bottom margin.
  18. It also runs backwards now; it deletes the previous page break instead of the
  19. next one.  Why, you ask?  The reason for this is that we have to keep the
  20. sform of the page we're de-numbering in the right place for the logic to
  21. work.  Otherwise repeated L-d commands can leave big chunks of blank lines
  22. lying around.  Running it backwards makes it much more likely that L-r
  23. followed by multiple L-d's will pretty much restore the original file.  (It
  24. will not delete the margin at the top of the first page.)  This also makes it
  25. easy to undo a L-v immediately after using it.
  26.  
  27. L-v mostly works the same, except that if it is used on the first line of a
  28. page, it creates only a top margin, instead of inserting a page break and
  29. thereby creating an entirely blank page.  (L-r uses this property to put a
  30. top margin at the beginning of the page it starts on.)  This will also be the
  31. case when bottomMargin is zero, which the old version did not handle well.
  32. In making a top margin, it notices existing blank lines and inserts only
  33. enough new ones to create a margin of the correct size.  And there are
  34. commented out lines to make it put dashes around the page number.
  35.  
  36. I've set it so that if the "middle" of a bottom margin is between two lines,
  37. it rounds toward the lower one instead of the upper one.  If you want to
  38. remove this change, take out the decNum(n53) in L-v and restore the commented
  39. out decNum(n53) in L-d.  The page number is also centered more accurately. 
  40. Remember to set your lineLength to reflect the actual paper being printed on
  41. for this to be accurate.
  42.  
  43. L-y has one change:  if it finds a page number in front of the next formfeed
  44. (or any footer text on that line) it deletes that text.  Then whether there
  45. was any text in front of the formfeed or not, it deletes all blank lines
  46. immediately above the formfeed.  Also it no longer uses alt-kp7 to do the
  47. delete, so it does not clobber your undo buffer.
  48.  
  49. There are several lines in L-v and L-d that should be removed if you have
  50. your printer set up to do an automatic perforation skip.  These lines are
  51. marked with @@@@ in a comment.  If you remove them, the effect will be that
  52. page numbers appear in the last line of the bottom margin instead of in the
  53. middle.  Restore the commented out decNum(n53) in L-d if you do this.  To use
  54. auto perf skip, set your lines/page to the length of the paper in lines minus
  55. the number of lines skipped at the perforation.  Assuming that the skip is
  56. equally balanced above and below the perforation (say 3 lines at the top and
  57. bottom of the paper, with a one inch skip), then you would set topMargin and
  58. bottomMargin to be three less than the actual size of margin you want to
  59. appear on the page.  For instance, my printer is set up to do a one inch perf
  60. skip on eleven inch paper, with the top of form set half an inch below the
  61. actual perforation, and generally prints six lines per inch.  To get one inch
  62. margins at both ends, I set both topMargin and bottomMargin to 3 and lines/
  63. page to 60.  If I were to turn off the perforation skip, I would set
  64. bottomMargin and lines/page larger, adding an equal amount to each.  I would
  65. not necessarily increase them by six, since that might put the page number
  66. lower than I want it.  As long as the difference puts the end of the text in
  67. the right place, the numbers do not have to reflect reality.
  68.  
  69. =============================================================================
  70.  
  71. .. if you want page headers and footers, modify this command:
  72.  
  73. Insert page-division at cursor
  74. <lAmiga-v:
  75.     getLocal(curFile,n54,pageLines)     .. don't clobber n49!
  76.     if (gtNum(2,n54)) {
  77.             putMsg("Must set lines/page > 1 first")
  78.             returnFalse
  79.     }
  80.     if (not is(curFile,sLine)) moveCursor(curFile,sLine)
  81.     if (not is(curFile,sForm)) {
  82.         if (is(curFile,formFeed)) clearChar(curFile)    .. will be replaced
  83.         getPageRowCol(n50,n51,n52)
  84.         getLocal(curFile,n53,bottomMargin)
  85. .. COMMENT OUT lines marked with @@@@ if using auto perforation skip:
  86.         decNum(n53)       .. @@@@ put number a bit lower when bottomMargin even
  87.         div(n53,n53,2)    .. @@@@
  88.         add(n51,n51,n53)  .. @@@@
  89.         while (gtNum(n54,n51)) { incNum(n51) insertChar(curFile,eLine) }
  90.         if (gtNum(n53,0)) {
  91.             getLocal(curFile,n54,lineLength)
  92.             div(n54,n54,2)
  93.             decNum(n54)         .. these two lines make centering more exact
  94.             if (geNum(n50,100)) decNum(n54)
  95.             while (decNum(n54))
  96.                 insertChar(curFile," ")
  97.             toWord(curFile,n50)
  98. ...... if one wants dashes around the number, un-comment-out these lines:
  99. ..          insertchar(curfile, " ")
  100. ..          insertchar(curfile, "-")
  101.             insertChar(curFile,12)              .. formfeed
  102. ..          movecursor(curfile, sword)
  103. ..          movecursor(curfile, schar)
  104. ..          movecursor(curfile, schar)
  105. ..          swapchar(curfile, "-")
  106. ..          movecursor(curfile, eline)
  107. ..          movecursor(curfile, echar)
  108.         }
  109.     }
  110.     if (not is(curFile,eFile)) {
  111.         getLocal(curFile, n54, topMargin)
  112.                 while (is(curFile, blankLine)) {
  113.                     moveCursor(curFile, downLine)
  114.                     if (not decNum(n54)) return
  115.                 }
  116.                 while (decNum(n54))
  117.                     insertChar(curFile, eLine)
  118.     }
  119. >
  120. this key inserts only a page header (top margin) if at sForm.  the new
  121. lAmiga-r makes use of that fact.
  122.  
  123. Delete PREVIOUS page-division
  124. <lAmiga-d:
  125.     while (not is(curFile,formFeed)) {
  126.         if (not is(curFile,sForm)) moveCursor(curFile,sForm)   .. else
  127.         if (not is(curFile,sLine)) moveCursor(curFile, sLine)
  128.         moveCursor(curFile, sChar)
  129.         if (is(curFile,sFile))
  130.             returnFalse                 .. maybe here delete top margin
  131.     }
  132.     if (not is(curFile,sLine)) moveCursor(curFile,sLine)
  133.     getPageRowCol(n54,n50,n51)                          .. don't clobber n49
  134.     getLocal(curFile,n54,topMargin)
  135.     getLocal(curFile,n53,bottomMargin)
  136. ..  decNum(n53) .. RESTORE this if the decNum(n53) in lAmiga-v is not used
  137.     div(n53, n53, 2)        .. @@@@ COMMENT THIS OUT if using auto perf skip
  138.     equateLoc(curFile,locA,atCursor)                    .. start of ff line
  139.     moveCursor(curFile,downLine)
  140.     while (decNum(n54) & is(curFile,blankLine))         .. del topmargin lines
  141.         moveCursor(curFile,downLine)
  142.     equateLoc(curFile, mouseLoc, locB)                  .. don't clobber locB
  143.     equateLoc(curFile,locB,atCursor)
  144.     equateLoc(curFile,atCursor,locA)
  145.     moveCursor(curFile,upLine)
  146.     while (decNum(n50)) {
  147.         if (not is(curFile,blankLine)) {
  148.             moveCursor(curFile,downLine)
  149.             goto label (3)
  150.         }
  151.         decNum(n53)
  152.         moveCursor(curFile,upLine)
  153.     }
  154.     label (3)
  155.     if (gtNum(0,n53) & !eqLoc(curFile,locB,eFile))
  156.         moveCursor(curFile,downLine)
  157.     equateLoc(curFile,locA,atCursor)
  158.     clearRgn(curFile,loc)
  159.     equateLoc(curFile,locB,mouseLoc)
  160. ..  if (geLoc(curFile,sPage,atCursor))  .. vscroll when at top corner
  161.         vScroll(atCursor)       .. ^^ that test can return incorrect result
  162. >
  163.  
  164. Auto-insert page-divisions and page-numbers in document
  165. <lAmiga-r:
  166.         putMsg("Scanning")
  167.         equateLoc(curFile,locA,atCursor)
  168.         freeBuf(buf54)
  169.         getSearch(buf49)                .. don't clobber search string
  170.         insertChar(buf54,12)
  171.         setSearch(buf54)
  172.         while (search(curFile,sInvert,eInvert,1))
  173.             if (not is(curFile, sLine)) {
  174.                 putMsg("Delete numbered paging divisions first using lAmiga-d")
  175.                 setSearch(buf49)
  176.                 returnFalse
  177.             }
  178.         putMsg(" ")
  179.         .. when there's no final eol/formfeed, eForm is never eFile, so:
  180.         moveCursor(curFile, eFile)
  181.         if (not is(curFile, sLine)) insertChar(curFile, eLine)
  182.         equateLoc(curFile, atCursor, locA)
  183.         if (not is(curFile,sForm)) moveCursor(curFile,sForm)
  184. ....    if (is(curFile, sFile))
  185.             runKey(lAmiga-v)            .. first page gets header
  186.         while (nothing) {
  187.             moveCursor(curFile,eForm)
  188.             getLocal(curFile,n53,bottomMargin)  .. inside loop cuz L-v trashes
  189.             getPageRowCol(n50,n51,n52)
  190.             getLocal(curFile,n52,pageLines)
  191.             if (gtNum(2,n52)) {
  192.                 putMsg("Must set lines/page > 1 first")
  193.                 getSearch(buf49)
  194.                 returnFalse
  195.             }
  196.             sub(n50, n52, n51)  .. number of lines page is short
  197.             incNum(n50)
  198.             if (not is(curFile, formFeed))
  199.                 moveCursor(curFile, downLine)   .. cuz at start of last line
  200.             if (geNum(n53, n50))                .. why make DO always run once?
  201.                 do (n54,n50,n53)
  202.                     moveCursor(curFile,upLine)          .. shave margin if any
  203.             runKey(lAmiga-v)
  204.             if (not moveCursor(curFile,downLine)) returnTrue
  205.             updateDisplay
  206.         }
  207. >
  208.  
  209.  
  210. Erase next page footer (number), leaving formfeed
  211. <lAmiga-y:
  212.     if (not is(curFile,eForm)) movecursor(curFile,eForm)
  213.     if (not is(curFile,12)) {
  214.         if (not is(curFile,eLine)) moveCursor(curFile,eLine)
  215.         if (is(curFile,12)) {
  216.         moveCursor(curFile, sLine)
  217.         clearRgn(curFile, line)
  218.     }
  219.     }
  220.     moveCursor(curFile, upLine)
  221.     while (is(curFile, blankLine)) {
  222.         clearRgn(curFile, line)
  223.         clearChar(curFile)
  224.         moveCursor(curFile, upLine)
  225.     }
  226.     moveCursor(curFile, downLine)
  227. >
  228.