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

  1. These two commands, which I threw together in about fifteen minutes, are for
  2. letting you know how your parentheses and squiggle braces match up.  When you
  3. press a closing brace or a closing paren, the matching opening one gets
  4. displayed as invert, if it is on the screen, until you type your next input. 
  5. It's a little slow if the one displayed is not on the same line, but it
  6. doesn't slow down input because it abandons the search for the matching open
  7. paren or open brace if you type another input.  It will not restore what the
  8. invert region was before the command.  It does not check whether things are
  9. inside quote marks or comments or anything like that.  It trashes locA.  NOTE
  10. that while the invert region is displayed it is busy-waiting for you to type
  11. something, so anything that waits for idle time won't work ...  so it's best
  12. not to leave it in that state unnecessarily.
  13.  
  14. Later on I added SC-0 [think of ctl-)] to toggle the matching feature on and
  15. off.  This version uses userGlobalA as the flag to control whether it's on or
  16. off.  By searching for occurrences of userGlobalA you can change it to use
  17. some other flag, either global or local, or an n-variable (no checked menu
  18. items in the latter case).
  19.  
  20.  
  21. Display matching left paren as invert (if on screen) until next input
  22. <shft-0:        .. NORMAL-)
  23.         typechar(")")
  24.         if (eqnum(userglobalA, 0) | not thiskey) returntrue
  25.         updatedisplay
  26.         equatenum(n0, 0)
  27.         equateloc(curfile, loca, atcursor)
  28.         while (movecursor(curfile, schar) & 
  29.                         not geloc(curfile, spage, atcursor) &
  30.                         not inputwaiting) {
  31.             if (is(curfile, ")")) incnum(n0)
  32.             else if (is(curfile, "(")) decnum(n0)
  33.             runkey(virtual-0)
  34.         }
  35.     movecursor(curfile, loca)
  36.     updatedisplay
  37. >
  38.  
  39. Display matching left brace as invert (if on screen) until next input
  40. <shft-]:        .. NORMAL-}
  41.         typechar("}")
  42.         if (eqnum(userglobalA, 0) | not thiskey) returntrue
  43.         updatedisplay
  44.         equatenum(n0, 0)
  45.         equateloc(curfile, loca, atcursor)
  46.         while (movecursor(curfile, schar) & 
  47.                         not geloc(curfile, spage, atcursor) &
  48.                         not inputwaiting) {
  49.             if (is(curfile, "}")) incnum(n0)
  50.             else if (is(curfile, "{")) decnum(n0)
  51.             runkey(virtual-0)
  52.         }
  53.     movecursor(curfile, loca)
  54.     updatedisplay
  55. >
  56.  
  57. <virtual-0:     if (eqnum(n0, 0)) {
  58.                     equateloc(curfile, sinvert, atcursor)
  59.                     movecursor(curfile, echar)
  60.                     equateloc(curfile, einvert, atcursor)
  61.                     updatedisplay
  62.                     movecursor(curfile, loca)
  63.                     updatedisplay
  64.                     while (not inputwaiting) nothing
  65. .. that nothing used to be delay(1) but the delay was often more like 10.
  66. .. I had to make it spin to get quick response to resumption of typing
  67.                     equateloc(curfile, einvert, sinvert)
  68.                     movecursor(curfile, sinvert)
  69.                     updatedisplay
  70.                 } >
  71.  
  72. These wouldn't need nearly so many updatedisplays if the displayflag bits
  73. were smarter...
  74.  
  75. Toggle whether ) and } show matching ( and {
  76. <shftctl-0:     if (eqnum(userglobalA, 0)) {
  77.                     putmsg("turning On paren matching")
  78.                     equatenum(userglobalA, 1)
  79.                 } else {
  80.                     putmsg("turning OFF paren matching")
  81.                     equatenum(userglobalA, 0)
  82.                 } >
  83.