Back to index

texmacs  1.0.7.15
archiver.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : archiver.hpp
00004 * DESCRIPTION: manage undo/redo history
00005 * COPYRIGHT  : (C) 2009  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef ARCHIVER_H
00013 #define ARCHIVER_H
00014 #include "patch.hpp"
00015 
00016 void global_clear_history ();
00017 void global_confirm ();
00018 
00019 class archiver_rep: public concrete_struct {
00020   patch    archive;        // undo and redo archive
00021   patch    current;        // current sequence of modifications
00022   int      depth;          // archive depth
00023   int      last_save;      // archive depth at last save
00024   int      last_autosave;  // archive depth at last autosave
00025   double   the_author;     // the author corresponding to the archiver
00026   double   the_owner;      // author of current modifications
00027   path     rp;             // root path for document
00028   observer undo_obs;       // observer for undoing changes
00029   bool     versioning;     // true during undo and redo operations
00030 
00031 protected:
00032   void apply (patch p);
00033   void split (patch p1, patch p2, patch& re1, patch& re2);
00034   patch make_future (patch p1, patch p2);
00035   patch expose (patch archive);
00036   void expose ();
00037   void normalize ();
00038   int corrected_depth ();
00039 
00040 public:
00041   archiver_rep (double author, path rp);
00042   ~archiver_rep ();
00043   void clear ();
00044   void show_all ();
00045 
00046   void add (modification m);
00047   void start_slave (double a);
00048   bool active ();
00049   bool has_history ();
00050   void cancel ();        // cancel current series of modifications
00051   void confirm ();       // move current modifications to history
00052   bool retract ();       // reopen last history item for further modifications
00053   bool forget ();        // undo and forget about last history item
00054   void forget_cursor (); // forget cursor modifications in last history item
00055   void simplify ();
00056 
00057   int  undo_possibilities ();
00058   int  redo_possibilities ();
00059   path undo_one (int i);
00060   path redo_one (int i);
00061   path undo (int i=0);
00062   path redo (int i=0);
00063   void mark_start (double m);
00064   bool mark_cancel (double m);
00065   void mark_end (double m);
00066 
00067   void require_save ();
00068   void require_autosave ();
00069   void notify_save ();
00070   void notify_autosave ();
00071   bool conform_save ();
00072   bool conform_autosave ();
00073 
00074   friend void archive_announce (archiver_rep* arch, modification mod);
00075   friend void global_clear_history ();
00076   friend void global_confirm ();
00077 };
00078 
00079 class archiver {
00080 CONCRETE (archiver);
00081   archiver (double author, path rp);
00082 };
00083 CONCRETE_CODE (archiver);
00084 
00085 #endif // defined ARCHIVER_H