1 /* $NetBSD: cut.h,v 1.3 2013/11/25 22:43:46 christos Exp $ */ 2 /*- 3 * Copyright (c) 1991, 1993, 1994 4 * The Regents of the University of California. All rights reserved. 5 * Copyright (c) 1991, 1993, 1994, 1995, 1996 6 * Keith Bostic. All rights reserved. 7 * 8 * See the LICENSE file for redistribution information. 9 * 10 * Id: cut.h,v 10.9 2000/07/22 17:31:18 skimo Exp (Berkeley) Date: 2000/07/22 17:31:18 11 */ 12 13 typedef struct _texth TEXTH; /* TEXT list head structure. */ 14 TAILQ_HEAD(_texth, _text); 15 16 /* Cut buffers. */ 17 struct _cb { 18 LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */ 19 TEXTH textq; /* Linked list of TEXT structures. */ 20 /* XXXX Needed ? Can non ascii-chars be cut buffer names ? */ 21 ARG_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_T *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 db_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 ARG_CHAR_T L__name; \ 69 L__name = ISUPPER(nch) ? TOLOWER(nch) : (nch); \ 70 for (cbp = sp->wp->cutq.lh_first; \ 71 cbp != NULL; cbp = cbp->q.le_next) \ 72 if (cbp->name == L__name) \ 73 break; \ 74 } 75 76 /* Flags to the cut() routine. */ 77 #define CUT_LINEMODE 0x01 /* Cut in line mode. */ 78 #define CUT_NUMOPT 0x02 /* Numeric buffer: optional. */ 79 #define CUT_NUMREQ 0x04 /* Numeric buffer: required. */ 80