home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / TextEditors&Viewers / Texteditors / FFRED10.LHA / fpl / IncSearch.FPL < prev    next >
Encoding:
Text File  |  1994-09-22  |  1.3 KB  |  55 lines

  1. export void IncSearch()
  2. {
  3.   string searchstring="";
  4.   string key;
  5.   int searchlen=0;
  6.   int repeat=1;
  7.   int keylen=0, counter;
  8.   int foundy[100], foundx[100];
  9.   int ret;
  10.  
  11.  
  12.   SearchSet("f+");        // Only search forward.
  13.  
  14.   while (repeat) {
  15.     Status(0, joinstr("Search:»", searchstring, "«"));
  16.     key=GetKey();
  17.     if (!strcmp(key, "\n") || !strcmp(key, "\r")) {
  18.       repeat=0;
  19.     } else if (!strcmp(key, "\b")) {
  20.       if (searchlen) {
  21.         RedrawScreen();
  22.         searchlen--;
  23.         GotoLine(foundy[searchlen], foundx[searchlen]);
  24.         searchstring=substr(searchstring, 0, searchlen);
  25.       }
  26.     } else if (searchlen<90) {
  27.       keylen=0;
  28.       if (!searchlen || strcmp(key, "\x13")) {
  29.         searchstring+=key;
  30.         searchlen+=(keylen=strlen(key));
  31.         for (counter=keylen; counter>0; counter--) {
  32.           foundx[searchlen-counter]=ReadInfo("byte_position");
  33.           foundy[searchlen-counter]=ReadInfo("line");
  34.         }
  35.         Visible(0);
  36.         CursorLeft(1);
  37.       }
  38.       ret=Search(searchstring);
  39.       if (ret<0) {
  40.         DisplayBeep();
  41.         if (keylen)
  42.           CursorRight(1);
  43.       }
  44.       RedrawScreen();
  45.       Visible(1);
  46.       if (ret>=0)
  47.         InverseLine(0, searchlen, 0);
  48.     }
  49.   }
  50.   RedrawScreen();
  51. }
  52.  
  53. AssignKey("IncSearch();", "Control s");
  54.  
  55.