Skip to content
Newer
Older
100644 161 lines (153 sloc) 7.9 KB
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
1 /* buffer.h */
2 /* Copyright 1995 by Steve Kirkendall */
3
4
5 struct undo_s
6 {
7 struct undo_s *next; /* pointer to the next-older version of this buffer */
8 long changes; /* change counter, used for restarting */
9 long changepos; /* where to move cursor if undone */
10 long buflines; /* number of lines in this version of the buffer */
11 long bufchars; /* number of characters in this version */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
12 struct umark_s *marklist; /* list of marks that were in this buffer */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
13 BLKNO bufinfo; /* bufinfo BLK of previous version */
14 #ifdef DEBUG_ALLOC
15 struct undo_s *link1, *link2; /* some other allocated undo versions */
16 struct buffer_s *buf; /* the buffer that this undoes */
17 char undoredo; /* 'u' for undo, 'r' for redo version */
18 #endif
19 };
20
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
21
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
22 typedef struct buffer_s
23 {
24 struct buffer_s *next;
25 struct mark_s *marks; /* linked list of marks pointing to this buffer */
26 struct undo_s *undo; /* linked list of undo versions of this buffer */
27 struct undo_s *redo; /* linked list of undo versions of this buffer */
28 struct undo_s *undolnptr; /* element of undo list which is line-undo version */
29 BLKNO bufinfo; /* blkno of the bufinfo block for this buffer */
30 long changes; /* change counter, used for restarting */
31 long changepos; /* position of the most recent change to this buffer */
32 long undoline; /* line number of "undolnptr" version */
33 long docursor; /* cursor position when "willdo" was set */
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
34 long ntagdefs; /* number of items in tagdef array */
35 struct tedef_s *tagdef; /* tag definitions in this buf */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
36 #ifdef FEATURE_AUTOCMD
37 ELVBOOL eachedit; /* "Edit" event for each change (else only when willdo is set) */
38 #endif
39 ELVBOOL willdo; /* save an "undo" version before next bufreplace()? */
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
40 long willevent; /* value of eventcount when willdo was set */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
41 #ifdef FEATURE_FOLD
42 struct fold_s *fold; /* list of active FOLDs */
43 struct fold_s *unfold; /* list of inactive FOLDs */
44 #endif
45 #ifdef FEATURE_REGION
46 struct region_s *regions; /* list of regions in this buffer */
47 #endif
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
48 OPTVAL filename; /* string: name of the file for this buffer */
49 OPTVAL bufname; /* string: name of buffer */
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
50 OPTVAL bufid; /* number: unique number for user buffer, or 0 */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
51 OPTVAL buflines; /* number: of lines, from txtbuf->lines */
52 OPTVAL bufchars; /* number: of bytes, from txtbuf->bytes */
53 OPTVAL retain; /* boolean: keep buffer after writing? */
54 OPTVAL modified; /* boolean: buffer modified since last write? */
55 OPTVAL edited; /* boolean: bufname changed since last write? */
56 OPTVAL newfile; /* boolean: buffer for non-existent file? */
57 OPTVAL readonly; /* boolean: no write perms on file? */
58 OPTVAL autoindent; /* boolean: auto-indent? */
59 OPTVAL inputtab; /* one of Tab/Spaces/Filename: <Tab> key in input mode */
60 OPTVAL autotab; /* boolean: use tabs characters shifting? */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
61 OPTVAL tabstop; /* tab: width of a tab */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
62 OPTVAL cc; /* string: program run by :cc command */
63 OPTVAL equalprg; /* string: program run by = command */
64 OPTVAL keywordprg; /* string: program run by shift-K command */
65 OPTVAL make; /* string: program run by :make command */
66 OPTVAL paragraphs; /* string: list of nroff paragraph codes */
67 OPTVAL sections; /* string: list of nroff section codes */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
68 OPTVAL shiftwidth; /* tab: shiftwidth used by << and >> */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
69 OPTVAL undolevels; /* number: number of undo versions to maintain */
70 OPTVAL textwidth; /* number: word wrap position (replaced wrapmargin) */
71 OPTVAL internal; /* boolean: is this a special-purpose buffer? */
72 OPTVAL bufdisplay; /* string: the default display mode */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
73 OPTVAL initialsyntax; /* start in "syntax" mode regardless of bufdisplay? */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
74 OPTVAL errlines; /* number: #lines when errlist created */
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
75 OPTVAL readeol; /* one of unix/dos/mac/text/binary: file read mode */
76 OPTVAL locked; /* boolean: prevent changes to buffer? */
77 OPTVAL partiallastline;/* boolean: file has no real last newline */
78 OPTVAL putstyle; /* one of {character line rectangle} */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
79 OPTVAL timestamp; /* timestamp of file, as a string */
80 OPTVAL guidewidth; /* widths of columns where guides are drawn */
81 OPTVAL hlobject; /* list of text objects to possibly highlight */
82 OPTVAL spell; /* should tags be considered words for spellchecking? */
83 OPTVAL lisp; /* lisp mode */
84 OPTVAL mapmode; /* which set of key maps to use */
85 OPTVAL smartargs; /* display arguments when typing func */
86 OPTVAL userprotocol; /* user-defined protocol */
87 OPTVAL bb; /* generic option */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
88 } *BUFFER;
89
90 #define o_filename(buf) ((buf)->filename.value.string)
91 #define o_bufname(buf) ((buf)->bufname.value.string)
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
92 #define o_bufid(buf) ((buf)->bufid.value.number)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
93 #define o_buflines(buf) ((buf)->buflines.value.number)
94 #define o_bufchars(buf) ((buf)->bufchars.value.number)
95 #define o_retain(buf) ((buf)->retain.value.boolean)
96 #define o_preservable(buf) ((buf)->preservable.value.boolean)
97 #define o_modified(buf) ((buf)->modified.value.boolean)
98 #define o_edited(buf) ((buf)->edited.value.boolean)
99 #define o_newfile(buf) ((buf)->newfile.value.boolean)
100 #define o_readonly(buf) ((buf)->readonly.value.boolean)
101 #define o_autoindent(buf) ((buf)->autoindent.value.boolean)
102 #define o_inputtab(buf) ((buf)->inputtab.value.character)
103 #define o_autotab(buf) ((buf)->autotab.value.boolean)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
104 #define o_tabstop(buf) ((buf)->tabstop.value.tab)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
105 #define o_cc(buf) ((buf)->cc.value.string)
106 #define o_equalprg(buf) ((buf)->equalprg.value.string)
107 #define o_keywordprg(buf) ((buf)->keywordprg.value.string)
108 #define o_make(buf) ((buf)->make.value.string)
109 #define o_paragraphs(buf) ((buf)->paragraphs.value.string)
110 #define o_sections(buf) ((buf)->sections.value.string)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
111 #define o_shiftwidth(buf) ((buf)->shiftwidth.value.tab)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
112 #define o_undolevels(buf) ((buf)->undolevels.value.number)
113 #define o_textwidth(buf) ((buf)->textwidth.value.number)
114 #define o_internal(buf) ((buf)->internal.value.boolean)
115 #define o_bufdisplay(buf) ((buf)->bufdisplay.value.string)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
116 #define o_initialsyntax(buf) ((buf)->initialsyntax.value.boolean)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
117 #define o_errlines(buf) ((buf)->errlines.value.number)
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
118 #define o_readeol(buf) ((buf)->readeol.value.character)
119 #define o_locked(buf) ((buf)->locked.value.boolean)
120 #define o_partiallastline(buf) ((buf)->partiallastline.value.boolean)
121 #define o_putstyle(buf) ((buf)->putstyle.value.character)
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
122 #define o_timestamp(buf) ((buf)->timestamp.value.string)
123 #define o_guidewidth(buf) ((buf)->guidewidth.value.tab)
124 #define o_hlobject(buf) ((buf)->hlobject.value.string)
125 #define o_spell(buf) ((buf)->spell.value.boolean)
126 #define o_lisp(buf) ((buf)->lisp.value.boolean)
127 #define o_mapmode(buf) ((buf)->mapmode.value.string)
128 #define o_smartargs(buf) ((buf)->smartargs.value.boolean)
129 #define o_userprotocol(buf) ((buf)->userprotocol.value.boolean)
130 #define o_bb(buf) ((buf)->userprotocol.value.string)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
131 #define BUFOPTQTY ((sizeof(struct buffer_s) - (int)bufoptvals((BUFFER)0)) / sizeof(OPTVAL))
132
133 #define bufbufinfo(buffer) ((buffer)->bufinfo)
134 #define bufoptvals(buffer) (&(buffer)->filename)
135 #define bufmarks(buffer) ((buffer)->marks)
136 #define bufsetmarks(buffer, mark) ((buffer)->marks = (mark))
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
137 #define buflist(start) ((start) ? (start)->next : elvis_buffers)
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
138
139 extern BUFFER bufdefault;
8d1ac0c @mbert Import Elvis 2.1 (written by Steve Kirkendall)
authored Dec 10, 2011
140 extern BUFFER elvis_buffers;
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
141 extern BUFFER bufdefopts;
142 extern MSGIMP bufmsgtype;
143 BEGIN_EXTERNC
144 extern void bufinit P_((void));
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
145 extern BUFFER bufalloc P_((CHAR *name, _BLKNO_ bufinfo, ELVBOOL internal));
2fe6e17 @mbert Import Elvis 2.2_1 (written by Steve Kirkendall)
authored Dec 10, 2011
146 extern CHAR *buffilenumber P_((BUFFER curbuf, CHAR **refp, CHAR **endptr));
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
147 extern BUFFER buffind P_((CHAR *name));
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
148 extern BUFFER bufload P_((CHAR *bufname, char *filename, ELVBOOL reload));
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
149 extern BUFFER bufpath P_((CHAR *path, char *filename, CHAR *bufname));
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored Dec 10, 2011
150 extern ELVBOOL bufunload P_((BUFFER buf, ELVBOOL force, ELVBOOL save));
151 extern ELVBOOL bufsave P_((BUFFER buf, ELVBOOL force, ELVBOOL mustwr));
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
152 extern void bufoptions P_((BUFFER buffer));
153 extern void buffree P_((BUFFER buffer));
154 extern void buftitle P_((BUFFER buffer, CHAR *title));
2fe6e17 @mbert Import Elvis 2.2_1 (written by Steve Kirkendall)
authored Dec 10, 2011
155 extern void bufappend P_((BUFFER buf, CHAR *str, int len));
156 #ifdef FEATURE_PERSIST
157 extern void bufpersistinit P_((void));
158 extern void bufpersistsave P_((BUFFER buf));
159 #endif
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored Dec 10, 2011
160 END_EXTERNC
Something went wrong with that request. Please try again.