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

  1.  
  2. For UEK users who use the commands in the Indent file (documented in
  3. Indent.doc), the following functions will make those commands more
  4. responsive, by preventing them from setting the PAGE_ displayFlag bit when
  5. only the cursor line has been modified.  These definitions replace the
  6. functions normal-tab, normal-bs (if you want to use it; it's commented out),
  7. and most importantly virtual-[, which is the engine at the core of the major
  8. indent functions.  Also included is a commented-out command (virtual-]) which
  9. is useful for finding out what is happening to displayFlag.  It shows which
  10. bits are currently set.
  11.  
  12.  
  13. NEEDS TO BACKSPACE SINGLY SOMETIMES?
  14.  
  15. Un-indent with alt-[ if in leading whitespace, else delete last char
  16. ..<normal-bs:   if (is(curfile, sline)) {
  17.                     if (eqloc(curfile, atcursor, spage))
  18.                         vscroll(atcursor)               .. BUG workaround
  19.                     if (movecursor(curfile, schar))
  20.                         clearchar(curfile)
  21.                     return
  22.                 }
  23.                 equateloc(curfile, locA, atcursor)
  24.                 while (movecursor(curfile, schar)) {
  25.                     if (not is(curfile, whitespace)) {     .. we're in mid-line
  26.                         movecursor(curfile, locA)
  27.                         getaddress(20, n9)                 .. displayFlag
  28.                         peek(n9, n8, 2)
  29.                         movecursor(curfile, schar)
  30.                         clearchar(curfile)
  31.                         poke(n9, n8, 2)         .. update this line only!
  32.                         return
  33.                     }
  34.                     if (is(curfile, sline)) {   .. we are in the leading indent
  35.                         runkey(alt-[)
  36.                         return
  37.                     }
  38.                 }
  39. > .. use shift-backspace to simply delete the previous character
  40.  
  41.  
  42. UEK version -- refuses to set PAGE_ or ALLPAGE_ in displayFlag if it is run
  43. only once, e.g. by alt-].  Goes ahead and sets them if run by e.g. alt-r.
  44.  
  45. Indent cursor line to column specified in n54, not preserving cursor col
  46. <virtual-[:     getAddress(20, n9)                      .. displayFlag
  47.                 peek(n9, n7, 2)
  48.                 if (not is(curfile, sline)) movecursor(curfile, sline)
  49.                 getlocal(curfile, n52, leftmargin)
  50.                 setlocal(curfile, leftmargin, n54)
  51. .... The manual says that nonzero leftmargin causes autoindent
  52. .... to be ignored.  But in version 2.5d1 autoindent false causes
  53. .... leftmargin to be ignored!  Grrr:
  54.         if (not getflag(curfile, autoindent)) {
  55.             add(n52, n52, 100000)
  56.             flipflag(curfile, autoindent)
  57.         }
  58.                 typechar(eline)         .. cause indent to leftmargin (n54)
  59.                 movecursor(curfile, upline)
  60.                 clearchar(curfile)
  61.         if (genum(n52, 100000)) {        .. GRRR
  62.             sub(n52, n52, 100000)
  63.             flipflag(curfile, autoindent)
  64.         }
  65.                 setlocal(curfile, leftmargin, n52)      .. restore old margin
  66. .. SUPER BOGUS BUG WORKAROUND:
  67.         if (getflag(curfile, mapchars)) {
  68.             flipflag(curfile, mapchars)
  69.             typechar(0)            .. snaps it back to reality!
  70.             flipflag(curfile, mapchars)
  71.         } else
  72.             typechar(0)
  73. .. end super bogosity
  74.                 if (eqnum(n7, 0)) {     .. false if run more than once
  75.                     peek(n9, n8, 2)     .. new displayFlags value
  76.                     and(n8, n8, 7)      .. mask out bad bits
  77.                     poke(n9, n8, 2)
  78.                 }
  79.         movecursor(curfile, locA)
  80.         if (is(curfile, sline)) runkey(ctl-[)
  81. >
  82.  
  83. Display the displayFlag bits for optimizing stuff.
  84. ..<virtual-]:   getAddress(20, n5)      .. displayFlag, 2 bytes
  85.                 peek(n5, n6, 2)
  86.                 freebuf(buf97)
  87.                 insertrgn(buf97, sfile, "   press any key
  88.  
  89. The following displayFlag bits are set:", all)
  90.                 if (and(n4, n6, 1)) insertrgn(buf97, efile, "
  91.   SHOWCURSOR_", all)
  92.                 if (and(n4, n6, 2)) insertrgn(buf97, efile, "
  93.   VSCROLL_", all)
  94.                 if (and(n4, n6, 4)) insertrgn(buf97, efile, "
  95.   HSCROLL_", all)
  96.                 if (and(n4, n6, 8)) insertrgn(buf97, efile, "
  97.   SHOWEOS_", all)
  98.                 if (and(n4, n6, 16)) insertrgn(buf97, efile, "
  99.   PAGE_", all)
  100.                 if (and(n4, n6, 0xffe0)) insertrgn(buf97, efile, "
  101.   ALLPAGE_", all)
  102.                 if (eqnum(n6, 0)) insertrgn(buf97, efile, "
  103.   (none)", all)
  104.                 insertchar(buf97, eline)
  105.                 equatenum(n3, curfile)
  106.                 editbuf(buf97)
  107.                 getkey(n6)
  108.                 editbuf(buf[n3])
  109.                 freebuf(buf97)
  110. >
  111. that should use text() now.
  112.