home *** CD-ROM | disk | FTP | other *** search
/ Dream 49 / Amiga_Dream_49.iso / atari / texte / oribin.zoo / bindings / go-match.fun < prev    next >
Text File  |  1991-07-09  |  4KB  |  174 lines

  1. {{{  comments
  2. ; Jump from [,{ or ( to a matching ],} or ).
  3. ; if no match can be found, a errormessage appears.
  4. }}}
  5. nodup
  6. {{{  libs
  7. {{{F pre-char.fun
  8. :::F pre-char.fun
  9. }}}
  10. {{{F error.fun
  11. :::F error.fun
  12. }}}
  13. }}}
  14. {{{  goto-matching-fence
  15. {{{  next_char op
  16. (deffun next_char (
  17.   O_RIGHT
  18.   if test-end-line (
  19.     {{{  next textline
  20.     do (
  21.       O_DOWN
  22.       if test-fold-line (
  23.         O_OPEN_FOLD
  24.       ) else (
  25.         if test-end-fold (O_CLOSE_FOLD) fi
  26.       ) fi
  27.     )
  28.     while and(not(test-bottom),not(test-text))
  29.       O_START_OF_LINE
  30.     }}}
  31.   ) fi
  32. ))
  33. }}}
  34. (deffun goto-matching-fence (
  35.   if not(test-text) (oops) fi
  36.   store-line matching-fence-y
  37.   store-pos  matching-fence-x
  38.   case
  39.     {{{   {
  40.     (test-char "{ (
  41.       set-counter fence-counter 1
  42.       do (
  43.         {{{  check one character
  44.         next_char
  45.         if test-char "{ (
  46.           add-counter fence-counter 1
  47.         ) else (
  48.           if test-char "} (add-counter fence-counter -1) fi
  49.         ) fi
  50.         }}}
  51.       ) while and(not(test-bottom),not(counter-0 fence-counter))
  52.       {{{  not found ?
  53.       if test-bottom (
  54.         goto-line-counter matching-fence-y
  55.         goto-counter matching-fence-x
  56.         failed
  57.       ) fi
  58.       }}}
  59.     ))
  60.     }}}
  61.     {{{   }
  62.     (test-char "} (
  63.       set-counter fence-counter 1
  64.       do (
  65.         {{{  check one character
  66.         previous-text-character
  67.         if test-char "} (
  68.           add-counter fence-counter 1
  69.         ) else (
  70.           if test-char "{ (add-counter fence-counter -1) fi
  71.         ) fi
  72.         }}}
  73.       ) while and(not(counter-0 fence-counter),not(test-top))
  74.       {{{  not found ?
  75.       if test-top (
  76.         goto-line-counter matching-fence-y
  77.         goto-counter matching-fence-x
  78.         failed
  79.       ) fi
  80.       }}}
  81.     ))
  82.     }}}
  83.     {{{   [
  84.     (test-char "[ (
  85.       set-counter fence-counter 1
  86.       do (
  87.         {{{  check one character
  88.         next_char
  89.         if test-char "[ (
  90.           add-counter fence-counter 1
  91.         ) else (
  92.           if test-char "] (add-counter fence-counter -1) fi
  93.         ) fi
  94.         }}}
  95.       ) while and(not(test-bottom),not(counter-0 fence-counter))
  96.       {{{  not found ?
  97.       if test-bottom (
  98.         goto-line-counter matching-fence-y
  99.         goto-counter matching-fence-x
  100.         failed
  101.       ) fi
  102.       }}}
  103.     ))
  104.     }}}
  105.     {{{   ]
  106.     (test-char "] (
  107.       set-counter fence-counter 1
  108.       do (
  109.         {{{  check one character
  110.         previous-text-character
  111.         if test-char "] (
  112.           add-counter fence-counter 1
  113.         ) else (
  114.           if test-char "[ (add-counter fence-counter -1) fi
  115.         ) fi
  116.         }}}
  117.       ) while and(not(counter-0 fence-counter),not(test-top))
  118.       {{{  not found ?
  119.       if test-top (
  120.         goto-line-counter matching-fence-y
  121.         goto-counter matching-fence-x
  122.         failed
  123.       ) fi
  124.       }}}
  125.     ))
  126.     }}}
  127.     {{{   (
  128.     (test-char "( (
  129.       set-counter fence-counter 1
  130.       do (
  131.         {{{  check one character
  132.         next_char
  133.         if test-char "( (
  134.           add-counter fence-counter 1
  135.         ) else (
  136.           if test-char ") (add-counter fence-counter -1) fi
  137.         ) fi
  138.         }}}
  139.       ) while and(not(test-bottom),not(counter-0 fence-counter))
  140.       {{{  not found ?
  141.       if test-bottom (
  142.         goto-line-counter matching-fence-y
  143.         goto-counter matching-fence-x
  144.         failed
  145.       ) fi
  146.       }}}
  147.     ))
  148.     }}}
  149.     {{{   )
  150.     (test-char ") (
  151.       set-counter fence-counter 1
  152.       do (
  153.         {{{  check one character
  154.         previous-text-character
  155.         if test-char ") (
  156.           add-counter fence-counter 1
  157.         ) else (
  158.           if test-char "( (add-counter fence-counter -1) fi
  159.         ) fi
  160.         }}}
  161.       ) while and(not(counter-0 fence-counter),not(test-top))
  162.       {{{  not found ?
  163.       if test-top (
  164.         goto-line-counter matching-fence-y
  165.         goto-counter matching-fence-x
  166.         failed
  167.       ) fi
  168.       }}}
  169.     ))
  170.     }}}
  171.   esac
  172. ))
  173. }}}
  174.