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