1 | /*- |
---|
2 | * Copyright (c) 1991, 1993, 1994 |
---|
3 | * The Regents of the University of California. All rights reserved. |
---|
4 | * Copyright (c) 1991, 1993, 1994, 1995, 1996 |
---|
5 | * Keith Bostic. All rights reserved. |
---|
6 | * |
---|
7 | * See the LICENSE file for redistribution information. |
---|
8 | * |
---|
9 | * @(#)cut.h 10.5 (Berkeley) 4/3/96 |
---|
10 | */ |
---|
11 | |
---|
12 | typedef struct _texth TEXTH; /* TEXT list head structure. */ |
---|
13 | CIRCLEQ_HEAD(_texth, _text); |
---|
14 | |
---|
15 | /* Cut buffers. */ |
---|
16 | struct _cb { |
---|
17 | LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */ |
---|
18 | TEXTH textq; /* Linked list of TEXT structures. */ |
---|
19 | CHAR_T name; /* Cut buffer name. */ |
---|
20 | size_t len; /* Total length of cut text. */ |
---|
21 | |
---|
22 | #define CB_LMODE 0x01 /* Cut was in line mode. */ |
---|
23 | u_int8_t flags; |
---|
24 | }; |
---|
25 | |
---|
26 | /* Lines/blocks of text. */ |
---|
27 | struct _text { /* Text: a linked list of lines. */ |
---|
28 | CIRCLEQ_ENTRY(_text) q; /* Linked list of text structures. */ |
---|
29 | char *lb; /* Line buffer. */ |
---|
30 | size_t lb_len; /* Line buffer length. */ |
---|
31 | size_t len; /* Line length. */ |
---|
32 | |
---|
33 | /* These fields are used by the vi text input routine. */ |
---|
34 | recno_t lno; /* 1-N: file line. */ |
---|
35 | size_t cno; /* 0-N: file character in line. */ |
---|
36 | size_t ai; /* 0-N: autoindent bytes. */ |
---|
37 | size_t insert; /* 0-N: bytes to insert (push). */ |
---|
38 | size_t offset; /* 0-N: initial, unerasable chars. */ |
---|
39 | size_t owrite; /* 0-N: chars to overwrite. */ |
---|
40 | size_t R_erase; /* 0-N: 'R' erase count. */ |
---|
41 | size_t sv_cno; /* 0-N: Saved line cursor. */ |
---|
42 | size_t sv_len; /* 0-N: Saved line length. */ |
---|
43 | |
---|
44 | /* |
---|
45 | * These fields returns information from the vi text input routine. |
---|
46 | * |
---|
47 | * The termination condition. Note, this field is only valid if the |
---|
48 | * text input routine returns success. |
---|
49 | * TERM_BS: User backspaced over the prompt. |
---|
50 | * TERM_CEDIT: User entered <edit-char>. |
---|
51 | * TERM_CR: User entered <carriage-return>; no data. |
---|
52 | * TERM_ESC: User entered <escape>; no data. |
---|
53 | * TERM_OK: Data available. |
---|
54 | * TERM_SEARCH: Incremental search. |
---|
55 | */ |
---|
56 | enum { |
---|
57 | TERM_BS, TERM_CEDIT, TERM_CR, TERM_ESC, TERM_OK, TERM_SEARCH |
---|
58 | } term; |
---|
59 | }; |
---|
60 | |
---|
61 | /* |
---|
62 | * Get named buffer 'name'. |
---|
63 | * Translate upper-case buffer names to lower-case buffer names. |
---|
64 | */ |
---|
65 | #define CBNAME(sp, cbp, nch) { \ |
---|
66 | CHAR_T L__name; \ |
---|
67 | L__name = isupper(nch) ? tolower(nch) : (nch); \ |
---|
68 | for (cbp = sp->gp->cutq.lh_first; \ |
---|
69 | cbp != NULL; cbp = cbp->q.le_next) \ |
---|
70 | if (cbp->name == L__name) \ |
---|
71 | break; \ |
---|
72 | } |
---|
73 | |
---|
74 | /* Flags to the cut() routine. */ |
---|
75 | #define CUT_LINEMODE 0x01 /* Cut in line mode. */ |
---|
76 | #define CUT_NUMOPT 0x02 /* Numeric buffer: optional. */ |
---|
77 | #define CUT_NUMREQ 0x04 /* Numeric buffer: required. */ |
---|