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

  1. export int Load_hook(string file, string windowtitle, string promptfile)
  2. {
  3.   int changes;
  4.   int ret=0;
  5.   if(changes=ReadInfo("changes"))
  6.     ret=(!Request(joinstr("Do you really want to overwrite your work?\n",
  7.                       "You have done ", itoa(changes), " changes!")));
  8.   return(ret);
  9. }
  10.  
  11. export int Kill_hook(int bufferid)
  12. {
  13.   int ret=0;
  14.   if (!bufferid)
  15.     bufferid=GetBufferID();
  16.   if (ReadInfo("shared", bufferid)==1 && (ReadInfo("type")&1)) {
  17.         /* Test if this a duplicated bufer,
  18.            if not so we'll check if any changes are done */
  19.   
  20.     int changes=ReadInfo("changes", bufferid);
  21.   
  22.     if (changes) {        /* Some changes have been done! */
  23.       ret=(!Request(joinstr(itoa(changes), " changes have been done!\n",
  24.                                  "Kill ",
  25.                                  ReadInfo("file_name"),
  26.                                  " anyway?")));
  27.     }
  28.   }
  29.   return(ret);
  30. }
  31.  
  32. export int Clear_hook(int bufferid)
  33. {
  34.   int ret=0;
  35.  
  36.   if (!bufferid) {
  37.     bufferid=GetBufferID();
  38.     if (ReadInfo("shared", bufferid)==1 && (ReadInfo("type")&1)) {
  39.           /* Test if this a duplicated buffer,
  40.              if not so we'll check if any changes are done */
  41.     
  42.       int changes=ReadInfo("changes", bufferid);
  43.     
  44.       if (changes) {        /* Some changes have been done! */
  45.         ret=(!Request(joinstr(itoa(changes), " changes have been done!\n",
  46.                                    "Clear ",
  47.                                    ReadInfo("file_name"),
  48.                                    " anyway?")));
  49.       }
  50.     }
  51.   }
  52.   return(ret);
  53. }
  54.  
  55. export int QuitAll_hook()
  56. {
  57.   int firstid=GetBufferID();
  58.   int id=firstid;
  59.   int numofchanged=0;
  60.   int ret=0;
  61.   string str;
  62.  
  63.   do {
  64.     if (ReadInfo("changes", id) && (ReadInfo("type")&1))
  65.       numofchanged++;
  66.     id=NextBuffer(id);
  67.     if (id == firstid)
  68.       id=0;
  69.   } while (id);
  70.  
  71.   if (numofchanged) {
  72.  
  73.     if(numofchanged>1)
  74.       str = " buffers are";
  75.     else
  76.       str = " buffer is";
  77.  
  78.     str = joinstr(ltostr(numofchanged), str, " changed!\nQuit anyway?");
  79.  
  80.     ret = !Request(str, "Quit information!", "Quit!|Don't Quit!");
  81.   }
  82.   return(ret);
  83. }
  84.  
  85. Hook("Load", "Load_hook");     /* Patch Load() with Load_hook()! */
  86. Hook("Kill", "Kill_hook");     /* Patch Kill() with Kill_hook()! */
  87. Hook("Clear", "Clear_hook");     /* Patch Clear() with Clear_hook()! */
  88. Hook("QuitAll", "QuitAll_hook"); /* Patch QuitAll() with QuitAll_hook()! */
  89.