home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / Editors / mjovesrc.zoo / buf.h < prev    next >
C/C++ Source or Header  |  1991-06-16  |  6KB  |  194 lines

  1. /***************************************************************************
  2.  * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
  3.  * is provided to you without charge, and with no warranty.  You may give  *
  4.  * away copies of JOVE, including sources, provided that this notice is    *
  5.  * included in all the files.                                              *
  6.  ***************************************************************************/
  7.  
  8. /* maximum length of a line (including '\0').  Currently cannot
  9.    be larger than a logical disk block. */
  10. #define    LBSIZE        JBUFSIZ
  11.  
  12. /* buffer types */
  13. #define B_SCRATCH    1    /* for internal things, e.g. minibuffer ... */
  14. #define B_FILE        2    /* normal file (we auto-save these.) */
  15. #define B_PROCESS    3    /* unix process output in this buffer */
  16.  
  17. /* major modes */
  18. #define FUNDAMENTAL    0    /* Fundamental mode */
  19. #define TEXT        1    /* Text mode */
  20. #define CMODE        2    /* C mode */
  21. #ifdef    LISP
  22. # define LISPMODE    3    /* Lisp mode */
  23. # define NMAJORS    4
  24. #else
  25. # define NMAJORS    3
  26. #endif
  27.  
  28. #define MajorMode(x)    (curbuf->b_major == (x))
  29. #define SetMajor(x)    { curbuf->b_major = (x); UpdModLine = YES; }
  30.  
  31. /* minor modes */
  32. #define Indent        (1 << 0)    /* indent same as previous line after return */
  33. #define ShowMatch    (1 << 1)    /* paren flash mode */
  34. #define Fill        (1 << 2)    /* text fill mode */
  35. #define OverWrite    (1 << 3)    /* over write mode */
  36. #define Abbrev        (1 << 4)    /* abbrev mode */
  37. #define ReadOnly    (1 << 5)    /* buffer is read only */
  38.  
  39. #define BufMinorMode(b, x)    (((b)->b_minor & (x)) != 0)
  40. #define MinorMode(x)        BufMinorMode(curbuf, (x))
  41.  
  42. /* global line scratch buffers */
  43. #ifdef    pdp11
  44. extern char    *genbuf,    /* scratch pad points at s_genbuf (see main()) */
  45.         *linebuf,    /* points at s_linebuf */
  46.         *iobuff;    /* for file reading ... points at s_iobuff */
  47. #else
  48. extern char    genbuf[LBSIZE],
  49.         linebuf[LBSIZE],
  50.         iobuff[LBSIZE];
  51. #endif
  52.  
  53. struct line {
  54.     Line    *l_prev,        /* pointer to prev */
  55.         *l_next;        /* pointer to next */
  56.     daddr    l_dline;        /* pointer to disk location */
  57. };
  58.  
  59. struct mark {
  60.     Line    *m_line;
  61.     int    m_char;
  62.     Mark    *m_next;    /* list of marks */
  63. #define M_FIXED        00
  64. #define M_FLOATER    01
  65. #define M_BIG_DELETE    02
  66.     char    m_flags;    /* FLOATERing mark? */
  67. };
  68.  
  69. struct buffer {
  70. #ifdef    MAC
  71.     int Type;        /* kludge... to look like a data_obj */
  72.     char *Name;        /* Name will not be used */
  73. #endif
  74.     Buffer    *b_next;        /* next buffer in chain */
  75.     char    *b_name,        /* buffer name */
  76.         *b_fname;        /* file name associated with buffer */
  77.     dev_t    b_dev;            /* device of file name. */
  78.     ino_t    b_ino;            /* inode of file name */
  79.     time_t    b_mtime;        /* last modify time ...
  80.                        to detect two people writing
  81.                        to the same file */
  82.     Line    *b_first,        /* pointer to first line in list */
  83.         *b_dot,            /* current line */
  84.         *b_last;        /* last line in list */
  85.     int    b_char;            /* current character in line */
  86.  
  87. #define NMARKS    8            /* number of marks in the ring */
  88.  
  89.     Mark    *b_markring[NMARKS],    /* new marks are pushed here */
  90. #define b_curmark(b)    ((b)->b_markring[(b)->b_themark])
  91. #define curmark        b_curmark(curbuf)
  92.         *b_marks;        /* all the marks for this buffer */
  93.     char    b_themark,        /* current mark (in b_markring) */
  94.         b_type,            /* file, scratch, process, iprocess */
  95.         b_ntbf,            /* (bool) needs to be found when we
  96.                        first select? */
  97.         b_modified;        /* (bool) is the buffer modified? */
  98.     int    b_major,        /* major mode */
  99.         b_minor;        /* and minor mode */
  100.     struct keymap    *b_map;        /* local bindings (if any) */
  101. #ifdef    IPROCS
  102.     Process    *b_process;        /* process we're attached to */
  103. #endif
  104. };
  105.  
  106. extern Buffer    *world,        /* first buffer */
  107.         *curbuf,    /* pointer into world for current buffer */
  108.         *lastbuf,    /* Last buffer we were in so we have a default
  109.                    buffer during a select buffer. */
  110.         *perr_buf;    /* Buffer with error messages */
  111.  
  112. #define curline    (curbuf->b_dot)
  113. #define curchar (curbuf->b_char)
  114.  
  115. /* kill buffer */
  116. #define NUMKILLS    10    /* number of kills saved in the kill ring */
  117. extern Line    *killbuf[NUMKILLS];
  118.  
  119. struct position {
  120.     Line    *p_line;
  121.     int    p_char;
  122. };
  123.  
  124. extern int    killptr;    /* index into killbuf */
  125.  
  126. extern Buffer
  127.     *buf_exists proto((char *name)),
  128.     *do_find proto((struct window *w, char *fname, bool force)),
  129.     *do_select proto((struct window *w,char *name)),
  130.     *file_exists proto((char *name));
  131.  
  132. extern char
  133.     *ask_buf proto((struct buffer *def));
  134.  
  135. extern UnivPtr
  136.     freealloc proto((UnivPtr obj, size_t size));
  137.  
  138. #ifdef    REALSTDC
  139. struct macro;    /* forward declaration preventing prototype scoping */
  140. #endif    /* REALSTDC */
  141.  
  142. extern void
  143.     TogMinor proto((int bit)),
  144.     initlist proto((struct buffer *b)),
  145.     setfname proto((struct buffer *b,char *name)),
  146.     set_ino proto((struct buffer *b)),
  147.     SetABuf proto((struct buffer *b)),
  148.     SetBuf proto((struct buffer *newbuf)),
  149.     AllMarkSet proto((struct buffer *b,struct line *line,int col)),
  150.     DFixMarks proto((struct line *line1,int char1,struct line *line2,int char2)),
  151.     DelMark proto((struct mark *m)),
  152.     IFixMarks proto((struct line *line1, int char1, struct line *line2, int char2)),
  153.     MarkSet proto((struct mark *m, struct line *line, int column)),
  154.     ToMark proto((struct mark *m)),
  155.     flush_marks proto((Buffer *)),
  156.     b_char proto((int n)),
  157.     b_word proto((int num)),
  158.     del_char proto((int dir,int num,int OK_kill)),
  159.     do_macro proto((struct macro *mac)),
  160.     do_set_mark proto((struct line *l, int c)),
  161.     f_char proto((int n)),
  162.     f_word proto((int num)),
  163.     ins_str proto((char *str,int ok_nl)),
  164.     insert_c proto((int c,int n)),
  165.     lfreelist proto((struct line *first)),
  166.     lfreereg proto((struct line *line1,struct line *line2)),
  167.     line_move proto((int dir, int n, bool line_cmd)),
  168.     mac_putc proto((int c)),
  169.     n_indent proto((int goal)),
  170.     open_lines proto((int n)),
  171.     reg_kill proto((struct line *line2, int char2, bool dot_moved)),
  172.     set_mark proto((void)),
  173.     unwind_macro_stack proto((void)),
  174.     buf_init proto((void));
  175.  
  176. extern int
  177.     ModMacs proto((void)),
  178.     in_macro proto((void)),
  179.     mac_getc proto((void)),
  180.     how_far proto((struct line *line,int col));
  181.  
  182. extern  struct line
  183.     *lastline proto((struct line *lp)),
  184.     *listput proto((struct buffer *buf,struct line *after)),
  185.     *nbufline proto((void)),
  186.     *next_line proto((struct line *line,int num)),
  187.     *prev_line proto((struct line *line,int num)),
  188.     *reg_delete proto((struct line *line1,int char1,struct line *line2,int char2));
  189.  
  190. extern Mark
  191.     *CurMark proto((void)),
  192.     *MakeMark proto((struct line *line,int column,int type));
  193.  
  194.