home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / eel / lenoil.arc / REVERT.E < prev    next >
Encoding:
Internet Message Format  |  1988-12-09  |  2.6 KB

  1. From:    IN%"lenoil@APPLE.COM"  "Robert Lenoil"  9-DEC-1988 16:12
  2. To:    p150bk19@VB.CC.CMU.EDU
  3. Subj:    REVERT.E
  4.  
  5. Received: from apple.com by VB.CC.CMU.EDU; Fri, 9 Dec 88 16:12 EST
  6. Received: by apple.com (5.59/25-eef) id AA17235; Fri, 9 Dec 88 13:10:01 PST
  7. Date: Fri, 9 Dec 88 13:10:01 PST
  8. From: Robert Lenoil <lenoil@APPLE.COM>
  9. Subject: REVERT.E
  10. To: p150bk19@VB.CC.CMU.EDU
  11. Message-Id: <8812092110.AA17235@apple.com>
  12.  
  13. /* The following copyright and trademark notice applies to some of the code
  14.  * herein; all other material is Copyright (c) 1986, 1987 by Robert Lenoil,
  15.  * with free copying allowed for any purpose, provided that this copyright
  16.  * notice is included.
  17.  */
  18.  
  19. /************************************************************************
  20. * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. *
  21. *                                                                       *
  22. *     Copyright (C) 1985 Lugaru Software Ltd.  All rights reserved.     *
  23. *                                                                       *
  24. * Limited permission is hereby granted to reproduce and modify this     *
  25. * copyrighted material provided that the resulting code is used only in *
  26. * conjunction with Lugaru products and that this notice is retained in  *
  27. * any such reproduction or modification.                                *
  28. ************************************************************************/
  29.  
  30. /*
  31.  * A revert command for Epsilon.
  32.  */
  33.  
  34. #include <eel.h>
  35.  
  36. /* This file adds the following commands/procedures:
  37. COMMAND           WRITTEN FOR VERSION
  38. revert_buffer           3.1
  39.  
  40. /* REVERT_BUFFER implements the good 'ol revert command. */
  41. command revert_buffer()
  42. {  char resp[80], *buf, *tbuf, *fname;
  43.    int strip = strip_returns, opoint = point, err;
  44.    short omark = mark;
  45.  
  46.    if (!filename || !*filename)
  47.       say("Buffer not a file buffer");
  48.    else if (!modified)
  49.       say("Buffer not modified");
  50.    else
  51.    {  get_string(resp, "Revert buffer? [n]");
  52.       if (toupper(*resp) == 'Y')
  53.       {  buf = bufname;
  54.          fname = filename;
  55.          bufname = tbuf = temp_buf();
  56.          if (err = file_read(fname, strip))
  57.          {  file_error(err, fname, "Couldn't revert buffer");
  58.             bufname = buf;
  59.          }
  60.          else
  61.          {  bufname = buf;
  62.             delete(0, size()-1);
  63.             bufname = tbuf;
  64.             xfer(buf, 0, size()-1);
  65.             bufname = buf;
  66.             modified = 0;
  67.             if (omark <= size()) mark = omark;
  68.             if (opoint <= size()) point = opoint;
  69.          }
  70.          delete_buffer(tbuf);
  71.       }
  72.    }
  73. }
  74.