|
|
1.1 root 1: /* Header file for the buffer manipulation primitives.
2: Copyright (C) 1985 Richard M. Stallman.
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: #ifdef lint
23: #include "undo.h"
24: #endif /* lint */
25:
26:
27: #define SetPoint point =
28:
29: #define PointRight point +=
30: #define PointLeft point -=
31:
32: struct buffer_text
33: {
34: unsigned char *p1; /* Address of first data char, minus 1 */
35: unsigned char *p2; /* p1 plus gap size */
36: int size1; /* # characters before gap */
37: int size2; /* # characters after gap */
38: int gap; /* gap size in chars */
39: int modified; /* tick at which contents last modified */
40: int head_clip; /* # of first char that's visible (origin 1) */
41: int tail_clip; /* # chars not visible at end of buffer */
42: int pointloc; /* # of char point is at (origin 1) */
43: };
44:
45: /* structure that defines a buffer */
46: struct buffer
47: {
48: struct buffer_text text; /* This describes the buffer's text */
49:
50: Lisp_Object number; /* buffer number, assigned when buffer made */
51: Lisp_Object name; /* the name of this buffer */
52: Lisp_Object filename; /* the name of the file associated
53: with this buffer */
54: Lisp_Object directory; /* Dir for expanding relative pathnames */
55: int save_modified; /* Value of text.modified when buffer last saved */
56: Lisp_Object save_length; /* Length of file when last read or saved. */
57: int modtime; /* Set to the modtime of the file when read */
58: /* Really should be time_t */
59: int backed_up; /* true iff this buffer has been been backed
60: up (if you write to its associated file
61: and it hasn't been backed up, then a
62: backup will be made) */
63: Lisp_Object auto_save_file_name; /* file name used for auto-saving this
64: buffer */
65: int auto_save_modified; /* the value of text.modified at the last auto-save. */
66: Lisp_Object read_only; /* Non-nil if buffer read-only */
67:
68: Lisp_Object markers; /* the markers that refer to this buffer.
69: This is actually a single marker ---
70: successive elements in its marker `chain'
71: are the other markers referring to this
72: buffer */
73: Lisp_Object mark; /* "The mark"; may be nil */
74:
75: Lisp_Object major_mode; /* Symbol naming major mode (eg lisp-mode) */
76: Lisp_Object mode_name; /* Pretty name of major mode (eg "Lisp") */
77: Lisp_Object mode_line_format; /* Format string for mode line */
78:
79: Lisp_Object keymap; /* Keys that are bound local to this buffer
80: (stuff like $J) */
81: struct Lisp_Vector *syntax_table_v; /* the syntax table in use */
82: Lisp_Object abbrev_table; /* This buffer's local abbrev table */
83:
84: /* Values of several buffer-local variables */
85: /* tab-width is buffer-local so that redisplay can find it
86: in buffers that are not current */
87: Lisp_Object case_fold_search;
88: Lisp_Object tab_width;
89: Lisp_Object fill_column;
90: Lisp_Object left_margin;
91: Lisp_Object auto_fill_hook; /* Function to call when insert space past fiull column */
92: /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER)
93: for all per-buffer variables of this buffer. */
94: Lisp_Object local_var_alist;
95:
96: /* Position in buffer at which display started
97: the last time this buffer was displayed */
98: int last_window_start;
99: /* Non-nil means do not display continuation lines */
100: Lisp_Object truncate_lines;
101: /* Non-nil means display ctl chars with uparrow */
102: Lisp_Object ctl_arrow;
103: /* Non-nil means do selective display;
104: See doc string in syms_of_buffer (buffer.c) for details. */
105: Lisp_Object selective_display;
106: /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */
107: Lisp_Object minor_modes;
108: /* Undo records for changes in this buffer. */
109: struct UndoData *undodata;
110: /* t if "self-insertion" should overwrite */
111: Lisp_Object overwrite_mode;
112: /* non-nil means abbrev mode is on. Expand abbrevs automatically. */
113: Lisp_Object abbrev_mode;
114: /* Next buffer, in chain of all buffers that exist. */
115: struct buffer *next;
116: };
117:
118: extern struct buffer *bf_cur; /* the current buffer */
119:
120: /* This structure contains data describing the text of the current buffer.
121: Switching buffers swaps their text data in and out of here */
122:
123: extern struct buffer_text bf_text;
124:
125: #define bf_p1 bf_text.p1
126: #define bf_p2 bf_text.p2
127: #define bf_s1 bf_text.size1
128: #define bf_s2 bf_text.size2
129: #define bf_gap bf_text.gap
130: #define bf_modified bf_text.modified
131: #define bf_head_clip bf_text.head_clip
132: #define bf_tail_clip bf_text.tail_clip
133: #define point bf_text.pointloc
134:
135: /* Lowest legal value of point for current buffer */
136: #define FirstCharacter bf_text.head_clip
137:
138: /* Number of last visible character in current buffer */
139: /* The highest legal value for point is one greater than this */
140: #define NumCharacters (bf_text.size1+bf_text.size2-bf_text.tail_clip)
141:
142: /* Return character at position n. No range checking */
143: #define CharAt(n) *(((n)>bf_s1 ? bf_p2 : bf_p1) + (n))
144:
145: extern void reset_buffer ();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.