home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff374.lzh / Mat / REF < prev    next >
Text File  |  1990-10-08  |  3KB  |  62 lines

  1. .K STR,FILE1,FILE2,FILE3
  2. .bra {
  3. .ket }
  4. ;;    REF       --  Highlights references in text
  5. ;;                  using the fast string search mode of Mat.
  6.  
  7. ;;  Each line of the file being searched is first checked for the
  8. ;;  presence of the string; if it is found, a pattern match and slice
  9. ;;  is applied to separate out the string; a template then reassembles
  10. ;;  the line with ANSI highlighting characters around the match.
  11. ;;  A title line is output for each file in which a match is found.
  12. ;;  For convenience, a termination line is also generated.
  13.  
  14. ;;  Output is to a temporary file, which is typed out in its entirety
  15. ;;  at the end (and left available for later re-examination).
  16.  
  17. ;; for convenience it is run as a lower-priority background task:
  18. run ChangeTaskPri -5 +
  19.  Mat >T:Ref_list S {STR} P "#?^{STR}^#?" T "^0^1^2" nocase TAG "^B^P..." {FILE1} {FILE2} {FILE3} label "+ + + +^|... no refs found" +
  20.  type T:Ref_list
  21.  
  22. ;;  Mat command line arguments:
  23. ;;          S {STR}     -- fast string search for the supplied argument
  24. ;;
  25. ;;          P "#?^{STR}^#?"   -- IF the line contains the string, this
  26. ;;                            pattern with slice marks will be applied;
  27. ;;                            As a result, slice 0 will be everything
  28. ;;                            before the matched segment, the segment
  29. ;;                            itself is slice 1, and what follows is
  30. ;;                            slice 2.
  31. ;;
  32. ;;          T "^0@[1;33m^1@[0;31m^2"    -- reassemble output with this
  33. ;;                                      template (ESC characters in the
  34. ;;                                      original have here been replaced
  35. ;;                                      with '@' for clarity).
  36. ;;              The template itself has the following parts:
  37. ;;                  ^0  -- begin with the original start of line (slice 0)
  38. ;;                  @[1;33m     -- ANSI highlighting code (color & bold)
  39. ;;                  ^1  -- slice 1 -- the matched string
  40. ;;                  @[0;31m     -- ANSI normal-text  code
  41. ;;                  ^2  -- slice 2 -- the rest of the line
  42. ;;
  43. ;;          nocase  -- ignore case in all matching
  44. ;;
  45. ;;          TAG "^B@[3;1m^P...@[0m" -- add this header before each file
  46. ;;                                  in which a match is found.  The ANSI
  47. ;;                                  strings are similar to those above
  48. ;;                                  (italic + bold);
  49. ;;              the markers are:
  50. ;;                  ^B  -- "break" -- an extra newline to start.
  51. ;;                  ^P  -- complete pathname of matched file.
  52. ;;
  53. ;;          {FILE1} {FILE2} {FILE3} -- up to three file specs allowed
  54. ;;
  55. ;;          label "+ + + +^|... no refs found" -- terminating line; the
  56. ;;                                                part before the "^|"
  57. ;;                                  separator will be output unless there
  58. ;;                                  were no matches, in which case the
  59. ;;                                  text following it will appear.
  60.  
  61.  
  62.