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