home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / wp / bmacs.zip / SRCHHILT.M < prev    next >
Text File  |  1989-01-01  |  3KB  |  94 lines

  1. ;***************************************************************************
  2. ;**
  3. ;** These macros can be used to improve the way that Brief handles
  4. ;** search targets. The macro highlight_searched can be called after
  5. ;** a search and will highlight the target if it is found. The highlight
  6. ;** will disappear when the user enters the first keystroke. This is very
  7. ;** useful if you are using an EGA in 43 line mode as it is sometimes hard
  8. ;** to find the cursor in a screen full of characters.
  9. ;** As a side comment, it would be VERY useful if ALL Brief macros returned
  10. ;** some status value that indicated success or failure. In this way they
  11. ;** become useful primitives for building higher level functions. This is
  12. ;** NOT done by the search and translate macros in SEARCH.M.
  13. ;**
  14. ;** Written for Brief v1.33 by Harold Handelsman, 22 Sept 1986
  15. ;**
  16. ;***************************************************************************
  17. ;**
  18. ;** local_search_again
  19. ;**
  20. ;** This routine will repeat the last search and highlight the text
  21. ;** if it was found. This should be assigned to Shift-F6 instead of
  22. ;** search_again. Similar routine can be made for kbd_fwd_search and
  23. ;** kbd_backward_search.
  24. ;**
  25.  
  26. (macro local_search_again
  27.    (
  28.       (search_again)
  29.       (highlight_searched)
  30.    )
  31. )
  32.  
  33. ;**
  34. ;** highlight_searched
  35. ;**
  36. ;** This routine will highlight the text if it was found, then wait
  37. ;** for the next keystroke. When the user types the next command, the
  38. ;** highlight is removed and the keystroke is then pushed back into
  39. ;** the buffer.
  40. ;**
  41.  
  42. (macro highlight_searched
  43.    (
  44.       (int ln)
  45.       (string st)
  46.  
  47.  
  48.       ;** Find the length of the search string.
  49.  
  50.       (= ln (strlen _s_pat))
  51.  
  52.       ;** Check if the search pattern has been specified.
  53.  
  54.       (if ln
  55.          (
  56.  
  57.             ;** Read the rest of the current line into a string.
  58.  
  59.             (= st (read))
  60.  
  61.             ;** If the target string is found then highlight it.
  62.             ;** (Note: search_string is always case sensitive and
  63.             ;** so will not always find the target.)
  64.  
  65.             (if (search_string _s_pat st ln (! _reg_exp))
  66.                (
  67.  
  68.                   ;** Move to the end of the target string.
  69.  
  70.                   (move_rel 0 (- ln 1))
  71.                   (drop_anchor)
  72.  
  73.                   ;** Now move to the start of the string.
  74.  
  75.                   (move_rel 0 (- 1 ln))
  76.  
  77.                   ;** Refresh to update the cursor position and wait for
  78.                   ;** the user to type a command.
  79.  
  80.                   (refresh)
  81.                   (while (== (= ln (read_char)) -1))
  82.  
  83.                   ;** Now delete the highlight and push the command back into
  84.                   ;** the buffer.
  85.  
  86.                   (raise_anchor)
  87.                   (push_back ln)
  88.                )
  89.             )
  90.          )
  91.       )
  92.    )
  93. )