home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / sprint / spoutlin.zip / OUTLIN.SPM
Text File  |  1989-07-02  |  8KB  |  263 lines

  1. ;                      ON-SCREEN OUTLINING MACROS
  2. ;  1/8/89
  3. ;  Written by Tom Streeter (75216.2530).  This replaces the versions uploaded
  4. ;  to Compuserve on 11/17/88 and 10/15/1988.
  5. ;  
  6. ;  This is an experimental set of macros to allow for simple onscreen
  7. ;  outlining.  Modifications, elaborations, and improvements to this should
  8. ;  be relatively simple, and are encouraged.
  9.  
  10. ;  Sprint's lack of an onscreen outliner, i.e. an outliner that automatically
  11. ;  numbers and letters text on screen in classic outline fashion, is a major
  12. ;  drawback.  There's much to be said for a word processor like Sprint that
  13. ;  doesn't jump on the WYSIWYG bandwagon; if you're concerned with the actual
  14. ;  words you write instead of how pretty they look on paper, then WYSIWYG
  15. ;  features can just get in the way.  Onscreen outlining, however, is not
  16. ;  necessarily a WYSIWYG feature; many of us use them for organizing our
  17. ;  thoughts, notes, etc. in a convenient way on the screen just to help us
  18. ;  think.  We never intend to print the outlines on paper.
  19. ;  
  20. ;  So I created the following set of macros.  To load, press Alt-U, M, L,
  21. ;  and select "Outline.SPM."  To get the outliner menu, either press
  22. ;  Alt-Shift-X and type "OtlMenu," or assign the menu to a key.  (A routine 
  23. ;  for assigning the menu to Alt-O is included below, along with one to 
  24. ;  add it to Sprint's main menu; just "uncomment" them.)  To create
  25. ;  an outline, open a new file with a single, default ruler at the top. 
  26. ;  (The outliner assumes the file has a default ruler, and won't work
  27. ;  unless the tabs are set at 5.)  Create each outline
  28. ;  entry by indenting the beginning of the entry using the Shift-Tab key
  29. ;  (NOT Sprint's ruler).  Indent one tab for main headings, two for
  30. ;  subheadings, and so on, up to four indents.  Once you have created one or
  31. ;  more entries, you can call the outliner menu and select "Insert
  32. ;  Numbering."  I couldn't figure out a way to generate Roman numerals using
  33. ;  Sprint's macro language, so running the outliner macro inserts numbers
  34. ;  before first level headings, capital letters before second level
  35. ;  headings, numbers again for third level headings, and lower case letters
  36. ;  for fourth level headings.   You can add entries by simply starting a new
  37. ;  line, and you can move existing entries around by cutting and pasting
  38. ;  them as you would in a normal Sprint document.  Just run the "Insert
  39. ;  Numbering" function to get the numbers and letters back into their proper
  40. ;  order.
  41. ;  
  42. ;  OTHER FUNCTIONS:  selecting "New Entry" from the menu creates a new entry
  43. ;  immediately below the one the cursor is currently in, and at the same
  44. ;  level. (It's handy for making lists.)  "Promote Entry" moves the current
  45. ;  entry to the left one notch and changes the outline numbering
  46. ;  accordingly, and "Demote Entry" does the reverse.  "Hide" is a simple
  47. ;  imitation of the hide function on other  outliners.  Basically, it sets
  48. ;  the ruler's right margin to 255 characters, which effectively "flattens"
  49. ;  all the entries to one line, allowing you to  see all (or most) of your
  50. ;  outline on screen at once.  "Show" restores things to normal.   "Remove
  51. ;  numbering" does just that, but it also promotes all entries to the first
  52. ;  level.  (This is necessary if you want to sort the outline elements.) 
  53. ;  Running "Insert Numbering" restores things to the way they were.
  54.  
  55. #define firstlevel
  56. #define secondlevel
  57. #define thirdlevel
  58. #define fourthlevel
  59.  
  60. ; Error checking--makes sure this is an outline file, i.e., that it has ^G's
  61. OtlCheck:
  62.     set themark
  63.     r toruler
  64.     f ('^G' csearch) || { 
  65.         to themark
  66.         exitmenus
  67.         error "** Warning: Not an Outline File."
  68.         }
  69.     to themark
  70.  
  71. ; Central routine--inserts #s based on column placement of ^G's
  72.  
  73. Outline:
  74.  
  75.     OtlCheck
  76.      set themark
  77.     message "\n Numbering Outline"
  78.  
  79.      0 -> firstlevel
  80.      0 -> secondlevel
  81.      0 -> thirdlevel
  82.      0 -> fourthlevel
  83.  
  84.      ; Go to top of outline and insert a default ruler.
  85.  
  86.      r toruler 
  87.      readruler 5 settab writeruler 0 -> modf
  88.  
  89.      while (search "^G^G") {del}        ; delete all extra ^G's (they build up
  90.     r toruler                        ; sometimes in heavily re-worked outlines).
  91.  
  92.      f while ('^G' csearch) {           ; Look for all Shift-Tabs.
  93.  
  94.           if column = 5 {               ; If they are indented 5 spaces, 
  95.                0 -> secondlevel         ; insert a first level number.
  96.                0 -> thirdlevel
  97.                0 -> fourthlevel
  98.                delete tosol
  99.                ++firstlevel
  100.                firstlevel put "%3d"
  101.                insert ".^I"
  102.                toeol 
  103.                }
  104.           else if column = 10 {         ; If they are indented 10,
  105.                0 -> thirdlevel          ; insert a second level letter.
  106.                0 -> fourthlevel
  107.                delete tosol
  108.                insert "^I  "
  109.                ++secondlevel
  110.                (secondlevel+64) insert
  111.                insert ".^I" 
  112.                toeol 
  113.                }
  114.           else if column = 15 {         ; If indented 15, third level.
  115.                0 -> fourthlevel
  116.                delete tosol
  117.                insert "^I^I  "
  118.                ++thirdlevel
  119.                thirdlevel put "%d"
  120.                insert ")^I" 
  121.                toeol 
  122.                }
  123.           else if column = 20 {        ; If indented 20, fourth level.
  124.                delete tosol
  125.                insert "^I^I^I  "
  126.                ++fourthlevel
  127.                (fourthlevel+96) insert
  128.                insert ")^I"
  129.                toeol 
  130.                }
  131.           else return
  132.      }
  133.      to themark
  134.  
  135. NewEntry:                                   ; Create a new entry.
  136.     OtlCheck
  137.      r ('^G' csearch)
  138.      if (column = 5) {
  139.           f to ispara
  140.           insert "^J^I^G"
  141.           }
  142.      if (column = 10) {
  143.           f to ispara
  144.           insert "^J^I^I^G"
  145.           }
  146.      if (column = 15) {
  147.           f to ispara
  148.           insert "^J^I^I^I^G"
  149.           }
  150.      if (column = 20) {
  151.           f to ispara
  152.           insert "^J^I^I^I^I^G"
  153.           }
  154.      outline
  155.  
  156. Hide:
  157.     set themark
  158.     OtlCheck
  159.      readruler 255 -> rightmargin writeruler
  160.     to themark
  161.  
  162. Show:
  163.     set themark
  164.     OtlCheck
  165.     readruler 65 -> rightmargin writeruler 
  166.     to themark 
  167.  
  168. Flatten:
  169.     OtlCheck
  170.     set themark
  171.     r toruler
  172.     f while ('^G' csearch) {
  173.         delete tosol
  174.         insert "^I"
  175.         toeol
  176.         }
  177.     to themark
  178.  
  179. Promote:
  180.     OtlCheck
  181.     set themark
  182.      r ('^G' csearch)
  183.      if (column = 5) {
  184.           error "Cannot be promoted."
  185.           }
  186.      if (column = 10) {
  187.         delete tosol
  188.           insert "^I^G"
  189.           }
  190.      if (column = 15) {
  191.           delete tosol
  192.           insert "^I^I^G"
  193.           }
  194.      if (column = 20) {
  195.           delete tosol
  196.           insert "^I^I^I^G"
  197.           }
  198.     to themark
  199.      outline
  200.  
  201. Demote:
  202.     OtlCheck
  203.     set themark
  204.      r ('^G' csearch)
  205.      if (column = 20) {
  206.           error "Cannot be demoted."
  207.           }
  208.      if (column = 15) {
  209.           delete tosol
  210.           insert "^I^I^I^I^G"
  211.           }
  212.      if (column = 10) {
  213.         delete tosol
  214.           insert "^I^I^I^G"
  215.           }
  216.      if (column = 5) {
  217.           delete tosol
  218.           insert "^I^I^G"
  219.           }
  220.     to themark
  221.      outline
  222.  
  223. OtlMenu:
  224.     menu "On Screen Outlining" {
  225.         "Insert Numbering"    OutLine,
  226.         "New Entry"        NewEntry,
  227.         "Promote Entry"    Promote,
  228.         "Demote Entry"        Demote,
  229.         "Hide"            Hide,
  230.         "Show"            Show,
  231.         "Remove Numbering"    Flatten
  232.         }
  233.  
  234. ; Uncomment the following to add the outline menu to Sprint's Main Menu.
  235. ;  SprintMenu :
  236. ;      menu "Sprint" {
  237. ;      "File"            FilesMenu,
  238. ;      "Edit"            EditMenu,
  239. ;      "_",
  240. ;      "Insert"            InsertMenu,
  241. ;      "Typestyle"        TypeStyleMenu,
  242. ;      "Style"            StyleMenu,
  243. ;      "Layout"            LayoutMenu,
  244. ;      "Outliner"        OtlMenu,
  245. ;      "_",
  246. ;      "Print"            PrintMenu,
  247. ;      "Window"            WindowsMenu,
  248. ;      "Utilities"        UtilitiesMenu,
  249. ;      "Customize"        CustomMenu,
  250. ;      "_",
  251. ;      "Quit"            ExitEditor
  252. ;          }
  253.   
  254. ;  Uncomment the following to assign the outline menu to the Alt-O key.
  255. ;  ~O : OtlMenu
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.