head	1.5;
access;
symbols
	perseant-exfatfs-base-20250801:1.5
	perseant-exfatfs-base-20240630:1.5
	perseant-exfatfs:1.5.0.46
	perseant-exfatfs-base:1.5
	cjep_sun2x:1.5.0.44
	cjep_sun2x-base:1.5
	cjep_staticlib_x-base1:1.5
	cjep_staticlib_x:1.5.0.42
	cjep_staticlib_x-base:1.5
	phil-wifi-20200421:1.5
	phil-wifi-20200411:1.5
	phil-wifi-20200406:1.5
	pgoyette-compat-merge-20190127:1.5
	pgoyette-compat-20190127:1.5
	pgoyette-compat-20190118:1.5
	pgoyette-compat-1226:1.5
	pgoyette-compat-1126:1.5
	pgoyette-compat-1020:1.5
	pgoyette-compat-0930:1.5
	pgoyette-compat-0906:1.5
	pgoyette-compat-0728:1.5
	pgoyette-compat-0625:1.5
	pgoyette-compat-0521:1.5
	pgoyette-compat-0502:1.5
	pgoyette-compat-0422:1.5
	pgoyette-compat-0415:1.5
	pgoyette-compat-0407:1.5
	pgoyette-compat-0330:1.5
	pgoyette-compat-0322:1.5
	pgoyette-compat-0315:1.5
	pgoyette-compat:1.5.0.40
	pgoyette-compat-base:1.5
	perseant-stdc-iso10646:1.5.0.38
	perseant-stdc-iso10646-base:1.5
	prg-localcount2-base3:1.5
	prg-localcount2-base2:1.5
	prg-localcount2-base1:1.5
	prg-localcount2:1.5.0.36
	prg-localcount2-base:1.5
	pgoyette-localcount-20170426:1.5
	bouyer-socketcan-base1:1.5
	pgoyette-localcount-20170320:1.5
	bouyer-socketcan:1.5.0.34
	bouyer-socketcan-base:1.5
	pgoyette-localcount-20170107:1.5
	pgoyette-localcount-20161104:1.5
	localcount-20160914:1.5
	pgoyette-localcount-20160806:1.5
	pgoyette-localcount-20160726:1.5
	pgoyette-localcount:1.5.0.32
	pgoyette-localcount-base:1.5
	netbsd-5-2-3-RELEASE:1.5
	netbsd-5-1-5-RELEASE:1.5
	yamt-pagecache-base9:1.5
	yamt-pagecache-tag8:1.5
	tls-earlyentropy:1.5.0.28
	tls-earlyentropy-base:1.5
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.5
	riastradh-drm2-base3:1.5
	netbsd-5-2-2-RELEASE:1.5
	netbsd-5-1-4-RELEASE:1.5
	netbsd-5-2-1-RELEASE:1.5
	netbsd-5-1-3-RELEASE:1.5
	agc-symver:1.5.0.30
	agc-symver-base:1.5
	tls-maxphys-base:1.5
	yamt-pagecache-base8:1.5
	netbsd-5-2:1.5.0.26
	yamt-pagecache-base7:1.5
	netbsd-5-2-RELEASE:1.5
	netbsd-5-2-RC1:1.5
	yamt-pagecache-base6:1.5
	yamt-pagecache-base5:1.5
	yamt-pagecache-base4:1.5
	netbsd-5-1-2-RELEASE:1.5
	netbsd-5-1-1-RELEASE:1.5
	yamt-pagecache-base3:1.5
	yamt-pagecache-base2:1.5
	yamt-pagecache:1.5.0.24
	yamt-pagecache-base:1.5
	bouyer-quota2-nbase:1.5
	bouyer-quota2:1.5.0.22
	bouyer-quota2-base:1.5
	matt-nb5-pq3:1.5.0.20
	matt-nb5-pq3-base:1.5
	netbsd-5-1:1.5.0.18
	netbsd-5-1-RELEASE:1.5
	netbsd-5-1-RC4:1.5
	netbsd-5-1-RC3:1.5
	netbsd-5-1-RC2:1.5
	netbsd-5-1-RC1:1.5
	netbsd-5-0-2-RELEASE:1.5
	netbsd-5-0-1-RELEASE:1.5
	jym-xensuspend-nbase:1.5
	netbsd-5-0:1.5.0.16
	netbsd-5-0-RELEASE:1.5
	netbsd-5-0-RC4:1.5
	netbsd-5-0-RC3:1.5
	netbsd-5-0-RC2:1.5
	jym-xensuspend:1.5.0.14
	jym-xensuspend-base:1.5
	netbsd-5-0-RC1:1.5
	netbsd-5:1.5.0.12
	netbsd-5-base:1.5
	mjf-devfs2:1.5.0.10
	mjf-devfs2-base:1.5
	yamt-pf42-base4:1.5
	yamt-pf42-base3:1.5
	hpcarm-cleanup-nbase:1.5
	yamt-pf42-base2:1.5
	yamt-pf42:1.5.0.8
	yamt-pf42-base:1.5
	keiichi-mipv6-nbase:1.5
	keiichi-mipv6:1.5.0.6
	keiichi-mipv6-base:1.5
	cube-autoconf:1.5.0.4
	cube-autoconf-base:1.5
	hpcarm-cleanup:1.5.0.2
	hpcarm-cleanup-base:1.5
	netbsd-1-1-PATCH001:1.4
	netbsd-1-1-RELEASE:1.4
	netbsd-1-1:1.4.0.4
	netbsd-1-1-base:1.4
	netbsd-1-0-PATCH06:1.4
	netbsd-1-0-PATCH05:1.4
	netbsd-1-0-PATCH04:1.4
	netbsd-1-0-PATCH03:1.4
	netbsd-1-0-PATCH02:1.4
	netbsd-1-0-PATCH1:1.4
	netbsd-1-0-PATCH0:1.4
	netbsd-1-0-RELEASE:1.4
	netbsd-1-0:1.4.0.2
	nvi-1-34b:1.1.1.3
	nvi-1-33b:1.1.1.3
	netbsd-1-0-base:1.3
	nvi-1-11b:1.1.1.2
	nvi-1-03:1.1.1.1
	bostic-nvi:1.1.1;
locks; strict;
comment	@ * @;


1.5
date	96.05.20.03.48.45;	author mrg;	state dead;
branches;
next	1.4;

1.4
date	94.08.17.16.36.53;	author cgd;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	94.03.28.04.30.44;	author cgd;	state Exp;
branches;
next	1.2;

1.2
date	94.01.24.06.41.19;	author cgd;	state Exp;
branches;
next	1.1;

1.1
date	94.01.24.05.53.09;	author cgd;	state Exp;
branches
	1.1.1.1;
next	;

1.4.2.1
date	94.08.17.16.36.53;	author cgd;	state dead;
branches;
next	1.4.2.2;

1.4.2.2
date	94.08.17.16.36.54;	author cgd;	state Exp;
branches;
next	;

1.1.1.1
date	94.01.24.05.53.10;	author cgd;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	94.03.28.02.57.15;	author cgd;	state Exp;
branches;
next	1.1.1.3;

1.1.1.3
date	94.08.17.16.17.33;	author cgd;	state Exp;
branches;
next	;


desc
@@


1.5
log
@merge in nvi 1.66
@
text
@/*-
 * Copyright (c) 1993, 1994
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@@(#)svi_screen.h	8.52 (Berkeley) 7/20/94
 */

/*
 * Structure for mapping lines to the screen.  An SMAP is an array, with one
 * structure element per screen line, which holds information describing the
 * physical line which is displayed in the screen line.  The first two fields
 * (lno and off) are all that are necessary to describe a line.  The rest of
 * the information is useful to keep information from being re-calculated.
 *
 * Lno is the line number.  Off is the screen offset into the line.  For
 * example, the pair 2:1 would be the first screen of line 2, and 2:2 would
 * be the second.  If doing left-right scrolling, all of the offsets will be
 * the same, i.e. for the second screen, 1:2, 2:2, 3:2, etc.  If doing the
 * standard vi scrolling, it will be staggered, i.e. 1:1, 1:2, 1:3, 2:1, 3:1,
 * etc.
 *
 * The SMAP is always as large as the physical screen, plus a slot for the
 * info line, so that there is room to add any screen into another one at
 * screen exit.
 */
typedef struct _smap {
	recno_t  lno;		/* 1-N: Physical file line number. */
	size_t	 off;		/* 1-N: Screen offset in the line. */

				/* svi_line() cache information. */
	size_t	 c_sboff;	/* 0-N: offset of first character byte. */
	size_t	 c_eboff;	/* 0-N: offset of  last character byte. */
	u_char	 c_scoff;	/* 0-N: offset into the first character. */
	u_char	 c_eclen;	/* 1-N: columns from the last character. */
	u_char	 c_ecsize;	/* 1-N: size of the  last character. */
} SMAP;

				/* Macros to flush/test cached information. */
#define	SMAP_CACHE(smp)		((smp)->c_ecsize != 0)
#define	SMAP_FLUSH(smp)		((smp)->c_ecsize = 0)

typedef struct _svi_private {
/* INITIALIZED AT SCREEN CREATE. */
	SMAP	*h_smap;	/* First slot of the line map. */
	SMAP	*t_smap;	/*  Last slot of the line map. */

	size_t	 exlinecount;	/* Ex overwrite count. */
	size_t	 extotalcount;	/* Ex overwrite count. */
	size_t	 exlcontinue;	/* Ex line continue value. */

				/* svi_opt_screens() cache information. */
#define	SVI_SCR_CFLUSH(svp)	svp->ss_lno = OOBLNO
	recno_t	 ss_lno;	/* 1-N: Line number. */
	size_t	 ss_screens;	/* Return value. */

	recno_t	 olno;		/* 1-N: old cursor file line. */
	size_t	 ocno;		/* 0-N: old file cursor column. */
	size_t	 sc_col;	/* 0-N: LOGICAL screen column. */

/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
	size_t	 srows;		/* 1-N: Rows in the terminal/window. */

	char	*VB;		/* Visual bell termcap string. */

#define	SVI_CURSES_INIT	0x001	/* Curses/termcap initialized. */
#define	SVI_CUR_INVALID	0x002	/* Cursor position is unknown. */
#define	SVI_DIVIDER	0x004	/* Screen divider is displayed. */
#define	SVI_INFOLINE	0x008	/* The infoline is being used by v_ntext(). */
#define	SVI_SCREENDIRTY	0x010	/* Screen needs refreshing. */
	u_int8_t flags;
} SVI_PRIVATE;

#define	SVP(sp)		((SVI_PRIVATE *)((sp)->svi_private))
#define	 HMAP		(SVP(sp)->h_smap)
#define	 TMAP		(SVP(sp)->t_smap)
#define	_HMAP(sp)	(SVP(sp)->h_smap)
#define	_TMAP(sp)	(SVP(sp)->t_smap)

/*
 * One extra slot is always allocated for the map so that we can use
 * it to do vi :colon command input; see svi_get().
 */
#define	SIZE_HMAP(sp)	(SVP(sp)->srows + 1)

#define	O_NUMBER_FMT	"%7lu "			/* O_NUMBER format, length. */
#define	O_NUMBER_LENGTH	8
						/* Columns on a screen. */
#define	SCREEN_COLS(sp)							\
	((O_ISSET(sp, O_NUMBER) ? (sp)->cols - O_NUMBER_LENGTH : (sp)->cols))

#define	HALFSCREEN(sp)	((sp)->t_maxrows / 2)	/* Half the screen. */
#define	HALFTEXT(sp)	((sp)->t_rows / 2)	/* Half the text. */

#define	INFOLINE(sp)	((sp)->t_maxrows)	/* Info line test, offset. */
#define	ISINFOLINE(sp, smp)	(((smp) - HMAP) == INFOLINE(sp))

						/* Small screen test. */
#define	ISSMALLSCREEN(sp)	((sp)->t_minrows != (sp)->t_maxrows)

/*
 * Next tab offset.
 *
 * !!!
 * There are problems with how the historical vi handled tabs.  For example,
 * by doing "set ts=3" and building lines that fold, you can get it to step
 * through tabs as if they were spaces and move inserted characters to new
 * positions when <esc> is entered.  I think that nvi does tabs correctly,
 * but there may be some historical incompatibilities.
 */
#define	TAB_OFF(sp, c)	(O_VAL(sp, O_TABSTOP) - (c) % O_VAL(sp, O_TABSTOP))

/* Move in a screen (absolute), and fail if it doesn't work. */
#ifdef DEBUG
#define	MOVEA(sp, lno, cno) {						\
	if (move(lno, cno) == ERR) {					\
		msgq(sp, M_ERR,						\
		    "Error: %s/%d: move:l(%u), c(%u), abs",		\
		    tail(__FILE__), __LINE__, lno, cno);		\
		return (1);						\
	}								\
}
#else
#define	MOVEA(sp, lno, cno)	(void)move(lno, cno)
#endif

/* Move in a window, and fail if it doesn't work. */
#ifdef DEBUG
#define	MOVE(sp, lno, cno) {						\
	size_t __lno = (sp)->woff + (lno);				\
	if (move(__lno, cno) == ERR) {					\
		msgq(sp, M_ERR,						\
		    "Error: %s/%d: move:l(%u), c(%u), o(%u)",		\
		    tail(__FILE__), __LINE__, lno, cno, sp->woff);	\
		return (1);						\
	}								\
}
#else
#define	MOVE(sp, lno, cno)	(void)move((sp)->woff + (lno), cno)
#endif

/* Add a character. */
#define	ADDCH(ch) {							\
	CHAR_T __ch = ch;						\
	ADDNSTR(KEY_NAME(sp, __ch), KEY_LEN(sp, __ch));			\
}

/* Add a string len bytes long. */
#ifdef DEBUG
#define	ADDNSTR(str, len) {						\
	if (addnstr(str, len) == ERR) {					\
		int __x, __y;						\
		getyx(stdscr, __y, __x);				\
		msgq(sp, M_ERR, "Error: %s/%d: addnstr: (%d/%u)",	\
		    tail(__FILE__), __LINE__, __y, __x);		\
		return (1);						\
	}								\
}
#else
#define	ADDNSTR(str, len)	(void)addnstr(str, len)
#endif

/* Add a string. */
#ifdef DEBUG
#define	ADDSTR(str) {							\
	if (addstr(str) == ERR) {					\
		int __x, __y;						\
		getyx(stdscr, __y, __x);				\
		msgq(sp, M_ERR, "Error: %s/%d: addstr: (%d/%u)",	\
		    tail(__FILE__), __LINE__, __y, __x);		\
		return (1);						\
	}								\
}
#else
#define	ADDSTR(str)	(void)addstr(str);
#endif

/* Public routines. */
void	svi_bell __P((SCR *));
int	svi_bg __P((SCR *));
int	svi_busy __P((SCR *, char const *));
int	svi_change __P((SCR *, EXF *, recno_t, enum operation));
size_t	svi_cm_public __P((SCR *, EXF *, recno_t, size_t));
int	svi_column __P((SCR *, EXF *, size_t *));
enum confirm
	svi_confirm __P((SCR *, EXF *, MARK *, MARK *));
int	svi_clear __P((SCR *));
int	svi_crel __P((SCR *, long));
int	svi_ex_cmd __P((SCR *, EXF *, struct _excmdarg *, MARK *));
int	svi_ex_run __P((SCR *, EXF *, MARK *));
int	svi_ex_write __P((void *, const char *, int));
int	svi_fg __P((SCR *, CHAR_T *));
int	svi_fmap __P((SCR *, enum seqtype, CHAR_T *, size_t, CHAR_T *, size_t));
enum input
	svi_get __P((SCR *, EXF *, TEXTH *, ARG_CHAR_T, u_int));
int	svi_optchange __P((SCR *, int));
int	svi_rabs __P((SCR *, long, enum adjust));
size_t	svi_rcm __P((SCR *, EXF *, recno_t));
int	svi_refresh __P((SCR *, EXF *));
int	svi_screen_copy __P((SCR *, SCR *));
int	svi_screen_edit __P((SCR *, EXF *));
int	svi_screen_end __P((SCR *));
int	svi_sm_fill __P((SCR *, EXF *, recno_t, enum position));
int	svi_sm_position __P((SCR *, EXF *, MARK *, u_long, enum position));
int	svi_sm_scroll __P((SCR *, EXF *, MARK *, recno_t, enum sctype));
int	svi_split __P((SCR *, ARGS *[], int));
int	svi_suspend __P((SCR *));
int	svi_swap __P((SCR *, SCR **, char *));

/* Private routines. */
size_t	svi_cm_private __P((SCR *, EXF *, recno_t, size_t, size_t));
int	svi_curses_end __P((SCR *));
int	svi_curses_init __P((SCR *));
void	svi_dtoh __P((SCR *, char *));
int	svi_init __P((SCR *));
int	svi_join __P((SCR *, SCR **));
void	svi_keypad __P((SCR *, int));
int	svi_line __P((SCR *, EXF *, SMAP *, size_t *, size_t *));
int	svi_msgflush __P((SCR *));
int	svi_number __P((SCR *, EXF *));
size_t	svi_opt_screens __P((SCR *, EXF *, recno_t, size_t *));
int	svi_paint __P((SCR *, EXF *));
int	svi_sm_1down __P((SCR *, EXF *));
int	svi_sm_1up __P((SCR *, EXF *));
int	svi_sm_cursor __P((SCR *, EXF *, SMAP **));
int	svi_sm_next __P((SCR *, EXF *, SMAP *, SMAP *));
recno_t	svi_sm_nlines __P((SCR *, EXF *, SMAP *, recno_t, size_t));
int	svi_sm_prev __P((SCR *, EXF *, SMAP *, SMAP *));
int	svi_term_end __P((SCR *sp));
int	svi_term_init __P((SCR *sp));

/* Private debugging routines. */
#ifdef DEBUG
int	svi_gdbrefresh __P((void));
#endif
@


1.4
log
@clean up import.  still have to hack some things.
@
text
@@


1.4.2.1
log
@file svi_screen.h was added on branch netbsd-1-0 on 1994-08-17 16:36:54 +0000
@
text
@d1 262
@


1.4.2.2
log
@clean up import.  still have to hack some things.
@
text
@a0 262
/*-
 * Copyright (c) 1993, 1994
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@@(#)svi_screen.h	8.52 (Berkeley) 7/20/94
 */

/*
 * Structure for mapping lines to the screen.  An SMAP is an array, with one
 * structure element per screen line, which holds information describing the
 * physical line which is displayed in the screen line.  The first two fields
 * (lno and off) are all that are necessary to describe a line.  The rest of
 * the information is useful to keep information from being re-calculated.
 *
 * Lno is the line number.  Off is the screen offset into the line.  For
 * example, the pair 2:1 would be the first screen of line 2, and 2:2 would
 * be the second.  If doing left-right scrolling, all of the offsets will be
 * the same, i.e. for the second screen, 1:2, 2:2, 3:2, etc.  If doing the
 * standard vi scrolling, it will be staggered, i.e. 1:1, 1:2, 1:3, 2:1, 3:1,
 * etc.
 *
 * The SMAP is always as large as the physical screen, plus a slot for the
 * info line, so that there is room to add any screen into another one at
 * screen exit.
 */
typedef struct _smap {
	recno_t  lno;		/* 1-N: Physical file line number. */
	size_t	 off;		/* 1-N: Screen offset in the line. */

				/* svi_line() cache information. */
	size_t	 c_sboff;	/* 0-N: offset of first character byte. */
	size_t	 c_eboff;	/* 0-N: offset of  last character byte. */
	u_char	 c_scoff;	/* 0-N: offset into the first character. */
	u_char	 c_eclen;	/* 1-N: columns from the last character. */
	u_char	 c_ecsize;	/* 1-N: size of the  last character. */
} SMAP;

				/* Macros to flush/test cached information. */
#define	SMAP_CACHE(smp)		((smp)->c_ecsize != 0)
#define	SMAP_FLUSH(smp)		((smp)->c_ecsize = 0)

typedef struct _svi_private {
/* INITIALIZED AT SCREEN CREATE. */
	SMAP	*h_smap;	/* First slot of the line map. */
	SMAP	*t_smap;	/*  Last slot of the line map. */

	size_t	 exlinecount;	/* Ex overwrite count. */
	size_t	 extotalcount;	/* Ex overwrite count. */
	size_t	 exlcontinue;	/* Ex line continue value. */

				/* svi_opt_screens() cache information. */
#define	SVI_SCR_CFLUSH(svp)	svp->ss_lno = OOBLNO
	recno_t	 ss_lno;	/* 1-N: Line number. */
	size_t	 ss_screens;	/* Return value. */

	recno_t	 olno;		/* 1-N: old cursor file line. */
	size_t	 ocno;		/* 0-N: old file cursor column. */
	size_t	 sc_col;	/* 0-N: LOGICAL screen column. */

/* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */
	size_t	 srows;		/* 1-N: Rows in the terminal/window. */

	char	*VB;		/* Visual bell termcap string. */

#define	SVI_CURSES_INIT	0x001	/* Curses/termcap initialized. */
#define	SVI_CUR_INVALID	0x002	/* Cursor position is unknown. */
#define	SVI_DIVIDER	0x004	/* Screen divider is displayed. */
#define	SVI_INFOLINE	0x008	/* The infoline is being used by v_ntext(). */
#define	SVI_SCREENDIRTY	0x010	/* Screen needs refreshing. */
	u_int8_t flags;
} SVI_PRIVATE;

#define	SVP(sp)		((SVI_PRIVATE *)((sp)->svi_private))
#define	 HMAP		(SVP(sp)->h_smap)
#define	 TMAP		(SVP(sp)->t_smap)
#define	_HMAP(sp)	(SVP(sp)->h_smap)
#define	_TMAP(sp)	(SVP(sp)->t_smap)

/*
 * One extra slot is always allocated for the map so that we can use
 * it to do vi :colon command input; see svi_get().
 */
#define	SIZE_HMAP(sp)	(SVP(sp)->srows + 1)

#define	O_NUMBER_FMT	"%7lu "			/* O_NUMBER format, length. */
#define	O_NUMBER_LENGTH	8
						/* Columns on a screen. */
#define	SCREEN_COLS(sp)							\
	((O_ISSET(sp, O_NUMBER) ? (sp)->cols - O_NUMBER_LENGTH : (sp)->cols))

#define	HALFSCREEN(sp)	((sp)->t_maxrows / 2)	/* Half the screen. */
#define	HALFTEXT(sp)	((sp)->t_rows / 2)	/* Half the text. */

#define	INFOLINE(sp)	((sp)->t_maxrows)	/* Info line test, offset. */
#define	ISINFOLINE(sp, smp)	(((smp) - HMAP) == INFOLINE(sp))

						/* Small screen test. */
#define	ISSMALLSCREEN(sp)	((sp)->t_minrows != (sp)->t_maxrows)

/*
 * Next tab offset.
 *
 * !!!
 * There are problems with how the historical vi handled tabs.  For example,
 * by doing "set ts=3" and building lines that fold, you can get it to step
 * through tabs as if they were spaces and move inserted characters to new
 * positions when <esc> is entered.  I think that nvi does tabs correctly,
 * but there may be some historical incompatibilities.
 */
#define	TAB_OFF(sp, c)	(O_VAL(sp, O_TABSTOP) - (c) % O_VAL(sp, O_TABSTOP))

/* Move in a screen (absolute), and fail if it doesn't work. */
#ifdef DEBUG
#define	MOVEA(sp, lno, cno) {						\
	if (move(lno, cno) == ERR) {					\
		msgq(sp, M_ERR,						\
		    "Error: %s/%d: move:l(%u), c(%u), abs",		\
		    tail(__FILE__), __LINE__, lno, cno);		\
		return (1);						\
	}								\
}
#else
#define	MOVEA(sp, lno, cno)	(void)move(lno, cno)
#endif

/* Move in a window, and fail if it doesn't work. */
#ifdef DEBUG
#define	MOVE(sp, lno, cno) {						\
	size_t __lno = (sp)->woff + (lno);				\
	if (move(__lno, cno) == ERR) {					\
		msgq(sp, M_ERR,						\
		    "Error: %s/%d: move:l(%u), c(%u), o(%u)",		\
		    tail(__FILE__), __LINE__, lno, cno, sp->woff);	\
		return (1);						\
	}								\
}
#else
#define	MOVE(sp, lno, cno)	(void)move((sp)->woff + (lno), cno)
#endif

/* Add a character. */
#define	ADDCH(ch) {							\
	CHAR_T __ch = ch;						\
	ADDNSTR(KEY_NAME(sp, __ch), KEY_LEN(sp, __ch));			\
}

/* Add a string len bytes long. */
#ifdef DEBUG
#define	ADDNSTR(str, len) {						\
	if (addnstr(str, len) == ERR) {					\
		int __x, __y;						\
		getyx(stdscr, __y, __x);				\
		msgq(sp, M_ERR, "Error: %s/%d: addnstr: (%d/%u)",	\
		    tail(__FILE__), __LINE__, __y, __x);		\
		return (1);						\
	}								\
}
#else
#define	ADDNSTR(str, len)	(void)addnstr(str, len)
#endif

/* Add a string. */
#ifdef DEBUG
#define	ADDSTR(str) {							\
	if (addstr(str) == ERR) {					\
		int __x, __y;						\
		getyx(stdscr, __y, __x);				\
		msgq(sp, M_ERR, "Error: %s/%d: addstr: (%d/%u)",	\
		    tail(__FILE__), __LINE__, __y, __x);		\
		return (1);						\
	}								\
}
#else
#define	ADDSTR(str)	(void)addstr(str);
#endif

/* Public routines. */
void	svi_bell __P((SCR *));
int	svi_bg __P((SCR *));
int	svi_busy __P((SCR *, char const *));
int	svi_change __P((SCR *, EXF *, recno_t, enum operation));
size_t	svi_cm_public __P((SCR *, EXF *, recno_t, size_t));
int	svi_column __P((SCR *, EXF *, size_t *));
enum confirm
	svi_confirm __P((SCR *, EXF *, MARK *, MARK *));
int	svi_clear __P((SCR *));
int	svi_crel __P((SCR *, long));
int	svi_ex_cmd __P((SCR *, EXF *, struct _excmdarg *, MARK *));
int	svi_ex_run __P((SCR *, EXF *, MARK *));
int	svi_ex_write __P((void *, const char *, int));
int	svi_fg __P((SCR *, CHAR_T *));
int	svi_fmap __P((SCR *, enum seqtype, CHAR_T *, size_t, CHAR_T *, size_t));
enum input
	svi_get __P((SCR *, EXF *, TEXTH *, ARG_CHAR_T, u_int));
int	svi_optchange __P((SCR *, int));
int	svi_rabs __P((SCR *, long, enum adjust));
size_t	svi_rcm __P((SCR *, EXF *, recno_t));
int	svi_refresh __P((SCR *, EXF *));
int	svi_screen_copy __P((SCR *, SCR *));
int	svi_screen_edit __P((SCR *, EXF *));
int	svi_screen_end __P((SCR *));
int	svi_sm_fill __P((SCR *, EXF *, recno_t, enum position));
int	svi_sm_position __P((SCR *, EXF *, MARK *, u_long, enum position));
int	svi_sm_scroll __P((SCR *, EXF *, MARK *, recno_t, enum sctype));
int	svi_split __P((SCR *, ARGS *[], int));
int	svi_suspend __P((SCR *));
int	svi_swap __P((SCR *, SCR **, char *));

/* Private routines. */
size_t	svi_cm_private __P((SCR *, EXF *, recno_t, size_t, size_t));
int	svi_curses_end __P((SCR *));
int	svi_curses_init __P((SCR *));
void	svi_dtoh __P((SCR *, char *));
int	svi_init __P((SCR *));
int	svi_join __P((SCR *, SCR **));
void	svi_keypad __P((SCR *, int));
int	svi_line __P((SCR *, EXF *, SMAP *, size_t *, size_t *));
int	svi_msgflush __P((SCR *));
int	svi_number __P((SCR *, EXF *));
size_t	svi_opt_screens __P((SCR *, EXF *, recno_t, size_t *));
int	svi_paint __P((SCR *, EXF *));
int	svi_sm_1down __P((SCR *, EXF *));
int	svi_sm_1up __P((SCR *, EXF *));
int	svi_sm_cursor __P((SCR *, EXF *, SMAP **));
int	svi_sm_next __P((SCR *, EXF *, SMAP *, SMAP *));
recno_t	svi_sm_nlines __P((SCR *, EXF *, SMAP *, recno_t, size_t));
int	svi_sm_prev __P((SCR *, EXF *, SMAP *, SMAP *));
int	svi_term_end __P((SCR *sp));
int	svi_term_init __P((SCR *sp));

/* Private debugging routines. */
#ifdef DEBUG
int	svi_gdbrefresh __P((void));
#endif
@


1.3
log
@nvi 1.11(beta) from bostic.  reconcile conflicts/kill rcsids.
@
text
@d2 1
a2 1
 * Copyright (c) 1993
d33 1
a33 1
 *	@@(#)svi_screen.h	8.38 (Berkeley) 3/15/94
d93 4
a96 4
#define	SVI_CUR_INVALID	0x001	/* Cursor position is unknown. */
#define	SVI_DIVIDER	0x002	/* Screen divider is displayed. */
#define	SVI_INFOLINE	0x004	/* The infoline is being used by v_ntext(). */
#define	SVI_NO_VBELL	0x008	/* No visual bell available. */
d98 1
a98 1
	u_int	 flags;
d141 1
d145 1
a145 1
		    "Error: %s/%d: move:l(%u), c(%u), abs.",		\
d150 3
d155 1
d160 1
a160 1
		    "Error: %s/%d: move:l(%u), c(%u), o(%u).",		\
d165 3
d171 2
a172 2
	int __ch = (ch);						\
	ADDNSTR(cname[__ch].name, cname[__ch].len);			\
d176 1
d181 1
a181 1
		msgq(sp, M_ERR, "Error: %s/%d: addnstr: (%d/%u).",	\
d186 3
d191 1
d196 1
a196 1
		msgq(sp, M_ERR, "Error: %s/%d: addstr: (%d/%u).",	\
d201 3
d220 1
d222 1
a222 1
	svi_get __P((SCR *, EXF *, TEXTH *, int, u_int));
a229 1
int	svi_sm_down __P((SCR *, EXF *, MARK *, recno_t, int));
d232 2
a233 2
int	svi_sm_up __P((SCR *, EXF *, MARK *, recno_t, int));
int	svi_split __P((SCR *, ARGS *[]));
d241 1
a241 1
int	svi_divider __P((SCR *));
d246 1
a249 2
void	svi_putchar __P((int));
size_t	svi_screens __P((SCR *, EXF *, char *, size_t, recno_t, size_t *));
d256 2
@


1.2
log
@more Ids than you'll ever want.
@
text
@d33 1
a33 2
 *	from: @@(#)svi_screen.h	8.30 (Berkeley) 12/22/93
 *	$Id$
d79 2
a80 1
				/* svi_screens() cache information. */
d128 10
a137 1
						/* Next tab offset. */
a139 5
						
#define SCNO_INCREMENT				/* Step through line. */\
	scno += (ch = *(u_char *)p++) == '\t' && !listset ?		\
	    TAB_OFF(sp, scno) : cname[ch].len

d194 1
a194 1
size_t	svi_chposition __P((SCR *, EXF *, recno_t, size_t));
d199 1
d207 2
a208 1
int	svi_rabs __P((SCR *, long));
a209 2
size_t	svi_relative __P((SCR *, EXF *, recno_t));
int	svi_rrel __P((SCR *, long));
d222 1
d228 1
a229 2
size_t	svi_lrelative __P((SCR *, EXF *, recno_t, size_t));
size_t	svi_ncols __P((SCR *, u_char *, size_t, size_t *));
d231 1
d233 2
a234 1
size_t	svi_screens __P((SCR *, EXF *, recno_t, size_t *));
@


1.1
log
@Initial revision
@
text
@d33 2
a34 1
 *	@@(#)svi_screen.h	8.30 (Berkeley) 12/22/93
@


1.1.1.1
log
@nvi 1.03, from ftp.cs.berkeley.edu, per keith bostic's permission.
@
text
@@


1.1.1.2
log
@nvi/nex 1.11beta from bostic.
@
text
@d33 1
a33 1
 *	@@(#)svi_screen.h	8.38 (Berkeley) 3/15/94
d79 1
a79 2
				/* svi_opt_screens() cache information. */
#define	SVI_SCR_CFLUSH(svp)	svp->ss_lno = OOBLNO
d127 1
a127 10
/*
 * Next tab offset.
 *
 * !!!
 * There are problems with how the historical vi handled tabs.  For example,
 * by doing "set ts=3" and building lines that fold, you can get it to step
 * through tabs as if they were spaces and move inserted characters to new
 * positions when <esc> is entered.  I think that nvi does tabs correctly,
 * but there may be some historical incompatibilities.
 */
d130 5
d189 1
a189 1
size_t	svi_cm_public __P((SCR *, EXF *, recno_t, size_t));
a193 1
int	svi_crel __P((SCR *, long));
d201 1
a201 2
int	svi_rabs __P((SCR *, long, enum adjust));
size_t	svi_rcm __P((SCR *, EXF *, recno_t));
d203 2
a216 1
size_t	svi_cm_private __P((SCR *, EXF *, recno_t, size_t, size_t));
a221 1
void	svi_keypad __P((SCR *, int));
d223 2
a225 1
size_t	svi_opt_screens __P((SCR *, EXF *, recno_t, size_t *));
d227 1
a227 2
void	svi_putchar __P((int));
size_t	svi_screens __P((SCR *, EXF *, char *, size_t, recno_t, size_t *));
@


1.1.1.3
log
@new public version of nvi
@
text
@d2 1
a2 1
 * Copyright (c) 1993, 1994
d33 1
a33 1
 *	@@(#)svi_screen.h	8.52 (Berkeley) 7/20/94
d93 4
a96 4
#define	SVI_CURSES_INIT	0x001	/* Curses/termcap initialized. */
#define	SVI_CUR_INVALID	0x002	/* Cursor position is unknown. */
#define	SVI_DIVIDER	0x004	/* Screen divider is displayed. */
#define	SVI_INFOLINE	0x008	/* The infoline is being used by v_ntext(). */
d98 1
a98 1
	u_int8_t flags;
a140 1
#ifdef DEBUG
d144 1
a144 1
		    "Error: %s/%d: move:l(%u), c(%u), abs",		\
a148 3
#else
#define	MOVEA(sp, lno, cno)	(void)move(lno, cno)
#endif
a150 1
#ifdef DEBUG
d155 1
a155 1
		    "Error: %s/%d: move:l(%u), c(%u), o(%u)",		\
a159 3
#else
#define	MOVE(sp, lno, cno)	(void)move((sp)->woff + (lno), cno)
#endif
d163 2
a164 2
	CHAR_T __ch = ch;						\
	ADDNSTR(KEY_NAME(sp, __ch), KEY_LEN(sp, __ch));			\
a167 1
#ifdef DEBUG
d172 1
a172 1
		msgq(sp, M_ERR, "Error: %s/%d: addnstr: (%d/%u)",	\
a176 3
#else
#define	ADDNSTR(str, len)	(void)addnstr(str, len)
#endif
a178 1
#ifdef DEBUG
d183 1
a183 1
		msgq(sp, M_ERR, "Error: %s/%d: addstr: (%d/%u)",	\
a187 3
#else
#define	ADDSTR(str)	(void)addstr(str);
#endif
a203 1
int	svi_fmap __P((SCR *, enum seqtype, CHAR_T *, size_t, CHAR_T *, size_t));
d205 1
a205 1
	svi_get __P((SCR *, EXF *, TEXTH *, ARG_CHAR_T, u_int));
d213 1
d216 2
a217 2
int	svi_sm_scroll __P((SCR *, EXF *, MARK *, recno_t, enum sctype));
int	svi_split __P((SCR *, ARGS *[], int));
d225 1
a225 1
void	svi_dtoh __P((SCR *, char *));
a229 1
int	svi_msgflush __P((SCR *));
d233 2
a240 2
int	svi_term_end __P((SCR *sp));
int	svi_term_init __P((SCR *sp));
@
