home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / emacs-15.0.3 / src / undo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-19  |  2.6 KB  |  71 lines

  1. /* Definitions of objects used by the GNU Emacs undo facility.
  2.    Copyright (C) 1985 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY.  No author or distributor
  8. accepts responsibility to anyone for the consequences of using it
  9. or for whether it serves any particular purpose or works at all,
  10. unless he says so in writing.  Refer to the GNU Emacs General Public
  11. License for full details.
  12.  
  13. Everyone is granted permission to copy, modify and redistribute
  14. GNU Emacs, but only under the conditions described in the
  15. GNU Emacs General Public License.   A copy of this license is
  16. supposed to have been given to you along with GNU Emacs so you
  17. can know your rights and responsibilities.  It should be in a
  18. file named COPYING.  Among other things, the copyright notice
  19. and this notice must be preserved on all copies.  */
  20.  
  21.  
  22. enum Ukinds {            /* The events that can exist in the undo
  23.                    queue. */
  24.     Uboundary,            /* A boundary between sets of undoable things
  25.                    */
  26.     Unundoable,            /* What's done is done -- some things can't
  27.                    be undone */
  28.     Udelete,            /* Delete characters to perform the undo */
  29.     Uinsert,            /* Insert .... */
  30.     Uchange,            /* Replace characters */
  31.     Uunmod,            /* Clear modification-flag to perform undo */
  32. };
  33.  
  34. struct UndoRec {        /* A record of a single undo action */
  35.     enum Ukinds kind;        /* the kind of action to be undone */
  36.     int pos;            /* Where change starts or ends.  */
  37.     int len;            /* Number of characters to insert, delete or
  38.                    replace.  Negative means they stretch
  39.                    back from `pos'.  */
  40. };
  41.  
  42. /* Note: in a record of type Uunmod, the `len' field is really
  43.    the buffer->modtime associated with the state at that time.
  44.    The buffer is marked as unmodified by undoing the Uunmod
  45.    only if the modtime field matches.  */
  46.  
  47. /* The undo history consists of two circular queues, one of characters and
  48.    one of UndoRecs.  When Uinsert recs are added to UndoRQ characters get
  49.    added to UndoCQ.  The position of the characters can be reconstructed by
  50.    subtracting len from the fill pointer. */
  51.  
  52. #define NUndoR    (((1 << 13) - 4) / sizeof (struct UndoRec))
  53. #define NUndoC    ((1 << 13) - 4)
  54.  
  55. /* Initially allocate them these sizes;
  56.  if these sizes get filled up, make them full size */
  57.  
  58. #define InitNUndoR 8
  59. #define InitNUndoC (512 - 4)
  60.  
  61. struct UndoData
  62.   {
  63.     struct UndoRec *undorecs;    /* The undo records, NUndoR of them */
  64.     char *undochars;    /* And the characters associated, NUndoC in all */
  65.     int nextrec;        /* Indices for storing in above two */
  66.     int nextchar;
  67.     int num_undorecs;        /* Sizes allocated */
  68.     int num_undochars;
  69.   };
  70.  
  71.