home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ME22-OS2.ZIP / MACROS.ZIP / SRCHMARK.M < prev    next >
Text File  |  1986-12-29  |  861b  |  39 lines

  1. /* The search-and-mark macro marks a block from the cursor position */
  2. /* until the first occurence of the char you type. */
  3.  
  4. init()
  5. {
  6.   assign_key("search_and_mark", 178);     /* ALT M */
  7. }
  8.  
  9. search_and_mark()
  10. {
  11.   int ch;
  12.  
  13.   mark();
  14.   message("Type character to find: ");
  15.   ch = get_tty_char();
  16.   if (ch == '\E')            /* <ESC> - abort operation */
  17.     clear_mark();
  18.   else if (ch == '\n')       /* mark till the end of the paragraph */
  19.   {
  20.     if (nextpara())  up();
  21.     setprompt(1);
  22.     mark();
  23.   }
  24.   else
  25.   {
  26.     if (fsearch(chr(ch)))     /* search for the char the user typed */
  27.     {
  28.       setprompt(1);          /* found!!! - prompt user for operation */
  29.       mark();
  30.     }
  31.     else
  32.     {
  33.       message("Char not found - press <RETURN> to continue");
  34.       ch = get_tty_char();
  35.       clear_mark();
  36.     }
  37.   }
  38. }
  39.