libncurses: Import https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz changes

Change-Id: I3433d30ca01359fd2e3623ede96b531f0b39cbfa
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/include/Caps b/include/Caps
index 120ae35..cd077b9 100644
--- a/include/Caps
+++ b/include/Caps
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 1998-2011,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
+# Copyright 1998-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -29,12 +30,12 @@
 # Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995
 #    and: Eric S. Raymond <esr@snark.thyrsus.com>
 #
-# $Id: Caps,v 1.39 2015/04/26 15:25:55 tom Exp $
+# $Id: Caps,v 1.56 2024/04/20 21:05:02 tom Exp $
 #
 # This is the master termcap/terminfo capability table.
 #
 # This table is used to generate initializers for tables that drive tic,
-# infocmp, and the library compilation code used to support the termcap 
+# infocmp, and the library compilation code used to support the termcap
 # compatibility hack.  It is also used to generate the tabular portion of the
 # terminfo(5) man page; lines beginning with `#%' are passed through to become
 # the terminfo table.
@@ -47,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -57,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -97,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -107,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -119,14 +120,14 @@
 # You'll need to write custom code, probably in postprocess_termcap() or
 # postprocess_terminfo(), to handle the translation.
 #
-# CONTROLLING ENTRY LENGTH 
+# CONTROLLING ENTRY LENGTH
 #
 # Notes on specific elisions made to fit translations within 1023 bytes:
 #
 # Machines with IBM PC-like keyboards want to be able to define the following
 # keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap-
 # only environments for End or Home-Down), key_dc, and key_ic.  This is also
-# the set of keys the `joe' editor will be upset if it can't see.  So don't 
+# the set of keys the `joe' editor will be upset if it can't see.  So don't
 # trim those out of the set to be translated to termcap, or various users of
 # the termcap file will become irate.
 #
@@ -147,68 +148,108 @@
 #
 # It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap
 # translations go back over critical if we do this.  As 4.4BSD curses fades
-# into history and GNU termcap's application base shrinks towards being GNU 
+# into history and GNU termcap's application base shrinks towards being GNU
 # Emacs only, we'll probably elide out some BSD-only capabilities in order
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses 
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
-#%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed through tparm with
-#%parms as given (#\fIi\fP).
-#%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
-#%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%The description field employs a handful of notations.
+#%.TP
+#%.B (P)
+#%indicates that padding may be specified.
+#%.TP
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
+#%.TP
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -247,18 +288,16 @@
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -277,20 +316,21 @@
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -309,18 +349,16 @@
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -383,6 +421,10 @@
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -409,8 +451,8 @@
 key_sr				kri	str	kR	KEY_SR		0521	-B-G-*	scroll-backward key
 key_stab			khts	str	kT	KEY_STAB	0524	-B-G-*	set-tab key
 key_up				kcuu1	str	ku	KEY_UP		0403	YBCGE	up-arrow key
-keypad_local			rmkx	str	ke	-		-	YBCGE	leave 'keyboard_transmit' mode
-keypad_xmit			smkx	str	ks	-		-	YBCGE	enter 'keyboard_transmit' mode
+keypad_local			rmkx	str	ke	-		-	YBCGE	leave keyboard transmit mode
+keypad_xmit			smkx	str	ks	-		-	YBCGE	enter keyboard transmit mode
 lab_f0				lf0	str	l0	-		-	-B-G-*	label on function key f0 if not f0
 lab_f1				lf1	str	l1	-		-	-B-G-*	label on function key f1 if not f1
 lab_f10				lf10	str	la	-		-	-----	label on function key f10 if not f10
@@ -445,6 +487,10 @@
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -511,6 +557,10 @@
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -573,6 +623,10 @@
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -596,7 +650,7 @@
 key_f63				kf63	str	Fr	KEY_F(63)	-	----E	F63 function key
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -641,6 +695,10 @@
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -686,19 +744,20 @@
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -707,7 +766,7 @@
 set_a_foreground		setaf	str	AF	-		-	-----	Set foreground color to #1, using ANSI escape
 set_a_background		setab	str	AB	-		-	-----	Set background color to #1, using ANSI escape
 pkey_plab			pfxl	str	xl	-		-	-----	Program function key #1 to type string #2 and show string #3
-device_type			devt	str	dv	-		-	-----	Indicate language/codeset support
+device_type			devt	str	dv	-		-	-----	Indicate language, codeset support
 code_set_init			csin	str	ci	-		-	-----	Init sequence for multiple codesets
 set0_des_seq			s0ds	str	s0	-		-	-----	Shift to codeset 0 (EUC set 0, ASCII)
 set1_des_seq			s1ds	str	s1	-		-	-----	Shift to codeset 1
@@ -735,9 +794,8 @@
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -746,15 +804,16 @@
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
 enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
 enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
@@ -764,7 +823,6 @@
 set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -826,7 +884,7 @@
 # GNU termcap *does* include the following extended capability,  Only the
 # now-obsolete Ann Arbor terminals used it.
 #
-# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region 
+# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region
 #
 # The following comments describe capnames so ancient that I believe no
 # software uses them any longer.  Some of these have to go because they
@@ -843,9 +901,9 @@
 # comma-separated list of capabilities for which there are corresponding keys.
 # The `kn' code is accepted but ignored.
 #
-# The `ma' capability seems to have been designed to map between the rogue(2)
-# motion keys (including jkhl) and characters emitted by arrow keys on some
-# primitive pre-ANSI terminals.  It's so obsolete it's fossilized...
+# The `ma' capability was a 4.0BSD feature used by vi version 2.
+# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh.
+# Besides being obsolete, that interpretation conflicts with max_attributes.
 #
 # Here is a description of memory_lock_above and memory_unlock:
 # "You can 'freeze' data on the screen by turning on Memory Lock in a line of
@@ -871,14 +929,14 @@
 # vertical_tab_delay		OTdV	num	dV	-		-	-B---	padding required for ^V
 number_of_function_keys		OTkn	num	kn	-		-	-B-G-	count of function keys
 other_non_function_keys		OTko	str	ko	-		-	-B-G-	list of self-mapped keycaps
-arrow_key_map			OTma	str	ma	-		-	YBC--	map arrow keys rogue(1) motion keys
+arrow_key_map			OTma	str	ma	-		-	YBC--	map motion-keys for vi version 2
 # memory_lock_above		OTml	str	ml	-		-	-B---	lock visible screen memory above the current line
 # memory_unlock			OTmu	str	mu	-		-	-B---	unlock visible screen memory above the current line
 has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
@@ -887,7 +945,7 @@
 # University of Waterloo termcap extensions (as described in mytinfo).
 # The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
 # be resolved by a type check.  The descriptions are guesses from what was
-# in the mytinfo tables. 
+# in the mytinfo tables.
 #
 # key_interrupt_char		OTki	str	ki	-		-	-----	string set by interrupt key (?)
 # key_kill_char			OTkk	str	kk	-		-	-----	string set by kill key (?)
@@ -936,7 +994,7 @@
 # Gv	186 \272 M-:	double vertical line
 #
 # The compiler will translate the single-line caps and discard the others
-# (via IGNORE aliases further down).  We don't want to do normal pad 
+# (via IGNORE aliases further down).  We don't want to do normal pad
 # translation on these, they're often single-character printable ASCII
 # strings that happen to be numerics.  There's awk code in parametrized.sh
 # that detects the acs_ prefix and uses it to suppress pad translation.
@@ -958,303 +1016,9 @@
 #
 # TERMINFO EXTENSION CAPABILITIES
 #
-# This section is almost all comments.  What it's mainly for is to describe
-# what capabilities need to be squeezed out to get down to the XSI Curses
-# standard set.  They are flagged with K.
-#
-# HP extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in HP
-# terminfo files.  Except for memory_lock and memory_unlock, they are
-# functionally identical to SVr4 extensions, but they make the binary format
-# different.  Grrr....
+# (see Caps-ncurses for the complete set of comments)
 #
 memory_lock			meml	str	ml	-		-	----K	lock memory above cursor
 memory_unlock			memu	str	mu	-		-	----K	unlock memory
-#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
-#label_on			smln	str	LO	-		-	-----	turn on soft labels
-#label_off			rmln	str	LF	-		-	-----	turn off soft labels
-#key_f11			kf11	str	F1	-		-	-----	F11 function key
-#key_f12			kf12	str	F2	-		-	-----	F12 function key
-#key_f13			kf13	str	F3	-		-	-----	F13 function key
-#key_f14			kf14	str	F4	-		-	-----	F14 function key
-#key_f15			kf15	str	F5	-		-	-----	F15 function key
-#key_f16			kf16	str	F6	-		-	-----	F16 function key
-#key_f17			kf17	str	F7	-		-	-----	F17 function key
-#key_f18			kf18	str	F8	-		-	-----	F18 function key
-#key_f19			kf19	str	F9	-		-	-----	F19 function key
-#key_f20			kf20	str	FA	-		-	-----	F20 function key
-#key_f21			kf21	str	FB	-		-	-----	F21 function key
-#key_f22			kf22	str	FC	-		-	-----	F22 function key
-#key_f23			kf23	str	FD	-		-	-----	F23 function key
-#key_f24			kf24	str	FE	-		-	-----	F24 function key
-#key_f25			kf25	str	FF	-		-	-----	F25 function key
-#key_f26			kf26	str	FG	-		-	-----	F26 function key
-#key_f27			kf27	str	FH	-		-	-----	F27 function key
-#key_f28			kf28	str	FI	-		-	-----	F28 function key
-#key_f29			kf29	str	FJ	-		-	-----	F29 function key
-#key_f30			kf30	str	FK	-		-	-----	F30 function key
-#key_f31			kf31	str	FL	-		-	-----	F31 function key
-#key_f32			kf32	str	FM	-		-	-----	F32 function key
-#key_f33			kf33	str	FN	-		-	-----	F33 function key
-#key_f34			kf34	str	FO	-		-	-----	F34 function key
-#key_f35			kf35	str	FP	-		-	-----	F35 function key
-#key_f36			kf36	str	FQ	-		-	-----	F36 function key
-#key_f37			kf37	str	FR	-		-	-----	F37 function key
-#key_f38			kf38	str	FS	-		-	-----	F38 function key
-#key_f39			kf39	str	FT	-		-	-----	F39 function key
-#key_f40			kf40	str	FU	-		-	-----	F40 function key
-#key_f41			kf41	str	FV	-		-	-----	F41 function key
-#key_f42			kf42	str	FW	-		-	-----	F42 function key
-#key_f43			kf43	str	FX	-		-	-----	F43 function key
-#key_f44			kf44	str	FY	-		-	-----	F44 function key
-#key_f45			kf45	str	FZ	-		-	-----	F45 function key
-#key_f46			kf46	str	Fa	-		-	-----	F46 function key
-#key_f47			kf47	str	Fb	-		-	-----	F47 function key
-#key_f48			kf48	str	Fc	-		-	-----	F48 function key
-#key_f49			kf49	str	Fd	-		-	-----	F49 function key
-#key_f50			kf50	str	Fe	-		-	-----	F50 function key
-#key_f51			kf51	str	Ff	-		-	-----	F51 function key
-#key_f52			kf52	str	Fg	-		-	-----	F52 function key
-#key_f53			kf53	str	Fh	-		-	-----	F53 function key
-#key_f54			kf54	str	Fi	-		-	-----	F54 function key
-#key_f55			kf55	str	Fj	-		-	-----	F55 function key
-#key_f56			kf56	str	Fk	-		-	-----	F56 function key
-#key_f57			kf57	str	Fl	-		-	-----	F57 function key
-#key_f58			kf58	str	Fm	-		-	-----	F58 function key
-#key_f59			kf59	str	Fn	-		-	-----	F59 function key
-#key_f60			kf60	str	Fo	-		-	-----	F60 function key
-#key_f61			kf61	str	Fp	-		-	-----	F61 function key
-#key_f62			kf62	str	Fq	-		-	-----	F62 function key
-#key_f63			kf63	str	Fr	-		-	-----	F63 function key
-#
-# IBM extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in IBM
-# terminfo files.
-#
-# The places in the box[12] capabilities correspond to acsc characters, here is
-# the mapping:
-#
-#	box1[0]  = ACS_ULCORNER
-#	box1[1]  = ACS_HLINE	
-#	box1[2]  = ACS_URCORNER
-#	box1[3]  = ACS_VLINE
-#	box1[4]  = ACS_LRCORNER
-#	box1[5]  = ACS_LLCORNER
-#	box1[6]  = ACS_TTEE
-#	box1[7]  = ACS_RTEE
-#	box1[8]  = ACS_BTEE
-#	box1[9]  = ACS_LTEE
-#	box1[10] = ACS_PLUS
-#
-# The box2 characters are the double-line versions of these forms graphics.
-#
 box_chars_1			box1	str	bx	-		-	----K	box characters primary set
-#box_chars_2			box2	str	by	-		-	----K	box characters secondary set
-#box_attr_1			batt1	str	Bx	-		-	----K	attributes for box1
-#box_attr_2			batt2	str	By	-		-	----K	attributes for box2
-#color_bg_0			colb0	str	d0	-		-	----K	background color 0
-#color_bg_1			colb1	str	d1	-		-	----K	background color 1
-#color_bg_2			colb2	str	d2	-		-	----K	background color 2
-#color_bg_3			colb3	str	d3	-		-	----K	background color 3
-#color_bg_4			colb4	str	d4	-		-	----K	background color 4
-#color_bg_5			colb5	str	d5	-		-	----K	background color 5
-#color_bg_6			colb6	str	d6	-		-	----K	background color 6
-#color_bg_7			colb7	str	d7	-		-	----K	background color 7
-#color_fg_0			colf0	str	c0	-		-	----K	foreground color 0
-#color_fg_1			colf1	str	c1	-		-	----K	foreground color 1
-#color_fg_2			colf2	str	c2	-		-	----K	foreground color 2
-#color_fg_3			colf3	str	c3	-		-	----K	foreground color 3
-#color_fg_4			colf4	str	c4	-		-	----K	foreground color 4
-#color_fg_5			colf5	str	c5	-		-	----K	foreground color 5
-#color_fg_6			colf6	str	c6	-		-	----K	foreground color 6
-#color_fg_7			colf7	str	c7	-		-	----K	foreground color 7
-#font_0				font0	str	f0	-		-	-----	select font 0
-#font_1				font1	str	f1	-		-	-----	select font 1
-#font_2				font2	str	f2	-		-	-----	select font 2
-#font_3				font3	str	f3	-		-	-----	select font 3
-#font_4				font4	str	f4	-		-	----K	select font 4
-#font_5				font5	str	f5	-		-	----K	select font 5
-#font_6				font6	str	f6	-		-	----K	select font 6
-#font_7				font7	str	f7	-		-	----K	select font 7
-#key_back_tab			kbtab	str	k0	-		-	-----	backtab key
-#key_do				kdo	str	ki	-		-	----K	do request key
-#key_command			kcmd	str	kd	-		-	----K	command-request key
-#key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
-#key_end			kend	str	kw	-		-	-----	end key
-#key_help			khlp	str	kq	-		-	-----	help key
-#key_newline			knl	str	nl	-		-	----K	newline key
-#key_next_pane			knpn	str	kv	-		-	----K	next-pane key
-#key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
-#key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
-#key_quit			kquit	str	kQ	-		-	----K	quit key
-#key_select			ksel	str	kU	-		-	-----	select key
-#key_scroll_left		kscl	str	kz	-		-	----K	scroll left
-#key_scroll_right		kscr	str	kZ	-		-	----K	scroll right
-#key_tab			ktab	str	ko	-		-	----K	tab key
-#key_smap_in1			kmpf1	str	Kv	-		-	----K	special mapped key 1 input
-#key_smap_out1			kmpt1	str	KV	-		-	----K	special mapped key 1 output
-#key_smap_in2			kmpf2	str	Kw	-		-	----K	special mapped key 2 input
-#key_smap_out2			kmpt2	str	KW	-		-	----K	special mapped key 2 output
-#key_smap_in3			kmpf3	str	Kx	-		-	----K	special mapped key 3 input
-#key_smap_out3			kmpt3	str	KX	-		-	----K	special mapped key 3 output
-#key_smap_in4			kmpf4	str	Ky	-		-	----K	special mapped key 4 input
-#key_smap_out4			kmpt4	str	KY	-		-	----K	special mapped key 4 output
-#key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
-#key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
-#appl_defined_str		apstr	str	za	-		-	----K	application-defined string
-# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
-# the IBM manual pages, so the cap name strings are guesses.  The terminfo
-# names are almost certainly right, the termcap ones almost certainly wrong.
-#key_smap_in6			kmpf6	str	k!	-		-	----K	special mapped key 6 input
-#key_smap_out6			kmpt6	str	K@	-		-	----K	special mapped key 6 output
-#key_smap_in7			kmpf7	str	k#	-		-	----K	special mapped key 7 input
-#key_smap_out7			kmpt7	str	K$	-		-	----K	special mapped key 7 output
-#key_smap_in8			kmpf8	str	k%	-		-	----K	special mapped key 8 input
-#key_smap_out8			kmpt8	str	K^	-		-	----K	special mapped key 8 output
-#key_smap_in9			kmpf9	str	k&	-		-	----K	special mapped key 9 input
-#key_smap_out9			kmpt9	str	K*	-		-	----K	special mapped key 9 output
-# Undocumented capabilities end here
-#key_sf1			ksf1	str	S1	-		-	----K	special function key 1
-#key_sf2			ksf2	str	S2	-		-	----K	special function key 2
-#key_sf3			ksf3	str	S3	-		-	----K	special function key 3
-#key_sf4			ksf4	str	S4	-		-	----K	special function key 4
-#key_sf5			ksf5	str	S5	-		-	----K	special function key 5
-#key_sf6			ksf6	str	S6	-		-	----K	special function key 6
-#key_sf7			ksf7	str	S7	-		-	----K	special function key 7
-#key_sf8			ksf8	str	S8	-		-	----K	special function key 8
-#key_sf9			ksf9	str	S9	-		-	----K	special function key 9
-#key_sf10			ksf10	str	SA	-		-	----K	special function key 10
-# AIX version 3 documents different codes for F11, F12 and does not mention
-# F13-F64.  AIX version 4 uses the same naming for F0-F63 as above.
-#key_f11			kf11	str	k<	-		-	-----	function key 11
-#key_f12			kf12	str	k>	-		-	-----	function key 12
-# Undocumented capabilities end here.
-#key_action			kact	str	kJ	-		-	----K	sent by action key
-# The IBM docs say these capabilities are for table-drawing, and are
-# valid only for aixterm descriptions.
-#enter_topline_mode		topl	str	tp	-		-	----K	start top-line mode
-#enter_bottom_mode		btml	str	bm	-		-	----K	start bottom-line mode
-#enter_rvert_mode		rvert	str	rv	-		-	----K	start right-vertical mode
-#enter_lvert_mode		lvert	str	lv	-		-	----K	start left-vertical mode
-#
-#############################################################################
-#
-# ALIAS DECLARATIONS
-#
-# Here we set up aliases for translating extensions into standard terminfo.
-#
-#---------------------------------- Termcap aliases -------------------------
-#
-# BSD aliases:
-#
-# This is a common error in many termcap files.  We'll get notified during
-# translation when this (or any other alias) fires.
-#
-capalias	sb	sr	BSD	scroll text down
-#
-# AT&T extensions:
-#
-# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
-# nonstandard capabilities.  Its signature is the KM capability, used to name
-# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
-# set.  Comments in the original, and a little cross-checking with other AT&T
-# documentation, seem to establish the following mappings:
-#
-capalias	BO	mr	AT&T	enter_reverse_mode
-capalias	CI	vi	AT&T	cursor_invisible
-capalias	CV	ve	AT&T	cursor_normal
-capalias	DS	mh	AT&T	enter_dim_mode
-#capalias	EE	me	AT&T	exit_attribute_mode	
-capalias	FE	LF	AT&T	label_on
-capalias	FL	LO	AT&T	label_off
-capalias	XS	mk	AT&T	enter_secure_mode
-#
-# We comment out EE because the conflicting XENIX EE is more common in 
-# old entries.
-#
-# XENIX extensions:
-#
-# These are the ones we know how to translate directly:
-#
-capalias	EE	mh	XENIX	exit_attribute_mode	
-capalias	GE	ae	XENIX	exit_alt_charset_mode
-capalias	GS	as	XENIX	enter_alt_charset_mode
-capalias	CF	vi	XENIX	cursor_invis
-capalias	CO	ve	XENIX	cursor_normal
-capalias	EN	@7	XENIX	key_end
-capalias	HM	kh	XENIX	key_home
-capalias	LD	kL	XENIX	key_dl
-capalias	PD	kN	XENIX	key_npage
-capalias	PN	po	XENIX	prtr_off
-capalias	PS	pf	XENIX	prtr_on
-capalias	PU	kP	XENIX	key_ppage
-capalias	RT	@8	XENIX	kent
-capalias	UP	ku	XENIX	kcuu1
-capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
-capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
-capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
-capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
-capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
-capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
-capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
-capalias	Gd	IGNORE	XENIX	double ACS_TTEE
-capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
-capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
-capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
-capalias	GG	IGNORE	XENIX	acs-glitch
-#
-# IBM extensions:
-#
-capalias	kq	%1	IBM	key_help
-#
-# Iris extensions:
-#
-capalias	HS	mh	IRIS	enter_dim_mode
-#
-# Tektronix extensions:
-#
-capalias	KA	k;	Tek	key_f10
-capalias	KB	F1	Tek	key_f11
-capalias	KC	F2	Tek	key_f12
-capalias	KD	F3	Tek	key_f13
-capalias	KE	F4	Tek	key_f14
-capalias	KF	F5	Tek	key_f15
-capalias	BC	Sb	Tek	set_background
-capalias	FC	Sf	Tek	set_foreground
-#
-# There are also the following:
-#
-#	XENIX	XENIX variable name	name clash with terminfo?
-#	-----	-------------------	-------------------------
-#	CL	key_char_left
-#	CR	key_char_right
-#	CW	key_change_window
-#	HP	??
-#	LF	key_linefeed 		label_off
-#	NU	key_next_unlocked_cell
-#	PL	??
-#	PR	??
-#	RC	key_recalc		remove_clock
-#	RF	key_toggle_ref		req_for_input
-#	WL	key_word_left
-#	WR	key_word_right
-#
-# If you know what any of the question-marked ones mean, please tell us.
-#
-#--------------------------------- Terminfo aliases ------------------------
-#
-# IBM extensions:
-#
-infoalias	font0	s0ds	IBM	set0_des_seq
-infoalias	font1	s1ds	IBM	set1_des_seq
-infoalias	font2	s2ds	IBM	set2_des_seq
-infoalias	font3	s3ds	IBM	set3_des_seq
-infoalias	kbtab	kcbt	IBM	key_backtab
-infoalias	ksel	kslt	IBM	key_select
-#
-# Some others are identical to SVr4/XPG4 capabilities, in particular:
-# kcmd, kend, khlp, and kf11...kf63.
-#
 #############################################################################
diff --git a/include/Caps-ncurses b/include/Caps-ncurses
new file mode 100644
index 0000000..f9a5da0
--- /dev/null
+++ b/include/Caps-ncurses
@@ -0,0 +1,478 @@
+##############################################################################
+# Copyright 2019-2022,2023 Thomas E. Dickey                                  #
+#                                                                            #
+# Permission is hereby granted, free of charge, to any person obtaining a    #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation  #
+# the rights to use, copy, modify, merge, publish, distribute, distribute    #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the  #
+# following conditions:                                                      #
+#                                                                            #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software.                        #
+#                                                                            #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
+# DEALINGS IN THE SOFTWARE.                                                  #
+#                                                                            #
+# Except as contained in this notice, the name(s) of the above copyright     #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written               #
+# authorization.                                                             #
+##############################################################################
+#
+# Author: Thomas E. Dickey
+#
+# $Id: Caps-ncurses,v 1.15 2023/10/28 21:55:47 tom Exp $
+#
+#############################################################################
+#
+# TERMINFO EXTENSION CAPABILITIES
+#
+# This section is all comments (selected lines are copied/uncommented into
+# specific "Caps" files).  The section describes what capabilities need to be
+# squeezed out to get down to the XSI Curses standard set.  They are flagged
+# with K.
+#
+# HP extensions
+#
+# These extensions follow ptr_non (replacing everything after it) in HP
+# terminfo files.  Except for memory_lock and memory_unlock, they are
+# functionally identical to SVr4 extensions, but they make the binary format
+# different.  Grrr....
+#
+#memory_lock			meml	str	ml	-		-	----K	lock memory above cursor
+#memory_unlock			memu	str	mu	-		-	----K	unlock memory
+#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
+#label_on			smln	str	LO	-		-	-----	turn on soft labels
+#label_off			rmln	str	LF	-		-	-----	turn off soft labels
+#key_f11			kf11	str	F1	-		-	-----	F11 function key
+#key_f12			kf12	str	F2	-		-	-----	F12 function key
+#key_f13			kf13	str	F3	-		-	-----	F13 function key
+#key_f14			kf14	str	F4	-		-	-----	F14 function key
+#key_f15			kf15	str	F5	-		-	-----	F15 function key
+#key_f16			kf16	str	F6	-		-	-----	F16 function key
+#key_f17			kf17	str	F7	-		-	-----	F17 function key
+#key_f18			kf18	str	F8	-		-	-----	F18 function key
+#key_f19			kf19	str	F9	-		-	-----	F19 function key
+#key_f20			kf20	str	FA	-		-	-----	F20 function key
+#key_f21			kf21	str	FB	-		-	-----	F21 function key
+#key_f22			kf22	str	FC	-		-	-----	F22 function key
+#key_f23			kf23	str	FD	-		-	-----	F23 function key
+#key_f24			kf24	str	FE	-		-	-----	F24 function key
+#key_f25			kf25	str	FF	-		-	-----	F25 function key
+#key_f26			kf26	str	FG	-		-	-----	F26 function key
+#key_f27			kf27	str	FH	-		-	-----	F27 function key
+#key_f28			kf28	str	FI	-		-	-----	F28 function key
+#key_f29			kf29	str	FJ	-		-	-----	F29 function key
+#key_f30			kf30	str	FK	-		-	-----	F30 function key
+#key_f31			kf31	str	FL	-		-	-----	F31 function key
+#key_f32			kf32	str	FM	-		-	-----	F32 function key
+#key_f33			kf33	str	FN	-		-	-----	F33 function key
+#key_f34			kf34	str	FO	-		-	-----	F34 function key
+#key_f35			kf35	str	FP	-		-	-----	F35 function key
+#key_f36			kf36	str	FQ	-		-	-----	F36 function key
+#key_f37			kf37	str	FR	-		-	-----	F37 function key
+#key_f38			kf38	str	FS	-		-	-----	F38 function key
+#key_f39			kf39	str	FT	-		-	-----	F39 function key
+#key_f40			kf40	str	FU	-		-	-----	F40 function key
+#key_f41			kf41	str	FV	-		-	-----	F41 function key
+#key_f42			kf42	str	FW	-		-	-----	F42 function key
+#key_f43			kf43	str	FX	-		-	-----	F43 function key
+#key_f44			kf44	str	FY	-		-	-----	F44 function key
+#key_f45			kf45	str	FZ	-		-	-----	F45 function key
+#key_f46			kf46	str	Fa	-		-	-----	F46 function key
+#key_f47			kf47	str	Fb	-		-	-----	F47 function key
+#key_f48			kf48	str	Fc	-		-	-----	F48 function key
+#key_f49			kf49	str	Fd	-		-	-----	F49 function key
+#key_f50			kf50	str	Fe	-		-	-----	F50 function key
+#key_f51			kf51	str	Ff	-		-	-----	F51 function key
+#key_f52			kf52	str	Fg	-		-	-----	F52 function key
+#key_f53			kf53	str	Fh	-		-	-----	F53 function key
+#key_f54			kf54	str	Fi	-		-	-----	F54 function key
+#key_f55			kf55	str	Fj	-		-	-----	F55 function key
+#key_f56			kf56	str	Fk	-		-	-----	F56 function key
+#key_f57			kf57	str	Fl	-		-	-----	F57 function key
+#key_f58			kf58	str	Fm	-		-	-----	F58 function key
+#key_f59			kf59	str	Fn	-		-	-----	F59 function key
+#key_f60			kf60	str	Fo	-		-	-----	F60 function key
+#key_f61			kf61	str	Fp	-		-	-----	F61 function key
+#key_f62			kf62	str	Fq	-		-	-----	F62 function key
+#key_f63			kf63	str	Fr	-		-	-----	F63 function key
+#
+# IBM extensions
+#
+# These extensions follow ptr_non (replacing everything after it) in IBM
+# terminfo files.
+#
+# The places in the box[12] capabilities correspond to acsc characters, here is
+# the mapping:
+#
+#	box1[0]  = ACS_ULCORNER
+#	box1[1]  = ACS_HLINE
+#	box1[2]  = ACS_URCORNER
+#	box1[3]  = ACS_VLINE
+#	box1[4]  = ACS_LRCORNER
+#	box1[5]  = ACS_LLCORNER
+#	box1[6]  = ACS_TTEE
+#	box1[7]  = ACS_RTEE
+#	box1[8]  = ACS_BTEE
+#	box1[9]  = ACS_LTEE
+#	box1[10] = ACS_PLUS
+#
+# The box2 characters are the double-line versions of these forms graphics.
+#
+#box_chars_1			box1	str	bx	-		-	----K	box characters primary set
+#box_chars_2			box2	str	by	-		-	----K	box characters secondary set
+#box_attr_1			batt1	str	Bx	-		-	----K	attributes for box1
+#box_attr_2			batt2	str	By	-		-	----K	attributes for box2
+#color_bg_0			colb0	str	d0	-		-	----K	background color 0
+#color_bg_1			colb1	str	d1	-		-	----K	background color 1
+#color_bg_2			colb2	str	d2	-		-	----K	background color 2
+#color_bg_3			colb3	str	d3	-		-	----K	background color 3
+#color_bg_4			colb4	str	d4	-		-	----K	background color 4
+#color_bg_5			colb5	str	d5	-		-	----K	background color 5
+#color_bg_6			colb6	str	d6	-		-	----K	background color 6
+#color_bg_7			colb7	str	d7	-		-	----K	background color 7
+#color_fg_0			colf0	str	c0	-		-	----K	foreground color 0
+#color_fg_1			colf1	str	c1	-		-	----K	foreground color 1
+#color_fg_2			colf2	str	c2	-		-	----K	foreground color 2
+#color_fg_3			colf3	str	c3	-		-	----K	foreground color 3
+#color_fg_4			colf4	str	c4	-		-	----K	foreground color 4
+#color_fg_5			colf5	str	c5	-		-	----K	foreground color 5
+#color_fg_6			colf6	str	c6	-		-	----K	foreground color 6
+#color_fg_7			colf7	str	c7	-		-	----K	foreground color 7
+#font_0				font0	str	f0	-		-	-----	select font 0
+#font_1				font1	str	f1	-		-	-----	select font 1
+#font_2				font2	str	f2	-		-	-----	select font 2
+#font_3				font3	str	f3	-		-	-----	select font 3
+#font_4				font4	str	f4	-		-	----K	select font 4
+#font_5				font5	str	f5	-		-	----K	select font 5
+#font_6				font6	str	f6	-		-	----K	select font 6
+#font_7				font7	str	f7	-		-	----K	select font 7
+#key_back_tab			kbtab	str	k0	-		-	-----	backtab key
+#key_do				kdo	str	ki	-		-	----K	do request key
+#key_command			kcmd	str	kd	-		-	----K	command-request key
+#key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
+#key_end			kend	str	kw	-		-	-----	end key
+#key_help			khlp	str	kq	-		-	-----	help key
+#key_newline			knl	str	nl	-		-	----K	newline key
+#key_next_pane			knpn	str	kv	-		-	----K	next-pane key
+#key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
+#key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
+#key_quit			kquit	str	kQ	-		-	----K	quit key
+#key_select			ksel	str	kU	-		-	-----	select key
+#key_scroll_left		kscl	str	kz	-		-	----K	scroll left
+#key_scroll_right		kscr	str	kZ	-		-	----K	scroll right
+#key_tab			ktab	str	ko	-		-	----K	tab key
+#key_smap_in1			kmpf1	str	Kv	-		-	----K	special mapped key 1 input
+#key_smap_out1			kmpt1	str	KV	-		-	----K	special mapped key 1 output
+#key_smap_in2			kmpf2	str	Kw	-		-	----K	special mapped key 2 input
+#key_smap_out2			kmpt2	str	KW	-		-	----K	special mapped key 2 output
+#key_smap_in3			kmpf3	str	Kx	-		-	----K	special mapped key 3 input
+#key_smap_out3			kmpt3	str	KX	-		-	----K	special mapped key 3 output
+#key_smap_in4			kmpf4	str	Ky	-		-	----K	special mapped key 4 input
+#key_smap_out4			kmpt4	str	KY	-		-	----K	special mapped key 4 output
+#key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
+#key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
+#appl_defined_str		apstr	str	za	-		-	----K	application-defined string
+# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
+# the IBM manual pages, so the cap name strings are guesses.  The terminfo
+# names are almost certainly right, the termcap ones almost certainly wrong.
+#key_smap_in6			kmpf6	str	k!	-		-	----K	special mapped key 6 input
+#key_smap_out6			kmpt6	str	K@	-		-	----K	special mapped key 6 output
+#key_smap_in7			kmpf7	str	k#	-		-	----K	special mapped key 7 input
+#key_smap_out7			kmpt7	str	K$	-		-	----K	special mapped key 7 output
+#key_smap_in8			kmpf8	str	k%	-		-	----K	special mapped key 8 input
+#key_smap_out8			kmpt8	str	K^	-		-	----K	special mapped key 8 output
+#key_smap_in9			kmpf9	str	k&	-		-	----K	special mapped key 9 input
+#key_smap_out9			kmpt9	str	K*	-		-	----K	special mapped key 9 output
+# Undocumented capabilities end here
+#key_sf1			ksf1	str	S1	-		-	----K	special function key 1
+#key_sf2			ksf2	str	S2	-		-	----K	special function key 2
+#key_sf3			ksf3	str	S3	-		-	----K	special function key 3
+#key_sf4			ksf4	str	S4	-		-	----K	special function key 4
+#key_sf5			ksf5	str	S5	-		-	----K	special function key 5
+#key_sf6			ksf6	str	S6	-		-	----K	special function key 6
+#key_sf7			ksf7	str	S7	-		-	----K	special function key 7
+#key_sf8			ksf8	str	S8	-		-	----K	special function key 8
+#key_sf9			ksf9	str	S9	-		-	----K	special function key 9
+#key_sf10			ksf10	str	SA	-		-	----K	special function key 10
+# AIX version 3 documents different codes for F11, F12 and does not mention
+# F13-F64.  AIX version 4 uses the same naming for F0-F63 as above.
+#key_f11			kf11	str	k<	-		-	-----	function key 11
+#key_f12			kf12	str	k>	-		-	-----	function key 12
+# Undocumented capabilities end here.
+#key_action			kact	str	kJ	-		-	----K	sent by action key
+# The IBM docs say these capabilities are for table-drawing, and are
+# valid only for aixterm descriptions.
+#enter_topline_mode		topl	str	tp	-		-	----K	start top-line mode
+#enter_bottom_mode		btml	str	bm	-		-	----K	start bottom-line mode
+#enter_rvert_mode		rvert	str	rv	-		-	----K	start right-vertical mode
+#enter_lvert_mode		lvert	str	lv	-		-	----K	start left-vertical mode
+#
+#############################################################################
+#
+# ALIAS DECLARATIONS
+#
+# Here we set up aliases for translating extensions into standard terminfo.
+#
+#---------------------------------- Termcap aliases -------------------------
+#
+# BSD aliases:
+#
+# This is a common error in many termcap files.  We'll get notified during
+# translation when this (or any other alias) fires.
+#
+capalias	sb	sr	BSD	scroll text down
+#
+# AT&T extensions:
+#
+# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
+# nonstandard capabilities.  Its signature is the KM capability, used to name
+# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
+# set.  Comments in the original, and a little cross-checking with other AT&T
+# documentation, seem to establish the following mappings:
+#
+capalias	BO	mr	AT&T	enter_reverse_mode
+capalias	CI	vi	AT&T	cursor_invisible
+capalias	CV	ve	AT&T	cursor_normal
+capalias	DS	mh	AT&T	enter_dim_mode
+#capalias	EE	me	AT&T	exit_attribute_mode
+capalias	FE	LF	AT&T	label_on
+capalias	FL	LO	AT&T	label_off
+capalias	XS	mk	AT&T	enter_secure_mode
+#
+# We comment out EE because the conflicting XENIX EE is more common in
+# old entries.
+#
+# XENIX extensions:
+#
+# These are the ones we know how to translate directly:
+#
+capalias	EE	mh	XENIX	exit_attribute_mode
+capalias	GE	ae	XENIX	exit_alt_charset_mode
+capalias	GS	as	XENIX	enter_alt_charset_mode
+capalias	CF	vi	XENIX	cursor_invis
+capalias	CO	ve	XENIX	cursor_normal
+capalias	EN	@7	XENIX	key_end
+capalias	HM	kh	XENIX	key_home
+capalias	LD	kL	XENIX	key_dl
+capalias	PD	kN	XENIX	key_npage
+capalias	PN	po	XENIX	prtr_off
+capalias	PS	pf	XENIX	prtr_on
+capalias	PU	kP	XENIX	key_ppage
+capalias	RT	@8	XENIX	kent
+capalias	UP	ku	XENIX	kcuu1
+capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
+capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
+capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
+capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
+capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
+capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
+capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
+capalias	Gd	IGNORE	XENIX	double ACS_TTEE
+capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
+capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
+capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
+capalias	GG	IGNORE	XENIX	acs-glitch
+#
+# IBM extensions:
+#
+capalias	kq	%1	IBM	key_help
+#
+# Iris extensions:
+#
+capalias	HS	mh	IRIS	enter_dim_mode
+#
+# Tektronix extensions:
+#
+capalias	KA	k;	Tek	key_f10
+capalias	KB	F1	Tek	key_f11
+capalias	KC	F2	Tek	key_f12
+capalias	KD	F3	Tek	key_f13
+capalias	KE	F4	Tek	key_f14
+capalias	KF	F5	Tek	key_f15
+capalias	BC	Sb	Tek	set_background
+capalias	FC	Sf	Tek	set_foreground
+#
+# There are also the following:
+#
+#	XENIX	XENIX variable name	name clash with terminfo?
+#	-----	-------------------	-------------------------
+#	CL	key_char_left
+#	CR	key_char_right
+#	CW	key_change_window
+#	HP	??
+#	LF	key_linefeed 		label_off
+#	NU	key_next_unlocked_cell
+#	PL	??
+#	PR	??
+#	RC	key_recalc		remove_clock
+#	RF	key_toggle_ref		req_for_input
+#	WL	key_word_left
+#	WR	key_word_right
+#
+# If you know what any of the question-marked ones mean, please tell us.
+#
+#--------------------------------- Terminfo aliases ------------------------
+#
+# IBM extensions:
+#
+infoalias	font0	s0ds	IBM	set0_des_seq
+infoalias	font1	s1ds	IBM	set1_des_seq
+infoalias	font2	s2ds	IBM	set2_des_seq
+infoalias	font3	s3ds	IBM	set3_des_seq
+infoalias	kbtab	kcbt	IBM	key_backtab
+infoalias	ksel	kslt	IBM	key_select
+#
+# Some others are identical to SVr4/XPG4 capabilities, in particular:
+# kcmd, kend, khlp, and kf11...kf63.
+#
+#############################################################################
+# This is a table of ncurses user-definable capabilities which applications
+# developers may have used.  ncurses may use the table to check consistency of
+# types/parameters.  Applications may have defined others (such as screen's
+# LP and NF), but where a standard capability is available, those alternatives
+# are not listed here.
+#
+used_by ncurses
+userdef	CO 	num	n	number of indexed colors overlaying RGB space
+userdef	E3	str	-	clears the terminal's scrollback buffer.
+userdef	NQ	bool	-	terminal does not support query/response
+userdef	RGB	bool	-	use direct colors with 1/3 of color-pair bits per color.
+userdef	RGB	num	n	use direct colors with given number of bits per color.
+userdef	RGB	str	-	use direct colors with given bit-layout.
+userdef	TS	str	-	like "tsl", but uses no parameter.
+userdef	U8	num	n	terminal does/does not support VT100 SI/SO when processing UTF-8 encoding.
+userdef	XM	str	n	initialize alternate xterm mouse mode
+userdef	grbom	str	-	disable real bold (not intensity bright) mode.
+userdef	gsbom	str	-	enable real bold (not intensity bright) mode.
+userdef	xm	str	-	mouse response, no parameters
+userdef	xm	str	n	mouse response, p1 = y-ordinate
+userdef	xm	str	nn	mouse response, p2 = x-ordinate
+userdef	xm	str	nnn	mouse response, p3 = button
+userdef	xm	str	nnns	mouse response, p4 = state, e.g., pressed or released
+userdef	xm	str	nnnsn	mouse response, p5 = y-ordinate starting region
+userdef	xm	str	nnnsnn	mouse response, p6 = x-ordinate starting region
+userdef	xm	str	nnnsnnn	mouse response, p7 = y-ordinate ending region
+userdef	xm	str	nnnsnnnn mouse response, p8 = x-ordinate ending region
+#
+used_by mintty
+userdef Rmol	str	-	remove overline-mode
+userdef Smol	str	-	set overline-mode
+userdef blink2	str	-	turn on rapid blinking
+userdef norm	str	-	turn off bold and half-bright mode
+userdef opaq	str	-	turn off blank mode
+userdef	setal	str	n	set underline-color
+userdef smul2	str	-	begin double underline mode
+#
+used_by screen
+userdef	AN	bool	-	turn on autonuke.
+userdef	AX	bool	-	understands ANSI set default fg/bg color (\E[39m / \E[49m).
+userdef	C0	str	-	use the string as a conversion table for font '0', like acsc.
+userdef	C8	bool	-	terminal shows bold as high-intensity colors.
+userdef	CE	str	-	switch cursor-keys back to normal mode.
+userdef	CS	str	-	switch cursor-keys to application mode.
+userdef	E0	str	-	switch charset 'G0' back to standard charset. Default is '\E(B'.
+userdef	G0	bool	-	terminal can deal with ISO 2022 font selection sequences.
+userdef	KJ	str	s	set the encoding of the terminal.
+userdef	OL	num	n	set the screen program's output buffer limit.
+userdef	S0	str	s	switch charset 'G0' to the specified charset. Default is '\E(%.'.
+userdef	TF	bool	-	add missing capabilities to screen's termcap/info entry. (Set by default).
+userdef	WS	str	nn	resize display. This capability has the desired width and height as arguments. SunView(tm) example: '\E[8;%d;%dt'.
+userdef	XC	str	s	describe a translation of characters to strings depending on the current font.
+userdef	XT	bool	-	terminal understands special xterm sequences (OSC, mouse tracking).
+userdef	Z0	str	-	change width to 132 columns.
+userdef	Z1	str	-	change width to 80 columns.
+#
+used_by tmux
+userdef	Cr	str	-	restore the default cursor color.
+userdef	Cs	str	s	set the cursor color.
+userdef	Csr	str	n	change the cursor style, overriding Ss.
+userdef	Ms	str	ss	store the current buffer in the host terminal's selection (clipboard).
+userdef	Se	str	-	reset the cursor style to the terminal initial state.
+userdef	Smulx	str	n	modify the appearance of underlines in VTE.
+userdef	Ss	str	n	change the cursor style.
+userdef	rmxx	str	-	reset ECMA-48 strikeout/crossed-out attributes.
+userdef	smxx	str	-	set ECMA-48 strikeout/crossed-out attributes.
+#
+used_by vim
+userdef	BD	str	-	disables bracketed paste
+userdef	BE	str	-	enables bracketed paste
+userdef	PE	str	-	is sent after pasted text
+userdef	PS	str	-	is sent before pasted text
+userdef	RV	str	-	report terminal secondary device attributes
+userdef	XR	str	-	report terminal version as a free-format string.
+userdef	XF	bool	-	terminal supports xterm focus in/out
+userdef	fd	str	-	disable xterm focus-events
+userdef	fe	str	-	enable xterm focus-events
+userdef	rv	str	-	response to RV, regular expression
+userdef	xr	str	-	response to XR, regular expression
+#
+used_by xterm
+userdef	csl	str	-	clear status line
+userdef	kDC3	str	-	alt delete-character
+userdef	kDC4	str	-	shift+alt delete-character
+userdef	kDC5	str	-	control delete-character
+userdef	kDC6	str	-	shift+control delete-character
+userdef	kDC7	str	-	alt+control delete-character
+userdef	kDN	str	-	shift down-cursor
+userdef	kDN3	str	-	alt down-cursor
+userdef	kDN4	str	-	shift+alt down-cursor
+userdef	kDN5	str	-	control down-cursor
+userdef	kDN6	str	-	shift+control down-cursor
+userdef	kDN7	str	-	alt+control down-cursor
+userdef	kEND3	str	-	alt end
+userdef	kEND4	str	-	shift+alt end
+userdef	kEND5	str	-	control end
+userdef	kEND6	str	-	shift+control end
+userdef	kEND7	str	-	alt+control end
+userdef	kHOM3	str	-	alt home
+userdef	kHOM4	str	-	shift+alt home
+userdef	kHOM5	str	-	control home
+userdef	kHOM6	str	-	shift+control home
+userdef	kHOM7	str	-	alt+control home
+userdef	kIC3	str	-	alt insert-character
+userdef	kIC4	str	-	shift+alt insert-character
+userdef	kIC5	str	-	control insert-character
+userdef	kIC6	str	-	shift+control insert-character
+userdef	kIC7	str	-	alt+control insert-character
+userdef	kLFT3	str	-	alt left-cursor
+userdef	kLFT4	str	-	shift+alt left-cursor
+userdef	kLFT5	str	-	control left-cursor
+userdef	kLFT6	str	-	shift+control left-cursor
+userdef	kLFT7	str	-	alt+control left-cursor
+userdef	kNXT3	str	-	alt next
+userdef	kNXT4	str	-	shift+alt next
+userdef	kNXT5	str	-	control next
+userdef	kNXT6	str	-	shift+control next
+userdef	kNXT7	str	-	alt+control next
+userdef	kPRV3	str	-	alt previous
+userdef	kPRV4	str	-	shift+alt previous
+userdef	kPRV5	str	-	control previous
+userdef	kPRV6	str	-	shift+control previous
+userdef	kPRV7	str	-	alt+control previous
+userdef	kRIT3	str	-	alt right-cursor
+userdef	kRIT4	str	-	shift+alt right-cursor
+userdef	kRIT5	str	-	control right-cursor
+userdef	kRIT6	str	-	shift+control right-cursor
+userdef	kRIT7	str	-	alt+control right-cursor
+userdef	kUP	str	-	shift up-cursor
+userdef	kUP3	str	-	alt up-cursor
+userdef	kUP4	str	-	shift+alt up-cursor
+userdef	kUP5	str	-	control up-cursor
+userdef	kUP6	str	-	shift+control up-cursor
+userdef	kUP7	str	-	alt+control up-cursor
+userdef	ka2	str	-	vt220-keypad extensions
+userdef	kb1	str	-	vt220-keypad extensions
+userdef	kb3	str	-	vt220-keypad extensions
+userdef	kc2	str	-	vt220-keypad extensions
+userdef	kxIN	str	-	mouse response on focus-in
+userdef	kxOUT	str	-	mouse response on focus-out
+#############################################################################
diff --git a/include/Caps.aix4 b/include/Caps.aix4
index 8fb53c2..1adb848 100644
--- a/include/Caps.aix4
+++ b/include/Caps.aix4
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2001-2011,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
+# Copyright 2001-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -28,13 +29,13 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.aix4,v 1.10 2015/04/26 15:25:55 tom Exp $
+# $Id: Caps.aix4,v 1.28 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with AIX 4.x's terminfo.
 #
 # This table is used to generate initializers for tables that drive tic,
-# infocmp, and the library compilation code used to support the termcap 
+# infocmp, and the library compilation code used to support the termcap
 # compatibility hack.  It is also used to generate the tabular portion of the
 # terminfo(5) man page; lines beginning with `#%' are passed through to become
 # the terminfo table.
@@ -47,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -57,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -97,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -107,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -119,14 +120,14 @@
 # You'll need to write custom code, probably in postprocess_termcap() or
 # postprocess_terminfo(), to handle the translation.
 #
-# CONTROLLING ENTRY LENGTH 
+# CONTROLLING ENTRY LENGTH
 #
 # Notes on specific elisions made to fit translations within 1023 bytes:
 #
 # Machines with IBM PC-like keyboards want to be able to define the following
 # keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap-
 # only environments for End or Home-Down), key_dc, and key_ic.  This is also
-# the set of keys the `joe' editor will be upset if it can't see.  So don't 
+# the set of keys the `joe' editor will be upset if it can't see.  So don't
 # trim those out of the set to be translated to termcap, or various users of
 # the termcap file will become irate.
 #
@@ -147,68 +148,108 @@
 #
 # It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap
 # translations go back over critical if we do this.  As 4.4BSD curses fades
-# into history and GNU termcap's application base shrinks towards being GNU 
+# into history and GNU termcap's application base shrinks towards being GNU
 # Emacs only, we'll probably elide out some BSD-only capabilities in order
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses 
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
-#%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed through tparm with
-#%parms as given (#\fIi\fP).
-#%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
-#%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%The description field employs a handful of notations.
+#%.TP
+#%.B (P)
+#%indicates that padding may be specified.
+#%.TP
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
+#%.TP
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -247,18 +288,16 @@
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -277,20 +316,21 @@
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -309,18 +349,16 @@
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -383,6 +421,10 @@
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -445,6 +487,10 @@
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -476,7 +522,7 @@
 # the mapping:
 #
 #	box1[0]  = ACS_ULCORNER
-#	box1[1]  = ACS_HLINE	
+#	box1[1]  = ACS_HLINE
 #	box1[2]  = ACS_URCORNER
 #	box1[3]  = ACS_VLINE
 #	box1[4]  = ACS_LRCORNER
@@ -517,15 +563,15 @@
 font_5				font5	str	f5	-		-	----K	select font 5
 font_6				font6	str	f6	-		-	----K	select font 6
 font_7				font7	str	f7	-		-	----K	select font 7
-key_back_tab			kbtab	str	k0	-		-	----K	backtab key
+key_back_tab			kbtab	str	kO	-		-	----K	backtab key
 key_do				kdo	str	ki	-		-	----K	do request key
-key_command			kcmd	str	kd	-		-	----K	command-request key
+key_command			kcmd	str	@4	-		-	----K	command-request key
 key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
-key_end				kend	str	kw	KEY_END		0550	-----	end key
-key_help			khlp	str	kq	-		-	-----	help key
-key_newline			knl	str	nl	-		-	----K	newline key
+key_end				kend	str	@7	KEY_END		0550	-----	end key
+key_help			khlp	str	%1	-		-	-----	help key
+key_newline			knl	str	kn	-		-	----K	newline key
 key_next_pane			knpn	str	kv	-		-	----K	next-pane key
-key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
+key_prev_cmd			kpcmd	str	kp	-		-	----K	previous-command key
 key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
 key_quit			kquit	str	kQ	-		-	----K	quit key
 key_select_aix			ksel	str	kU	-		-	-----	select key
@@ -543,13 +589,13 @@
 key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
 key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
 appl_defined_str		apstr	str	za	-		-	----K	application-defined string
-key_smap_in6			kmpf6	str	kr	-		-	----K	special mapped key 6 input
+key_smap_in6			kmpf6	str	Kr	-		-	----K	special mapped key 6 input
 key_smap_out6			kmpt6	str	KR	-		-	----K	special mapped key 6 output
-key_smap_in7			kmpf7	str	ks	-		-	----K	special mapped key 7 input
+key_smap_in7			kmpf7	str	Ks	-		-	----K	special mapped key 7 input
 key_smap_out7			kmpt7	str	KS	-		-	----K	special mapped key 7 output
-key_smap_in8			kmpf8	str	kt	-		-	----K	special mapped key 8 input
+key_smap_in8			kmpf8	str	Kt	-		-	----K	special mapped key 8 input
 key_smap_out8			kmpt8	str	KT	-		-	----K	special mapped key 8 output
-key_smap_in9			kmpf9	str	ku	-		-	----K	special mapped key 9 input
+key_smap_in9			kmpf9	str	Ku	-		-	----K	special mapped key 9 input
 key_smap_out9			kmpt9	str	KU	-		-	----K	special mapped key 9 output
 key_sf1				ksf1	str	S1	-		-	----K	special function key 1
 key_sf2				ksf2	str	S2	-		-	----K	special function key 2
@@ -593,6 +639,10 @@
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -666,6 +716,10 @@
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -698,7 +752,7 @@
 req_for_input			rfi	str	RF	-		-	-----	send next input char (for ptys)
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -743,6 +797,10 @@
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -788,19 +846,20 @@
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -837,9 +896,8 @@
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -848,25 +906,25 @@
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
-enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
-enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
-enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
-enter_right_hl_mode		erhlm	str	Xr	-		-	-----	Enter right highlight mode
-enter_top_hl_mode		ethlm	str	Xt	-		-	-----	Enter top highlight mode
-enter_vertical_hl_mode		evhlm	str	Xv	-		-	-----	Enter vertical highlight mode
-set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
+#enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
+#enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
+#enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
+#enter_right_hl_mode		erhlm	str	Xr	-		-	-----	Enter right highlight mode
+#enter_top_hl_mode		ethlm	str	Xt	-		-	-----	Enter top highlight mode
+#enter_vertical_hl_mode		evhlm	str	Xv	-		-	-----	Enter vertical highlight mode
+#set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -928,7 +986,7 @@
 # GNU termcap *does* include the following extended capability,  Only the
 # now-obsolete Ann Arbor terminals used it.
 #
-# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region 
+# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region
 #
 # The following comments describe capnames so ancient that I believe no
 # software uses them any longer.  Some of these have to go because they
@@ -945,9 +1003,9 @@
 # comma-separated list of capabilities for which there are corresponding keys.
 # The `kn' code is accepted but ignored.
 #
-# The `ma' capability seems to have been designed to map between the rogue(2)
-# motion keys (including jkhl) and characters emitted by arrow keys on some
-# primitive pre-ANSI terminals.  It's so obsolete it's fossilized...
+# The `ma' capability was a 4.0BSD feature used by vi version 2.
+# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh.
+# Besides being obsolete, that interpretation conflicts with max_attributes.
 #
 # Here is a description of memory_lock_above and memory_unlock:
 # "You can 'freeze' data on the screen by turning on Memory Lock in a line of
@@ -973,14 +1031,14 @@
 # vertical_tab_delay		OTdV	num	dV	-		-	-B---	padding required for ^V
 number_of_function_keys		OTkn	num	kn	-		-	-B-G-	count of function keys
 other_non_function_keys		OTko	str	ko	-		-	-B-G-	list of self-mapped keycaps
-arrow_key_map			OTma	str	ma	-		-	YBC--	map arrow keys rogue(1) motion keys
+arrow_key_map			OTma	str	ma	-		-	YBC--	map motion-keys for vi version 2
 # memory_lock_above		OTml	str	ml	-		-	-B---	lock visible screen memory above the current line
 # memory_unlock			OTmu	str	mu	-		-	-B---	unlock visible screen memory above the current line
 has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
@@ -989,7 +1047,7 @@
 # University of Waterloo termcap extensions (as described in mytinfo).
 # The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
 # be resolved by a type check.  The descriptions are guesses from what was
-# in the mytinfo tables. 
+# in the mytinfo tables.
 #
 # key_interrupt_char		OTki	str	ki	-		-	-----	string set by interrupt key (?)
 # key_kill_char			OTkk	str	kk	-		-	-----	string set by kill key (?)
@@ -1038,7 +1096,7 @@
 # Gv	186 \272 M-:	double vertical line
 #
 # The compiler will translate the single-line caps and discard the others
-# (via IGNORE aliases further down).  We don't want to do normal pad 
+# (via IGNORE aliases further down).  We don't want to do normal pad
 # translation on these, they're often single-character printable ASCII
 # strings that happen to be numerics.  There's awk code in parametrized.sh
 # that detects the acs_ prefix and uses it to suppress pad translation.
@@ -1060,192 +1118,9 @@
 #
 # TERMINFO EXTENSION CAPABILITIES
 #
-# This section is almost all comments.  What it's mainly for is to describe
-# what capabilities need to be squeezed out to get down to the XSI Curses
-# standard set.  They are flagged with K.
-#
-# HP extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in HP
-# terminfo files.  Except for memory_lock and memory_unlock, they are
-# functionally identical to SVr4 extensions, but they make the binary format
-# different.  Grrr....
+# (see Caps-ncurses for the complete set of comments)
 #
 memory_lock			meml	str	ml	-		-	----K	lock memory above cursor
 memory_unlock			memu	str	mu	-		-	----K	unlock memory
-#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
-#label_on			smln	str	LO	-		-	-----	turn on soft labels
-#label_off			rmln	str	LF	-		-	-----	turn off soft labels
-#key_f11			kf11	str	F1	-		-	-----	F11 function key
-#key_f12			kf12	str	F2	-		-	-----	F12 function key
-#key_f13			kf13	str	F3	-		-	-----	F13 function key
-#key_f14			kf14	str	F4	-		-	-----	F14 function key
-#key_f15			kf15	str	F5	-		-	-----	F15 function key
-#key_f16			kf16	str	F6	-		-	-----	F16 function key
-#key_f17			kf17	str	F7	-		-	-----	F17 function key
-#key_f18			kf18	str	F8	-		-	-----	F18 function key
-#key_f19			kf19	str	F9	-		-	-----	F19 function key
-#key_f20			kf20	str	FA	-		-	-----	F20 function key
-#key_f21			kf21	str	FB	-		-	-----	F21 function key
-#key_f22			kf22	str	FC	-		-	-----	F22 function key
-#key_f23			kf23	str	FD	-		-	-----	F23 function key
-#key_f24			kf24	str	FE	-		-	-----	F24 function key
-#key_f25			kf25	str	FF	-		-	-----	F25 function key
-#key_f26			kf26	str	FG	-		-	-----	F26 function key
-#key_f27			kf27	str	FH	-		-	-----	F27 function key
-#key_f28			kf28	str	FI	-		-	-----	F28 function key
-#key_f29			kf29	str	FJ	-		-	-----	F29 function key
-#key_f30			kf30	str	FK	-		-	-----	F30 function key
-#key_f31			kf31	str	FL	-		-	-----	F31 function key
-#key_f32			kf32	str	FM	-		-	-----	F32 function key
-#key_f33			kf33	str	FN	-		-	-----	F33 function key
-#key_f34			kf34	str	FO	-		-	-----	F34 function key
-#key_f35			kf35	str	FP	-		-	-----	F35 function key
-#key_f36			kf36	str	FQ	-		-	-----	F36 function key
-#key_f37			kf37	str	FR	-		-	-----	F37 function key
-#key_f38			kf38	str	FS	-		-	-----	F38 function key
-#key_f39			kf39	str	FT	-		-	-----	F39 function key
-#key_f40			kf40	str	FU	-		-	-----	F40 function key
-#key_f41			kf41	str	FV	-		-	-----	F41 function key
-#key_f42			kf42	str	FW	-		-	-----	F42 function key
-#key_f43			kf43	str	FX	-		-	-----	F43 function key
-#key_f44			kf44	str	FY	-		-	-----	F44 function key
-#key_f45			kf45	str	FZ	-		-	-----	F45 function key
-#key_f46			kf46	str	Fa	-		-	-----	F46 function key
-#key_f47			kf47	str	Fb	-		-	-----	F47 function key
-#key_f48			kf48	str	Fc	-		-	-----	F48 function key
-#key_f49			kf49	str	Fd	-		-	-----	F49 function key
-#key_f50			kf50	str	Fe	-		-	-----	F50 function key
-#key_f51			kf51	str	Ff	-		-	-----	F51 function key
-#key_f52			kf52	str	Fg	-		-	-----	F52 function key
-#key_f53			kf53	str	Fh	-		-	-----	F53 function key
-#key_f54			kf54	str	Fi	-		-	-----	F54 function key
-#key_f55			kf55	str	Fj	-		-	-----	F55 function key
-#key_f56			kf56	str	Fk	-		-	-----	F56 function key
-#key_f57			kf57	str	Fl	-		-	-----	F57 function key
-#key_f58			kf58	str	Fm	-		-	-----	F58 function key
-#key_f59			kf59	str	Fn	-		-	-----	F59 function key
-#key_f60			kf60	str	Fo	-		-	-----	F60 function key
-#key_f61			kf61	str	Fp	-		-	-----	F61 function key
-#key_f62			kf62	str	Fq	-		-	-----	F62 function key
-#key_f63			kf63	str	Fr	-		-	-----	F63 function key
-#
-#############################################################################
-#
-# ALIAS DECLARATIONS
-#
-# Here we set up aliases for translating extensions into standard terminfo.
-#
-#---------------------------------- Termcap aliases -------------------------
-#
-# BSD aliases:
-#
-# This is a common error in many termcap files.  We'll get notified during
-# translation when this (or any other alias) fires.
-#
-capalias	sb	sr	BSD	scroll text down
-#
-# AT&T extensions:
-#
-# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
-# nonstandard capabilities.  Its signature is the KM capability, used to name
-# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
-# set.  Comments in the original, and a little cross-checking with other AT&T
-# documentation, seem to establish the following mappings:
-#
-capalias	BO	mr	AT&T	enter_reverse_mode
-capalias	CI	vi	AT&T	cursor_invisible
-capalias	CV	ve	AT&T	cursor_normal
-capalias	DS	mh	AT&T	enter_dim_mode
-#capalias	EE	me	AT&T	exit_attribute_mode	
-capalias	FE	LF	AT&T	label_on
-capalias	FL	LO	AT&T	label_off
-capalias	XS	mk	AT&T	enter_secure_mode
-#
-# We comment out EE because the conflicting XENIX EE is more common in 
-# old entries.
-#
-# XENIX extensions:
-#
-# These are the ones we know how to translate directly:
-#
-capalias	EE	mh	XENIX	exit_attribute_mode	
-capalias	GE	ae	XENIX	exit_alt_charset_mode
-capalias	GS	as	XENIX	enter_alt_charset_mode
-capalias	CF	vi	XENIX	cursor_invis
-capalias	CO	ve	XENIX	cursor_normal
-capalias	EN	@7	XENIX	key_end
-capalias	HM	kh	XENIX	key_home
-capalias	LD	kL	XENIX	key_dl
-capalias	PD	kN	XENIX	key_npage
-capalias	PN	po	XENIX	prtr_off
-capalias	PS	pf	XENIX	prtr_on
-capalias	PU	kP	XENIX	key_ppage
-capalias	RT	@8	XENIX	kent
-capalias	UP	ku	XENIX	kcuu1
-capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
-capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
-capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
-capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
-capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
-capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
-capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
-capalias	Gd	IGNORE	XENIX	double ACS_TTEE
-capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
-capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
-capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
-capalias	GG	IGNORE	XENIX	acs-glitch
-#
-# IBM extensions:
-#
-capalias	kq	%1	IBM	key_help
-#
-# Iris extensions:
-#
-capalias	HS	mh	IRIS	enter_dim_mode
-#
-# Tektronix extensions:
-#
-capalias	KA	k;	Tek	key_f10
-capalias	KB	F1	Tek	key_f11
-capalias	KC	F2	Tek	key_f12
-capalias	KD	F3	Tek	key_f13
-capalias	KE	F4	Tek	key_f14
-capalias	KF	F5	Tek	key_f15
-capalias	BC	Sb	Tek	set_background
-capalias	FC	Sf	Tek	set_foreground
-#
-# There are also the following:
-#
-#	XENIX	XENIX variable name	name clash with terminfo?
-#	-----	-------------------	-------------------------
-#	CL	key_char_left
-#	CR	key_char_right
-#	CW	key_change_window
-#	HP	??
-#	LF	key_linefeed 		label_off
-#	NU	key_next_unlocked_cell
-#	PL	??
-#	PR	??
-#	RC	key_recalc		remove_clock
-#	RF	key_toggle_ref		req_for_input
-#	WL	key_word_left
-#	WR	key_word_right
-#
-# If you know what any of the question-marked ones mean, please tell us.
-#
-#--------------------------------- Terminfo aliases ------------------------
-#
-# IBM extensions:
-#
-infoalias	font0	s0ds	IBM	set0_des_seq
-infoalias	font1	s1ds	IBM	set1_des_seq
-infoalias	font2	s2ds	IBM	set2_des_seq
-infoalias	font3	s3ds	IBM	set3_des_seq
-infoalias	kbtab	kcbt	IBM	key_backtab
-infoalias	ksel	kslt	IBM	key_select
-#
-# Some others are identical to SVr4/XPG4 capabilities, in particular:
-# kcmd, kend, khlp, and kf11...kf63.
 #
 #############################################################################
diff --git a/include/Caps.hpux11 b/include/Caps.hpux11
index 512aa82..723556f 100644
--- a/include/Caps.hpux11
+++ b/include/Caps.hpux11
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2002-2011,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
+# Copyright 2002-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -28,13 +29,13 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.hpux11,v 1.7 2015/04/26 15:25:55 tom Exp $
+# $Id: Caps.hpux11,v 1.26 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with HPUX 11.x's terminfo.
 #
 # This table is used to generate initializers for tables that drive tic,
-# infocmp, and the library compilation code used to support the termcap 
+# infocmp, and the library compilation code used to support the termcap
 # compatibility hack.  It is also used to generate the tabular portion of the
 # terminfo(5) man page; lines beginning with `#%' are passed through to become
 # the terminfo table.
@@ -47,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -57,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -97,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -107,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -119,14 +120,14 @@
 # You'll need to write custom code, probably in postprocess_termcap() or
 # postprocess_terminfo(), to handle the translation.
 #
-# CONTROLLING ENTRY LENGTH 
+# CONTROLLING ENTRY LENGTH
 #
 # Notes on specific elisions made to fit translations within 1023 bytes:
 #
 # Machines with IBM PC-like keyboards want to be able to define the following
 # keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap-
 # only environments for End or Home-Down), key_dc, and key_ic.  This is also
-# the set of keys the `joe' editor will be upset if it can't see.  So don't 
+# the set of keys the `joe' editor will be upset if it can't see.  So don't
 # trim those out of the set to be translated to termcap, or various users of
 # the termcap file will become irate.
 #
@@ -147,68 +148,108 @@
 #
 # It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap
 # translations go back over critical if we do this.  As 4.4BSD curses fades
-# into history and GNU termcap's application base shrinks towards being GNU 
+# into history and GNU termcap's application base shrinks towards being GNU
 # Emacs only, we'll probably elide out some BSD-only capabilities in order
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses 
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
-#%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed through tparm with
-#%parms as given (#\fIi\fP).
-#%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
-#%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%The description field employs a handful of notations.
+#%.TP
+#%.B (P)
+#%indicates that padding may be specified.
+#%.TP
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
+#%.TP
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -230,7 +271,7 @@
 tilde_glitch			hz	bool	hz	-	-	YB-GE	cannot print ~'s (Hazeltine)
 transparent_underline		ul	bool	ul	-	-	YBCGE	underline character overstrikes
 xon_xoff			xon	bool	xo	-	-	YB---	terminal uses xon/xoff handshaking
-# end booleans for HPUX 9, 10 (non-color curses)
+# end Booleans for HPUX 9, 10 (non-color curses)
 needs_xon_xoff			nxon	bool	nx	-	-	-----	padding will not work, xon/xoff required
 prtr_silent			mc5i	bool	5i	-	-	-----	printer will not echo on screen
 hard_cursor			chts	bool	HC	-	-	-----	cursor is hard to see
@@ -248,18 +289,16 @@
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -279,26 +318,27 @@
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
 max_micro_address		maddr	num	Yd	-	-	-----	maximum value in micro_..._address
 max_micro_jump			mjump	num	Ye	-	-	-----	maximum value in parm_..._micro
-micro_col_size			mcs	num	Yf	-	-	-----	character step size when in micro mode
+micro_char_size			mcs	num	Yf	-	-	-----	character step size when in micro mode
 micro_line_size			mls	num	Yg	-	-	-----	line step size when in micro mode
 number_of_pins			npins	num	Yh	-	-	-----	numbers of pins in print-head
 output_res_char			orc	num	Yi	-	-	-----	horizontal resolution in units per line
@@ -311,18 +351,16 @@
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -385,6 +423,10 @@
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -447,6 +489,10 @@
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -512,6 +558,10 @@
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -572,6 +622,10 @@
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -604,7 +658,7 @@
 req_for_input			rfi	str	RF	-		-	-----	send next input char (for ptys)
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -649,6 +703,10 @@
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -694,19 +752,20 @@
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -743,9 +802,8 @@
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -754,31 +812,33 @@
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%AIX and Solaris do not provide termcap names for these; HPUX does.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
-enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
-enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
-enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
-enter_right_hl_mode		erhlm	str	Xr	-		-	-----	Enter right highlight mode
-enter_top_hl_mode		ethlm	str	Xt	-		-	-----	Enter top highlight mode
-enter_vertical_hl_mode		evhlm	str	Xv	-		-	-----	Enter vertical highlight mode
-set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
-exit_horizontal_hl_mode 	rhhlm	str	XH	-		-	----K	Exit horizontal highlight mode
-exit_left_hl_mode 		rlhlm	str	XL	-		-	----K	Exit left highlight mode
-exit_low_hl_mode 		rlohlm	str	XO	-		-	----K	Exit low highlight mode
-exit_right_hl_mode 		rrhlm	str	XR	-		-	----K	Exit right highlight mode
-exit_top_hl_mode 		rthlm	str	XT	-		-	----K	Exit top highlight mode
-exit_vertical_hl_mode 		rvhlm	str	XV	-		-	----K	Exit vertical highlight mode
+enter_horizontal_hl_mode	ehhlm	str	Q1	-		-	-----	Enter horizontal highlight mode
+enter_left_hl_mode		elhlm	str	Q2	-		-	-----	Enter left highlight mode
+enter_low_hl_mode		elohlm	str	Q3	-		-	-----	Enter low highlight mode
+enter_right_hl_mode		erhlm	str	Q4	-		-	-----	Enter right highlight mode
+enter_top_hl_mode		ethlm	str	Q5	-		-	-----	Enter top highlight mode
+enter_vertical_hl_mode		evhlm	str	Q6	-		-	-----	Enter vertical highlight mode
+set_a_attributes		sgr1	str	Q7	-		-	-----	Define second set of video attributes #1-#6
+exit_horizontal_hl_mode 	rmhhlm	str	Q8	-		-	----K	Exit horizontal highlight mode
+exit_left_hl_mode 		rmlhlm	str	Q9	-		-	----K	Exit left highlight mode
+exit_low_hl_mode 		rmlohlm	str	Qa	-		-	----K	Exit low highlight mode
+exit_right_hl_mode 		rmrhlm	str	Qb	-		-	----K	Exit right highlight mode
+exit_top_hl_mode 		rmthlm	str	Qc	-		-	----K	Exit top highlight mode
+exit_vertical_hl_mode 		rmvhlm	str	Qd	-		-	----K	Exit vertical highlight mode
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -840,7 +900,7 @@
 # GNU termcap *does* include the following extended capability,  Only the
 # now-obsolete Ann Arbor terminals used it.
 #
-# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region 
+# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region
 #
 # The following comments describe capnames so ancient that I believe no
 # software uses them any longer.  Some of these have to go because they
@@ -857,9 +917,9 @@
 # comma-separated list of capabilities for which there are corresponding keys.
 # The `kn' code is accepted but ignored.
 #
-# The `ma' capability seems to have been designed to map between the rogue(2)
-# motion keys (including jkhl) and characters emitted by arrow keys on some
-# primitive pre-ANSI terminals.  It's so obsolete it's fossilized...
+# The `ma' capability was a 4.0BSD feature used by vi version 2.
+# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh.
+# Besides being obsolete, that interpretation conflicts with max_attributes.
 #
 # Here is a description of memory_lock_above and memory_unlock:
 # "You can 'freeze' data on the screen by turning on Memory Lock in a line of
@@ -885,14 +945,14 @@
 # vertical_tab_delay		OTdV	num	dV	-		-	-B---	padding required for ^V
 number_of_function_keys		OTkn	num	kn	-		-	-B-G-	count of function keys
 other_non_function_keys		OTko	str	ko	-		-	-B-G-	list of self-mapped keycaps
-arrow_key_map			OTma	str	ma	-		-	YBC--	map arrow keys rogue(1) motion keys
+arrow_key_map			OTma	str	ma	-		-	YBC--	map motion-keys for vi version 2
 # memory_lock_above		OTml	str	ml	-		-	-B---	lock visible screen memory above the current line
 # memory_unlock			OTmu	str	mu	-		-	-B---	unlock visible screen memory above the current line
 has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
@@ -901,7 +961,7 @@
 # University of Waterloo termcap extensions (as described in mytinfo).
 # The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
 # be resolved by a type check.  The descriptions are guesses from what was
-# in the mytinfo tables. 
+# in the mytinfo tables.
 #
 # key_interrupt_char		OTki	str	ki	-		-	-----	string set by interrupt key (?)
 # key_kill_char			OTkk	str	kk	-		-	-----	string set by kill key (?)
@@ -950,7 +1010,7 @@
 # Gv	186 \272 M-:	double vertical line
 #
 # The compiler will translate the single-line caps and discard the others
-# (via IGNORE aliases further down).  We don't want to do normal pad 
+# (via IGNORE aliases further down).  We don't want to do normal pad
 # translation on these, they're often single-character printable ASCII
 # strings that happen to be numerics.  There's awk code in parametrized.sh
 # that detects the acs_ prefix and uses it to suppress pad translation.
@@ -972,303 +1032,8 @@
 #
 # TERMINFO EXTENSION CAPABILITIES
 #
-# This section is almost all comments.  What it's mainly for is to describe
-# what capabilities need to be squeezed out to get down to the XSI Curses
-# standard set.  They are flagged with K.
-#
-# HP extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in HP
-# terminfo files.  Except for memory_lock and memory_unlock, they are
-# functionally identical to SVr4 extensions, but they make the binary format
-# different.  Grrr....
-#
-#memory_lock			meml	str	ml	-		-	----K	memory lock above
-#memory_unlock			memu	str	mu	-		-	----K	memory unlock
-#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
-#label_on			smln	str	LO	-		-	-----	turn on soft labels
-#label_off			rmln	str	LF	-		-	-----	turn off soft labels
-#key_f11			kf11	str	F1	-		-	-----	F11 function key
-#key_f12			kf12	str	F2	-		-	-----	F12 function key
-#key_f13			kf13	str	F3	-		-	-----	F13 function key
-#key_f14			kf14	str	F4	-		-	-----	F14 function key
-#key_f15			kf15	str	F5	-		-	-----	F15 function key
-#key_f16			kf16	str	F6	-		-	-----	F16 function key
-#key_f17			kf17	str	F7	-		-	-----	F17 function key
-#key_f18			kf18	str	F8	-		-	-----	F18 function key
-#key_f19			kf19	str	F9	-		-	-----	F19 function key
-#key_f20			kf20	str	FA	-		-	-----	F20 function key
-#key_f21			kf21	str	FB	-		-	-----	F21 function key
-#key_f22			kf22	str	FC	-		-	-----	F22 function key
-#key_f23			kf23	str	FD	-		-	-----	F23 function key
-#key_f24			kf24	str	FE	-		-	-----	F24 function key
-#key_f25			kf25	str	FF	-		-	-----	F25 function key
-#key_f26			kf26	str	FG	-		-	-----	F26 function key
-#key_f27			kf27	str	FH	-		-	-----	F27 function key
-#key_f28			kf28	str	FI	-		-	-----	F28 function key
-#key_f29			kf29	str	FJ	-		-	-----	F29 function key
-#key_f30			kf30	str	FK	-		-	-----	F30 function key
-#key_f31			kf31	str	FL	-		-	-----	F31 function key
-#key_f32			kf32	str	FM	-		-	-----	F32 function key
-#key_f33			kf33	str	FN	-		-	-----	F33 function key
-#key_f34			kf34	str	FO	-		-	-----	F34 function key
-#key_f35			kf35	str	FP	-		-	-----	F35 function key
-#key_f36			kf36	str	FQ	-		-	-----	F36 function key
-#key_f37			kf37	str	FR	-		-	-----	F37 function key
-#key_f38			kf38	str	FS	-		-	-----	F38 function key
-#key_f39			kf39	str	FT	-		-	-----	F39 function key
-#key_f40			kf40	str	FU	-		-	-----	F40 function key
-#key_f41			kf41	str	FV	-		-	-----	F41 function key
-#key_f42			kf42	str	FW	-		-	-----	F42 function key
-#key_f43			kf43	str	FX	-		-	-----	F43 function key
-#key_f44			kf44	str	FY	-		-	-----	F44 function key
-#key_f45			kf45	str	FZ	-		-	-----	F45 function key
-#key_f46			kf46	str	Fa	-		-	-----	F46 function key
-#key_f47			kf47	str	Fb	-		-	-----	F47 function key
-#key_f48			kf48	str	Fc	-		-	-----	F48 function key
-#key_f49			kf49	str	Fd	-		-	-----	F49 function key
-#key_f50			kf50	str	Fe	-		-	-----	F50 function key
-#key_f51			kf51	str	Ff	-		-	-----	F51 function key
-#key_f52			kf52	str	Fg	-		-	-----	F52 function key
-#key_f53			kf53	str	Fh	-		-	-----	F53 function key
-#key_f54			kf54	str	Fi	-		-	-----	F54 function key
-#key_f55			kf55	str	Fj	-		-	-----	F55 function key
-#key_f56			kf56	str	Fk	-		-	-----	F56 function key
-#key_f57			kf57	str	Fl	-		-	-----	F57 function key
-#key_f58			kf58	str	Fm	-		-	-----	F58 function key
-#key_f59			kf59	str	Fn	-		-	-----	F59 function key
-#key_f60			kf60	str	Fo	-		-	-----	F60 function key
-#key_f61			kf61	str	Fp	-		-	-----	F61 function key
-#key_f62			kf62	str	Fq	-		-	-----	F62 function key
-#key_f63			kf63	str	Fr	-		-	-----	F63 function key
-#
-# IBM extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in IBM
-# terminfo files.
-#
-# The places in the box[12] capabilities correspond to acsc characters, here is
-# the mapping:
-#
-#	box1[0]  = ACS_ULCORNER
-#	box1[1]  = ACS_HLINE	
-#	box1[2]  = ACS_URCORNER
-#	box1[3]  = ACS_VLINE
-#	box1[4]  = ACS_LRCORNER
-#	box1[5]  = ACS_LLCORNER
-#	box1[6]  = ACS_TTEE
-#	box1[7]  = ACS_RTEE
-#	box1[8]  = ACS_BTEE
-#	box1[9]  = ACS_LTEE
-#	box1[10] = ACS_PLUS
-#
-# The box2 characters are the double-line versions of these forms graphics.
+# (see Caps-ncurses for the complete set of comments)
 #
 box_chars_1			box1	str	bx	-		-	----K	box characters primary set
-#box_chars_2			box2	str	by	-		-	----K	box characters secondary set
-#box_attr_1			batt1	str	Bx	-		-	----K	attributes for box1
-#box_attr_2			batt2	str	By	-		-	----K	attributes for box2
-#color_bg_0			colb0	str	d0	-		-	----K	background color 0
-#color_bg_1			colb1	str	d1	-		-	----K	background color 1
-#color_bg_2			colb2	str	d2	-		-	----K	background color 2
-#color_bg_3			colb3	str	d3	-		-	----K	background color 3
-#color_bg_4			colb4	str	d4	-		-	----K	background color 4
-#color_bg_5			colb5	str	d5	-		-	----K	background color 5
-#color_bg_6			colb6	str	d6	-		-	----K	background color 6
-#color_bg_7			colb7	str	d7	-		-	----K	background color 7
-#color_fg_0			colf0	str	c0	-		-	----K	foreground color 0
-#color_fg_1			colf1	str	c1	-		-	----K	foreground color 1
-#color_fg_2			colf2	str	c2	-		-	----K	foreground color 2
-#color_fg_3			colf3	str	c3	-		-	----K	foreground color 3
-#color_fg_4			colf4	str	c4	-		-	----K	foreground color 4
-#color_fg_5			colf5	str	c5	-		-	----K	foreground color 5
-#color_fg_6			colf6	str	c6	-		-	----K	foreground color 6
-#color_fg_7			colf7	str	c7	-		-	----K	foreground color 7
-#font_0				font0	str	f0	-		-	-----	select font 0
-#font_1				font1	str	f1	-		-	-----	select font 1
-#font_2				font2	str	f2	-		-	-----	select font 2
-#font_3				font3	str	f3	-		-	-----	select font 3
-#font_4				font4	str	f4	-		-	----K	select font 4
-#font_5				font5	str	f5	-		-	----K	select font 5
-#font_6				font6	str	f6	-		-	----K	select font 6
-#font_7				font7	str	f7	-		-	----K	select font 7
-#key_back_tab			kbtab	str	k0	-		-	-----	backtab key
-#key_do				kdo	str	ki	-		-	----K	do request key
-#key_command			kcmd	str	kd	-		-	----K	command-request key
-#key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
-#key_end			kend	str	kw	-		-	-----	end key
-#key_help			khlp	str	kq	-		-	-----	help key
-#key_newline			knl	str	nl	-		-	----K	newline key
-#key_next_pane			knpn	str	kv	-		-	----K	next-pane key
-#key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
-#key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
-#key_quit			kquit	str	kQ	-		-	----K	quit key
-#key_select			ksel	str	kU	-		-	-----	select key
-#key_scroll_left		kscl	str	kz	-		-	----K	scroll left
-#key_scroll_right		kscr	str	kZ	-		-	----K	scroll right
-#key_tab			ktab	str	ko	-		-	----K	tab key
-#key_smap_in1			kmpf1	str	Kv	-		-	----K	special mapped key 1 input
-#key_smap_out1			kmpt1	str	KV	-		-	----K	special mapped key 1 output
-#key_smap_in2			kmpf2	str	Kw	-		-	----K	special mapped key 2 input
-#key_smap_out2			kmpt2	str	KW	-		-	----K	special mapped key 2 output
-#key_smap_in3			kmpf3	str	Kx	-		-	----K	special mapped key 3 input
-#key_smap_out3			kmpt3	str	KX	-		-	----K	special mapped key 3 output
-#key_smap_in4			kmpf4	str	Ky	-		-	----K	special mapped key 4 input
-#key_smap_out4			kmpt4	str	KY	-		-	----K	special mapped key 4 output
-#key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
-#key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
-#appl_defined_str		apstr	str	za	-		-	----K	application-defined string
-# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
-# the IBM manual pages, so the cap name strings are guesses.  The terminfo
-# names are almost certainly right, the termcap ones almost certainly wrong.
-#key_smap_in6			kmpf6	str	k!	-		-	----K	special mapped key 6 input
-#key_smap_out6			kmpt6	str	K@	-		-	----K	special mapped key 6 output
-#key_smap_in7			kmpf7	str	k#	-		-	----K	special mapped key 7 input
-#key_smap_out7			kmpt7	str	K$	-		-	----K	special mapped key 7 output
-#key_smap_in8			kmpf8	str	k%	-		-	----K	special mapped key 8 input
-#key_smap_out8			kmpt8	str	K^	-		-	----K	special mapped key 8 output
-#key_smap_in9			kmpf9	str	k&	-		-	----K	special mapped key 9 input
-#key_smap_out9			kmpt9	str	K*	-		-	----K	special mapped key 9 output
-# Undocumented capabilities end here
-#key_sf1			ksf1	str	S1	-		-	----K	special function key 1
-#key_sf2			ksf2	str	S2	-		-	----K	special function key 2
-#key_sf3			ksf3	str	S3	-		-	----K	special function key 3
-#key_sf4			ksf4	str	S4	-		-	----K	special function key 4
-#key_sf5			ksf5	str	S5	-		-	----K	special function key 5
-#key_sf6			ksf6	str	S6	-		-	----K	special function key 6
-#key_sf7			ksf7	str	S7	-		-	----K	special function key 7
-#key_sf8			ksf8	str	S8	-		-	----K	special function key 8
-#key_sf9			ksf9	str	S9	-		-	----K	special function key 9
-#key_sf10			ksf10	str	SA	-		-	----K	special function key 10
-# AIX version 3 documents different codes for F11, F12 and does not mention
-# F13-F64.  AIX version 4 uses the same naming for F0-F63 as above.
-#key_f11			kf11	str	k<	-		-	-----	function key 11
-#key_f12			kf12	str	k>	-		-	-----	function key 12
-# Undocumented capabilities end here.
-#key_action			kact	str	kJ	-		-	----K	sent by action key
-# The IBM docs say these capabilities are for table-drawing, and are
-# valid only for aixterm descriptions.
-#enter_topline_mode		topl	str	tp	-		-	----K	start top-line mode
-#enter_bottom_mode		btml	str	bm	-		-	----K	start bottom-line mode
-#enter_rvert_mode		rvert	str	rv	-		-	----K	start right-vertical mode
-#enter_lvert_mode		lvert	str	lv	-		-	----K	start left-vertical mode
-#
-#############################################################################
-#
-# ALIAS DECLARATIONS
-#
-# Here we set up aliases for translating extensions into standard terminfo.
-#
-#---------------------------------- Termcap aliases -------------------------
-#
-# BSD aliases:
-#
-# This is a common error in many termcap files.  We'll get notified during
-# translation when this (or any other alias) fires.
-#
-capalias	sb	sr	BSD	scroll text down
-#
-# AT&T extensions:
-#
-# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
-# nonstandard capabilities.  Its signature is the KM capability, used to name
-# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
-# set.  Comments in the original, and a little cross-checking with other AT&T
-# documentation, seem to establish the following mappings:
-#
-capalias	BO	mr	AT&T	enter_reverse_mode
-capalias	CI	vi	AT&T	cursor_invisible
-capalias	CV	ve	AT&T	cursor_normal
-capalias	DS	mh	AT&T	enter_dim_mode
-#capalias	EE	me	AT&T	exit_attribute_mode	
-capalias	FE	LF	AT&T	label_on
-capalias	FL	LO	AT&T	label_off
-capalias	XS	mk	AT&T	enter_secure_mode
-#
-# We comment out EE because the conflicting XENIX EE is more common in 
-# old entries.
-#
-# XENIX extensions:
-#
-# These are the ones we know how to translate directly:
-#
-capalias	EE	mh	XENIX	exit_attribute_mode	
-capalias	GE	ae	XENIX	exit_alt_charset_mode
-capalias	GS	as	XENIX	enter_alt_charset_mode
-capalias	CF	vi	XENIX	cursor_invis
-capalias	CO	ve	XENIX	cursor_normal
-capalias	EN	@7	XENIX	key_end
-capalias	HM	kh	XENIX	key_home
-capalias	LD	kL	XENIX	key_dl
-capalias	PD	kN	XENIX	key_npage
-capalias	PN	po	XENIX	prtr_off
-capalias	PS	pf	XENIX	prtr_on
-capalias	PU	kP	XENIX	key_ppage
-capalias	RT	@8	XENIX	kent
-capalias	UP	ku	XENIX	kcuu1
-capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
-capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
-capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
-capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
-capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
-capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
-capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
-capalias	Gd	IGNORE	XENIX	double ACS_TTEE
-capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
-capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
-capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
-capalias	GG	IGNORE	XENIX	acs-glitch
-#
-# IBM extensions:
-#
-capalias	kq	%1	IBM	key_help
-#
-# Iris extensions:
-#
-capalias	HS	mh	IRIS	enter_dim_mode
-#
-# Tektronix extensions:
-#
-capalias	KA	k;	Tek	key_f10
-capalias	KB	F1	Tek	key_f11
-capalias	KC	F2	Tek	key_f12
-capalias	KD	F3	Tek	key_f13
-capalias	KE	F4	Tek	key_f14
-capalias	KF	F5	Tek	key_f15
-capalias	BC	Sb	Tek	set_background
-capalias	FC	Sf	Tek	set_foreground
-#
-# There are also the following:
-#
-#	XENIX	XENIX variable name	name clash with terminfo?
-#	-----	-------------------	-------------------------
-#	CL	key_char_left
-#	CR	key_char_right
-#	CW	key_change_window
-#	HP	??
-#	LF	key_linefeed 		label_off
-#	NU	key_next_unlocked_cell
-#	PL	??
-#	PR	??
-#	RC	key_recalc		remove_clock
-#	RF	key_toggle_ref		req_for_input
-#	WL	key_word_left
-#	WR	key_word_right
-#
-# If you know what any of the question-marked ones mean, please tell us.
-#
-#--------------------------------- Terminfo aliases ------------------------
-#
-# IBM extensions:
-#
-infoalias	font0	s0ds	IBM	set0_des_seq
-infoalias	font1	s1ds	IBM	set1_des_seq
-infoalias	font2	s2ds	IBM	set2_des_seq
-infoalias	font3	s3ds	IBM	set3_des_seq
-infoalias	kbtab	kcbt	IBM	key_backtab
-infoalias	ksel	kslt	IBM	key_select
-#
-# Some others are identical to SVr4/XPG4 capabilities, in particular:
-# kcmd, kend, khlp, and kf11...kf63.
 #
 #############################################################################
diff --git a/include/Caps.keys b/include/Caps.keys
index ebf392b..6f8a84e 100644
--- a/include/Caps.keys
+++ b/include/Caps.keys
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2001-2013,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
+# Copyright 2001-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -29,14 +30,14 @@
 # Author: Thomas Dickey
 #    and: Ilya Zakharevich
 #
-# $Id: Caps.keys,v 1.8 2015/04/26 15:25:55 tom Exp $
+# $Id: Caps.keys,v 1.25 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is illustrates an experimental extension to describe alt-, shift- and
 # control-modifiers applied to function and normal keys, as done on IBM pc's.
 #
 # This table is used to generate initializers for tables that drive tic,
-# infocmp, and the library compilation code used to support the termcap 
+# infocmp, and the library compilation code used to support the termcap
 # compatibility hack.  It is also used to generate the tabular portion of the
 # terminfo(5) man page; lines beginning with `#%' are passed through to become
 # the terminfo table.
@@ -49,7 +50,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -59,7 +60,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -99,8 +100,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -109,7 +110,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -121,14 +122,14 @@
 # You'll need to write custom code, probably in postprocess_termcap() or
 # postprocess_terminfo(), to handle the translation.
 #
-# CONTROLLING ENTRY LENGTH 
+# CONTROLLING ENTRY LENGTH
 #
 # Notes on specific elisions made to fit translations within 1023 bytes:
 #
 # Machines with IBM PC-like keyboards want to be able to define the following
 # keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap-
 # only environments for End or Home-Down), key_dc, and key_ic.  This is also
-# the set of keys the `joe' editor will be upset if it can't see.  So don't 
+# the set of keys the `joe' editor will be upset if it can't see.  So don't
 # trim those out of the set to be translated to termcap, or various users of
 # the termcap file will become irate.
 #
@@ -149,68 +150,109 @@
 #
 # It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap
 # translations go back over critical if we do this.  As 4.4BSD curses fades
-# into history and GNU termcap's application base shrinks towards being GNU 
+# into history and GNU termcap's application base shrinks towards being GNU
 # Emacs only, we'll probably elide out some BSD-only capabilities in order
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo codes are "setcolor", "kcdelete",
+# "kcinsert", "kadelete", and "kcinsert" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses 
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
-#%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed through tparm with
-#%parms as given (#\fIi\fP).
-#%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
-#%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%The description field employs a handful of notations.
+#%.TP
+#%.B (P)
+#%indicates that padding may be specified.
+#%.TP
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
+#%.TP
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -249,18 +291,16 @@
 cpi_changes_res			cpix	bool	YF	-	-	-----	changing character pitch changes resolution
 lpi_changes_res			lpix	bool	YG	-	-	-----	changing line pitch changes resolution
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -279,20 +319,21 @@
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%but are not yet documented in the man page.
+#%They came in with SVr4's printer support.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 buffer_capacity			bufsz	num	Ya	-	-	-----	numbers of bytes buffered before printing
 dot_vert_spacing		spinv	num	Yb	-	-	-----	spacing of pins vertically in pins per inch
 dot_horz_spacing		spinh	num	Yc	-	-	-----	spacing of dots horizontally in dots per inch
@@ -311,18 +352,16 @@
 bit_image_entwining		bitwin	num	Yo	-	-	-----	number of passes for each bit-image row
 bit_image_type			bitype	num	Yp	-	-	-----	type of bit-image device
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -385,6 +424,10 @@
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -447,6 +490,10 @@
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -513,6 +560,10 @@
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -575,6 +626,10 @@
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -598,7 +653,7 @@
 key_f63				kf63	str	Fr	KEY_F(63)	-	----E	F63 function key
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 label_format			fln	str	Lf	-		-	-----	label format
 set_clock			sclk	str	SC	-		-	-----	set clock, #1 hrs #2 mins #3 secs
@@ -731,6 +786,10 @@
 change_res_vert			cvr	str	ZD	-		-	-----	Change vertical resolution to #1
 define_char			defc	str	ZE	-		-	-----	Define a character #1, #2 dots wide, descender #3
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -776,19 +835,20 @@
 these_cause_cr			docr	str	Zw	-		-	-----	Printing any of these characters causes CR
 zero_motion			zerom	str	Zx	-		-	-----	No motion for subsequent character
 #%.TE
-#%.ad
-#%
+#%.PP
+#%.
 #%The following string capabilities are present in the SVr4.0 term structure,
 #%but were originally not documented in the man page.
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw18.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 char_set_names			csnm	str	Zy	-		-	-----	Produce #1'th item from list of character set names
 key_mouse			kmous	str	Km	KEY_MOUSE	0631	-----	Mouse event has occurred
 mouse_info			minfo	str	Mi	-		-	-----	Mouse status information
@@ -825,9 +885,8 @@
 scancode_escape			scesc	str	S7	-		-	-----	Escape for scancode emulation
 alt_scancode_esc		scesa	str	S8	-		-	-----	Alternate escape for scancode emulation
 #%.TE
-#%.ad
-#%
-#%.in .8i
+#%.PP
+#%.
 #%The XSI Curses standard added these hardcopy capabilities.
 #%They were used in some post-4.1 versions of System V curses,
 #%e.g., Solaris 2.5 and IRIX 6.x.
@@ -836,15 +895,16 @@
 #%If your compiled terminfo entries use these,
 #%they may not be binary-compatible with System V terminfo
 #%entries after SVr4.1; beware!
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 enter_horizontal_hl_mode	ehhlm	str	Xh	-		-	-----	Enter horizontal highlight mode
 enter_left_hl_mode		elhlm	str	Xl	-		-	-----	Enter left highlight mode
 enter_low_hl_mode		elohlm	str	Xo	-		-	-----	Enter low highlight mode
@@ -854,7 +914,6 @@
 set_a_attributes		sgr1	str	sA	-		-	-----	Define second set of video attributes #1-#6
 set_pglen_inch			slength	str	YI	-		-	-----	Set page length to #1 hundredth of an inch (some implementations use sL for termcap).
 #%.TE
-#%.ad
 #
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -916,7 +975,7 @@
 # GNU termcap *does* include the following extended capability,  Only the
 # now-obsolete Ann Arbor terminals used it.
 #
-# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region 
+# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region
 #
 # The following comments describe capnames so ancient that I believe no
 # software uses them any longer.  Some of these have to go because they
@@ -933,9 +992,9 @@
 # comma-separated list of capabilities for which there are corresponding keys.
 # The `kn' code is accepted but ignored.
 #
-# The `ma' capability seems to have been designed to map between the rogue(2)
-# motion keys (including jkhl) and characters emitted by arrow keys on some
-# primitive pre-ANSI terminals.  It's so obsolete it's fossilized...
+# The `ma' capability was a 4.0BSD feature used by vi version 2.
+# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh.
+# Besides being obsolete, that interpretation conflicts with max_attributes.
 #
 # Here is a description of memory_lock_above and memory_unlock:
 # "You can 'freeze' data on the screen by turning on Memory Lock in a line of
@@ -961,14 +1020,14 @@
 # vertical_tab_delay		OTdV	num	dV	-		-	-B---	padding required for ^V
 number_of_function_keys		OTkn	num	kn	-		-	-B-G-	count of function keys
 other_non_function_keys		OTko	str	ko	-		-	-B-G-	list of self-mapped keycaps
-arrow_key_map			OTma	str	ma	-		-	YBC--	map arrow keys rogue(1) motion keys
+arrow_key_map			OTma	str	ma	-		-	YBC--	map motion-keys for vi version 2
 # memory_lock_above		OTml	str	ml	-		-	-B---	lock visible screen memory above the current line
 # memory_unlock			OTmu	str	mu	-		-	-B---	unlock visible screen memory above the current line
 has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
@@ -977,7 +1036,7 @@
 # University of Waterloo termcap extensions (as described in mytinfo).
 # The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
 # be resolved by a type check.  The descriptions are guesses from what was
-# in the mytinfo tables. 
+# in the mytinfo tables.
 #
 # key_interrupt_char		OTki	str	ki	-		-	-----	string set by interrupt key (?)
 # key_kill_char			OTkk	str	kk	-		-	-----	string set by kill key (?)
@@ -1026,7 +1085,7 @@
 # Gv	186 \272 M-:	double vertical line
 #
 # The compiler will translate the single-line caps and discard the others
-# (via IGNORE aliases further down).  We don't want to do normal pad 
+# (via IGNORE aliases further down).  We don't want to do normal pad
 # translation on these, they're often single-character printable ASCII
 # strings that happen to be numerics.  There's awk code in parametrized.sh
 # that detects the acs_ prefix and uses it to suppress pad translation.
@@ -1048,303 +1107,10 @@
 #
 # TERMINFO EXTENSION CAPABILITIES
 #
-# This section is almost all comments.  What it's mainly for is to describe
-# what capabilities need to be squeezed out to get down to the XSI Curses
-# standard set.  They are flagged with K.
-#
-# HP extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in HP
-# terminfo files.  Except for memory_lock and memory_unlock, they are
-# functionally identical to SVr4 extensions, but they make the binary format
-# different.  Grrr....
+# (see Caps-ncurses for the complete set of comments)
 #
 memory_lock			meml	str	ml	-		-	----K	lock memory above cursor
 memory_unlock			memu	str	mu	-		-	----K	unlock memory
-#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
-#label_on			smln	str	LO	-		-	-----	turn on soft labels
-#label_off			rmln	str	LF	-		-	-----	turn off soft labels
-#key_f11			kf11	str	F1	-		-	-----	F11 function key
-#key_f12			kf12	str	F2	-		-	-----	F12 function key
-#key_f13			kf13	str	F3	-		-	-----	F13 function key
-#key_f14			kf14	str	F4	-		-	-----	F14 function key
-#key_f15			kf15	str	F5	-		-	-----	F15 function key
-#key_f16			kf16	str	F6	-		-	-----	F16 function key
-#key_f17			kf17	str	F7	-		-	-----	F17 function key
-#key_f18			kf18	str	F8	-		-	-----	F18 function key
-#key_f19			kf19	str	F9	-		-	-----	F19 function key
-#key_f20			kf20	str	FA	-		-	-----	F20 function key
-#key_f21			kf21	str	FB	-		-	-----	F21 function key
-#key_f22			kf22	str	FC	-		-	-----	F22 function key
-#key_f23			kf23	str	FD	-		-	-----	F23 function key
-#key_f24			kf24	str	FE	-		-	-----	F24 function key
-#key_f25			kf25	str	FF	-		-	-----	F25 function key
-#key_f26			kf26	str	FG	-		-	-----	F26 function key
-#key_f27			kf27	str	FH	-		-	-----	F27 function key
-#key_f28			kf28	str	FI	-		-	-----	F28 function key
-#key_f29			kf29	str	FJ	-		-	-----	F29 function key
-#key_f30			kf30	str	FK	-		-	-----	F30 function key
-#key_f31			kf31	str	FL	-		-	-----	F31 function key
-#key_f32			kf32	str	FM	-		-	-----	F32 function key
-#key_f33			kf33	str	FN	-		-	-----	F33 function key
-#key_f34			kf34	str	FO	-		-	-----	F34 function key
-#key_f35			kf35	str	FP	-		-	-----	F35 function key
-#key_f36			kf36	str	FQ	-		-	-----	F36 function key
-#key_f37			kf37	str	FR	-		-	-----	F37 function key
-#key_f38			kf38	str	FS	-		-	-----	F38 function key
-#key_f39			kf39	str	FT	-		-	-----	F39 function key
-#key_f40			kf40	str	FU	-		-	-----	F40 function key
-#key_f41			kf41	str	FV	-		-	-----	F41 function key
-#key_f42			kf42	str	FW	-		-	-----	F42 function key
-#key_f43			kf43	str	FX	-		-	-----	F43 function key
-#key_f44			kf44	str	FY	-		-	-----	F44 function key
-#key_f45			kf45	str	FZ	-		-	-----	F45 function key
-#key_f46			kf46	str	Fa	-		-	-----	F46 function key
-#key_f47			kf47	str	Fb	-		-	-----	F47 function key
-#key_f48			kf48	str	Fc	-		-	-----	F48 function key
-#key_f49			kf49	str	Fd	-		-	-----	F49 function key
-#key_f50			kf50	str	Fe	-		-	-----	F50 function key
-#key_f51			kf51	str	Ff	-		-	-----	F51 function key
-#key_f52			kf52	str	Fg	-		-	-----	F52 function key
-#key_f53			kf53	str	Fh	-		-	-----	F53 function key
-#key_f54			kf54	str	Fi	-		-	-----	F54 function key
-#key_f55			kf55	str	Fj	-		-	-----	F55 function key
-#key_f56			kf56	str	Fk	-		-	-----	F56 function key
-#key_f57			kf57	str	Fl	-		-	-----	F57 function key
-#key_f58			kf58	str	Fm	-		-	-----	F58 function key
-#key_f59			kf59	str	Fn	-		-	-----	F59 function key
-#key_f60			kf60	str	Fo	-		-	-----	F60 function key
-#key_f61			kf61	str	Fp	-		-	-----	F61 function key
-#key_f62			kf62	str	Fq	-		-	-----	F62 function key
-#key_f63			kf63	str	Fr	-		-	-----	F63 function key
-#
-# IBM extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in IBM
-# terminfo files.
-#
-# The places in the box[12] capabilities correspond to acsc characters, here is
-# the mapping:
-#
-#	box1[0]  = ACS_ULCORNER
-#	box1[1]  = ACS_HLINE	
-#	box1[2]  = ACS_URCORNER
-#	box1[3]  = ACS_VLINE
-#	box1[4]  = ACS_LRCORNER
-#	box1[5]  = ACS_LLCORNER
-#	box1[6]  = ACS_TTEE
-#	box1[7]  = ACS_RTEE
-#	box1[8]  = ACS_BTEE
-#	box1[9]  = ACS_LTEE
-#	box1[10] = ACS_PLUS
-#
-# The box2 characters are the double-line versions of these forms graphics.
-#
 box_chars_1			box1	str	bx	-		-	----K	box characters primary set
-#box_chars_2			box2	str	by	-		-	----K	box characters secondary set
-#box_attr_1			batt1	str	Bx	-		-	----K	attributes for box1
-#box_attr_2			batt2	str	By	-		-	----K	attributes for box2
-#color_bg_0			colb0	str	d0	-		-	----K	background color 0
-#color_bg_1			colb1	str	d1	-		-	----K	background color 1
-#color_bg_2			colb2	str	d2	-		-	----K	background color 2
-#color_bg_3			colb3	str	d3	-		-	----K	background color 3
-#color_bg_4			colb4	str	d4	-		-	----K	background color 4
-#color_bg_5			colb5	str	d5	-		-	----K	background color 5
-#color_bg_6			colb6	str	d6	-		-	----K	background color 6
-#color_bg_7			colb7	str	d7	-		-	----K	background color 7
-#color_fg_0			colf0	str	c0	-		-	----K	foreground color 0
-#color_fg_1			colf1	str	c1	-		-	----K	foreground color 1
-#color_fg_2			colf2	str	c2	-		-	----K	foreground color 2
-#color_fg_3			colf3	str	c3	-		-	----K	foreground color 3
-#color_fg_4			colf4	str	c4	-		-	----K	foreground color 4
-#color_fg_5			colf5	str	c5	-		-	----K	foreground color 5
-#color_fg_6			colf6	str	c6	-		-	----K	foreground color 6
-#color_fg_7			colf7	str	c7	-		-	----K	foreground color 7
-#font_0				font0	str	f0	-		-	-----	select font 0
-#font_1				font1	str	f1	-		-	-----	select font 1
-#font_2				font2	str	f2	-		-	-----	select font 2
-#font_3				font3	str	f3	-		-	-----	select font 3
-#font_4				font4	str	f4	-		-	----K	select font 4
-#font_5				font5	str	f5	-		-	----K	select font 5
-#font_6				font6	str	f6	-		-	----K	select font 6
-#font_7				font7	str	f7	-		-	----K	select font 7
-#key_back_tab			kbtab	str	k0	-		-	-----	backtab key
-#key_do				kdo	str	ki	-		-	----K	do request key
-#key_command			kcmd	str	kd	-		-	----K	command-request key
-#key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
-#key_end			kend	str	kw	-		-	-----	end key
-#key_help			khlp	str	kq	-		-	-----	help key
-#key_newline			knl	str	nl	-		-	----K	newline key
-#key_next_pane			knpn	str	kv	-		-	----K	next-pane key
-#key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
-#key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
-#key_quit			kquit	str	kQ	-		-	----K	quit key
-#key_select			ksel	str	kU	-		-	-----	select key
-#key_scroll_left		kscl	str	kz	-		-	----K	scroll left
-#key_scroll_right		kscr	str	kZ	-		-	----K	scroll right
-#key_tab			ktab	str	ko	-		-	----K	tab key
-#key_smap_in1			kmpf1	str	Kv	-		-	----K	special mapped key 1 input
-#key_smap_out1			kmpt1	str	KV	-		-	----K	special mapped key 1 output
-#key_smap_in2			kmpf2	str	Kw	-		-	----K	special mapped key 2 input
-#key_smap_out2			kmpt2	str	KW	-		-	----K	special mapped key 2 output
-#key_smap_in3			kmpf3	str	Kx	-		-	----K	special mapped key 3 input
-#key_smap_out3			kmpt3	str	KX	-		-	----K	special mapped key 3 output
-#key_smap_in4			kmpf4	str	Ky	-		-	----K	special mapped key 4 input
-#key_smap_out4			kmpt4	str	KY	-		-	----K	special mapped key 4 output
-#key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
-#key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
-#appl_defined_str		apstr	str	za	-		-	----K	application-defined string
-# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
-# the IBM manual pages, so the cap name strings are guesses.  The terminfo
-# names are almost certainly right, the termcap ones almost certainly wrong.
-#key_smap_in6			kmpf6	str	k!	-		-	----K	special mapped key 6 input
-#key_smap_out6			kmpt6	str	K@	-		-	----K	special mapped key 6 output
-#key_smap_in7			kmpf7	str	k#	-		-	----K	special mapped key 7 input
-#key_smap_out7			kmpt7	str	K$	-		-	----K	special mapped key 7 output
-#key_smap_in8			kmpf8	str	k%	-		-	----K	special mapped key 8 input
-#key_smap_out8			kmpt8	str	K^	-		-	----K	special mapped key 8 output
-#key_smap_in9			kmpf9	str	k&	-		-	----K	special mapped key 9 input
-#key_smap_out9			kmpt9	str	K*	-		-	----K	special mapped key 9 output
-# Undocumented capabilities end here
-#key_sf1			ksf1	str	S1	-		-	----K	special function key 1
-#key_sf2			ksf2	str	S2	-		-	----K	special function key 2
-#key_sf3			ksf3	str	S3	-		-	----K	special function key 3
-#key_sf4			ksf4	str	S4	-		-	----K	special function key 4
-#key_sf5			ksf5	str	S5	-		-	----K	special function key 5
-#key_sf6			ksf6	str	S6	-		-	----K	special function key 6
-#key_sf7			ksf7	str	S7	-		-	----K	special function key 7
-#key_sf8			ksf8	str	S8	-		-	----K	special function key 8
-#key_sf9			ksf9	str	S9	-		-	----K	special function key 9
-#key_sf10			ksf10	str	SA	-		-	----K	special function key 10
-# AIX version 3 documents different codes for F11, F12 and does not mention
-# F13-F64.  AIX version 4 uses the same naming for F0-F63 as above.
-#key_f11			kf11	str	k<	-		-	-----	function key 11
-#key_f12			kf12	str	k>	-		-	-----	function key 12
-# Undocumented capabilities end here.
-#key_action			kact	str	kJ	-		-	----K	sent by action key
-# The IBM docs say these capabilities are for table-drawing, and are
-# valid only for aixterm descriptions.
-#enter_topline_mode		topl	str	tp	-		-	----K	start top-line mode
-#enter_bottom_mode		btml	str	bm	-		-	----K	start bottom-line mode
-#enter_rvert_mode		rvert	str	rv	-		-	----K	start right-vertical mode
-#enter_lvert_mode		lvert	str	lv	-		-	----K	start left-vertical mode
-#
-#############################################################################
-#
-# ALIAS DECLARATIONS
-#
-# Here we set up aliases for translating extensions into standard terminfo.
-#
-#---------------------------------- Termcap aliases -------------------------
-#
-# BSD aliases:
-#
-# This is a common error in many termcap files.  We'll get notified during
-# translation when this (or any other alias) fires.
-#
-capalias	sb	sr	BSD	scroll text down
-#
-# AT&T extensions:
-#
-# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
-# nonstandard capabilities.  Its signature is the KM capability, used to name
-# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
-# set.  Comments in the original, and a little cross-checking with other AT&T
-# documentation, seem to establish the following mappings:
-#
-capalias	BO	mr	AT&T	enter_reverse_mode
-capalias	CI	vi	AT&T	cursor_invisible
-capalias	CV	ve	AT&T	cursor_normal
-capalias	DS	mh	AT&T	enter_dim_mode
-#capalias	EE	me	AT&T	exit_attribute_mode	
-capalias	FE	LF	AT&T	label_on
-capalias	FL	LO	AT&T	label_off
-capalias	XS	mk	AT&T	enter_secure_mode
-#
-# We comment out EE because the conflicting XENIX EE is more common in 
-# old entries.
-#
-# XENIX extensions:
-#
-# These are the ones we know how to translate directly:
-#
-capalias	EE	mh	XENIX	exit_attribute_mode	
-capalias	GE	ae	XENIX	exit_alt_charset_mode
-capalias	GS	as	XENIX	enter_alt_charset_mode
-capalias	CF	vi	XENIX	cursor_invis
-capalias	CO	ve	XENIX	cursor_normal
-capalias	EN	@7	XENIX	key_end
-capalias	HM	kh	XENIX	key_home
-capalias	LD	kL	XENIX	key_dl
-capalias	PD	kN	XENIX	key_npage
-capalias	PN	po	XENIX	prtr_off
-capalias	PS	pf	XENIX	prtr_on
-capalias	PU	kP	XENIX	key_ppage
-capalias	RT	@8	XENIX	kent
-capalias	UP	ku	XENIX	kcuu1
-capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
-capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
-capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
-capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
-capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
-capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
-capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
-capalias	Gd	IGNORE	XENIX	double ACS_TTEE
-capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
-capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
-capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
-capalias	GG	IGNORE	XENIX	acs-glitch
-#
-# IBM extensions:
-#
-capalias	kq	%1	IBM	key_help
-#
-# Iris extensions:
-#
-capalias	HS	mh	IRIS	enter_dim_mode
-#
-# Tektronix extensions:
-#
-capalias	KA	k;	Tek	key_f10
-capalias	KB	F1	Tek	key_f11
-capalias	KC	F2	Tek	key_f12
-capalias	KD	F3	Tek	key_f13
-capalias	KE	F4	Tek	key_f14
-capalias	KF	F5	Tek	key_f15
-capalias	BC	Sb	Tek	set_background
-capalias	FC	Sf	Tek	set_foreground
-#
-# There are also the following:
-#
-#	XENIX	XENIX variable name	name clash with terminfo?
-#	-----	-------------------	-------------------------
-#	CL	key_char_left
-#	CR	key_char_right
-#	CW	key_change_window
-#	HP	??
-#	LF	key_linefeed 		label_off
-#	NU	key_next_unlocked_cell
-#	PL	??
-#	PR	??
-#	RC	key_recalc		remove_clock
-#	RF	key_toggle_ref		req_for_input
-#	WL	key_word_left
-#	WR	key_word_right
-#
-# If you know what any of the question-marked ones mean, please tell us.
-#
-#--------------------------------- Terminfo aliases ------------------------
-#
-# IBM extensions:
-#
-infoalias	font0	s0ds	IBM	set0_des_seq
-infoalias	font1	s1ds	IBM	set1_des_seq
-infoalias	font2	s2ds	IBM	set2_des_seq
-infoalias	font3	s3ds	IBM	set3_des_seq
-infoalias	kbtab	kcbt	IBM	key_backtab
-infoalias	ksel	kslt	IBM	key_select
-#
-# Some others are identical to SVr4/XPG4 capabilities, in particular:
-# kcmd, kend, khlp, and kf11...kf63.
 #
 #############################################################################
diff --git a/include/Caps.osf1r5 b/include/Caps.osf1r5
index e1bfe0b..ece14ae 100644
--- a/include/Caps.osf1r5
+++ b/include/Caps.osf1r5
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2002-2011,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
+# Copyright 2002-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -28,13 +29,13 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.osf1r5,v 1.7 2015/04/26 15:25:55 tom Exp $
+# $Id: Caps.osf1r5,v 1.24 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with OSF/1 version 5 (Tru64) terminfo.
 #
 # This table is used to generate initializers for tables that drive tic,
-# infocmp, and the library compilation code used to support the termcap 
+# infocmp, and the library compilation code used to support the termcap
 # compatibility hack.  It is also used to generate the tabular portion of the
 # terminfo(5) man page; lines beginning with `#%' are passed through to become
 # the terminfo table.
@@ -47,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -57,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -97,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -107,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -119,14 +120,14 @@
 # You'll need to write custom code, probably in postprocess_termcap() or
 # postprocess_terminfo(), to handle the translation.
 #
-# CONTROLLING ENTRY LENGTH 
+# CONTROLLING ENTRY LENGTH
 #
 # Notes on specific elisions made to fit translations within 1023 bytes:
 #
 # Machines with IBM PC-like keyboards want to be able to define the following
 # keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap-
 # only environments for End or Home-Down), key_dc, and key_ic.  This is also
-# the set of keys the `joe' editor will be upset if it can't see.  So don't 
+# the set of keys the `joe' editor will be upset if it can't see.  So don't
 # trim those out of the set to be translated to termcap, or various users of
 # the termcap file will become irate.
 #
@@ -147,68 +148,108 @@
 #
 # It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap
 # translations go back over critical if we do this.  As 4.4BSD curses fades
-# into history and GNU termcap's application base shrinks towards being GNU 
+# into history and GNU termcap's application base shrinks towards being GNU
 # Emacs only, we'll probably elide out some BSD-only capabilities in order
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variables) are
+# "enter_near_letter_quality" and "bit_image_carriage_return" (tied at
+# 25n), and the longest terminfo code is "setcolor" (8n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses 
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
-#%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed through tparm with
-#%parms as given (#\fIi\fP).
-#%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
-#%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%The description field employs a handful of notations.
+#%.TP
+#%.B (P)
+#%indicates that padding may be specified.
+#%.TP
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
+#%.TP
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -247,18 +288,16 @@
 row_addr_glitch			xvpa	bool	YD	-	-	-----	only positive motion for vpa/mvpa caps
 semi_auto_right_margin		sam	bool	YE	-	-	-----	printing in last column causes cr
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -293,18 +332,16 @@
 print_rate			cps	num	Ym	-	-	-----	print rate in characters per second
 wide_char_size			widcs	num	Yn	-	-	-----	character step size when in double wide mode
 #%.TE
-#%.ad
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -367,6 +404,10 @@
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -429,6 +470,10 @@
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -584,6 +629,10 @@
 end_bit_image_region		endbi	str	Yy	-		-	-----	End a bit-image region
 enter_am_mode			smam	str	SA	-		-	-----	turn on automatic margins
 enter_doublewide_mode		swidm	str	ZF	-		-	-----	Enter double-wide mode
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 enter_draft_quality		sdrfq	str	ZG	-		-	-----	Enter draft-quality mode
 enter_italics_mode		sitm	str	ZH	-		-	-----	Enter italic mode
 enter_leftward_mode		slm	str	ZI	-		-	-----	Start leftward carriage motion
@@ -630,6 +679,10 @@
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -668,6 +721,10 @@
 key_restart			krst	str	&4	KEY_RESTART	0567	-----	restart key
 key_resume			kres	str	&5	KEY_RESUME	0570	-----	resume key
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(25n)2 Lbw(8n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -738,7 +795,7 @@
 set_color_band		setcolor	str	Yz	-		-	-----	Change to ribbon color #1
 set_color_pair			scp	str	sp	-		-	-----	Set current color pair to #1
 set_foreground			setf	str	Sf	-		-	-----	Set foreground color #1
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_left_margin_parm		smglp	str	Zm	-		-	-----	Set left (right) margin at column #1
 set_lr_margin			smglr	str	ML	-		-	-----	Set both left and right margins to #1, #2.  (ML is not in BSD termcap).
 set_page_length			slines	str	YZ	-		-	-----	Set page length to #1 lines
@@ -834,7 +891,7 @@
 # GNU termcap *does* include the following extended capability,  Only the
 # now-obsolete Ann Arbor terminals used it.
 #
-# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region 
+# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region
 #
 # The following comments describe capnames so ancient that I believe no
 # software uses them any longer.  Some of these have to go because they
@@ -851,9 +908,9 @@
 # comma-separated list of capabilities for which there are corresponding keys.
 # The `kn' code is accepted but ignored.
 #
-# The `ma' capability seems to have been designed to map between the rogue(2)
-# motion keys (including jkhl) and characters emitted by arrow keys on some
-# primitive pre-ANSI terminals.  It's so obsolete it's fossilized...
+# The `ma' capability was a 4.0BSD feature used by vi version 2.
+# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh.
+# Besides being obsolete, that interpretation conflicts with max_attributes.
 #
 # Here is a description of memory_lock_above and memory_unlock:
 # "You can 'freeze' data on the screen by turning on Memory Lock in a line of
@@ -879,14 +936,14 @@
 # vertical_tab_delay		OTdV	num	dV	-		-	-B---	padding required for ^V
 number_of_function_keys		OTkn	num	kn	-		-	-B-G-	count of function keys
 other_non_function_keys		OTko	str	ko	-		-	-B-G-	list of self-mapped keycaps
-arrow_key_map			OTma	str	ma	-		-	YBC--	map arrow keys rogue(1) motion keys
+arrow_key_map			OTma	str	ma	-		-	YBC--	map motion-keys for vi version 2
 # memory_lock_above		OTml	str	ml	-		-	-B---	lock visible screen memory above the current line
 # memory_unlock			OTmu	str	mu	-		-	-B---	unlock visible screen memory above the current line
 has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
@@ -895,7 +952,7 @@
 # University of Waterloo termcap extensions (as described in mytinfo).
 # The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
 # be resolved by a type check.  The descriptions are guesses from what was
-# in the mytinfo tables. 
+# in the mytinfo tables.
 #
 # key_interrupt_char		OTki	str	ki	-		-	-----	string set by interrupt key (?)
 # key_kill_char			OTkk	str	kk	-		-	-----	string set by kill key (?)
@@ -944,7 +1001,7 @@
 # Gv	186 \272 M-:	double vertical line
 #
 # The compiler will translate the single-line caps and discard the others
-# (via IGNORE aliases further down).  We don't want to do normal pad 
+# (via IGNORE aliases further down).  We don't want to do normal pad
 # translation on these, they're often single-character printable ASCII
 # strings that happen to be numerics.  There's awk code in parametrized.sh
 # that detects the acs_ prefix and uses it to suppress pad translation.
@@ -966,303 +1023,9 @@
 #
 # TERMINFO EXTENSION CAPABILITIES
 #
-# This section is almost all comments.  What it's mainly for is to describe
-# what capabilities need to be squeezed out to get down to the XSI Curses
-# standard set.  They are flagged with K.
-#
-# HP extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in HP
-# terminfo files.  Except for memory_lock and memory_unlock, they are
-# functionally identical to SVr4 extensions, but they make the binary format
-# different.  Grrr....
+# (see Caps-ncurses for the complete set of comments)
 #
 memory_lock			meml	str	ml	-		-	----K	lock memory above cursor
 memory_unlock			memu	str	mu	-		-	----K	unlock memory
-#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
-#label_on			smln	str	LO	-		-	-----	turn on soft labels
-#label_off			rmln	str	LF	-		-	-----	turn off soft labels
-#key_f11			kf11	str	F1	-		-	-----	F11 function key
-#key_f12			kf12	str	F2	-		-	-----	F12 function key
-#key_f13			kf13	str	F3	-		-	-----	F13 function key
-#key_f14			kf14	str	F4	-		-	-----	F14 function key
-#key_f15			kf15	str	F5	-		-	-----	F15 function key
-#key_f16			kf16	str	F6	-		-	-----	F16 function key
-#key_f17			kf17	str	F7	-		-	-----	F17 function key
-#key_f18			kf18	str	F8	-		-	-----	F18 function key
-#key_f19			kf19	str	F9	-		-	-----	F19 function key
-#key_f20			kf20	str	FA	-		-	-----	F20 function key
-#key_f21			kf21	str	FB	-		-	-----	F21 function key
-#key_f22			kf22	str	FC	-		-	-----	F22 function key
-#key_f23			kf23	str	FD	-		-	-----	F23 function key
-#key_f24			kf24	str	FE	-		-	-----	F24 function key
-#key_f25			kf25	str	FF	-		-	-----	F25 function key
-#key_f26			kf26	str	FG	-		-	-----	F26 function key
-#key_f27			kf27	str	FH	-		-	-----	F27 function key
-#key_f28			kf28	str	FI	-		-	-----	F28 function key
-#key_f29			kf29	str	FJ	-		-	-----	F29 function key
-#key_f30			kf30	str	FK	-		-	-----	F30 function key
-#key_f31			kf31	str	FL	-		-	-----	F31 function key
-#key_f32			kf32	str	FM	-		-	-----	F32 function key
-#key_f33			kf33	str	FN	-		-	-----	F33 function key
-#key_f34			kf34	str	FO	-		-	-----	F34 function key
-#key_f35			kf35	str	FP	-		-	-----	F35 function key
-#key_f36			kf36	str	FQ	-		-	-----	F36 function key
-#key_f37			kf37	str	FR	-		-	-----	F37 function key
-#key_f38			kf38	str	FS	-		-	-----	F38 function key
-#key_f39			kf39	str	FT	-		-	-----	F39 function key
-#key_f40			kf40	str	FU	-		-	-----	F40 function key
-#key_f41			kf41	str	FV	-		-	-----	F41 function key
-#key_f42			kf42	str	FW	-		-	-----	F42 function key
-#key_f43			kf43	str	FX	-		-	-----	F43 function key
-#key_f44			kf44	str	FY	-		-	-----	F44 function key
-#key_f45			kf45	str	FZ	-		-	-----	F45 function key
-#key_f46			kf46	str	Fa	-		-	-----	F46 function key
-#key_f47			kf47	str	Fb	-		-	-----	F47 function key
-#key_f48			kf48	str	Fc	-		-	-----	F48 function key
-#key_f49			kf49	str	Fd	-		-	-----	F49 function key
-#key_f50			kf50	str	Fe	-		-	-----	F50 function key
-#key_f51			kf51	str	Ff	-		-	-----	F51 function key
-#key_f52			kf52	str	Fg	-		-	-----	F52 function key
-#key_f53			kf53	str	Fh	-		-	-----	F53 function key
-#key_f54			kf54	str	Fi	-		-	-----	F54 function key
-#key_f55			kf55	str	Fj	-		-	-----	F55 function key
-#key_f56			kf56	str	Fk	-		-	-----	F56 function key
-#key_f57			kf57	str	Fl	-		-	-----	F57 function key
-#key_f58			kf58	str	Fm	-		-	-----	F58 function key
-#key_f59			kf59	str	Fn	-		-	-----	F59 function key
-#key_f60			kf60	str	Fo	-		-	-----	F60 function key
-#key_f61			kf61	str	Fp	-		-	-----	F61 function key
-#key_f62			kf62	str	Fq	-		-	-----	F62 function key
-#key_f63			kf63	str	Fr	-		-	-----	F63 function key
-#
-# IBM extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in IBM
-# terminfo files.
-#
-# The places in the box[12] capabilities correspond to acsc characters, here is
-# the mapping:
-#
-#	box1[0]  = ACS_ULCORNER
-#	box1[1]  = ACS_HLINE	
-#	box1[2]  = ACS_URCORNER
-#	box1[3]  = ACS_VLINE
-#	box1[4]  = ACS_LRCORNER
-#	box1[5]  = ACS_LLCORNER
-#	box1[6]  = ACS_TTEE
-#	box1[7]  = ACS_RTEE
-#	box1[8]  = ACS_BTEE
-#	box1[9]  = ACS_LTEE
-#	box1[10] = ACS_PLUS
-#
-# The box2 characters are the double-line versions of these forms graphics.
-#
-#box_chars_1			box1	str	bx	-		-	----K	box characters primary set
-#box_chars_2			box2	str	by	-		-	----K	box characters secondary set
-#box_attr_1			batt1	str	Bx	-		-	----K	attributes for box1
-#box_attr_2			batt2	str	By	-		-	----K	attributes for box2
-#color_bg_0			colb0	str	d0	-		-	----K	background color 0
-#color_bg_1			colb1	str	d1	-		-	----K	background color 1
-#color_bg_2			colb2	str	d2	-		-	----K	background color 2
-#color_bg_3			colb3	str	d3	-		-	----K	background color 3
-#color_bg_4			colb4	str	d4	-		-	----K	background color 4
-#color_bg_5			colb5	str	d5	-		-	----K	background color 5
-#color_bg_6			colb6	str	d6	-		-	----K	background color 6
-#color_bg_7			colb7	str	d7	-		-	----K	background color 7
-#color_fg_0			colf0	str	c0	-		-	----K	foreground color 0
-#color_fg_1			colf1	str	c1	-		-	----K	foreground color 1
-#color_fg_2			colf2	str	c2	-		-	----K	foreground color 2
-#color_fg_3			colf3	str	c3	-		-	----K	foreground color 3
-#color_fg_4			colf4	str	c4	-		-	----K	foreground color 4
-#color_fg_5			colf5	str	c5	-		-	----K	foreground color 5
-#color_fg_6			colf6	str	c6	-		-	----K	foreground color 6
-#color_fg_7			colf7	str	c7	-		-	----K	foreground color 7
-#font_0				font0	str	f0	-		-	-----	select font 0
-#font_1				font1	str	f1	-		-	-----	select font 1
-#font_2				font2	str	f2	-		-	-----	select font 2
-#font_3				font3	str	f3	-		-	-----	select font 3
-#font_4				font4	str	f4	-		-	----K	select font 4
-#font_5				font5	str	f5	-		-	----K	select font 5
-#font_6				font6	str	f6	-		-	----K	select font 6
-#font_7				font7	str	f7	-		-	----K	select font 7
-#key_back_tab			kbtab	str	k0	-		-	-----	backtab key
-#key_do				kdo	str	ki	-		-	----K	do request key
-#key_command			kcmd	str	kd	-		-	----K	command-request key
-#key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
-#key_end			kend	str	kw	-		-	-----	end key
-#key_help			khlp	str	kq	-		-	-----	help key
-#key_newline			knl	str	nl	-		-	----K	newline key
-#key_next_pane			knpn	str	kv	-		-	----K	next-pane key
-#key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
-#key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
-#key_quit			kquit	str	kQ	-		-	----K	quit key
-#key_select			ksel	str	kU	-		-	-----	select key
-#key_scroll_left		kscl	str	kz	-		-	----K	scroll left
-#key_scroll_right		kscr	str	kZ	-		-	----K	scroll right
-#key_tab			ktab	str	ko	-		-	----K	tab key
-#key_smap_in1			kmpf1	str	Kv	-		-	----K	special mapped key 1 input
-#key_smap_out1			kmpt1	str	KV	-		-	----K	special mapped key 1 output
-#key_smap_in2			kmpf2	str	Kw	-		-	----K	special mapped key 2 input
-#key_smap_out2			kmpt2	str	KW	-		-	----K	special mapped key 2 output
-#key_smap_in3			kmpf3	str	Kx	-		-	----K	special mapped key 3 input
-#key_smap_out3			kmpt3	str	KX	-		-	----K	special mapped key 3 output
-#key_smap_in4			kmpf4	str	Ky	-		-	----K	special mapped key 4 input
-#key_smap_out4			kmpt4	str	KY	-		-	----K	special mapped key 4 output
-#key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
-#key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
-#appl_defined_str		apstr	str	za	-		-	----K	application-defined string
-# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
-# the IBM manual pages, so the cap name strings are guesses.  The terminfo
-# names are almost certainly right, the termcap ones almost certainly wrong.
-#key_smap_in6			kmpf6	str	k!	-		-	----K	special mapped key 6 input
-#key_smap_out6			kmpt6	str	K@	-		-	----K	special mapped key 6 output
-#key_smap_in7			kmpf7	str	k#	-		-	----K	special mapped key 7 input
-#key_smap_out7			kmpt7	str	K$	-		-	----K	special mapped key 7 output
-#key_smap_in8			kmpf8	str	k%	-		-	----K	special mapped key 8 input
-#key_smap_out8			kmpt8	str	K^	-		-	----K	special mapped key 8 output
-#key_smap_in9			kmpf9	str	k&	-		-	----K	special mapped key 9 input
-#key_smap_out9			kmpt9	str	K*	-		-	----K	special mapped key 9 output
-# Undocumented capabilities end here
-#key_sf1			ksf1	str	S1	-		-	----K	special function key 1
-#key_sf2			ksf2	str	S2	-		-	----K	special function key 2
-#key_sf3			ksf3	str	S3	-		-	----K	special function key 3
-#key_sf4			ksf4	str	S4	-		-	----K	special function key 4
-#key_sf5			ksf5	str	S5	-		-	----K	special function key 5
-#key_sf6			ksf6	str	S6	-		-	----K	special function key 6
-#key_sf7			ksf7	str	S7	-		-	----K	special function key 7
-#key_sf8			ksf8	str	S8	-		-	----K	special function key 8
-#key_sf9			ksf9	str	S9	-		-	----K	special function key 9
-#key_sf10			ksf10	str	SA	-		-	----K	special function key 10
-# AIX version 3 documents different codes for F11, F12 and does not mention
-# F13-F64.  AIX version 4 uses the same naming for F0-F63 as above.
-#key_f11			kf11	str	k<	-		-	-----	function key 11
-#key_f12			kf12	str	k>	-		-	-----	function key 12
-# Undocumented capabilities end here.
-#key_action			kact	str	kJ	-		-	----K	sent by action key
-# The IBM docs say these capabilities are for table-drawing, and are
-# valid only for aixterm descriptions.
-#enter_topline_mode		topl	str	tp	-		-	----K	start top-line mode
-#enter_bottom_mode		btml	str	bm	-		-	----K	start bottom-line mode
-#enter_rvert_mode		rvert	str	rv	-		-	----K	start right-vertical mode
-#enter_lvert_mode		lvert	str	lv	-		-	----K	start left-vertical mode
-#
-#############################################################################
-#
-# ALIAS DECLARATIONS
-#
-# Here we set up aliases for translating extensions into standard terminfo.
-#
-#---------------------------------- Termcap aliases -------------------------
-#
-# BSD aliases:
-#
-# This is a common error in many termcap files.  We'll get notified during
-# translation when this (or any other alias) fires.
-#
-capalias	sb	sr	BSD	scroll text down
-#
-# AT&T extensions:
-#
-# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
-# nonstandard capabilities.  Its signature is the KM capability, used to name
-# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
-# set.  Comments in the original, and a little cross-checking with other AT&T
-# documentation, seem to establish the following mappings:
-#
-capalias	BO	mr	AT&T	enter_reverse_mode
-capalias	CI	vi	AT&T	cursor_invisible
-capalias	CV	ve	AT&T	cursor_normal
-capalias	DS	mh	AT&T	enter_dim_mode
-#capalias	EE	me	AT&T	exit_attribute_mode	
-capalias	FE	LF	AT&T	label_on
-capalias	FL	LO	AT&T	label_off
-capalias	XS	mk	AT&T	enter_secure_mode
-#
-# We comment out EE because the conflicting XENIX EE is more common in 
-# old entries.
-#
-# XENIX extensions:
-#
-# These are the ones we know how to translate directly:
-#
-capalias	EE	mh	XENIX	exit_attribute_mode	
-capalias	GE	ae	XENIX	exit_alt_charset_mode
-capalias	GS	as	XENIX	enter_alt_charset_mode
-capalias	CF	vi	XENIX	cursor_invis
-capalias	CO	ve	XENIX	cursor_normal
-capalias	EN	@7	XENIX	key_end
-capalias	HM	kh	XENIX	key_home
-capalias	LD	kL	XENIX	key_dl
-capalias	PD	kN	XENIX	key_npage
-capalias	PN	po	XENIX	prtr_off
-capalias	PS	pf	XENIX	prtr_on
-capalias	PU	kP	XENIX	key_ppage
-capalias	RT	@8	XENIX	kent
-capalias	UP	ku	XENIX	kcuu1
-capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
-capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
-capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
-capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
-capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
-capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
-capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
-capalias	Gd	IGNORE	XENIX	double ACS_TTEE
-capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
-capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
-capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
-capalias	GG	IGNORE	XENIX	acs-glitch
-#
-# IBM extensions:
-#
-capalias	kq	%1	IBM	key_help
-#
-# Iris extensions:
-#
-capalias	HS	mh	IRIS	enter_dim_mode
-#
-# Tektronix extensions:
-#
-capalias	KA	k;	Tek	key_f10
-capalias	KB	F1	Tek	key_f11
-capalias	KC	F2	Tek	key_f12
-capalias	KD	F3	Tek	key_f13
-capalias	KE	F4	Tek	key_f14
-capalias	KF	F5	Tek	key_f15
-capalias	BC	Sb	Tek	set_background
-capalias	FC	Sf	Tek	set_foreground
-#
-# There are also the following:
-#
-#	XENIX	XENIX variable name	name clash with terminfo?
-#	-----	-------------------	-------------------------
-#	CL	key_char_left
-#	CR	key_char_right
-#	CW	key_change_window
-#	HP	??
-#	LF	key_linefeed 		label_off
-#	NU	key_next_unlocked_cell
-#	PL	??
-#	PR	??
-#	RC	key_recalc		remove_clock
-#	RF	key_toggle_ref		req_for_input
-#	WL	key_word_left
-#	WR	key_word_right
-#
-# If you know what any of the question-marked ones mean, please tell us.
-#
-#--------------------------------- Terminfo aliases ------------------------
-#
-# IBM extensions:
-#
-infoalias	font0	s0ds	IBM	set0_des_seq
-infoalias	font1	s1ds	IBM	set1_des_seq
-infoalias	font2	s2ds	IBM	set2_des_seq
-infoalias	font3	s3ds	IBM	set3_des_seq
-infoalias	kbtab	kcbt	IBM	key_backtab
-infoalias	ksel	kslt	IBM	key_select
-#
-# Some others are identical to SVr4/XPG4 capabilities, in particular:
-# kcmd, kend, khlp, and kf11...kf63.
 #
 #############################################################################
diff --git a/include/Caps.uwin b/include/Caps.uwin
index b09f612..a41e9ec 100644
--- a/include/Caps.uwin
+++ b/include/Caps.uwin
@@ -1,5 +1,6 @@
 ##############################################################################
-# Copyright (c) 2001-2010,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2023,2024 Thomas E. Dickey                                  #
+# Copyright 2001-2015,2016 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -28,13 +29,13 @@
 #
 # Author: Thomas Dickey
 #
-# $Id: Caps.uwin,v 1.6 2015/04/26 15:24:21 tom Exp $
+# $Id: Caps.uwin,v 1.23 2024/04/20 21:05:02 tom Exp $
 #
 # This is an adaptation of ncurses' termcap/terminfo capability table, which
 # is designed to align with U/Win's terminfo.
 #
 # This table is used to generate initializers for tables that drive tic,
-# infocmp, and the library compilation code used to support the termcap 
+# infocmp, and the library compilation code used to support the termcap
 # compatibility hack.  It is also used to generate the tabular portion of the
 # terminfo(5) man page; lines beginning with `#%' are passed through to become
 # the terminfo table.
@@ -47,7 +48,7 @@
 #
 # Column 1: terminfo variable name
 # Column 2: terminfo capability name
-# Column 3: capability type (boolean, numeric, or string)
+# Column 3: capability type (Boolean, numeric, or string)
 # Column 4: termcap capability name
 # Column 5: KEY_xxx name, if any, `-' otherwise
 # Column 6: value for KEY_xxx name, if any, `-' otherwise
@@ -57,7 +58,7 @@
 #
 # The codes following [Y-] in column 7 describe the versions of termcap which
 # use the given capability.  This information is not used by the curses library
-# proper; rather, it's there to help the terminfo maintainer avoid emitting
+# proper; rather, it is there to help the terminfo maintainer avoid emitting
 # termcap entry translations that are more than 1023 bytes long (and tank a
 # lot of old termcap-using programs).  The codes read as follows:
 #	B = mentioned in the BSD man page for 4.4BSD curses
@@ -97,8 +98,8 @@
 # 3. List it in the standard table.  You almost certainly do *not* want
 # to do this -- the capabilities in that one, and their order, have been
 # carefully chosen to be SVr4-binary-compatible when they're written out
-# as a terminfo object, and breaking this would be bad.  It's up to the ncurses
-# library what to do with the terminfo data after it's read in.
+# as a terminfo object, and breaking this would be bad.  It is up to the ncurses
+# library what to do with the terminfo data after it is read in.
 #
 # 4. List it in the aliases table with an IGNORE target field.  If you
 # do this, the capability will be ignored on input (though the user will
@@ -107,7 +108,7 @@
 # 5. List it in the extensions table. If you do this, the compiler will
 # silently accept the capability, but the curses library proper will never
 # see it (because it won't be written out as part of the terminfo object
-# format).  It's up to you what you have the compiler do with it.
+# format).  It is up to you what you have the compiler do with it.
 #
 # There are two opposite reasons to choose option 5.  One is when you want
 # to eat the capability silently and discard it when doing translations
@@ -119,14 +120,14 @@
 # You'll need to write custom code, probably in postprocess_termcap() or
 # postprocess_terminfo(), to handle the translation.
 #
-# CONTROLLING ENTRY LENGTH 
+# CONTROLLING ENTRY LENGTH
 #
 # Notes on specific elisions made to fit translations within 1023 bytes:
 #
 # Machines with IBM PC-like keyboards want to be able to define the following
 # keys: key_npage, key_ppage, key_home, key_ll (which is used for in termcap-
 # only environments for End or Home-Down), key_dc, and key_ic.  This is also
-# the set of keys the `joe' editor will be upset if it can't see.  So don't 
+# the set of keys the `joe' editor will be upset if it can't see.  So don't
 # trim those out of the set to be translated to termcap, or various users of
 # the termcap file will become irate.
 #
@@ -147,68 +148,108 @@
 #
 # It would be nice to keep f11 and f12 for Emacs use, but a couple of termcap
 # translations go back over critical if we do this.  As 4.4BSD curses fades
-# into history and GNU termcap's application base shrinks towards being GNU 
+# into history and GNU termcap's application base shrinks towards being GNU
 # Emacs only, we'll probably elide out some BSD-only capabilities in order
 # to buy space for non-essentials Emacs is still using.  Capabilities high
 # on that hit list: rc, sc, uc.
 #
+# FORMATTING THE TABLES
+#
+# We manually specify a (minimum) column width for the capability name
+# and terminfo code columns in the tables to achieve a consistent
+# arrangement; as used here, tbl(1) cannot know the width required by
+# one table's data while formatting another's.
+#
+# The longest capability names (C variable) is
+# "hue_lightness_saturation" (24n), and the longest terminfo code is
+# "colornm" (7n).
+#
+# The tables are a tight fit on traditional man(7) implementations that
+# use a line length of 65n, and the "Description" column has little room
+# within which the formatter can make breaking or adjustment decisions.
+# Words like "micro_..._address" and "parm_..._micro" don't break.
+# Reducing the inter-column gaps to 2 ens gives them enough room.  --GBR
+#
 #############################################################################
 #
 # STANDARD CAPABILITIES
 #
-#%The following is a complete table of the capabilities included in a
-#%terminfo description block and available to terminfo-using code.  In each
-#%line of the table,
-#%
-#%The \fBvariable\fR is the name by which the programmer (at the terminfo level)
-#%accesses the capability.
-#%
-#%The \fBcapname\fR is the short name used in the text of the database,
-#%and is used by a person updating the database.
-#%Whenever possible, capnames are chosen to be the same as or similar to
-#%the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses 
-#%identical or very similar names).  Semantics are also intended to match
-#%those of the specification.
-#%
-#%The termcap code is the old
-#%.B termcap
-#%capability name (some capabilities are new, and have names which termcap
-#%did not originate).
-#%.P
-#%Capability names have no hard length limit, but an informal limit of 5
-#%characters has been adopted to keep them short and to allow the tabs in
-#%the source file
-#%.B Caps
+#%Tables of capabilities
+#%.I \%ncurses
+#%recognizes in a
+#%.I \%term\%info
+#%terminal type description and available to
+#%.IR \%term\%info -using
+#%code follow.
+#%.bP
+#%The capability name identifies the symbol by which the programmer
+#%using the
+#%.I \%term\%info
+#%API accesses the capability.
+#%.bP
+#%The TI
+#%.RI ( \%term\%info )
+#%code is the short name used by a person composing or updating a
+#%terminal type entry.
+#%.IP
+#%Whenever possible,
+#%these codes are the same as or similar to those of the ANSI X3.64-1979
+#%standard
+#%(now superseded by ECMA-48,
+#%which uses identical or very similar names).
+#%Semantics are also intended to match those of the specification.
+#%.IP
+#%.I \%term\%info
+#%codes have no hard length limit,
+#%but
+#%.I \%ncurses
+#%maintains an informal one of 5 characters to keep them short and to
+#%allow the tabs in the source file
+#%.I Caps
 #%to line up nicely.
-#%
-#%Finally, the description field attempts to convey the semantics of the
-#%capability.  You may find some codes in the description field:
-#%.TP
-#%(P)
-#%indicates that padding may be specified
-#%.TP
-#%#[1-9]
-#%in the description field indicates that the string is passed through tparm with
-#%parms as given (#\fIi\fP).
-#%.TP
-#%(P*)
-#%indicates that padding may vary in proportion to the number of
-#%lines affected
-#%.TP
-#%(#\d\fIi\fP\u)
-#%indicates the \fIi\fP\uth\d parameter.
-#%
+#%(Some standard codes exceed this limit regardless.)
+#%.bP
+#%The TC
+#%.RI ( termcap )
+#%code is that used by the corresponding API of
+#%.IR \%ncurses .
+#%(Some capabilities are new,
+#%and have names that BSD
+#%.I termcap
+#%did not originate.)
+#%.bP
+#%The description field attempts to convey the capability's semantics.
 #%.PP
-#% These are the boolean capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBBooleans	name	Code\fR
+#%The description field employs a handful of notations.
+#%.TP
+#%.B (P)
+#%indicates that padding may be specified.
+#%.TP
+#%.B (P*)
+#%indicates that padding may vary in proportion to the number of output
+#%lines affected.
+#%.TP
+#%.BI # i
+#%indicates the
+#%.IR i th
+#%parameter of a string capability;
+#%the programmer should pass the string to \fB\%tparm\fP(3X) with the
+#%parameters listed.
+#%.IP
+#%If the description lists no parameters,
+#%passing the string to \fB\%tparm\fP(3X) may produce unexpected
+#%behavior,
+#%for instance if the string contains percent signs.
+#%.
+#%.PP
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Boolean Capability Name	TI	TC	Description
+#%_
 auto_left_margin		bw	bool	bw	-	-	YB-G-	cub1 wraps from column 0 to last column
 auto_right_margin		am	bool	am	-	-	YBCGE	terminal has automatic margins
 no_esc_ctlc			xsb	bool	xb	-	-	YBCG-	beehive (f1=escape, f2=ctrl C)
@@ -240,18 +281,16 @@
 can_change			ccc	bool	cc	-	-	-----	terminal can re-define existing colors
 hue_lightness_saturation	hls	bool	hl	-	-	-----	terminal uses only HLS color notation (Tektronix)
 #%.TE
-#%.ad
-#%
-#%These are the numeric capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBNumeric	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
+#%\&	Code	\&
+#%Numeric Capability Name	TI	TC	Description
+#%_
 columns				cols	num	co	-	-	YBCGE	number of columns in a line
 init_tabs			it	num	it	-	-	YB-G-	tabs initially every # spaces
 lines				lines	num	li	-	-	YBCGE	number of lines on screen or page
@@ -271,24 +310,16 @@
 max_pairs			pairs	num	pa	-	-	-----	maximum number of color-pairs on the screen
 no_color_video			ncv	num	NC	-	-	-----	video attributes that cannot be used with colors
 #%.TE
-#%.ad
-#%
-#%The following numeric capabilities are present in the SVr4.0 term structure,
-#%but are not yet documented in the man page.  They came in with SVr4's
-#%printer support.
-#%
-#%.na
-#%
-#%These are the string capabilities:
-#%
-#%.na
-#%.TS H
-#%center expand;
-#%c l l c
-#%c l l c
-#%lw25 lw6 lw2 lw20.
-#%\fBVariable	Cap-	TCap	Description\fR
-#%\fBString	name	Code\fR
+#%.PP
+#%.
+#%.TS
+#%center;
+#%Lb        Cb       S   Lb
+#%Lb        Lb       Lb  Lb
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
+#%\&	Code	\&
+#%String Capability Name	TI	TC	Description
+#%_
 back_tab			cbt	str	bt	-		-	YBCGE	back tab (P)
 bell				bel	str	bl	-		-	YB-GE	audible signal (bell) (P)
 carriage_return			cr	str	cr	-		-	YBCGE	carriage return (P*) (P*)
@@ -351,6 +382,10 @@
 key_dc				kdch1	str	kD	KEY_DC		0512	YB-G-	delete-character key
 key_dl				kdl1	str	kL	KEY_DL		0510	-B-G-*	delete-line key
 key_down			kcud1	str	kd	KEY_DOWN	0402	YBCGE	down-arrow key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 key_eic				krmir	str	kM	KEY_EIC		0514	-B-G-*	sent by rmir or smir in insert mode
 key_eol				kel	str	kE	KEY_EOL		0517	-B-G-*	clear-to-end-of-line key
 key_eos				ked	str	kS	KEY_EOS		0516	-B-G-*	clear-to-end-of-screen key
@@ -413,6 +448,10 @@
 repeat_char			rep	str	rp	-		-	YB-GE	repeat char #1 #2 times (P*)
 reset_1string			rs1	str	r1	-		-	-B---	reset string
 reset_2string			rs2	str	r2	-		-	-B---	reset string
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 reset_3string			rs3	str	r3	-		-	-B---	reset string
 reset_file			rf	str	rf	-		-	-B---	name of reset file
 restore_cursor			rc	str	rc	-		-	YBCG-	restore cursor to position of last save_cursor
@@ -479,6 +518,10 @@
 key_save			ksav	str	&6	KEY_SAVE	0571	-----	save key
 key_suspend			kspd	str	&7	KEY_SUSPEND	0627	-----	suspend key
 key_undo			kund	str	&8	KEY_UNDO	0630	-----	undo key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 key_sbeg			kBEG	str	&9	KEY_SBEG	0572	-----	shifted begin key
 key_scancel			kCAN	str	&0	KEY_SCANCEL	0573	-----	shifted cancel key
 key_scommand			kCMD	str	*1	KEY_SCOMMAND	0574	-----	shifted command key
@@ -541,6 +584,10 @@
 key_f40				kf40	str	FU	KEY_F(40)	-	----E	F40 function key
 key_f41				kf41	str	FV	KEY_F(41)	-	----E	F41 function key
 key_f42				kf42	str	FW	KEY_F(42)	-	----E	F42 function key
+#%.TE
+#%.TS
+#%center;
+#%Lbw(24n)2 Lbw(7n)2 Lb2 Lx.
 key_f43				kf43	str	FX	KEY_F(43)	-	----E	F43 function key
 key_f44				kf44	str	FY	KEY_F(44)	-	----E	F44 function key
 key_f45				kf45	str	FZ	KEY_F(45)	-	----E	F45 function key
@@ -564,7 +611,7 @@
 key_f63				kf63	str	Fr	KEY_F(63)	-	----E	F63 function key
 clr_bol				el1	str	cb	-		-	-----	Clear to beginning of line
 clear_margins			mgc	str	MC	-		-	-----	clear right and left soft margins
-set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column.	 See smgl. (ML is not in BSD termcap).
+set_left_margin			smgl	str	ML	-		-	-----	set left soft margin at current column (not in BSD \fItermcap\fP)
 set_right_margin		smgr	str	MR	-		-	-----	set right soft margin at current column
 device_type			devt	str	dv	-		-	-----	Indicate language/codeset support
 code_set_init			csin	str	ci	-		-	-----	Init sequence for multiple codesets
@@ -588,7 +635,6 @@
 set_color_pair			scp	str	sp	-		-	-----	Set current color pair to #1
 set_foreground			setf	str	Sf	-		-	-----	Set foreground color #1
 #%.TE
-#%.ad
 #%
 # The magic token below tells the tic compiler-generator code that all the caps
 # past it should be ignored (not written out) when dumping terminfo objects. It
@@ -650,7 +696,7 @@
 # GNU termcap *does* include the following extended capability,  Only the
 # now-obsolete Ann Arbor terminals used it.
 #
-# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region 
+# gnu_change_scroll_region	OTcS	str	cS	-		-	---GE	alternate set scrolling region
 #
 # The following comments describe capnames so ancient that I believe no
 # software uses them any longer.  Some of these have to go because they
@@ -667,9 +713,9 @@
 # comma-separated list of capabilities for which there are corresponding keys.
 # The `kn' code is accepted but ignored.
 #
-# The `ma' capability seems to have been designed to map between the rogue(2)
-# motion keys (including jkhl) and characters emitted by arrow keys on some
-# primitive pre-ANSI terminals.  It's so obsolete it's fossilized...
+# The `ma' capability was a 4.0BSD feature used by vi version 2.
+# It consists of pairs of characters corresponding to kl, kr, ku, kd, and kh.
+# Besides being obsolete, that interpretation conflicts with max_attributes.
 #
 # Here is a description of memory_lock_above and memory_unlock:
 # "You can 'freeze' data on the screen by turning on Memory Lock in a line of
@@ -695,14 +741,14 @@
 # vertical_tab_delay		OTdV	num	dV	-		-	-B---	padding required for ^V
 number_of_function_keys		OTkn	num	kn	-		-	-B-G-	count of function keys
 other_non_function_keys		OTko	str	ko	-		-	-B-G-	list of self-mapped keycaps
-arrow_key_map			OTma	str	ma	-		-	YBC--	map arrow keys rogue(1) motion keys
+arrow_key_map			OTma	str	ma	-		-	YBC--	map motion-keys for vi version 2
 # memory_lock_above		OTml	str	ml	-		-	-B---	lock visible screen memory above the current line
 # memory_unlock			OTmu	str	mu	-		-	-B---	unlock visible screen memory above the current line
 has_hardware_tabs		OTpt	bool	pt	-		-	YB---	has 8-char tabs invoked with ^I
 return_does_clr_eol		OTxr	bool	xr	-		-	YB---	return clears the line
 # tek_4025_insert_line		OTxx	bool	xx	-		-	-BC--	Tektronix 4025 insert-line glitch
 #
-# mytinfo described this as a termcap capability, but it's not listed in the
+# mytinfo described this as a termcap capability, but it is not listed in the
 # 4.4BSD man pages, and not found in the 4.4BSD termcap file.  The ncurses
 # package, like System V, behaves as though it is always true.
 #
@@ -711,7 +757,7 @@
 # University of Waterloo termcap extensions (as described in mytinfo).
 # The `xl' termcap file clashes with a terminfo name; this ambiguity cannot
 # be resolved by a type check.  The descriptions are guesses from what was
-# in the mytinfo tables. 
+# in the mytinfo tables.
 #
 # key_interrupt_char		OTki	str	ki	-		-	-----	string set by interrupt key (?)
 # key_kill_char			OTkk	str	kk	-		-	-----	string set by kill key (?)
@@ -760,7 +806,7 @@
 # Gv	186 \272 M-:	double vertical line
 #
 # The compiler will translate the single-line caps and discard the others
-# (via IGNORE aliases further down).  We don't want to do normal pad 
+# (via IGNORE aliases further down).  We don't want to do normal pad
 # translation on these, they're often single-character printable ASCII
 # strings that happen to be numerics.  There's awk code in parametrized.sh
 # that detects the acs_ prefix and uses it to suppress pad translation.
@@ -782,303 +828,10 @@
 #
 # TERMINFO EXTENSION CAPABILITIES
 #
-# This section is almost all comments.  What it's mainly for is to describe
-# what capabilities need to be squeezed out to get down to the XSI Curses
-# standard set.  They are flagged with K.
-#
-# HP extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in HP
-# terminfo files.  Except for memory_lock and memory_unlock, they are
-# functionally identical to SVr4 extensions, but they make the binary format
-# different.  Grrr....
+# (see Caps-ncurses for the complete set of comments)
 #
 memory_lock			meml	str	ml	-		-	----K	lock memory above cursor
 memory_unlock			memu	str	mu	-		-	----K	unlock memory
-#plab_norm			pln	str	pn	-		-	-----	program label #1 to show string #2
-#label_on			smln	str	LO	-		-	-----	turn on soft labels
-#label_off			rmln	str	LF	-		-	-----	turn off soft labels
-#key_f11			kf11	str	F1	-		-	-----	F11 function key
-#key_f12			kf12	str	F2	-		-	-----	F12 function key
-#key_f13			kf13	str	F3	-		-	-----	F13 function key
-#key_f14			kf14	str	F4	-		-	-----	F14 function key
-#key_f15			kf15	str	F5	-		-	-----	F15 function key
-#key_f16			kf16	str	F6	-		-	-----	F16 function key
-#key_f17			kf17	str	F7	-		-	-----	F17 function key
-#key_f18			kf18	str	F8	-		-	-----	F18 function key
-#key_f19			kf19	str	F9	-		-	-----	F19 function key
-#key_f20			kf20	str	FA	-		-	-----	F20 function key
-#key_f21			kf21	str	FB	-		-	-----	F21 function key
-#key_f22			kf22	str	FC	-		-	-----	F22 function key
-#key_f23			kf23	str	FD	-		-	-----	F23 function key
-#key_f24			kf24	str	FE	-		-	-----	F24 function key
-#key_f25			kf25	str	FF	-		-	-----	F25 function key
-#key_f26			kf26	str	FG	-		-	-----	F26 function key
-#key_f27			kf27	str	FH	-		-	-----	F27 function key
-#key_f28			kf28	str	FI	-		-	-----	F28 function key
-#key_f29			kf29	str	FJ	-		-	-----	F29 function key
-#key_f30			kf30	str	FK	-		-	-----	F30 function key
-#key_f31			kf31	str	FL	-		-	-----	F31 function key
-#key_f32			kf32	str	FM	-		-	-----	F32 function key
-#key_f33			kf33	str	FN	-		-	-----	F33 function key
-#key_f34			kf34	str	FO	-		-	-----	F34 function key
-#key_f35			kf35	str	FP	-		-	-----	F35 function key
-#key_f36			kf36	str	FQ	-		-	-----	F36 function key
-#key_f37			kf37	str	FR	-		-	-----	F37 function key
-#key_f38			kf38	str	FS	-		-	-----	F38 function key
-#key_f39			kf39	str	FT	-		-	-----	F39 function key
-#key_f40			kf40	str	FU	-		-	-----	F40 function key
-#key_f41			kf41	str	FV	-		-	-----	F41 function key
-#key_f42			kf42	str	FW	-		-	-----	F42 function key
-#key_f43			kf43	str	FX	-		-	-----	F43 function key
-#key_f44			kf44	str	FY	-		-	-----	F44 function key
-#key_f45			kf45	str	FZ	-		-	-----	F45 function key
-#key_f46			kf46	str	Fa	-		-	-----	F46 function key
-#key_f47			kf47	str	Fb	-		-	-----	F47 function key
-#key_f48			kf48	str	Fc	-		-	-----	F48 function key
-#key_f49			kf49	str	Fd	-		-	-----	F49 function key
-#key_f50			kf50	str	Fe	-		-	-----	F50 function key
-#key_f51			kf51	str	Ff	-		-	-----	F51 function key
-#key_f52			kf52	str	Fg	-		-	-----	F52 function key
-#key_f53			kf53	str	Fh	-		-	-----	F53 function key
-#key_f54			kf54	str	Fi	-		-	-----	F54 function key
-#key_f55			kf55	str	Fj	-		-	-----	F55 function key
-#key_f56			kf56	str	Fk	-		-	-----	F56 function key
-#key_f57			kf57	str	Fl	-		-	-----	F57 function key
-#key_f58			kf58	str	Fm	-		-	-----	F58 function key
-#key_f59			kf59	str	Fn	-		-	-----	F59 function key
-#key_f60			kf60	str	Fo	-		-	-----	F60 function key
-#key_f61			kf61	str	Fp	-		-	-----	F61 function key
-#key_f62			kf62	str	Fq	-		-	-----	F62 function key
-#key_f63			kf63	str	Fr	-		-	-----	F63 function key
-#
-# IBM extensions
-#
-# These extensions follow ptr_non (replacing everything after it) in IBM
-# terminfo files.
-#
-# The places in the box[12] capabilities correspond to acsc characters, here is
-# the mapping:
-#
-#	box1[0]  = ACS_ULCORNER
-#	box1[1]  = ACS_HLINE	
-#	box1[2]  = ACS_URCORNER
-#	box1[3]  = ACS_VLINE
-#	box1[4]  = ACS_LRCORNER
-#	box1[5]  = ACS_LLCORNER
-#	box1[6]  = ACS_TTEE
-#	box1[7]  = ACS_RTEE
-#	box1[8]  = ACS_BTEE
-#	box1[9]  = ACS_LTEE
-#	box1[10] = ACS_PLUS
-#
-# The box2 characters are the double-line versions of these forms graphics.
-#
 box_chars_1			box1	str	bx	-		-	----K	box characters primary set
-#box_chars_2			box2	str	by	-		-	----K	box characters secondary set
-#box_attr_1			batt1	str	Bx	-		-	----K	attributes for box1
-#box_attr_2			batt2	str	By	-		-	----K	attributes for box2
-#color_bg_0			colb0	str	d0	-		-	----K	background color 0
-#color_bg_1			colb1	str	d1	-		-	----K	background color 1
-#color_bg_2			colb2	str	d2	-		-	----K	background color 2
-#color_bg_3			colb3	str	d3	-		-	----K	background color 3
-#color_bg_4			colb4	str	d4	-		-	----K	background color 4
-#color_bg_5			colb5	str	d5	-		-	----K	background color 5
-#color_bg_6			colb6	str	d6	-		-	----K	background color 6
-#color_bg_7			colb7	str	d7	-		-	----K	background color 7
-#color_fg_0			colf0	str	c0	-		-	----K	foreground color 0
-#color_fg_1			colf1	str	c1	-		-	----K	foreground color 1
-#color_fg_2			colf2	str	c2	-		-	----K	foreground color 2
-#color_fg_3			colf3	str	c3	-		-	----K	foreground color 3
-#color_fg_4			colf4	str	c4	-		-	----K	foreground color 4
-#color_fg_5			colf5	str	c5	-		-	----K	foreground color 5
-#color_fg_6			colf6	str	c6	-		-	----K	foreground color 6
-#color_fg_7			colf7	str	c7	-		-	----K	foreground color 7
-#font_0				font0	str	f0	-		-	-----	select font 0
-#font_1				font1	str	f1	-		-	-----	select font 1
-#font_2				font2	str	f2	-		-	-----	select font 2
-#font_3				font3	str	f3	-		-	-----	select font 3
-#font_4				font4	str	f4	-		-	----K	select font 4
-#font_5				font5	str	f5	-		-	----K	select font 5
-#font_6				font6	str	f6	-		-	----K	select font 6
-#font_7				font7	str	f7	-		-	----K	select font 7
-#key_back_tab			kbtab	str	k0	-		-	-----	backtab key
-#key_do				kdo	str	ki	-		-	----K	do request key
-#key_command			kcmd	str	kd	-		-	----K	command-request key
-#key_command_pane		kcpn	str	kW	-		-	----K	command-pane key
-#key_end			kend	str	kw	-		-	-----	end key
-#key_help			khlp	str	kq	-		-	-----	help key
-#key_newline			knl	str	nl	-		-	----K	newline key
-#key_next_pane			knpn	str	kv	-		-	----K	next-pane key
-#key_prev_cmd			kppn	str	kp	-		-	----K	previous-command key
-#key_prev_pane			kppn	str	kV	-		-	----K	previous-pane key
-#key_quit			kquit	str	kQ	-		-	----K	quit key
-#key_select			ksel	str	kU	-		-	-----	select key
-#key_scroll_left		kscl	str	kz	-		-	----K	scroll left
-#key_scroll_right		kscr	str	kZ	-		-	----K	scroll right
-#key_tab			ktab	str	ko	-		-	----K	tab key
-#key_smap_in1			kmpf1	str	Kv	-		-	----K	special mapped key 1 input
-#key_smap_out1			kmpt1	str	KV	-		-	----K	special mapped key 1 output
-#key_smap_in2			kmpf2	str	Kw	-		-	----K	special mapped key 2 input
-#key_smap_out2			kmpt2	str	KW	-		-	----K	special mapped key 2 output
-#key_smap_in3			kmpf3	str	Kx	-		-	----K	special mapped key 3 input
-#key_smap_out3			kmpt3	str	KX	-		-	----K	special mapped key 3 output
-#key_smap_in4			kmpf4	str	Ky	-		-	----K	special mapped key 4 input
-#key_smap_out4			kmpt4	str	KY	-		-	----K	special mapped key 4 output
-#key_smap_in5			kmpf5	str	Kz	-		-	----K	special mapped key 5 input
-#key_smap_out5			kmpt5	str	KZ	-		-	----K	special mapped key 5 output
-#appl_defined_str		apstr	str	za	-		-	----K	application-defined string
-# The key_smap_in[6789] and key_smap_out[6789] capabilities aren't described in
-# the IBM manual pages, so the cap name strings are guesses.  The terminfo
-# names are almost certainly right, the termcap ones almost certainly wrong.
-#key_smap_in6			kmpf6	str	k!	-		-	----K	special mapped key 6 input
-#key_smap_out6			kmpt6	str	K@	-		-	----K	special mapped key 6 output
-#key_smap_in7			kmpf7	str	k#	-		-	----K	special mapped key 7 input
-#key_smap_out7			kmpt7	str	K$	-		-	----K	special mapped key 7 output
-#key_smap_in8			kmpf8	str	k%	-		-	----K	special mapped key 8 input
-#key_smap_out8			kmpt8	str	K^	-		-	----K	special mapped key 8 output
-#key_smap_in9			kmpf9	str	k&	-		-	----K	special mapped key 9 input
-#key_smap_out9			kmpt9	str	K*	-		-	----K	special mapped key 9 output
-# Undocumented capabilities end here
-#key_sf1			ksf1	str	S1	-		-	----K	special function key 1
-#key_sf2			ksf2	str	S2	-		-	----K	special function key 2
-#key_sf3			ksf3	str	S3	-		-	----K	special function key 3
-#key_sf4			ksf4	str	S4	-		-	----K	special function key 4
-#key_sf5			ksf5	str	S5	-		-	----K	special function key 5
-#key_sf6			ksf6	str	S6	-		-	----K	special function key 6
-#key_sf7			ksf7	str	S7	-		-	----K	special function key 7
-#key_sf8			ksf8	str	S8	-		-	----K	special function key 8
-#key_sf9			ksf9	str	S9	-		-	----K	special function key 9
-#key_sf10			ksf10	str	SA	-		-	----K	special function key 10
-# AIX version 3 documents different codes for F11, F12 and does not mention
-# F13-F64.  AIX version 4 uses the same naming for F0-F63 as above.
-#key_f11			kf11	str	k<	-		-	-----	function key 11
-#key_f12			kf12	str	k>	-		-	-----	function key 12
-# Undocumented capabilities end here.
-#key_action			kact	str	kJ	-		-	----K	sent by action key
-# The IBM docs say these capabilities are for table-drawing, and are
-# valid only for aixterm descriptions.
-#enter_topline_mode		topl	str	tp	-		-	----K	start top-line mode
-#enter_bottom_mode		btml	str	bm	-		-	----K	start bottom-line mode
-#enter_rvert_mode		rvert	str	rv	-		-	----K	start right-vertical mode
-#enter_lvert_mode		lvert	str	lv	-		-	----K	start left-vertical mode
-#
-#############################################################################
-#
-# ALIAS DECLARATIONS
-#
-# Here we set up aliases for translating extensions into standard terminfo.
-#
-#---------------------------------- Termcap aliases -------------------------
-#
-# BSD aliases:
-#
-# This is a common error in many termcap files.  We'll get notified during
-# translation when this (or any other alias) fires.
-#
-capalias	sb	sr	BSD	scroll text down
-#
-# AT&T extensions:
-#
-# The old AT&T 5410, 5420, 5425, pc6300plus, 610, and s4 entries used a set of
-# nonstandard capabilities.  Its signature is the KM capability, used to name
-# some sort of keymap file.  EE, BO, CI, CV, XS, DS, FL and FE are in this
-# set.  Comments in the original, and a little cross-checking with other AT&T
-# documentation, seem to establish the following mappings:
-#
-capalias	BO	mr	AT&T	enter_reverse_mode
-capalias	CI	vi	AT&T	cursor_invisible
-capalias	CV	ve	AT&T	cursor_normal
-capalias	DS	mh	AT&T	enter_dim_mode
-#capalias	EE	me	AT&T	exit_attribute_mode	
-capalias	FE	LF	AT&T	label_on
-capalias	FL	LO	AT&T	label_off
-capalias	XS	mk	AT&T	enter_secure_mode
-#
-# We comment out EE because the conflicting XENIX EE is more common in 
-# old entries.
-#
-# XENIX extensions:
-#
-# These are the ones we know how to translate directly:
-#
-capalias	EE	mh	XENIX	exit_attribute_mode	
-capalias	GE	ae	XENIX	exit_alt_charset_mode
-capalias	GS	as	XENIX	enter_alt_charset_mode
-capalias	CF	vi	XENIX	cursor_invis
-capalias	CO	ve	XENIX	cursor_normal
-capalias	EN	@7	XENIX	key_end
-capalias	HM	kh	XENIX	key_home
-capalias	LD	kL	XENIX	key_dl
-capalias	PD	kN	XENIX	key_npage
-capalias	PN	po	XENIX	prtr_off
-capalias	PS	pf	XENIX	prtr_on
-capalias	PU	kP	XENIX	key_ppage
-capalias	RT	@8	XENIX	kent
-capalias	UP	ku	XENIX	kcuu1
-capalias	G6	IGNORE	XENIX	double-ACS_ULCORNER
-capalias	G7	IGNORE	XENIX	double-ACS_LLCORNER
-capalias	G5	IGNORE	XENIX	double-ACS_URCORNER
-capalias	G8	IGNORE	XENIX	double-ACS_LRCORNER
-capalias	Gr	IGNORE	XENIX	double-ACS_LTEE
-capalias	Gr	IGNORE	XENIX	double-ACS_RTEE
-capalias	Gu	IGNORE	XENIX	double-ACS_BTEE
-capalias	Gd	IGNORE	XENIX	double ACS_TTEE
-capalias	Gh	IGNORE	XENIX	double-ACS_HLINE
-capalias	Gv	IGNORE	XENIX	double-ACS_VLINE
-capalias	Gc	IGNORE	XENIX	double-ACS_PLUS
-capalias	GG	IGNORE	XENIX	acs-glitch
-#
-# IBM extensions:
-#
-capalias	kq	%1	IBM	key_help
-#
-# Iris extensions:
-#
-capalias	HS	mh	IRIS	enter_dim_mode
-#
-# Tektronix extensions:
-#
-capalias	KA	k;	Tek	key_f10
-capalias	KB	F1	Tek	key_f11
-capalias	KC	F2	Tek	key_f12
-capalias	KD	F3	Tek	key_f13
-capalias	KE	F4	Tek	key_f14
-capalias	KF	F5	Tek	key_f15
-capalias	BC	Sb	Tek	set_background
-capalias	FC	Sf	Tek	set_foreground
-#
-# There are also the following:
-#
-#	XENIX	XENIX variable name	name clash with terminfo?
-#	-----	-------------------	-------------------------
-#	CL	key_char_left
-#	CR	key_char_right
-#	CW	key_change_window
-#	HP	??
-#	LF	key_linefeed 		label_off
-#	NU	key_next_unlocked_cell
-#	PL	??
-#	PR	??
-#	RC	key_recalc		remove_clock
-#	RF	key_toggle_ref		req_for_input
-#	WL	key_word_left
-#	WR	key_word_right
-#
-# If you know what any of the question-marked ones mean, please tell us.
-#
-#--------------------------------- Terminfo aliases ------------------------
-#
-# IBM extensions:
-#
-infoalias	font0	s0ds	IBM	set0_des_seq
-infoalias	font1	s1ds	IBM	set1_des_seq
-infoalias	font2	s2ds	IBM	set2_des_seq
-infoalias	font3	s3ds	IBM	set3_des_seq
-infoalias	kbtab	kcbt	IBM	key_backtab
-infoalias	ksel	kslt	IBM	key_select
-#
-# Some others are identical to SVr4/XPG4 capabilities, in particular:
-# kcmd, kend, khlp, and kf11...kf63.
 #
 #############################################################################
diff --git a/include/MKhashsize.sh b/include/MKhashsize.sh
index 11b3111..8a534d4 100755
--- a/include/MKhashsize.sh
+++ b/include/MKhashsize.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 1998,2006 Free Software Foundation, Inc.                     #
+# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 1998,2006 Free Software Foundation, Inc.                         #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -26,7 +27,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKhashsize.sh,v 1.7 2006/10/22 00:45:39 tom Exp $
+# $Id: MKhashsize.sh,v 1.9 2020/02/02 23:34:34 tom Exp $
 #
 # MKhashsize.sh --- generate size include for hash functions
 #
@@ -34,8 +35,8 @@
 echo " * hashsize.h -- hash and token table constants"
 echo " */"
 
-CAPS="${1-Caps}"
-TABSIZE=`grep -v '^[ #]' $CAPS | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | wc -l`
+test $# = 0 && set Caps
+TABSIZE=`cat "$@" | grep -v '^[ #]' | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | grep -v "^userdef" | grep -v "^used_by" | wc -l`
 
 echo ""
 echo "#define CAPTABSIZE	${TABSIZE}"
diff --git a/include/MKkey_defs.sh b/include/MKkey_defs.sh
index 45a06d0..e58ee2b 100755
--- a/include/MKkey_defs.sh
+++ b/include/MKkey_defs.sh
@@ -1,7 +1,8 @@
 #! /bin/sh
-# $Id: MKkey_defs.sh,v 1.15 2013/03/09 16:32:01 tom Exp $
+# $Id: MKkey_defs.sh,v 1.24 2024/01/19 12:26:17 tom Exp $
 ##############################################################################
-# Copyright (c) 2001-2003,2013 Free Software Foundation, Inc.                #
+# Copyright 2019-2022,2024 Thomas E. Dickey                                  #
+# Copyright 2001-2013,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -34,26 +35,28 @@
 #
 # Extract function-key definitions from the Caps file
 #
-: ${AWK-awk}
-DATA=${1-Caps}
+: "${AWK-awk}"
+
+test $# = 0 && set Caps
 
 data=data$$
 pass1=pass1_$$
 pass2=pass2_$$
 pass3=pass3_$$
 pass4=pass4_$$
-trap 'rm -f $data pass[1234]_$$' 0 1 2 5 15
+trap 'rm -f $data pass[1234]_$$; exit 1' 1 2 3 15
+trap 'rm -f $data pass[1234]_$$' 0
 
 # change repeated tabs (used for readability) to single tabs (needed to make
 # awk see the right field alignment of the corresponding columns):
-if sort -k 6 $DATA >$data 2>/dev/null
+if sort -k 6 "$@" >$data 2>/dev/null
 then
 	# POSIX
-	sed -e 's/[	][	]*/	/g' < $DATA |sort -n -k 6 >$data
-elif sort -n +5 $DATA >$data 2>/dev/null
+	sed -e 's/[	][	]*/	/g' "$@" |sort -n -k 6 >$data
+elif sort -n +5 "$@" >$data 2>/dev/null
 then
 	# SunOS (and SVr4, marked as obsolete but still recognized)
-	sed -e 's/[	][	]*/	/g' < $DATA |sort -n +5 >$data
+	sed -e 's/[	][	]*/	/g' "$@" |sort -n +5 >$data
 else
 	echo "Your sort utility is broken.  Please install one that works." >&2
 	exit 1
@@ -61,16 +64,14 @@
 
 # add keys that we generate automatically:
 cat >>$data <<EOF
-key_resize	kr1	str	R1	KEY_RESIZE	+	-----	Terminal resize event
-key_event	kv1	str	V1	KEY_EVENT	+	-----	We were interrupted by an event
+key_resize	kr1	str	R1	KEY_RESIZE	+	NCURSES_SIGWINCH 	Terminal resize event
 EOF
 
-THIS=./`basename $0`
-PARM=./`basename $DATA`
+THIS=./`basename "$0"`
 
 cat <<EOF
 /*
- * These definitions were generated by $THIS $PARM
+ * These definitions were generated by $THIS $*
  */
 EOF
 
@@ -124,6 +125,8 @@
 /^#/		{next;}
 /^capalias/	{next;}
 /^infoalias/	{next;}
+/^used_by/	{next;}
+/^userdef/	{next;}
 
 $5 != "-" && $6 != "-" {
 		if ($6 == "+") {
@@ -139,6 +142,12 @@
 			maxkey = thiskey;
 		if (pass == 2 || pass == 3) {
 			showkey=sprintf(octal_fmt, thiskey);
+			ifdef = 0;
+			if (index($7,"NCURSES_") == 1) {
+				ifdef = 1;
+				printf "\n";
+				printf "#if %s\n", $7;
+			}
 			if ($5 == "KEY_F(0)" ) {
 				printf "#define "
 				print_cols("KEY_F0", 16);
@@ -157,6 +166,9 @@
 					printf " %s", $i
 				print " */"
 			}
+			if (ifdef != 0) {
+				printf "#endif\n";
+			}
 		}
 	}
 END	{
diff --git a/include/MKncurses_def.sh b/include/MKncurses_def.sh
index 4aac865..22d80c2 100755
--- a/include/MKncurses_def.sh
+++ b/include/MKncurses_def.sh
@@ -1,7 +1,8 @@
 #! /bin/sh
-# $Id: MKncurses_def.sh,v 1.2 2003/10/25 16:19:46 tom Exp $
+# $Id: MKncurses_def.sh,v 1.5 2022/07/16 17:03:59 tom Exp $
 ##############################################################################
-# Copyright (c) 2000 Free Software Foundation, Inc.                          #
+# Copyright 2020,2022 Thomas E. Dickey                                       #
+# Copyright 2000,2003 Free Software Foundation, Inc.                         #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -55,7 +56,7 @@
 
 EOF
 
-${AWK-awk} <$DEFS '
+"${AWK-awk}" <"$DEFS" '
 !/^[@#]/ {
 	if ( NF == 1 )
 	{
diff --git a/include/MKparametrized.sh b/include/MKparametrized.sh
index 3ce5d9c..5d0cae1 100755
--- a/include/MKparametrized.sh
+++ b/include/MKparametrized.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 1998-2006,2014 Free Software Foundation, Inc.                #
+# Copyright 2019,2020 Thomas E. Dickey                                       #
+# Copyright 1998-2014,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -26,15 +27,18 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: MKparametrized.sh,v 1.7 2014/05/24 15:07:19 tom Exp $
+# $Id: MKparametrized.sh,v 1.10 2020/02/02 23:34:34 tom Exp $
 #
 # MKparametrized.sh -- generate indirection vectors for various sort methods
 #
 # The output of this script is C source for an array specifying whether
 # termcap strings should undergo parameter and padding translation.
 #
-CAPS="${1-Caps}"
+[ $# = 0 ] && set - Caps
+
 cat <<EOF
+#ifndef PARAMETRIZED_H
+#define PARAMETRIZED_H 1
 /*
  * parametrized.h --- is a termcap capability parametrized?
  *
@@ -52,7 +56,14 @@
 # XENIX acs_* capabilities.  Maybe someday we'll dedicate a flag field for
 # this, that would be cleaner....
 
-${AWK-awk} <$CAPS '
+cat "$@" | ${AWK-awk} '
+
+/^#/ { next ; }
+/^capalias/ { next ; }
+/^infoalias/ { next ; }
+/^used_by/ { next ; }
+/^userdef/ { next ; }
+
 $3 != "str"		{next;}
 $1 ~ /^acs_/		{print "-1,\t/* ", $2, " */"; count++; next;}
 $1 ~ /^label_format/	{print "-1,\t/* ", $2, " */"; count++; next;}
@@ -61,3 +72,4 @@
 END			{printf("} /* %d entries */;\n\n", count);}
 '
 
+echo "#endif /* PARAMETRIZED_H */"
diff --git a/include/MKterm.h.awk b/include/MKterm.h.awk
deleted file mode 100644
index 3ba0433..0000000
--- a/include/MKterm.h.awk
+++ /dev/null
@@ -1,334 +0,0 @@
-# vile:awkmode
-BEGIN		{
-		    print  "/****************************************************************************"
-		    print  " * Copyright (c) 1998-2011,2013 Free Software Foundation, Inc.              *"
-		    print  " *                                                                          *"
-		    print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
-		    print  " * copy of this software and associated documentation files (the            *"
-		    print  " * \"Software\"), to deal in the Software without restriction, including      *"
-		    print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
-		    print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
-		    print  " * copies of the Software, and to permit persons to whom the Software is    *"
-		    print  " * furnished to do so, subject to the following conditions:                 *"
-		    print  " *                                                                          *"
-		    print  " * The above copyright notice and this permission notice shall be included  *"
-		    print  " * in all copies or substantial portions of the Software.                   *"
-		    print  " *                                                                          *"
-		    print  " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
-		    print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
-		    print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
-		    print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
-		    print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
-		    print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
-		    print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
-		    print  " *                                                                          *"
-		    print  " * Except as contained in this notice, the name(s) of the above copyright   *"
-		    print  " * holders shall not be used in advertising or otherwise to promote the     *"
-		    print  " * sale, use or other dealings in this Software without prior written       *"
-		    print  " * authorization.                                                           *"
-		    print  " ****************************************************************************/"
-		    print  ""
-		    print  "/****************************************************************************/"
-		    print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
-		    print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
-		    print  "/*    and: Thomas E. Dickey                        1995-on                  */"
-		    print  "/****************************************************************************/"
-		    print  ""
-		    print  "/* $Id: MKterm.h.awk.in,v 1.62 2013/08/17 19:21:56 tom Exp $ */"
-		    print  ""
-		    print  "/*"
-		    print  "**	term.h -- Definition of struct term"
-		    print  "*/"
-		    print  ""
-		    print  "#ifndef NCURSES_TERM_H_incl"
-		    print  "#define NCURSES_TERM_H_incl 1"
-		    print  ""
-		    print  "#undef  NCURSES_VERSION"
-		    print  "#define NCURSES_VERSION \"6.0\""
-		    print  ""
-		    print  "#include <ncurses_dll.h>"
-		    print  ""
-		    print  "#ifdef __cplusplus"
-		    print  "extern \"C\" {"
-		    print  "#endif"
-		    print  ""
-		    print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
-		    print  " * definition (based on the system for which this was configured)."
-		    print  " */"
-		    print  ""
-		    print  "#undef  NCURSES_CONST"
-		    print  "#define NCURSES_CONST const"
-		    print  ""
-		    print  "#undef  NCURSES_SBOOL"
-		    print  "#define NCURSES_SBOOL char"
-		    print  ""
-		    print  "#undef  NCURSES_USE_DATABASE"
-		    print  "#define NCURSES_USE_DATABASE 1"
-		    print  ""
-		    print  "#undef  NCURSES_USE_TERMCAP"
-		    print  "#define NCURSES_USE_TERMCAP 0"
-		    print  ""
-		    print  "#undef  NCURSES_XNAMES"
-		    print  "#define NCURSES_XNAMES 1"
-		    print  ""
-		    print  "/* We will use these symbols to hide differences between"
-		    print  " * termios/termio/sgttyb interfaces."
-		    print  " */"
-		    print  "#undef  TTY"
-		    print  "#undef  SET_TTY"
-		    print  "#undef  GET_TTY"
-		    print  ""
-		    print  "/* Assume POSIX termio if we have the header and function */"
-		    print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
-		    print  "#if 1 && 1"
-		    print  ""
-		    print  "#undef  TERMIOS"
-		    print  "#define TERMIOS 1"
-		    print  ""
-		    print  "#include <termios.h>"
-		    print  "#define TTY struct termios"
-		    print  ""
-		    print  "#else /* !HAVE_TERMIOS_H */"
-		    print  ""
-		    print  "/* #if HAVE_TERMIO_H */"
-		    print  "#if 1"
-		    print  ""
-		    print  "#undef  TERMIOS"
-		    print  "#define TERMIOS 1"
-		    print  ""
-		    print  "#include <termio.h>"
-		    print  "#define TTY struct termio"
-		    print  ""
-		    print  "#else /* !HAVE_TERMIO_H */"
-		    print  ""
-		    print  "#if __MINGW32__"
-		    print  "#  include <ncurses_mingw.h>"
-		    print  "#  define TTY struct termios"
-		    print  "#else"
-		    print  "#undef TERMIOS"
-		    print  "#include <sgtty.h>"
-		    print  "#include <sys/ioctl.h>"
-		    print  "#define TTY struct sgttyb"
-		    print  "#endif /* MINGW32 */"
-		    print  "#endif /* HAVE_TERMIO_H */"
-		    print  ""
-		    print  "#endif /* HAVE_TERMIOS_H */"
-		    print  ""
-		    print  "#ifdef TERMIOS"
-		    print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
-		    print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
-		    print  "#else"
-		    print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
-		    print  "#define SET_TTY(fd, buf) stty(fd, buf)"
-		    print  "#endif"
-		    print  ""
-		    print  "#define NAMESIZE 256"
-		    print  ""
-		    print  "#define CUR cur_term->type."
-		    print  ""
-		}
-
-$2 == "%%-STOP-HERE-%%"	{
-			print  ""
-			printf "#define BOOLWRITE %d\n", BoolCount
-			printf "#define NUMWRITE  %d\n", NumberCount
-			printf "#define STRWRITE  %d\n", StringCount
-			print  ""
-			print  "/* older synonyms for some capabilities */"
-			print  "#define beehive_glitch	no_esc_ctlc"
-			print  "#define teleray_glitch	dest_tabs_magic_smso"
-			print  "#define micro_char_size micro_col_size"
-			print  ""
-			print  "#ifdef __INTERNAL_CAPS_VISIBLE"
-		}
-
-/^#/		{next;}
-
-$1 == "acs_chars"	{acsindex = StringCount}
-
-$3 == "bool"	{
-		    printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
-		}
-
-$3 == "num"	{
-		    printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
-		}
-
-$3 == "str"	{
-		    printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
-		}
-
-END		{
-			print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
-			print  ""
-			print  ""
-			print  "/*"
-			print  " * Predefined terminfo array sizes"
-			print  " */"
-			printf "#define BOOLCOUNT %d\n", BoolCount
-			printf "#define NUMCOUNT  %d\n", NumberCount
-			printf "#define STRCOUNT  %d\n", StringCount
-			print  ""
-			print  "/* used by code for comparing entries */"
-			print  "#define acs_chars_index	", acsindex
-			print  ""
-			print  "typedef struct termtype {	/* in-core form of terminfo data */"
-			print  "    char  *term_names;		/* str_table offset of term names */"
-			print  "    char  *str_table;		/* pointer to string table */"
-			print  "    NCURSES_SBOOL  *Booleans;	/* array of boolean values */"
-			print  "    short *Numbers;		/* array of integer values */"
-			print  "    char  **Strings;		/* array of string offsets */"
-			print  ""
-			print  "#if NCURSES_XNAMES"
-			print  "    char  *ext_str_table;	/* pointer to extended string table */"
-			print  "    char  **ext_Names;		/* corresponding names */"
-			print  ""
-			print  "    unsigned short num_Booleans;/* count total Booleans */"
-			print  "    unsigned short num_Numbers;	/* count total Numbers */"
-			print  "    unsigned short num_Strings;	/* count total Strings */"
-			print  ""
-			print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
-			print  "    unsigned short ext_Numbers;	/* count extensions to Numbers */"
-			print  "    unsigned short ext_Strings;	/* count extensions to Strings */"
-			print  "#endif /* NCURSES_XNAMES */"
-			print  ""
-			print  "} TERMTYPE;"
-			print  ""
-			print  "typedef struct term {		/* describe an actual terminal */"
-			print  "    TERMTYPE	type;		/* terminal type description */"
-			print  "    short	Filedes;	/* file description being written to */"
-			print  "    TTY		Ottyb,		/* original state of the terminal */"
-			print  "		Nttyb;		/* current state of the terminal */"
-			print  "    int		_baudrate;	/* used to compute padding */"
-			print  "    char *      _termname;      /* used for termname() */"
-			print  "} TERMINAL;"
-			print  ""
-			print  "#if 0 && !0"
-			print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
-			print  "#elif 0"
-			print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
-			print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
-			print  "#else"
-			print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
-			print  "#endif"
-			print  ""
-			print  "#if 0 || 0"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
-			print  ""
-			print  "#define boolnames  NCURSES_PUBLIC_VAR(boolnames())"
-			print  "#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())"
-			print  "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
-			print  "#define numnames   NCURSES_PUBLIC_VAR(numnames())"
-			print  "#define numcodes   NCURSES_PUBLIC_VAR(numcodes())"
-			print  "#define numfnames  NCURSES_PUBLIC_VAR(numfnames())"
-			print  "#define strnames   NCURSES_PUBLIC_VAR(strnames())"
-			print  "#define strcodes   NCURSES_PUBLIC_VAR(strcodes())"
-			print  "#define strfnames  NCURSES_PUBLIC_VAR(strfnames())"
-			print  ""
-			print  "#else"
-			print  ""
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
-			print  ""
-			print  "#endif"
-			print  ""
-			print  "/* internals */"
-			print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
-			print  "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
-			print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
-			print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
-			print  "extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE *const);"
-			print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
-			print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
-			print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
-			print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
-			print  ""
-			print  "/* entry points */"
-			print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
-			print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
-			print  ""
-			print  "/* miscellaneous entry points */"
-			print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
-			print  "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
-			print  ""
-			print  "/* terminfo entry points, also declared in curses.h */"
-			print  "#if !defined(__NCURSES_H)"
-			print  "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
-			print  "extern NCURSES_EXPORT(int) putp (const char *);"
-			print  "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
-			print  ""
-			print  "#if 1 /* NCURSES_TPARM_VARARGS */"
-			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* special */"
-			print  "#else"
-			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* special */"
-			print  "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* special */"
-			print  "#endif"
-			print  ""
-			print  "extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */"
-			print  ""
-			print  "#endif /* __NCURSES_H */"
-			print  ""
-			print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
-			print  "#if !defined(NCURSES_TERMCAP_H_incl)"
-			print  "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
-			print  "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
-			print  "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
-			print  "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
-			print  "#endif /* NCURSES_TERMCAP_H_incl */"
-			print  ""
-			print  "/*"
-			print  " * Include curses.h before term.h to enable these extensions."
-			print  " */"
-			print  "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
-			print  ""
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);"
-			print  ""
-			print  "#if 1 /* NCURSES_TPARM_VARARGS */"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...);	/* special */"
-			print  "#else"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* special */"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...);	/* special */"
-			print  "#endif"
-			print  ""
-			print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
-			print  ""
-			print  "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
-			print  ""
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
-			print  "#endif /* NCURSES_SP_FUNCS */"
-			print  ""
-			print  "#ifdef __cplusplus"
-			print  "}"
-			print  "#endif"
-			print  ""
-			print  "#endif /* NCURSES_TERM_H_incl */"
-		}
diff --git a/include/MKterm.h.awk.in b/include/MKterm.h.awk.in
index 587ee52..a93d8e8 100644
--- a/include/MKterm.h.awk.in
+++ b/include/MKterm.h.awk.in
@@ -1,334 +1,413 @@
 # vile:awkmode
-BEGIN		{
-		    print  "/****************************************************************************"
-		    print  " * Copyright (c) 1998-2011,2013 Free Software Foundation, Inc.              *"
-		    print  " *                                                                          *"
-		    print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
-		    print  " * copy of this software and associated documentation files (the            *"
-		    print  " * \"Software\"), to deal in the Software without restriction, including      *"
-		    print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
-		    print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
-		    print  " * copies of the Software, and to permit persons to whom the Software is    *"
-		    print  " * furnished to do so, subject to the following conditions:                 *"
-		    print  " *                                                                          *"
-		    print  " * The above copyright notice and this permission notice shall be included  *"
-		    print  " * in all copies or substantial portions of the Software.                   *"
-		    print  " *                                                                          *"
-		    print  " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
-		    print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
-		    print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
-		    print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
-		    print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
-		    print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
-		    print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
-		    print  " *                                                                          *"
-		    print  " * Except as contained in this notice, the name(s) of the above copyright   *"
-		    print  " * holders shall not be used in advertising or otherwise to promote the     *"
-		    print  " * sale, use or other dealings in this Software without prior written       *"
-		    print  " * authorization.                                                           *"
-		    print  " ****************************************************************************/"
-		    print  ""
-		    print  "/****************************************************************************/"
-		    print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
-		    print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
-		    print  "/*    and: Thomas E. Dickey                        1995-on                  */"
-		    print  "/****************************************************************************/"
-		    print  ""
-		    print  "/* $Id: MKterm.h.awk.in,v 1.62 2013/08/17 19:21:56 tom Exp $ */"
-		    print  ""
-		    print  "/*"
-		    print  "**	term.h -- Definition of struct term"
-		    print  "*/"
-		    print  ""
-		    print  "#ifndef NCURSES_TERM_H_incl"
-		    print  "#define NCURSES_TERM_H_incl 1"
-		    print  ""
-		    print  "#undef  NCURSES_VERSION"
-		    print  "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
-		    print  ""
-		    print  "#include <ncurses_dll.h>"
-		    print  ""
-		    print  "#ifdef __cplusplus"
-		    print  "extern \"C\" {"
-		    print  "#endif"
-		    print  ""
-		    print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
-		    print  " * definition (based on the system for which this was configured)."
-		    print  " */"
-		    print  ""
-		    print  "#undef  NCURSES_CONST"
-		    print  "#define NCURSES_CONST @NCURSES_CONST@"
-		    print  ""
-		    print  "#undef  NCURSES_SBOOL"
-		    print  "#define NCURSES_SBOOL @NCURSES_SBOOL@"
-		    print  ""
-		    print  "#undef  NCURSES_USE_DATABASE"
-		    print  "#define NCURSES_USE_DATABASE @NCURSES_USE_DATABASE@"
-		    print  ""
-		    print  "#undef  NCURSES_USE_TERMCAP"
-		    print  "#define NCURSES_USE_TERMCAP @NCURSES_USE_TERMCAP@"
-		    print  ""
-		    print  "#undef  NCURSES_XNAMES"
-		    print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
-		    print  ""
-		    print  "/* We will use these symbols to hide differences between"
-		    print  " * termios/termio/sgttyb interfaces."
-		    print  " */"
-		    print  "#undef  TTY"
-		    print  "#undef  SET_TTY"
-		    print  "#undef  GET_TTY"
-		    print  ""
-		    print  "/* Assume POSIX termio if we have the header and function */"
-		    print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
-		    print  "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
-		    print  ""
-		    print  "#undef  TERMIOS"
-		    print  "#define TERMIOS 1"
-		    print  ""
-		    print  "#include <termios.h>"
-		    print  "#define TTY struct termios"
-		    print  ""
-		    print  "#else /* !HAVE_TERMIOS_H */"
-		    print  ""
-		    print  "/* #if HAVE_TERMIO_H */"
-		    print  "#if @HAVE_TERMIO_H@"
-		    print  ""
-		    print  "#undef  TERMIOS"
-		    print  "#define TERMIOS 1"
-		    print  ""
-		    print  "#include <termio.h>"
-		    print  "#define TTY struct termio"
-		    print  ""
-		    print  "#else /* !HAVE_TERMIO_H */"
-		    print  ""
-		    print  "#if __MINGW32__"
-		    print  "#  include <ncurses_mingw.h>"
-		    print  "#  define TTY struct termios"
-		    print  "#else"
-		    print  "#undef TERMIOS"
-		    print  "#include <sgtty.h>"
-		    print  "#include <sys/ioctl.h>"
-		    print  "#define TTY struct sgttyb"
-		    print  "#endif /* MINGW32 */"
-		    print  "#endif /* HAVE_TERMIO_H */"
-		    print  ""
-		    print  "#endif /* HAVE_TERMIOS_H */"
-		    print  ""
-		    print  "#ifdef TERMIOS"
-		    print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
-		    print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
-		    print  "#else"
-		    print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
-		    print  "#define SET_TTY(fd, buf) stty(fd, buf)"
-		    print  "#endif"
-		    print  ""
-		    print  "#define NAMESIZE 256"
-		    print  ""
-		    print  "#define CUR cur_term->type."
-		    print  ""
-		}
+function declare_termtype(number,suffix) {
+	printf "typedef struct termtype%s {	/* in-core form of terminfo data */\n", suffix;
+	print  "    char  *term_names;		/* str_table offset of term names */"
+	print  "    char  *str_table;		/* pointer to string table */"
+	print  "    NCURSES_SBOOL  *Booleans;	/* array of boolean values */"
+	printf "    %-5s *Numbers;		/* array of integer values */\n", number;
+	print  "    char  **Strings;		/* array of string offsets */"
+	print  ""
+	print  "#if NCURSES_XNAMES"
+	print  "    char  *ext_str_table;	/* pointer to extended string table */"
+	print  "    char  **ext_Names;		/* corresponding names */"
+	print  ""
+	print  "    unsigned short num_Booleans;/* count total Booleans */";
+	print  "    unsigned short num_Numbers;	/* count total Numbers */";
+	print  "    unsigned short num_Strings;	/* count total Strings */";
+	print  ""
+	print  "    unsigned short ext_Booleans;/* count extensions to Booleans */";
+	print  "    unsigned short ext_Numbers;	/* count extensions to Numbers */";
+	print  "    unsigned short ext_Strings;	/* count extensions to Strings */";
+	print  "#endif /* NCURSES_XNAMES */"
+	print  ""
+	printf "} TERMTYPE%s;\n", suffix;
+}
+BEGIN {
+	lcurl = "{";
+	rcurl = "}";
+	print  "/****************************************************************************"
+	print  " * Copyright 2018-2021,2023 Thomas E. Dickey                                *"
+	print  " * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *"
+	print  " *                                                                          *"
+	print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
+	print  " * copy of this software and associated documentation files (the            *"
+	print  " * \"Software\"), to deal in the Software without restriction, including      *"
+	print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
+	print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
+	print  " * copies of the Software, and to permit persons to whom the Software is    *"
+	print  " * furnished to do so, subject to the following conditions:                 *"
+	print  " *                                                                          *"
+	print  " * The above copyright notice and this permission notice shall be included  *"
+	print  " * in all copies or substantial portions of the Software.                   *"
+	print  " *                                                                          *"
+	print  " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
+	print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
+	print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
+	print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
+	print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
+	print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
+	print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
+	print  " *                                                                          *"
+	print  " * Except as contained in this notice, the name(s) of the above copyright   *"
+	print  " * holders shall not be used in advertising or otherwise to promote the     *"
+	print  " * sale, use or other dealings in this Software without prior written       *"
+	print  " * authorization.                                                           *"
+	print  " ****************************************************************************/"
+	print  ""
+	print  "/****************************************************************************/"
+	print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
+	print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
+	print  "/*    and: Thomas E. Dickey                        1995-on                  */"
+	print  "/****************************************************************************/"
+	print  ""
+	print  "/* $Id: MKterm.h.awk.in,v 1.85 2023/04/23 19:15:36 tom Exp $ */"
+	print  ""
+	print  "/*"
+	print  "**	term.h -- Definition of struct term"
+	print  "*/"
+	print  ""
+	print  "#ifndef NCURSES_TERM_H_incl"
+	print  "#define NCURSES_TERM_H_incl 1"
+	print  ""
+	print  "#undef  NCURSES_VERSION"
+	print  "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
+	print  ""
+	print  "#include <ncurses_dll.h>"
+	print  ""
+	print  "#ifdef __cplusplus"
+	printf "extern \"C\" %s\n", lcurl;
+	print  "#endif"
+	print  ""
+	print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
+	print  " * definition (based on the system for which this was configured)."
+	print  " */"
+	print  ""
+	print  "#ifndef __NCURSES_H"
+	print  ""
+	print  "typedef struct screen  SCREEN;"
+	print  ""
+	print  "#if @NCURSES_SP_FUNCS@"
+	print  "#undef  NCURSES_SP_FUNCS"
+	print  "#define NCURSES_SP_FUNCS @NCURSES_PATCH@"
+	print  "#undef  NCURSES_SP_NAME"
+	print  "#define NCURSES_SP_NAME(name) name##_sp"
+	print  ""
+	print  "/* Define the sp-funcs helper function */"
+	print  "#undef  NCURSES_SP_OUTC"
+	print  "#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)"
+	print  "typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);"
+	print  "#endif"
+	print  ""
+	print  "#endif /* __NCURSES_H */"
+	print  ""
+	print  "#undef  NCURSES_CONST"
+	print  "#define NCURSES_CONST @NCURSES_CONST@"
+	print  ""
+	print  "#undef  NCURSES_SBOOL"
+	print  "#define NCURSES_SBOOL @NCURSES_SBOOL@"
+	print  ""
+	print  "#undef  NCURSES_USE_DATABASE"
+	print  "#define NCURSES_USE_DATABASE @NCURSES_USE_DATABASE@"
+	print  ""
+	print  "#undef  NCURSES_USE_TERMCAP"
+	print  "#define NCURSES_USE_TERMCAP @NCURSES_USE_TERMCAP@"
+	print  ""
+	print  "#undef  NCURSES_XNAMES"
+	print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
+	print  ""
+	print  "/* We will use these symbols to hide differences between"
+	print  " * termios/termio/sgttyb interfaces."
+	print  " */"
+	print  "#undef  TTY"
+	print  "#undef  SET_TTY"
+	print  "#undef  GET_TTY"
+	print  ""
+	print  "/* Assume POSIX termio if we have the header and function */"
+	print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
+	print  "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
+	print  ""
+	print  "#undef  TERMIOS"
+	print  "#define TERMIOS 1"
+	print  ""
+	print  "#include <termios.h>"
+	print  "#define TTY struct termios"
+	print  ""
+	print  "#else /* !HAVE_TERMIOS_H */"
+	print  ""
+	print  "/* #if HAVE_TERMIO_H */"
+	print  "#if @HAVE_TERMIO_H@"
+	print  ""
+	print  "#undef  TERMIOS"
+	print  "#define TERMIOS 1"
+	print  ""
+	print  "#include <termio.h>"
+	print  "#define TTY struct termio"
+	print  ""
+	print  "#else /* !HAVE_TERMIO_H */"
+	print  ""
+	print  "#if (defined(_WIN32) || defined(_WIN64))"
+	print  "#if @EXP_WIN32_DRIVER@"
+	print  "#include <win32_curses.h>"
+	print  "#define TTY struct winconmode"
+	print  "#else"
+	print  "#include <ncurses_mingw.h>"
+	print  "#define TTY struct termios"
+	print  "#endif"
+	print  "#else"
+	print  "#undef TERMIOS"
+	print  "#include <sgtty.h>"
+	print  "#include <sys/ioctl.h>"
+	print  "#define TTY struct sgttyb"
+	print  "#endif /* MINGW32 */"
+	print  "#endif /* HAVE_TERMIO_H */"
+	print  ""
+	print  "#endif /* HAVE_TERMIOS_H */"
+	print  ""
+	print  "#ifdef TERMIOS"
+	print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
+	print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
+	print  "#elif @EXP_WIN32_DRIVER@ && (defined(_WIN32) || defined(_WIN64))"
+	print  "#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf)"
+	print  "#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf)"
+	print  "#else"
+	print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
+	print  "#define SET_TTY(fd, buf) stty(fd, buf)"
+	print  "#endif"
+	print  ""
+	print  "#ifndef	GCC_NORETURN"
+	print  "#define	GCC_NORETURN /* nothing */"
+	print  "#endif"
+	print  ""
+	print  "#define NAMESIZE 256"
+	print  ""
+	print  "/* The cast works because TERMTYPE is the first data in TERMINAL */"
+	print  "#define CUR ((TERMTYPE *)(cur_term))->"
+	print  ""
+}
 
-$2 == "%%-STOP-HERE-%%"	{
-			print  ""
-			printf "#define BOOLWRITE %d\n", BoolCount
-			printf "#define NUMWRITE  %d\n", NumberCount
-			printf "#define STRWRITE  %d\n", StringCount
-			print  ""
-			print  "/* older synonyms for some capabilities */"
-			print  "#define beehive_glitch	no_esc_ctlc"
-			print  "#define teleray_glitch	dest_tabs_magic_smso"
-			print  "#define micro_char_size micro_col_size"
-			print  ""
-			print  "#ifdef __INTERNAL_CAPS_VISIBLE"
-		}
+$2 == "%%-STOP-HERE-%%" {
+	print  ""
+	printf "#define BOOLWRITE %d\n", BoolCount
+	printf "#define NUMWRITE  %d\n", NumberCount
+	printf "#define STRWRITE  %d\n", StringCount
+	print  ""
+	print  "/* older synonyms for some capabilities */"
+	print  "#define beehive_glitch	no_esc_ctlc"
+	print  "#define teleray_glitch	dest_tabs_magic_smso"
+	print  ""
+	print  "/* HPUX-11 uses this name rather than the standard one */"
+	print  "#ifndef micro_char_size"
+	print  "#define micro_char_size micro_col_size"
+	print  "#endif"
+	print  ""
+	print  "#ifdef __INTERNAL_CAPS_VISIBLE"
+}
 
-/^#/		{next;}
+/^#/ { next; }
 
-$1 == "acs_chars"	{acsindex = StringCount}
+/^used_by/ { next ; }
+/^userdef/ { next ; }
 
-$3 == "bool"	{
-		    printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
-		}
+$1 == "acs_chars" {
+	acsindex = StringCount;
+}
 
-$3 == "num"	{
-		    printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
-		}
+$3 == "bool" {
+	printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
+}
 
-$3 == "str"	{
-		    printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
-		}
+$3 == "num" {
+	printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
+}
 
-END		{
-			print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
-			print  ""
-			print  ""
-			print  "/*"
-			print  " * Predefined terminfo array sizes"
-			print  " */"
-			printf "#define BOOLCOUNT %d\n", BoolCount
-			printf "#define NUMCOUNT  %d\n", NumberCount
-			printf "#define STRCOUNT  %d\n", StringCount
-			print  ""
-			print  "/* used by code for comparing entries */"
-			print  "#define acs_chars_index	", acsindex
-			print  ""
-			print  "typedef struct termtype {	/* in-core form of terminfo data */"
-			print  "    char  *term_names;		/* str_table offset of term names */"
-			print  "    char  *str_table;		/* pointer to string table */"
-			print  "    NCURSES_SBOOL  *Booleans;	/* array of boolean values */"
-			print  "    short *Numbers;		/* array of integer values */"
-			print  "    char  **Strings;		/* array of string offsets */"
-			print  ""
-			print  "#if NCURSES_XNAMES"
-			print  "    char  *ext_str_table;	/* pointer to extended string table */"
-			print  "    char  **ext_Names;		/* corresponding names */"
-			print  ""
-			print  "    unsigned short num_Booleans;/* count total Booleans */"
-			print  "    unsigned short num_Numbers;	/* count total Numbers */"
-			print  "    unsigned short num_Strings;	/* count total Strings */"
-			print  ""
-			print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
-			print  "    unsigned short ext_Numbers;	/* count extensions to Numbers */"
-			print  "    unsigned short ext_Strings;	/* count extensions to Strings */"
-			print  "#endif /* NCURSES_XNAMES */"
-			print  ""
-			print  "} TERMTYPE;"
-			print  ""
-			print  "typedef struct term {		/* describe an actual terminal */"
-			print  "    TERMTYPE	type;		/* terminal type description */"
-			print  "    short	Filedes;	/* file description being written to */"
-			print  "    TTY		Ottyb,		/* original state of the terminal */"
-			print  "		Nttyb;		/* current state of the terminal */"
-			print  "    int		_baudrate;	/* used to compute padding */"
-			print  "    char *      _termname;      /* used for termname() */"
-			print  "} TERMINAL;"
-			print  ""
-			print  "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@"
-			print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
-			print  "#elif @cf_cv_enable_reentrant@"
-			print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
-			print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
-			print  "#else"
-			print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
-			print  "#endif"
-			print  ""
-			print  "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
-			print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
-			print  ""
-			print  "#define boolnames  NCURSES_PUBLIC_VAR(boolnames())"
-			print  "#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())"
-			print  "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
-			print  "#define numnames   NCURSES_PUBLIC_VAR(numnames())"
-			print  "#define numcodes   NCURSES_PUBLIC_VAR(numcodes())"
-			print  "#define numfnames  NCURSES_PUBLIC_VAR(numfnames())"
-			print  "#define strnames   NCURSES_PUBLIC_VAR(strnames())"
-			print  "#define strcodes   NCURSES_PUBLIC_VAR(strcodes())"
-			print  "#define strfnames  NCURSES_PUBLIC_VAR(strfnames())"
-			print  ""
-			print  "#else"
-			print  ""
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
-			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
-			print  ""
-			print  "#endif"
-			print  ""
-			print  "/* internals */"
-			print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
-			print  "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
-			print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
-			print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
-			print  "extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE *const);"
-			print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
-			print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
-			print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
-			print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
-			print  ""
-			print  "/* entry points */"
-			print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
-			print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
-			print  ""
-			print  "/* miscellaneous entry points */"
-			print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
-			print  "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
-			print  ""
-			print  "/* terminfo entry points, also declared in curses.h */"
-			print  "#if !defined(__NCURSES_H)"
-			print  "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
-			print  "extern NCURSES_EXPORT(int) putp (const char *);"
-			print  "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
-			print  ""
-			print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
-			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* special */"
-			print  "#else"
-			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* special */"
-			print  "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* special */"
-			print  "#endif"
-			print  ""
-			print  "extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */"
-			print  ""
-			print  "#endif /* __NCURSES_H */"
-			print  ""
-			print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
-			print  "#if !defined(NCURSES_TERMCAP_H_incl)"
-			print  "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
-			print  "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
-			print  "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
-			print  "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
-			print  "#endif /* NCURSES_TERMCAP_H_incl */"
-			print  ""
-			print  "/*"
-			print  " * Include curses.h before term.h to enable these extensions."
-			print  " */"
-			print  "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
-			print  ""
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);"
-			print  ""
-			print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...);	/* special */"
-			print  "#else"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* special */"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...);	/* special */"
-			print  "#endif"
-			print  ""
-			print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);"
-			print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
-			print  ""
-			print  "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
-			print  ""
-			print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
-			print  "#endif /* NCURSES_SP_FUNCS */"
-			print  ""
-			print  "#ifdef __cplusplus"
-			print  "}"
-			print  "#endif"
-			print  ""
-			print  "#endif /* NCURSES_TERM_H_incl */"
-		}
+$3 == "str" {
+	printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
+}
+
+END {
+	print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
+	print  ""
+	print  ""
+	print  "/*"
+	print  " * Predefined terminfo array sizes"
+	print  " */"
+	printf "#define BOOLCOUNT %d\n", BoolCount
+	printf "#define NUMCOUNT  %d\n", NumberCount
+	printf "#define STRCOUNT  %d\n", StringCount
+	print  ""
+	print  "/* used by code for comparing entries */"
+	print  "#define acs_chars_index	", acsindex
+	print  ""
+	declare_termtype("short","");
+	print  ""
+	print  "/*"
+	print  " * The only reason these structures are visible is for read-only use."
+	print  " * Programs which modify the data are not, never were, portable across"
+	print  " * curses implementations."
+	print  " *"
+	print  " * The first field in TERMINAL is used in macros."
+	print  " * The remaining fields are private."
+	print  " */"
+	print  "#ifdef NCURSES_INTERNALS"
+	print  ""
+	print  "#undef TERMINAL"
+	print  "#define TERMINAL struct term"
+	print  "TERMINAL;"
+	print  ""
+	if (@NCURSES_EXT_COLORS@) {
+	declare_termtype("int","2");
+	} else {
+	print  "#undef TERMTYPE2"
+	print  "#define TERMTYPE2 TERMTYPE"
+	}
+	print  "#else"
+	print  ""
+	print  "typedef struct term {		/* describe an actual terminal */"
+	print  "    TERMTYPE	type;		/* terminal type description */"
+	print  "} TERMINAL;"
+	print  ""
+	print  "#endif /* NCURSES_INTERNALS */"
+	print  ""
+	print  ""
+	print  "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@"
+	print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
+	print  "#elif @cf_cv_enable_reentrant@"
+	print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
+	print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
+	print  "#else"
+	print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
+	print  "#endif"
+	print  ""
+	print  "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
+	print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
+	print  ""
+	print  "#define boolnames  NCURSES_PUBLIC_VAR(boolnames())"
+	print  "#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())"
+	print  "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
+	print  "#define numnames   NCURSES_PUBLIC_VAR(numnames())"
+	print  "#define numcodes   NCURSES_PUBLIC_VAR(numcodes())"
+	print  "#define numfnames  NCURSES_PUBLIC_VAR(numfnames())"
+	print  "#define strnames   NCURSES_PUBLIC_VAR(strnames())"
+	print  "#define strcodes   NCURSES_PUBLIC_VAR(strcodes())"
+	print  "#define strfnames  NCURSES_PUBLIC_VAR(strfnames())"
+	print  ""
+	print  "#else"
+	print  ""
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
+	print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
+	print  ""
+	print  "#endif"
+	print  ""
+	print  "/*"
+	print  " * These entrypoints are used only by the ncurses utilities such as tic."
+	print  " */"
+	print  "#ifdef NCURSES_INTERNALS"
+	print  ""
+	print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
+	print  "extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);"
+	print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);"
+	print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);"
+	print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
+	print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
+	print  "extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);"
+	print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
+	print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
+	print  ""
+	print  "#endif /* NCURSES_INTERNALS */"
+	print  ""
+	print  "/*"
+	print  " * Normal entry points"
+	print  " */"
+	print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
+	print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
+	print  ""
+	print  "/* miscellaneous entry points */"
+	print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
+	print  "extern NCURSES_EXPORT(int) setupterm (const char *,int,int *);"
+	print  ""
+	print  "/* terminfo entry points, also declared in curses.h */"
+	print  "#if !defined(__NCURSES_H)"
+	print  "extern NCURSES_EXPORT(char *) tigetstr (const char *);"
+	print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
+	print  "extern NCURSES_EXPORT(int) putp (const char *);"
+	print  "extern NCURSES_EXPORT(int) tigetflag (const char *);"
+	print  "extern NCURSES_EXPORT(int) tigetnum (const char *);"
+	print  ""
+	print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
+	print  "extern NCURSES_EXPORT(char *) tparm (const char *, ...);	/* special */"
+	print  "#else"
+	print  "extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long);	/* special */"
+	print  "#endif"
+	print  ""
+	print  "extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */"
+	print  "extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...);	/* special */"
+	print  "extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *);	/* special */"
+	print  ""
+	print  "#endif /* __NCURSES_H */"
+	print  ""
+	print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
+	print  "#if !defined(NCURSES_TERMCAP_H_incl)"
+	print  "extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);"
+	print  "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
+	print  "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
+	print  "extern NCURSES_EXPORT(int) tgetflag (const char *);"
+	print  "extern NCURSES_EXPORT(int) tgetnum (const char *);"
+	print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
+	print  "#endif /* NCURSES_TERMCAP_H_incl */"
+	print  ""
+	print  "/*"
+	print  " * Include curses.h before term.h to enable these extensions."
+	print  " */"
+	print  "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
+	print  ""
+	print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *);"
+	print  ""
+	print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
+	print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...);	/* special */"
+	print  "#else"
+	print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long);	/* special */"
+	print  "#endif"
+	print  ""
+	print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
+	print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **);"
+	print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
+	print  ""
+	print  "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
+	print  ""
+	print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
+	print  "#endif /* NCURSES_SP_FUNCS */"
+	print  ""
+	print  "/*"
+	print  " * Debugging features."
+	print  " */"
+	print  "extern GCC_NORETURN NCURSES_EXPORT(void)    exit_terminfo(int);"
+	print  ""
+	print  "#ifdef __cplusplus"
+	printf "%s\n", rcurl;
+	print  "#endif"
+	print  ""
+	print  "#endif /* NCURSES_TERM_H_incl */"
+}
diff --git a/include/Makefile b/include/Makefile
deleted file mode 100644
index e8470fc..0000000
--- a/include/Makefile
+++ /dev/null
@@ -1,181 +0,0 @@
-# $Id: Makefile.in,v 1.43 2015/08/05 09:25:55 tom Exp $
-##############################################################################
-# Copyright (c) 1998-2013,2015 Free Software Foundation, Inc.                #
-#                                                                            #
-# Permission is hereby granted, free of charge, to any person obtaining a    #
-# copy of this software and associated documentation files (the "Software"), #
-# to deal in the Software without restriction, including without limitation  #
-# the rights to use, copy, modify, merge, publish, distribute, distribute    #
-# with modifications, sublicense, and/or sell copies of the Software, and to #
-# permit persons to whom the Software is furnished to do so, subject to the  #
-# following conditions:                                                      #
-#                                                                            #
-# The above copyright notice and this permission notice shall be included in #
-# all copies or substantial portions of the Software.                        #
-#                                                                            #
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
-# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
-# DEALINGS IN THE SOFTWARE.                                                  #
-#                                                                            #
-# Except as contained in this notice, the name(s) of the above copyright     #
-# holders shall not be used in advertising or otherwise to promote the sale, #
-# use or other dealings in this Software without prior written               #
-# authorization.                                                             #
-##############################################################################
-#
-# Author: Thomas E. Dickey 1996-2001
-#
-# Makefile for ncurses source code.
-#
-# This makes/installs ncurses include-files
-#
-# The variable 'srcdir' refers to the source-distribution, and can be set with
-# the configure script by "--srcdir=DIR".
-
-# turn off _all_ suffix rules; we'll generate our own
-.SUFFIXES:
-
-SHELL		= /bin/sh
-
-THIS		= Makefile
-
-DESTDIR		= 
-srcdir		= .
-prefix		= /system
-exec_prefix	= ${prefix}
-includedir	= ${prefix}/include
-includesubdir	= /ncurses
-
-INCLUDEDIR	= $(DESTDIR)$(includedir)$(includesubdir)
-
-INSTALL		= /usr/bin/install -c
-INSTALL_DATA	= ${INSTALL} -m 644
-
-AWK		= mawk
-LN_S		= ln -s -f
-
-CTAGS		= 
-ETAGS		= 
-
-VERSION		= 6.0
-
-# The "Caps" file specifies the terminfo database format, as well as the list
-# of function keys.
-TERMINFO_CAPS	= $(srcdir)/Caps
-
-# These files are generated by the configure script
-CONFIG_SRC = \
-	MKterm.h.awk \
-	curses.head \
-	ncurses_dll.h \
-	termcap.h \
-	unctrl.h
-
-# These files are generated by this makefile
-AUTO_SRC = \
-	curses.h \
-	hashsize.h \
-	ncurses_def.h \
-	parametrized.h \
-	config.h \
-	term.h
-
-################################################################################
-all \
-libs \
-depend \
-sources \
-install ::	$(AUTO_SRC)
-
-curses.h : $(TERMINFO_CAPS) \
-		curses.head \
-		$(srcdir)/curses.tail \
-		$(srcdir)/MKkey_defs.sh
-	cat curses.head >$@
-	AWK=$(AWK) $(SHELL) $(srcdir)/MKkey_defs.sh $(TERMINFO_CAPS) >>$@
-	$(SHELL) -c 'if test "chtype" = "cchar_t" ; then cat $(srcdir)/curses.wide >>$@ ; fi'
-	cat $(srcdir)/curses.tail >>$@
-
-term.h: $(TERMINFO_CAPS) MKterm.h.awk
-	$(AWK) -f MKterm.h.awk $(TERMINFO_CAPS) > $@
-	$(SHELL) $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@
-
-hashsize.h: $(TERMINFO_CAPS) $(srcdir)/MKhashsize.sh
-	$(SHELL) $(srcdir)/MKhashsize.sh $(TERMINFO_CAPS) >$@
-
-ncurses_def.h: $(srcdir)/ncurses_defs $(srcdir)/MKncurses_def.sh
-	AWK=$(AWK) $(SHELL) $(srcdir)/MKncurses_def.sh $(srcdir)/ncurses_defs >$@
-
-parametrized.h: $(TERMINFO_CAPS) $(srcdir)/MKparametrized.sh
-	AWK=$(AWK) $(SHELL) $(srcdir)/MKparametrized.sh $(TERMINFO_CAPS) >$@
-
-# This is required by pthread.h on MinGW
-config.h:
-	touch $@
-
-tags:
-	$(CTAGS) *.[ch]
-
-#TAGS:
-#	$(ETAGS) *.[ch]
-
-mostlyclean ::
-	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
-
-clean :: mostlyclean
-	-rm -f $(AUTO_SRC)
-	-rm -rf *.dSYM
-
-distclean :: clean
-	-rm -f Makefile $(CONFIG_SRC) config.h
-
-realclean :: distclean
-
-###############################################################################
-# The remainder of this file is automatically generated during configuration
-###############################################################################
-
-# generated by mk-hdr.awk
-#  subset:     ticlib+termlib+ext_tinfo+base+ext_funcs
-#  compat:     yes
-
-${INCLUDEDIR} :
-	mkdir -p $@
-
-install \
-install.libs \
-install.includes :: ${AUTO_SRC} ${INCLUDEDIR} \
-		curses.h \
-		unctrl.h \
-		ncurses_dll.h \
-		term.h \
-		termcap.h \
-		$(srcdir)/tic.h \
-		$(srcdir)/term_entry.h \
-		$(srcdir)/nc_tparm.h
-	@ (cd ${INCLUDEDIR} && rm -f curses.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} curses.h
-	@ (cd ${INCLUDEDIR} && rm -f ncurses.h && ${LN_S} curses.h ncurses.h)
-	@ (cd ${INCLUDEDIR} && rm -f unctrl.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} unctrl.h
-	@ (cd ${INCLUDEDIR} && rm -f ncurses_dll.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} ncurses_dll.h
-	@ (cd ${INCLUDEDIR} && rm -f term.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} term.h
-	@ (cd ${INCLUDEDIR} && rm -f termcap.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} termcap.h
-	@ (cd ${INCLUDEDIR} && rm -f tic.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} $(srcdir)/tic.h
-	@ (cd ${INCLUDEDIR} && rm -f term_entry.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} $(srcdir)/term_entry.h
-	@ (cd ${INCLUDEDIR} && rm -f nc_tparm.h) ; ../headers.sh ${INSTALL_DATA} ${INCLUDEDIR} ${srcdir} $(srcdir)/nc_tparm.h
-
-uninstall \
-uninstall.libs \
-uninstall.includes ::
-	-@ (cd ${INCLUDEDIR} && rm -f curses.h)
-	-@ (cd ${INCLUDEDIR} && rm -f ncurses.h)
-	-@ (cd ${INCLUDEDIR} && rm -f unctrl.h)
-	-@ (cd ${INCLUDEDIR} && rm -f ncurses_dll.h)
-	-@ (cd ${INCLUDEDIR} && rm -f term.h)
-	-@ (cd ${INCLUDEDIR} && rm -f termcap.h)
-	-@ (cd ${INCLUDEDIR} && rm -f tic.h)
-	-@ (cd ${INCLUDEDIR} && rm -f term_entry.h)
-	-@ (cd ${INCLUDEDIR} && rm -f nc_tparm.h)
diff --git a/include/Makefile.in b/include/Makefile.in
index cfa9876..351383b 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,6 +1,7 @@
-# $Id: Makefile.in,v 1.43 2015/08/05 09:25:55 tom Exp $
+# $Id: Makefile.in,v 1.53 2021/07/03 18:56:51 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2013,2015 Free Software Foundation, Inc.                #
+# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
+# Copyright 1998-2013,2015 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -27,7 +28,7 @@
 # authorization.                                                             #
 ##############################################################################
 #
-# Author: Thomas E. Dickey 1996-2001
+# Author: Thomas E. Dickey 1996-on
 #
 # Makefile for ncurses source code.
 #
@@ -58,6 +59,10 @@
 AWK		= @AWK@
 LN_S		= @LN_S@
 
+CC		= @CC@
+CFLAGS		= @CFLAGS@ @EXTRA_CFLAGS@
+CPPFLAGS	= -DHAVE_CONFIG_H -I. @CPPFLAGS@
+
 CTAGS		= @CTAGS@
 ETAGS		= @ETAGS@
 
@@ -66,6 +71,8 @@
 # The "Caps" file specifies the terminfo database format, as well as the list
 # of function keys.
 TERMINFO_CAPS	= $(srcdir)/@TERMINFO_CAPS@
+CAPLIST	=	$(TERMINFO_CAPS) \
+		$(srcdir)/Caps-ncurses
 
 # These files are generated by the configure script
 CONFIG_SRC = \
@@ -85,33 +92,52 @@
 	term.h
 
 ################################################################################
+
+@MAKE_PHONY@.PHONY :	all
+@MAKE_PHONY@.PHONY :	check
+@MAKE_PHONY@.PHONY :	clean
+@MAKE_PHONY@.PHONY :	depend
+@MAKE_PHONY@.PHONY :	distclean
+@MAKE_PHONY@.PHONY :	install
+@MAKE_PHONY@.PHONY :	install.libs
+@MAKE_PHONY@.PHONY :	libs
+@MAKE_PHONY@.PHONY :	mostlyclean
+@MAKE_PHONY@.PHONY :	realclean
+@MAKE_PHONY@.PHONY :	sources
+@MAKE_PHONY@.PHONY :	uninstall
+@MAKE_PHONY@.PHONY :	uninstall.libs
+
 all \
 libs \
 depend \
 sources \
 install ::	$(AUTO_SRC)
 
-curses.h : $(TERMINFO_CAPS) \
+curses.h :	$(CAPLIST) \
 		curses.head \
 		$(srcdir)/curses.tail \
 		$(srcdir)/MKkey_defs.sh
 	cat curses.head >$@
-	AWK=$(AWK) $(SHELL) $(srcdir)/MKkey_defs.sh $(TERMINFO_CAPS) >>$@
+	AWK=$(AWK) $(SHELL) $(srcdir)/MKkey_defs.sh $(CAPLIST) >>$@
+	$(SHELL) -c 'if test "@NCURSES_WGETCH_EVENTS@" = "1" ; then cat $(srcdir)/curses.events >>$@ ; fi'
 	$(SHELL) -c 'if test "@NCURSES_CH_T@" = "cchar_t" ; then cat $(srcdir)/curses.wide >>$@ ; fi'
 	cat $(srcdir)/curses.tail >>$@
 
-term.h: $(TERMINFO_CAPS) MKterm.h.awk
-	$(AWK) -f MKterm.h.awk $(TERMINFO_CAPS) > $@
+term.h: 	$(CAPLIST) \
+		MKterm.h.awk
+	$(AWK) -f MKterm.h.awk $(CAPLIST) > $@
 	$(SHELL) $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@
 
-hashsize.h: $(TERMINFO_CAPS) $(srcdir)/MKhashsize.sh
-	$(SHELL) $(srcdir)/MKhashsize.sh $(TERMINFO_CAPS) >$@
+hashsize.h:	$(CAPLIST) \
+		$(srcdir)/MKhashsize.sh
+	$(SHELL) $(srcdir)/MKhashsize.sh $(CAPLIST) >$@
 
 ncurses_def.h: $(srcdir)/ncurses_defs $(srcdir)/MKncurses_def.sh
 	AWK=$(AWK) $(SHELL) $(srcdir)/MKncurses_def.sh $(srcdir)/ncurses_defs >$@
 
-parametrized.h: $(TERMINFO_CAPS) $(srcdir)/MKparametrized.sh
-	AWK=$(AWK) $(SHELL) $(srcdir)/MKparametrized.sh $(TERMINFO_CAPS) >$@
+parametrized.h: $(CAPLIST) \
+		$(srcdir)/MKparametrized.sh
+	AWK=$(AWK) $(SHELL) $(srcdir)/MKparametrized.sh $(CAPLIST) >$@
 
 # This is required by pthread.h on MinGW
 config.h:
@@ -135,6 +161,17 @@
 
 realclean :: distclean
 
+# Verify that each header-file can be compiled without including another.
+check:
+	@$(SHELL) -c "for header in *.h;\
+		do \
+			echo \"** testing \$${header}\" ; \
+			echo \"#include <\$${header}>\" >headers.c; \
+			echo \"int main(void) { return 0; }\" >>headers.c; \
+			$(CC) -c $(CFLAGS) $(CPPFLAGS) headers.c; \
+		done"
+	-@rm -f headers.*
+
 ###############################################################################
 # The remainder of this file is automatically generated during configuration
 ###############################################################################
diff --git a/include/capdefaults.c b/include/capdefaults.c
index da76cc1..0bdda14 100644
--- a/include/capdefaults.c
+++ b/include/capdefaults.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2008 Free Software Foundation, Inc.              *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2000,2008 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,11 +33,11 @@
  *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: capdefaults.c,v 1.14 2008/11/16 00:19:59 juergen Exp $ */
+/* $Id: capdefaults.c,v 1.16 2021/09/04 10:52:55 tom Exp $ */
 
     /*
      * Compute obsolete capabilities.  The reason this is an include file is
-     * that the two places where it's needed want the macros to generate
+     * that the two places where it is needed require the macros to generate
      * offsets to different structures.  See the file Caps for explanations of
      * these conversions.
      *
diff --git a/include/config.h b/include/config.h
deleted file mode 100644
index e69de29..0000000
--- a/include/config.h
+++ /dev/null
diff --git a/include/curses.events b/include/curses.events
new file mode 100644
index 0000000..2509b1b
--- /dev/null
+++ b/include/curses.events
@@ -0,0 +1,55 @@
+/* $Id: curses.events,v 1.4 2024/01/19 09:24:17 tom Exp $ */
+/*
+ * vile:cmode:
+ * This file is part of ncurses, designed to be appended after curses.h.in
+ * (see that file for the relevant copyright).
+ */
+
+/*
+ * This is an extension to support events...
+ */
+#ifdef NCURSES_WGETCH_EVENTS
+#if !defined(__BEOS__) || defined(__HAIKU__)
+   /* Fix _nc_timed_wait() on BEOS... */
+#  define NCURSES_EVENT_VERSION	1
+#endif	/* !defined(__BEOS__) */
+
+/*
+ * Bits to set in _nc_event.data.flags
+ */
+#  define _NC_EVENT_TIMEOUT_MSEC	1
+#  define _NC_EVENT_FILE		2
+#  define _NC_EVENT_FILE_READABLE	2
+#  if 0					/* Not supported yet... */
+#    define _NC_EVENT_FILE_WRITABLE	4
+#    define _NC_EVENT_FILE_EXCEPTION	8
+#  endif
+
+typedef struct
+{
+    int type;
+    union
+    {
+	long timeout_msec;	/* _NC_EVENT_TIMEOUT_MSEC */
+	struct
+	{
+	    unsigned int flags;
+	    int fd;
+	    unsigned int result;
+	} fev;				/* _NC_EVENT_FILE */
+    } data;
+} _nc_event;
+
+typedef struct
+{
+    int count;
+    int result_flags;	/* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
+    _nc_event *events[1];
+} _nc_eventlist;
+
+extern NCURSES_EXPORT(int) wgetch_events (WINDOW *, _nc_eventlist *) GCC_DEPRECATED(experimental option); /* experimental */
+extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *) GCC_DEPRECATED(experimental option); /* experimental */
+
+#define KEY_EVENT	0634		/* We were interrupted by an event */
+
+#endif /* NCURSES_WGETCH_EVENTS */
diff --git a/include/curses.h b/include/curses.h
deleted file mode 100644
index 1ca213b..0000000
--- a/include/curses.h
+++ /dev/null
@@ -1,1712 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey                        1996-on                 *
- ****************************************************************************/
-
-/* $Id: curses.h.in,v 1.241 2014/08/09 20:39:44 tom Exp $ */
-
-#ifndef __NCURSES_H
-#define __NCURSES_H
-
-#define CURSES 1
-#define CURSES_H 1
-
-/* These are defined only in curses.h, and are used for conditional compiles */
-#define NCURSES_VERSION_MAJOR 6
-#define NCURSES_VERSION_MINOR 0
-#define NCURSES_VERSION_PATCH 20150808
-
-/* This is defined in more than one ncurses header, for identification */
-#undef  NCURSES_VERSION
-#define NCURSES_VERSION "6.0"
-
-/*
- * Identify the mouse encoding version.
- */
-#define NCURSES_MOUSE_VERSION 2
-
-/*
- * Definitions to facilitate DLL's.
- */
-#include <ncurses_dll.h>
-
-#if 1
-#include <stdint.h>
-#endif
-
-/*
- * User-definable tweak to disable the include of <stdbool.h>.
- */
-#ifndef NCURSES_ENABLE_STDBOOL_H
-#define NCURSES_ENABLE_STDBOOL_H 1
-#endif
-
-/*
- * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
- * configured using --disable-macros.
- */
-#ifndef NCURSES_ATTR_T
-#define NCURSES_ATTR_T int
-#endif
-
-/*
- * Expands to 'const' if ncurses is configured using --enable-const.  Note that
- * doing so makes it incompatible with other implementations of X/Open Curses.
- */
-#undef  NCURSES_CONST
-#define NCURSES_CONST const
-
-#undef NCURSES_INLINE
-#define NCURSES_INLINE inline
-
-/*
- * The internal type used for color values, and for color-pairs.  The latter
- * allows the curses library to enumerate the combinations of foreground and
- * background colors used by an application, and is normally the product of the
- * total foreground and background colors.
- *
- * X/Open uses "short" for both of these types, ultimately because they are
- * numbers from the terminal database, which uses 16-bit signed values.
- */
-#undef	NCURSES_COLOR_T
-#define	NCURSES_COLOR_T short
-
-#undef	NCURSES_PAIRS_T
-#define	NCURSES_PAIRS_T short
-
-/*
- * Definition used to make WINDOW and similar structs opaque.
- */
-#ifndef NCURSES_OPAQUE
-#define NCURSES_OPAQUE 0
-#endif
-
-/*
- * The reentrant code relies on the opaque setting, but adds features.
- */
-#ifndef NCURSES_REENTRANT
-#define NCURSES_REENTRANT 0
-#endif
-
-/*
- * Control whether bindings for interop support are added.
- */
-#undef	NCURSES_INTEROP_FUNCS
-#define	NCURSES_INTEROP_FUNCS 1
-
-/*
- * The internal type used for window dimensions.
- */
-#undef	NCURSES_SIZE_T
-#define	NCURSES_SIZE_T short
-
-/*
- * Control whether tparm() supports varargs or fixed-parameter list.
- */
-#undef NCURSES_TPARM_VARARGS
-#define NCURSES_TPARM_VARARGS 1
-
-/*
- * Control type used for tparm's arguments.  While X/Open equates long and
- * char* values, this is not always workable for 64-bit platforms.
- */
-#undef NCURSES_TPARM_ARG
-#define NCURSES_TPARM_ARG intptr_t
-
-/*
- * NCURSES_CH_T is used in building the library, but not used otherwise in
- * this header file, since that would make the normal/wide-character versions
- * of the header incompatible.
- */
-#undef	NCURSES_CH_T
-#define NCURSES_CH_T chtype
-
-#if 1 && defined(_LP64)
-typedef unsigned chtype;
-typedef unsigned mmask_t;
-#else
-typedef uint32_t chtype;
-typedef uint32_t mmask_t;
-#endif
-
-/*
- * We need FILE, etc.  Include this before checking any feature symbols.
- */
-#include <stdio.h>
-
-/*
- * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or
- * conflicting) when _XOPEN_SOURCE is 500 or greater.  If NCURSES_WIDECHAR is
- * not already defined, e.g., if the platform relies upon nonstandard feature
- * test macros, define it at this point if the standard feature test macros
- * indicate that it should be defined.
- */
-#ifndef NCURSES_WIDECHAR
-#if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
-#define NCURSES_WIDECHAR 1
-#else
-#define NCURSES_WIDECHAR 0
-#endif
-#endif /* NCURSES_WIDECHAR */
-
-#include <stdarg.h>	/* we need va_list */
-#if NCURSES_WIDECHAR
-#include <stddef.h>	/* we want wchar_t */
-#endif
-
-/* X/Open and SVr4 specify that curses implements 'bool'.  However, C++ may also
- * implement it.  If so, we must use the C++ compiler's type to avoid conflict
- * with other interfaces.
- *
- * A further complication is that <stdbool.h> may declare 'bool' to be a
- * different type, such as an enum which is not necessarily compatible with
- * C++.  If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
- * Otherwise, let it remain a typedef to avoid conflicts with other #define's.
- * In either case, make a typedef for NCURSES_BOOL which can be used if needed
- * from either C or C++.
- */
-
-#undef TRUE
-#define TRUE    1
-
-#undef FALSE
-#define FALSE   0
-
-typedef unsigned NCURSES_BOOL;
-
-#if defined(__cplusplus)	/* __cplusplus, etc. */
-
-/* use the C++ compiler's bool type */
-#define NCURSES_BOOL bool
-
-#else			/* c89, c99, etc. */
-
-#if NCURSES_ENABLE_STDBOOL_H
-#include <stdbool.h>
-/* use whatever the C compiler decides bool really is */
-#define NCURSES_BOOL bool
-#else
-/* there is no predefined bool - use our own */
-#undef bool
-#define bool NCURSES_BOOL
-#endif
-
-#endif /* !__cplusplus, etc. */
-
-#ifdef __cplusplus
-extern "C" {
-#define NCURSES_CAST(type,value) static_cast<type>(value)
-#else
-#define NCURSES_CAST(type,value) (type)(value)
-#endif
-
-/*
- * X/Open attributes.  In the ncurses implementation, they are identical to the
- * A_ attributes.
- */
-#define WA_ATTRIBUTES	A_ATTRIBUTES
-#define WA_NORMAL	A_NORMAL
-#define WA_STANDOUT	A_STANDOUT
-#define WA_UNDERLINE	A_UNDERLINE
-#define WA_REVERSE	A_REVERSE
-#define WA_BLINK	A_BLINK
-#define WA_DIM		A_DIM
-#define WA_BOLD		A_BOLD
-#define WA_ALTCHARSET	A_ALTCHARSET
-#define WA_INVIS	A_INVIS
-#define WA_PROTECT	A_PROTECT
-#define WA_HORIZONTAL	A_HORIZONTAL
-#define WA_LEFT		A_LEFT
-#define WA_LOW		A_LOW
-#define WA_RIGHT	A_RIGHT
-#define WA_TOP		A_TOP
-#define WA_VERTICAL	A_VERTICAL
-
-#if 1
-#define WA_ITALIC	A_ITALIC	/* ncurses extension */
-#endif
-
-/* colors */
-#define COLOR_BLACK	0
-#define COLOR_RED	1
-#define COLOR_GREEN	2
-#define COLOR_YELLOW	3
-#define COLOR_BLUE	4
-#define COLOR_MAGENTA	5
-#define COLOR_CYAN	6
-#define COLOR_WHITE	7
-
-/* line graphics */
-
-#if 0 || NCURSES_REENTRANT
-NCURSES_WRAPPED_VAR(chtype*, acs_map);
-#define acs_map NCURSES_PUBLIC_VAR(acs_map())
-#else
-extern NCURSES_EXPORT_VAR(chtype) acs_map[];
-#endif
-
-#define NCURSES_ACS(c)	(acs_map[NCURSES_CAST(unsigned char,(c))])
-
-/* VT100 symbols begin here */
-#define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
-#define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
-#define ACS_URCORNER	NCURSES_ACS('k') /* upper right corner */
-#define ACS_LRCORNER	NCURSES_ACS('j') /* lower right corner */
-#define ACS_LTEE	NCURSES_ACS('t') /* tee pointing right */
-#define ACS_RTEE	NCURSES_ACS('u') /* tee pointing left */
-#define ACS_BTEE	NCURSES_ACS('v') /* tee pointing up */
-#define ACS_TTEE	NCURSES_ACS('w') /* tee pointing down */
-#define ACS_HLINE	NCURSES_ACS('q') /* horizontal line */
-#define ACS_VLINE	NCURSES_ACS('x') /* vertical line */
-#define ACS_PLUS	NCURSES_ACS('n') /* large plus or crossover */
-#define ACS_S1		NCURSES_ACS('o') /* scan line 1 */
-#define ACS_S9		NCURSES_ACS('s') /* scan line 9 */
-#define ACS_DIAMOND	NCURSES_ACS('`') /* diamond */
-#define ACS_CKBOARD	NCURSES_ACS('a') /* checker board (stipple) */
-#define ACS_DEGREE	NCURSES_ACS('f') /* degree symbol */
-#define ACS_PLMINUS	NCURSES_ACS('g') /* plus/minus */
-#define ACS_BULLET	NCURSES_ACS('~') /* bullet */
-/* Teletype 5410v1 symbols begin here */
-#define ACS_LARROW	NCURSES_ACS(',') /* arrow pointing left */
-#define ACS_RARROW	NCURSES_ACS('+') /* arrow pointing right */
-#define ACS_DARROW	NCURSES_ACS('.') /* arrow pointing down */
-#define ACS_UARROW	NCURSES_ACS('-') /* arrow pointing up */
-#define ACS_BOARD	NCURSES_ACS('h') /* board of squares */
-#define ACS_LANTERN	NCURSES_ACS('i') /* lantern symbol */
-#define ACS_BLOCK	NCURSES_ACS('0') /* solid square block */
-/*
- * These aren't documented, but a lot of System Vs have them anyway
- * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
- * The ACS_names may not match AT&T's, our source didn't know them.
- */
-#define ACS_S3		NCURSES_ACS('p') /* scan line 3 */
-#define ACS_S7		NCURSES_ACS('r') /* scan line 7 */
-#define ACS_LEQUAL	NCURSES_ACS('y') /* less/equal */
-#define ACS_GEQUAL	NCURSES_ACS('z') /* greater/equal */
-#define ACS_PI		NCURSES_ACS('{') /* Pi */
-#define ACS_NEQUAL	NCURSES_ACS('|') /* not equal */
-#define ACS_STERLING	NCURSES_ACS('}') /* UK pound sign */
-
-/*
- * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
- * is the right, b is the bottom, and l is the left.  t, r, b, and l might
- * be B (blank), S (single), D (double), or T (thick).  The subset defined
- * here only uses B and S.
- */
-#define ACS_BSSB	ACS_ULCORNER
-#define ACS_SSBB	ACS_LLCORNER
-#define ACS_BBSS	ACS_URCORNER
-#define ACS_SBBS	ACS_LRCORNER
-#define ACS_SBSS	ACS_RTEE
-#define ACS_SSSB	ACS_LTEE
-#define ACS_SSBS	ACS_BTEE
-#define ACS_BSSS	ACS_TTEE
-#define ACS_BSBS	ACS_HLINE
-#define ACS_SBSB	ACS_VLINE
-#define ACS_SSSS	ACS_PLUS
-
-#undef	ERR
-#define ERR     (-1)
-
-#undef	OK
-#define OK      (0)
-
-/* values for the _flags member */
-#define _SUBWIN         0x01	/* is this a sub-window? */
-#define _ENDLINE        0x02	/* is the window flush right? */
-#define _FULLWIN        0x04	/* is the window full-screen? */
-#define _SCROLLWIN      0x08	/* bottom edge is at screen bottom? */
-#define _ISPAD	        0x10	/* is this window a pad? */
-#define _HASMOVED       0x20	/* has cursor moved since last refresh? */
-#define _WRAPPED        0x40	/* cursor was just wrappped */
-
-/*
- * this value is used in the firstchar and lastchar fields to mark
- * unchanged lines
- */
-#define _NOCHANGE       -1
-
-/*
- * this value is used in the oldindex field to mark lines created by insertions
- * and scrolls.
- */
-#define _NEWINDEX	-1
-
-typedef struct screen  SCREEN;
-typedef struct _win_st WINDOW;
-
-typedef	chtype	attr_t;		/* ...must be at least as wide as chtype */
-
-#if NCURSES_WIDECHAR
-
-#if 0
-#ifdef mblen			/* libutf8.h defines it w/o undefining first */
-#undef mblen
-#endif
-#include <libutf8.h>
-#endif
-
-#if 0
-#include <wchar.h>		/* ...to get mbstate_t, etc. */
-#endif
-
-#if 0
-typedef unsigned short wchar_t;
-#endif
-
-#if 0
-typedef unsigned int wint_t;
-#endif
-
-/*
- * cchar_t stores an array of CCHARW_MAX wide characters.  The first is
- * normally a spacing character.  The others are non-spacing.  If those
- * (spacing and nonspacing) do not fill the array, a null L'\0' follows.
- * Otherwise, a null is assumed to follow when extracting via getcchar().
- */
-#define CCHARW_MAX	5
-typedef struct
-{
-    attr_t	attr;
-    wchar_t	chars[CCHARW_MAX];
-#if 0
-#undef NCURSES_EXT_COLORS
-#define NCURSES_EXT_COLORS 20150808
-    int		ext_color;	/* color pair, must be more than 16-bits */
-#endif
-}
-cchar_t;
-
-#endif /* NCURSES_WIDECHAR */
-
-#if !NCURSES_OPAQUE
-struct ldat;
-
-struct _win_st
-{
-	NCURSES_SIZE_T _cury, _curx; /* current cursor position */
-
-	/* window location and size */
-	NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
-	NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
-
-	short   _flags;		/* window state flags */
-
-	/* attribute tracking */
-	attr_t  _attrs;		/* current attribute for non-space character */
-	chtype  _bkgd;		/* current background char/attribute pair */
-
-	/* option values set by user */
-	bool	_notimeout;	/* no time out on function-key entry? */
-	bool	_clear;		/* consider all data in the window invalid? */
-	bool	_leaveok;	/* OK to not reset cursor on exit? */
-	bool	_scroll;	/* OK to scroll this window? */
-	bool	_idlok;		/* OK to use insert/delete line? */
-	bool	_idcok;		/* OK to use insert/delete char? */
-	bool	_immed;		/* window in immed mode? (not yet used) */
-	bool	_sync;		/* window in sync mode? */
-	bool	_use_keypad;	/* process function keys into KEY_ symbols? */
-	int	_delay;		/* 0 = nodelay, <0 = blocking, >0 = delay */
-
-	struct ldat *_line;	/* the actual line data */
-
-	/* global screen state */
-	NCURSES_SIZE_T _regtop;	/* top line of scrolling region */
-	NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
-
-	/* these are used only if this is a sub-window */
-	int	_parx;		/* x coordinate of this window in parent */
-	int	_pary;		/* y coordinate of this window in parent */
-	WINDOW	*_parent;	/* pointer to parent if a sub-window */
-
-	/* these are used only if this is a pad */
-	struct pdat
-	{
-	    NCURSES_SIZE_T _pad_y,      _pad_x;
-	    NCURSES_SIZE_T _pad_top,    _pad_left;
-	    NCURSES_SIZE_T _pad_bottom, _pad_right;
-	} _pad;
-
-	NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
-
-#if NCURSES_WIDECHAR
-	cchar_t  _bkgrnd;	/* current background char/attribute pair */
-#if 0
-	int	_color;		/* current color-pair for non-space character */
-#endif
-#endif
-};
-#endif /* NCURSES_OPAQUE */
-
-/*
- * This is an extension to support events...
- */
-#if 1
-#ifdef NCURSES_WGETCH_EVENTS
-#if !defined(__BEOS__) || defined(__HAIKU__)
-   /* Fix _nc_timed_wait() on BEOS... */
-#  define NCURSES_EVENT_VERSION	1
-#endif	/* !defined(__BEOS__) */
-
-/*
- * Bits to set in _nc_event.data.flags
- */
-#  define _NC_EVENT_TIMEOUT_MSEC	1
-#  define _NC_EVENT_FILE		2
-#  define _NC_EVENT_FILE_READABLE	2
-#  if 0					/* Not supported yet... */
-#    define _NC_EVENT_FILE_WRITABLE	4
-#    define _NC_EVENT_FILE_EXCEPTION	8
-#  endif
-
-typedef struct
-{
-    int type;
-    union
-    {
-	long timeout_msec;	/* _NC_EVENT_TIMEOUT_MSEC */
-	struct
-	{
-	    unsigned int flags;
-	    int fd;
-	    unsigned int result;
-	} fev;				/* _NC_EVENT_FILE */
-    } data;
-} _nc_event;
-
-typedef struct
-{
-    int count;
-    int result_flags;	/* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
-    _nc_event *events[1];
-} _nc_eventlist;
-
-extern NCURSES_EXPORT(int) wgetch_events (WINDOW *, _nc_eventlist *);	/* experimental */
-extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *);/* experimental */
-
-#endif /* NCURSES_WGETCH_EVENTS */
-#endif /* NCURSES_EXT_FUNCS */
-
-/*
- * GCC (and some other compilers) define '__attribute__'; we're using this
- * macro to alert the compiler to flag inconsistencies in printf/scanf-like
- * function calls.  Just in case '__attribute__' isn't defined, make a dummy.
- * Old versions of G++ do not accept it anyway, at least not consistently with
- * GCC.
- */
-#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__))
-#define __attribute__(p) /* nothing */
-#endif
-
-/*
- * We cannot define these in ncurses_cfg.h, since they require parameters to be
- * passed (that is non-portable).  If you happen to be using gcc with warnings
- * enabled, define
- *	GCC_PRINTF
- *	GCC_SCANF
- * to improve checking of calls to printw(), etc.
- */
-#ifndef GCC_PRINTFLIKE
-#if defined(GCC_PRINTF) && !defined(printf)
-#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
-#else
-#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
-#endif
-#endif
-
-#ifndef GCC_SCANFLIKE
-#if defined(GCC_SCANF) && !defined(scanf)
-#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
-#else
-#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
-#endif
-#endif
-
-#ifndef	GCC_NORETURN
-#define	GCC_NORETURN /* nothing */
-#endif
-
-#ifndef	GCC_UNUSED
-#define	GCC_UNUSED /* nothing */
-#endif
-
-/*
- * Curses uses a helper function.  Define our type for this to simplify
- * extending it for the sp-funcs feature.
- */
-typedef int (*NCURSES_OUTC)(int);
-
-/*
- * Function prototypes.  This is the complete X/Open Curses list of required
- * functions.  Those marked `generated' will have sources generated from the
- * macro definitions later in this file, in order to satisfy XPG4.2
- * requirements.
- */
-
-extern NCURSES_EXPORT(int) addch (const chtype);			/* generated */
-extern NCURSES_EXPORT(int) addchnstr (const chtype *, int);		/* generated */
-extern NCURSES_EXPORT(int) addchstr (const chtype *);			/* generated */
-extern NCURSES_EXPORT(int) addnstr (const char *, int);			/* generated */
-extern NCURSES_EXPORT(int) addstr (const char *);			/* generated */
-extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T);			/* generated */
-extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T);			/* generated */
-extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T);			/* generated */
-extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *);	/* generated */
-extern NCURSES_EXPORT(int) attr_off (attr_t, void *);			/* generated */
-extern NCURSES_EXPORT(int) attr_on (attr_t, void *);			/* generated */
-extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *);		/* generated */
-extern NCURSES_EXPORT(int) baudrate (void);				/* implemented */
-extern NCURSES_EXPORT(int) beep  (void);				/* implemented */
-extern NCURSES_EXPORT(int) bkgd (chtype);				/* generated */
-extern NCURSES_EXPORT(void) bkgdset (chtype);				/* generated */
-extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* generated */
-extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype);		/* generated */
-extern NCURSES_EXPORT(bool) can_change_color (void);			/* implemented */
-extern NCURSES_EXPORT(int) cbreak (void);				/* implemented */
-extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *);	/* generated */
-extern NCURSES_EXPORT(int) clear (void);				/* generated */
-extern NCURSES_EXPORT(int) clearok (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) clrtobot (void);				/* generated */
-extern NCURSES_EXPORT(int) clrtoeol (void);				/* generated */
-extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*);	/* implemented */
-extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*);			/* generated */
-extern NCURSES_EXPORT(int) COLOR_PAIR (int);				/* generated */
-extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int);	/* implemented */
-extern NCURSES_EXPORT(int) curs_set (int);				/* implemented */
-extern NCURSES_EXPORT(int) def_prog_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) def_shell_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) delay_output (int);				/* implemented */
-extern NCURSES_EXPORT(int) delch (void);				/* generated */
-extern NCURSES_EXPORT(void) delscreen (SCREEN *);			/* implemented */
-extern NCURSES_EXPORT(int) delwin (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) deleteln (void);				/* generated */
-extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int);	/* implemented */
-extern NCURSES_EXPORT(int) doupdate (void);				/* implemented */
-extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) echo (void);					/* implemented */
-extern NCURSES_EXPORT(int) echochar (const chtype);			/* generated */
-extern NCURSES_EXPORT(int) erase (void);				/* generated */
-extern NCURSES_EXPORT(int) endwin (void);				/* implemented */
-extern NCURSES_EXPORT(char) erasechar (void);				/* implemented */
-extern NCURSES_EXPORT(void) filter (void);				/* implemented */
-extern NCURSES_EXPORT(int) flash (void);				/* implemented */
-extern NCURSES_EXPORT(int) flushinp (void);				/* implemented */
-extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getch (void);				/* generated */
-extern NCURSES_EXPORT(int) getnstr (char *, int);			/* generated */
-extern NCURSES_EXPORT(int) getstr (char *);				/* generated */
-extern NCURSES_EXPORT(WINDOW *) getwin (FILE *);			/* implemented */
-extern NCURSES_EXPORT(int) halfdelay (int);				/* implemented */
-extern NCURSES_EXPORT(bool) has_colors (void);				/* implemented */
-extern NCURSES_EXPORT(bool) has_ic (void);				/* implemented */
-extern NCURSES_EXPORT(bool) has_il (void);				/* implemented */
-extern NCURSES_EXPORT(int) hline (chtype, int);				/* generated */
-extern NCURSES_EXPORT(void) idcok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(int) idlok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(void) immedok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(chtype) inch (void);				/* generated */
-extern NCURSES_EXPORT(int) inchnstr (chtype *, int);			/* generated */
-extern NCURSES_EXPORT(int) inchstr (chtype *);				/* generated */
-extern NCURSES_EXPORT(WINDOW *) initscr (void);				/* implemented */
-extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T);	/* implemented */
-extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T);		/* implemented */
-extern NCURSES_EXPORT(int) innstr (char *, int);			/* generated */
-extern NCURSES_EXPORT(int) insch (chtype);				/* generated */
-extern NCURSES_EXPORT(int) insdelln (int);				/* generated */
-extern NCURSES_EXPORT(int) insertln (void);				/* generated */
-extern NCURSES_EXPORT(int) insnstr (const char *, int);			/* generated */
-extern NCURSES_EXPORT(int) insstr (const char *);			/* generated */
-extern NCURSES_EXPORT(int) instr (char *);				/* generated */
-extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(bool) isendwin (void);				/* implemented */
-extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int);		/* implemented */
-extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int);		/* implemented */
-extern NCURSES_EXPORT(int) keypad (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(char) killchar (void);				/* implemented */
-extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(char *) longname (void);				/* implemented */
-extern NCURSES_EXPORT(int) meta (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) move (int, int);				/* generated */
-extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);		/* generated */
-extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *);	/* generated */
-extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *);		/* generated */
-extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *);	/* generated */
-extern NCURSES_EXPORT(int) mvcur (int,int,int,int);			/* implemented */
-extern NCURSES_EXPORT(int) mvdelch (int, int);				/* generated */
-extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int);		/* implemented */
-extern NCURSES_EXPORT(int) mvgetch (int, int);				/* generated */
-extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int);		/* generated */
-extern NCURSES_EXPORT(int) mvgetstr (int, int, char *);			/* generated */
-extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int);		/* generated */
-extern NCURSES_EXPORT(chtype) mvinch (int, int);			/* generated */
-extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *);		/* generated */
-extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int);		/* generated */
-extern NCURSES_EXPORT(int) mvinsch (int, int, chtype);			/* generated */
-extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *);		/* generated */
-extern NCURSES_EXPORT(int) mvinstr (int, int, char *);			/* generated */
-extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...)		/* implemented */
-		GCC_PRINTFLIKE(3,4);
-extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...)	/* implemented */
-		GCC_SCANFLIKE(3,4);
-extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype);	/* generated */
-extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */
-extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *);	/* generated */
-extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *);	/* generated */
-extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */
-extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *);	/* generated */
-extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int);			/* implemented */
-extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int);			/* generated */
-extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *);		/* generated */
-extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype);		/* generated */
-extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *);	/* generated */
-extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *);		/* generated */
-extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...)	/* implemented */
-		GCC_PRINTFLIKE(4,5);
-extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...)	/* implemented */
-		GCC_SCANFLIKE(4,5);
-extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int);	/* generated */
-extern NCURSES_EXPORT(int) napms (int);					/* implemented */
-extern NCURSES_EXPORT(WINDOW *) newpad (int,int);		       	/* implemented */
-extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *);	/* implemented */
-extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int);	       	/* implemented */
-extern NCURSES_EXPORT(int) nl (void);					/* implemented */
-extern NCURSES_EXPORT(int) nocbreak (void);				/* implemented */
-extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) noecho (void);				/* implemented */
-extern NCURSES_EXPORT(int) nonl (void);					/* implemented */
-extern NCURSES_EXPORT(void) noqiflush (void);				/* implemented */
-extern NCURSES_EXPORT(int) noraw (void);				/* implemented */
-extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *);		/* implemented */
-extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *);		/* implemented */
-extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*);		/* implemented */
-extern NCURSES_EXPORT(int) PAIR_NUMBER (int);				/* generated */
-extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype);		/* implemented */
-extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */
-extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int);	/* implemented */
-extern NCURSES_EXPORT(int) printw (const char *,...)			/* implemented */
-		GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *);			/* implemented */
-extern NCURSES_EXPORT(void) qiflush (void);				/* implemented */
-extern NCURSES_EXPORT(int) raw (void);					/* implemented */
-extern NCURSES_EXPORT(int) redrawwin (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) refresh (void);				/* generated */
-extern NCURSES_EXPORT(int) resetty (void);				/* implemented */
-extern NCURSES_EXPORT(int) reset_prog_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) reset_shell_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int));	/* implemented */
-extern NCURSES_EXPORT(int) savetty (void);				/* implemented */
-extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...)		/* implemented */
-		GCC_SCANFLIKE(1,2);
-extern NCURSES_EXPORT(int) scr_dump (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) scr_init (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) scrl (int);					/* generated */
-extern NCURSES_EXPORT(int) scroll (WINDOW *);				/* generated */
-extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) scr_restore (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) scr_set (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) setscrreg (int,int);				/* generated */
-extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *);			/* implemented */
-extern NCURSES_EXPORT(int) slk_attroff (const chtype);			/* implemented */
-extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *);		/* generated:WIDEC */
-extern NCURSES_EXPORT(int) slk_attron (const chtype);			/* implemented */
-extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*);			/* generated:WIDEC */
-extern NCURSES_EXPORT(int) slk_attrset (const chtype);			/* implemented */
-extern NCURSES_EXPORT(attr_t) slk_attr (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*);	/* implemented */
-extern NCURSES_EXPORT(int) slk_clear (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T);				/* implemented */
-extern NCURSES_EXPORT(int) slk_init (int);				/* implemented */
-extern NCURSES_EXPORT(char *) slk_label (int);				/* implemented */
-extern NCURSES_EXPORT(int) slk_noutrefresh (void);			/* implemented */
-extern NCURSES_EXPORT(int) slk_refresh (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_restore (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_set (int,const char *,int);		/* implemented */
-extern NCURSES_EXPORT(int) slk_touch (void);	      	       		/* implemented */
-extern NCURSES_EXPORT(int) standout (void);				/* generated */
-extern NCURSES_EXPORT(int) standend (void);				/* generated */
-extern NCURSES_EXPORT(int) start_color (void);				/* implemented */
-extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int);	/* implemented */
-extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int);	/* implemented */
-extern NCURSES_EXPORT(int) syncok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(chtype) termattrs (void);				/* implemented */
-extern NCURSES_EXPORT(char *) termname (void);				/* implemented */
-extern NCURSES_EXPORT(void) timeout (int);				/* generated */
-extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int);		/* generated */
-extern NCURSES_EXPORT(int) touchwin (WINDOW *);				/* generated */
-extern NCURSES_EXPORT(int) typeahead (int);				/* implemented */
-extern NCURSES_EXPORT(int) ungetch (int);				/* implemented */
-extern NCURSES_EXPORT(int) untouchwin (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(void) use_env (bool);				/* implemented */
-extern NCURSES_EXPORT(void) use_tioctl (bool);				/* implemented */
-extern NCURSES_EXPORT(int) vidattr (chtype);				/* implemented */
-extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC);		/* implemented */
-extern NCURSES_EXPORT(int) vline (chtype, int);				/* generated */
-extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list);	/* generated */
-extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list);	/* generated */
-extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype);		/* implemented */
-extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int);	/* implemented */
-extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *);		/* generated */
-extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int);	/* implemented */
-extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *);		/* generated */
-extern NCURSES_EXPORT(int) wattron (WINDOW *, int);			/* generated */
-extern NCURSES_EXPORT(int) wattroff (WINDOW *, int);			/* generated */
-extern NCURSES_EXPORT(int) wattrset (WINDOW *, int);			/* generated */
-extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *);	/* generated */
-extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *);		/* implemented */
-extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *);	/* implemented */
-extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *);	/* generated */
-extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype);			/* implemented */
-extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype);			/* implemented */
-extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* implemented */
-extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */
-extern NCURSES_EXPORT(int) wclear (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wclrtobot (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*);		/* implemented */
-extern NCURSES_EXPORT(void) wcursyncup (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wdelch (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wdeleteln (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype);		/* implemented */
-extern NCURSES_EXPORT(int) werase (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wgetch (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int);		/* implemented */
-extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *);			/* generated */
-extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int);		/* implemented */
-extern NCURSES_EXPORT(chtype) winch (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int);		/* implemented */
-extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *);		/* generated */
-extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int);		/* implemented */
-extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype);			/* implemented */
-extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int);			/* implemented */
-extern NCURSES_EXPORT(int) winsertln (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int);	/* implemented */
-extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *);		/* generated */
-extern NCURSES_EXPORT(int) winstr (WINDOW *, char *);			/* generated */
-extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int);			/* implemented */
-extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...)		/* implemented */
-		GCC_PRINTFLIKE(2,3);
-extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int);		/* implemented */
-extern NCURSES_EXPORT(int) wrefresh (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wscanw (WINDOW *, NCURSES_CONST char *,...)	/* implemented */
-		GCC_SCANFLIKE(2,3);
-extern NCURSES_EXPORT(int) wscrl (WINDOW *,int);			/* implemented */
-extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int);		/* implemented */
-extern NCURSES_EXPORT(int) wstandout (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) wstandend (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(void) wsyncdown (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(void) wsyncup (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int);			/* implemented */
-extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int);		/* implemented */
-extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int);		/* implemented */
-
-/*
- * These are also declared in <term.h>:
- */
-extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(int) putp (const char *);				/* implemented */
-
-#if NCURSES_TPARM_VARARGS
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* special */
-#else
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG);	/* special */
-extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* special */
-#endif
-
-extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */
-
-/*
- * These functions are not in X/Open, but we use them in macro definitions:
- */
-extern NCURSES_EXPORT(int) getattrs (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getcurx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getcury (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getbegx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getbegy (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getmaxx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getmaxy (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getparx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getpary (const WINDOW *);			/* generated */
-
-/*
- * vid_attr() was implemented originally based on a draft of X/Open curses.
- */
-#if !NCURSES_WIDECHAR
-#define vid_attr(a,pair,opts) vidattr(a)
-#endif
-
-/*
- * These functions are extensions - not in X/Open Curses.
- */
-#if 1
-#undef  NCURSES_EXT_FUNCS
-#define NCURSES_EXT_FUNCS 20150808
-typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
-typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
-extern NCURSES_EXPORT(bool) is_term_resized (int, int);
-extern NCURSES_EXPORT(char *) keybound (int, int);
-extern NCURSES_EXPORT(const char *) curses_version (void);
-extern NCURSES_EXPORT(int) assume_default_colors (int, int);
-extern NCURSES_EXPORT(int) define_key (const char *, int);
-extern NCURSES_EXPORT(int) get_escdelay (void);
-extern NCURSES_EXPORT(int) key_defined (const char *);
-extern NCURSES_EXPORT(int) keyok (int, bool);
-extern NCURSES_EXPORT(int) resize_term (int, int);
-extern NCURSES_EXPORT(int) resizeterm (int, int);
-extern NCURSES_EXPORT(int) set_escdelay (int);
-extern NCURSES_EXPORT(int) set_tabsize (int);
-extern NCURSES_EXPORT(int) use_default_colors (void);
-extern NCURSES_EXPORT(int) use_extended_names (bool);
-extern NCURSES_EXPORT(int) use_legacy_coding (int);
-extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *);
-extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *);
-extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
-extern NCURSES_EXPORT(void) nofilter(void);
-
-/*
- * These extensions provide access to information stored in the WINDOW even
- * when NCURSES_OPAQUE is set:
- */
-extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_pad (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */
-
-#else
-#define curses_version() NCURSES_VERSION
-#endif
-
-/*
- * Extra extension-functions, which pass a SCREEN pointer rather than using
- * a global variable SP.
- */
-#if 1
-#undef  NCURSES_SP_FUNCS
-#define NCURSES_SP_FUNCS 20150808
-#define NCURSES_SP_NAME(name) name##_sp
-
-/* Define the sp-funcs helper function */
-#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)
-typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);
-
-extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */
-
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *);			/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool);	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, NCURSES_CONST char *, FILE *, FILE *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int));	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype);	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */
-#if 1
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-#endif
-#else
-#undef  NCURSES_SP_FUNCS
-#define NCURSES_SP_FUNCS 0
-#define NCURSES_SP_NAME(name) name
-#define NCURSES_SP_OUTC NCURSES_OUTC
-#endif
-
-/* attributes */
-
-#define NCURSES_ATTR_SHIFT       8
-#define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT))
-
-#define A_NORMAL	(1U - 1U)
-#define A_ATTRIBUTES	NCURSES_BITS(~(1U - 1U),0)
-#define A_CHARTEXT	(NCURSES_BITS(1U,0) - 1U)
-#define A_COLOR		NCURSES_BITS(((1U) << 8) - 1U,0)
-#define A_STANDOUT	NCURSES_BITS(1U,8)
-#define A_UNDERLINE	NCURSES_BITS(1U,9)
-#define A_REVERSE	NCURSES_BITS(1U,10)
-#define A_BLINK		NCURSES_BITS(1U,11)
-#define A_DIM		NCURSES_BITS(1U,12)
-#define A_BOLD		NCURSES_BITS(1U,13)
-#define A_ALTCHARSET	NCURSES_BITS(1U,14)
-#define A_INVIS		NCURSES_BITS(1U,15)
-#define A_PROTECT	NCURSES_BITS(1U,16)
-#define A_HORIZONTAL	NCURSES_BITS(1U,17)
-#define A_LEFT		NCURSES_BITS(1U,18)
-#define A_LOW		NCURSES_BITS(1U,19)
-#define A_RIGHT		NCURSES_BITS(1U,20)
-#define A_TOP		NCURSES_BITS(1U,21)
-#define A_VERTICAL	NCURSES_BITS(1U,22)
-
-#if 1
-#define A_ITALIC	NCURSES_BITS(1U,23)	/* ncurses extension */
-#endif
-
-/*
- * Most of the pseudo functions are macros that either provide compatibility
- * with older versions of curses, or provide inline functionality to improve
- * performance.
- */
-
-/*
- * These pseudo functions are always implemented as macros:
- */
-
-#define getyx(win,y,x)   	(y = getcury(win), x = getcurx(win))
-#define getbegyx(win,y,x)	(y = getbegy(win), x = getbegx(win))
-#define getmaxyx(win,y,x)	(y = getmaxy(win), x = getmaxx(win))
-#define getparyx(win,y,x)	(y = getpary(win), x = getparx(win))
-
-#define getsyx(y,x) do { if (newscr) { \
-			     if (is_leaveok(newscr)) \
-				(y) = (x) = -1; \
-			     else \
-				 getyx(newscr,(y), (x)); \
-			} \
-		    } while(0)
-
-#define setsyx(y,x) do { if (newscr) { \
-			    if ((y) == -1 && (x) == -1) \
-				leaveok(newscr, TRUE); \
-			    else { \
-				leaveok(newscr, FALSE); \
-				wmove(newscr, (y), (x)); \
-			    } \
-			} \
-		    } while(0)
-
-#ifndef NCURSES_NOMACROS
-
-/*
- * These miscellaneous pseudo functions are provided for compatibility:
- */
-
-#define wgetstr(w, s)		wgetnstr(w, s, -1)
-#define getnstr(s, n)		wgetnstr(stdscr, s, (n))
-
-#define setterm(term)		setupterm(term, 1, (int *)0)
-
-#define fixterm()		reset_prog_mode()
-#define resetterm()		reset_shell_mode()
-#define saveterm()		def_prog_mode()
-#define crmode()		cbreak()
-#define nocrmode()		nocbreak()
-#define gettmode()
-
-/* It seems older SYSV curses versions define these */
-#if !NCURSES_OPAQUE
-#define getattrs(win)		NCURSES_CAST(int, (win) ? (win)->_attrs : A_NORMAL)
-#define getcurx(win)		((win) ? (win)->_curx : ERR)
-#define getcury(win)		((win) ? (win)->_cury : ERR)
-#define getbegx(win)		((win) ? (win)->_begx : ERR)
-#define getbegy(win)		((win) ? (win)->_begy : ERR)
-#define getmaxx(win)		((win) ? ((win)->_maxx + 1) : ERR)
-#define getmaxy(win)		((win) ? ((win)->_maxy + 1) : ERR)
-#define getparx(win)		((win) ? (win)->_parx : ERR)
-#define getpary(win)		((win) ? (win)->_pary : ERR)
-#endif /* NCURSES_OPAQUE */
-
-#define wstandout(win)      	(wattrset(win,A_STANDOUT))
-#define wstandend(win)      	(wattrset(win,A_NORMAL))
-
-#define wattron(win,at)		wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
-#define wattroff(win,at)	wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
-
-#if !NCURSES_OPAQUE
-#if NCURSES_WIDECHAR && 0
-#define wattrset(win,at)	((win) \
-				  ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \
-                                     (win)->_attrs = NCURSES_CAST(attr_t, at), \
-                                     OK) \
-				  : ERR)
-#else
-#define wattrset(win,at)        ((win) \
-				  ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
-				     OK) \
-				  : ERR)
-#endif
-#endif /* NCURSES_OPAQUE */
-
-#define scroll(win)		wscrl(win,1)
-
-#define touchwin(win)		wtouchln((win), 0, getmaxy(win), 1)
-#define touchline(win, s, c)	wtouchln((win), s, c, 1)
-#define untouchwin(win)		wtouchln((win), 0, getmaxy(win), 0)
-
-#define box(win, v, h)		wborder(win, v, v, h, h, 0, 0, 0, 0)
-#define border(ls, rs, ts, bs, tl, tr, bl, br)	wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
-#define hline(ch, n)		whline(stdscr, ch, (n))
-#define vline(ch, n)		wvline(stdscr, ch, (n))
-
-#define winstr(w, s)		winnstr(w, s, -1)
-#define winchstr(w, s)		winchnstr(w, s, -1)
-#define winsstr(w, s)		winsnstr(w, s, -1)
-
-#if !NCURSES_OPAQUE
-#define redrawwin(win)		wredrawln(win, 0, ((win) ? (win)->_maxy+1 : -1))
-#endif /* NCURSES_OPAQUE */
-
-#define waddstr(win,str)	waddnstr(win,str,-1)
-#define waddchstr(win,str)	waddchnstr(win,str,-1)
-
-/*
- * These apply to the first 256 color pairs.
- */
-#define COLOR_PAIR(n)	NCURSES_BITS((n), 0)
-#define PAIR_NUMBER(a)	(NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
-
-/*
- * pseudo functions for standard screen
- */
-
-#define addch(ch)		waddch(stdscr,(ch))
-#define addchnstr(str,n)	waddchnstr(stdscr,(str),(n))
-#define addchstr(str)		waddchstr(stdscr,(str))
-#define addnstr(str,n)		waddnstr(stdscr,(str),(n))
-#define addstr(str)		waddnstr(stdscr,(str),-1)
-#define attroff(at)		wattroff(stdscr,(at))
-#define attron(at)		wattron(stdscr,(at))
-#define attrset(at)		wattrset(stdscr,(at))
-#define attr_get(ap,cp,o)	wattr_get(stdscr,(ap),(cp),(o))
-#define attr_off(a,o)		wattr_off(stdscr,(a),(o))
-#define attr_on(a,o)		wattr_on(stdscr,(a),(o))
-#define attr_set(a,c,o)		wattr_set(stdscr,(a),(c),(o))
-#define bkgd(ch)		wbkgd(stdscr,(ch))
-#define bkgdset(ch)		wbkgdset(stdscr,(ch))
-#define chgat(n,a,c,o)		wchgat(stdscr,(n),(a),(c),(o))
-#define clear()			wclear(stdscr)
-#define clrtobot()		wclrtobot(stdscr)
-#define clrtoeol()		wclrtoeol(stdscr)
-#define color_set(c,o)		wcolor_set(stdscr,(c),(o))
-#define delch()			wdelch(stdscr)
-#define deleteln()		winsdelln(stdscr,-1)
-#define echochar(c)		wechochar(stdscr,(c))
-#define erase()			werase(stdscr)
-#define getch()			wgetch(stdscr)
-#define getstr(str)		wgetstr(stdscr,(str))
-#define inch()			winch(stdscr)
-#define inchnstr(s,n)		winchnstr(stdscr,(s),(n))
-#define inchstr(s)		winchstr(stdscr,(s))
-#define innstr(s,n)		winnstr(stdscr,(s),(n))
-#define insch(c)		winsch(stdscr,(c))
-#define insdelln(n)		winsdelln(stdscr,(n))
-#define insertln()		winsdelln(stdscr,1)
-#define insnstr(s,n)		winsnstr(stdscr,(s),(n))
-#define insstr(s)		winsstr(stdscr,(s))
-#define instr(s)		winstr(stdscr,(s))
-#define move(y,x)		wmove(stdscr,(y),(x))
-#define refresh()		wrefresh(stdscr)
-#define scrl(n)			wscrl(stdscr,(n))
-#define setscrreg(t,b)		wsetscrreg(stdscr,(t),(b))
-#define standend()		wstandend(stdscr)
-#define standout()		wstandout(stdscr)
-#define timeout(delay)		wtimeout(stdscr,(delay))
-#define wdeleteln(win)		winsdelln(win,-1)
-#define winsertln(win)		winsdelln(win,1)
-
-/*
- * mv functions
- */
-
-#define mvwaddch(win,y,x,ch)		(wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch)))
-#define mvwaddchnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n)))
-#define mvwaddchstr(win,y,x,str)	(wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1))
-#define mvwaddnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n)))
-#define mvwaddstr(win,y,x,str)		(wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1))
-#define mvwdelch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wdelch(win))
-#define mvwchgat(win,y,x,n,a,c,o)	(wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o)))
-#define mvwgetch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wgetch(win))
-#define mvwgetnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n)))
-#define mvwgetstr(win,y,x,str)		(wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str)))
-#define mvwhline(win,y,x,c,n)		(wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n)))
-#define mvwinch(win,y,x)		(wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
-#define mvwinchnstr(win,y,x,s,n)	(wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n)))
-#define mvwinchstr(win,y,x,s)		(wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s)))
-#define mvwinnstr(win,y,x,s,n)		(wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n)))
-#define mvwinsch(win,y,x,c)		(wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c)))
-#define mvwinsnstr(win,y,x,s,n)		(wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n)))
-#define mvwinsstr(win,y,x,s)		(wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s)))
-#define mvwinstr(win,y,x,s)		(wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s)))
-#define mvwvline(win,y,x,c,n)		(wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n)))
-
-#define mvaddch(y,x,ch)			mvwaddch(stdscr,(y),(x),(ch))
-#define mvaddchnstr(y,x,str,n)		mvwaddchnstr(stdscr,(y),(x),(str),(n))
-#define mvaddchstr(y,x,str)		mvwaddchstr(stdscr,(y),(x),(str))
-#define mvaddnstr(y,x,str,n)		mvwaddnstr(stdscr,(y),(x),(str),(n))
-#define mvaddstr(y,x,str)		mvwaddstr(stdscr,(y),(x),(str))
-#define mvchgat(y,x,n,a,c,o)		mvwchgat(stdscr,(y),(x),(n),(a),(c),(o))
-#define mvdelch(y,x)			mvwdelch(stdscr,(y),(x))
-#define mvgetch(y,x)			mvwgetch(stdscr,(y),(x))
-#define mvgetnstr(y,x,str,n)		mvwgetnstr(stdscr,(y),(x),(str),(n))
-#define mvgetstr(y,x,str)		mvwgetstr(stdscr,(y),(x),(str))
-#define mvhline(y,x,c,n)		mvwhline(stdscr,(y),(x),(c),(n))
-#define mvinch(y,x)			mvwinch(stdscr,(y),(x))
-#define mvinchnstr(y,x,s,n)		mvwinchnstr(stdscr,(y),(x),(s),(n))
-#define mvinchstr(y,x,s)		mvwinchstr(stdscr,(y),(x),(s))
-#define mvinnstr(y,x,s,n)		mvwinnstr(stdscr,(y),(x),(s),(n))
-#define mvinsch(y,x,c)			mvwinsch(stdscr,(y),(x),(c))
-#define mvinsnstr(y,x,s,n)		mvwinsnstr(stdscr,(y),(x),(s),(n))
-#define mvinsstr(y,x,s)			mvwinsstr(stdscr,(y),(x),(s))
-#define mvinstr(y,x,s)			mvwinstr(stdscr,(y),(x),(s))
-#define mvvline(y,x,c,n)		mvwvline(stdscr,(y),(x),(c),(n))
-
-/*
- * Some wide-character functions can be implemented without the extensions.
- */
-#if !NCURSES_OPAQUE
-#define getbkgd(win)                    ((win) ? ((win)->_bkgd) : 0)
-#endif /* NCURSES_OPAQUE */
-
-#define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
-#define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
-
-#if !NCURSES_OPAQUE
-#if NCURSES_WIDECHAR && 0
-#define wattr_set(win,a,p,opts)		(((win) \
-					  ? ((win)->_attrs = ((a) & ~A_COLOR), \
-					     (win)->_color = (p)) \
-					  : OK), \
-					 OK)
-#define wattr_get(win,a,p,opts)		((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
-					 (void)(((p) != (void *)0) ? (*(p) = (NCURSES_PAIRS_T) ((win) ? (win)->_color : 0)) : OK), \
-					 OK)
-#else
-#define wattr_set(win,a,p,opts)		(((win) \
-					  ? ((win)->_attrs = (((a) & ~A_COLOR) | (attr_t)COLOR_PAIR(p))) \
-					  : OK), \
-					 OK)
-#define wattr_get(win,a,p,opts)		((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
-					 (void)(((p) != (void *)0) ? (*(p) = (NCURSES_PAIRS_T) ((win) ? PAIR_NUMBER((win)->_attrs) : 0)) : OK), \
-					 OK)
-#endif
-#endif /* NCURSES_OPAQUE */
-
-/*
- * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
- * varargs.h.  It adds new calls vw_printw/vw_scanw, which are supposed to
- * use POSIX stdarg.h.  The ncurses versions of vwprintw/vwscanw already
- * use stdarg.h, so...
- */
-#define vw_printw		vwprintw
-#define vw_scanw		vwscanw
-
-/*
- * Export fallback function for use in C++ binding.
- */
-#if !1
-#define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
-NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
-#endif
-
-/*
- * These macros are extensions - not in X/Open Curses.
- */
-#if 1
-#if !NCURSES_OPAQUE
-#define is_cleared(win)		((win) ? (win)->_clear : FALSE)
-#define is_idcok(win)		((win) ? (win)->_idcok : FALSE)
-#define is_idlok(win)		((win) ? (win)->_idlok : FALSE)
-#define is_immedok(win)		((win) ? (win)->_immed : FALSE)
-#define is_keypad(win)		((win) ? (win)->_use_keypad : FALSE)
-#define is_leaveok(win)		((win) ? (win)->_leaveok : FALSE)
-#define is_nodelay(win)		((win) ? ((win)->_delay == 0) : FALSE)
-#define is_notimeout(win)	((win) ? (win)->_notimeout : FALSE)
-#define is_pad(win)		((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
-#define is_scrollok(win)	((win) ? (win)->_scroll : FALSE)
-#define is_subwin(win)		((win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE)
-#define is_syncok(win)		((win) ? (win)->_sync : FALSE)
-#define wgetdelay(win)		((win) ? (win)->_delay : 0)
-#define wgetparent(win)		((win) ? (win)->_parent : 0)
-#define wgetscrreg(win,t,b)	((win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
-#endif
-#endif
-
-#endif /* NCURSES_NOMACROS */
-
-/*
- * Public variables.
- *
- * Notes:
- *	a. ESCDELAY was an undocumented feature under AIX curses.
- *	   It gives the ESC expire time in milliseconds.
- *	b. ttytype is needed for backward compatibility
- */
-#if NCURSES_REENTRANT
-
-NCURSES_WRAPPED_VAR(WINDOW *, curscr);
-NCURSES_WRAPPED_VAR(WINDOW *, newscr);
-NCURSES_WRAPPED_VAR(WINDOW *, stdscr);
-NCURSES_WRAPPED_VAR(char *, ttytype);
-NCURSES_WRAPPED_VAR(int, COLORS);
-NCURSES_WRAPPED_VAR(int, COLOR_PAIRS);
-NCURSES_WRAPPED_VAR(int, COLS);
-NCURSES_WRAPPED_VAR(int, ESCDELAY);
-NCURSES_WRAPPED_VAR(int, LINES);
-NCURSES_WRAPPED_VAR(int, TABSIZE);
-
-#define curscr      NCURSES_PUBLIC_VAR(curscr())
-#define newscr      NCURSES_PUBLIC_VAR(newscr())
-#define stdscr      NCURSES_PUBLIC_VAR(stdscr())
-#define ttytype     NCURSES_PUBLIC_VAR(ttytype())
-#define COLORS      NCURSES_PUBLIC_VAR(COLORS())
-#define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS())
-#define COLS        NCURSES_PUBLIC_VAR(COLS())
-#define ESCDELAY    NCURSES_PUBLIC_VAR(ESCDELAY())
-#define LINES       NCURSES_PUBLIC_VAR(LINES())
-#define TABSIZE     NCURSES_PUBLIC_VAR(TABSIZE())
-
-#else
-
-extern NCURSES_EXPORT_VAR(WINDOW *) curscr;
-extern NCURSES_EXPORT_VAR(WINDOW *) newscr;
-extern NCURSES_EXPORT_VAR(WINDOW *) stdscr;
-extern NCURSES_EXPORT_VAR(char) ttytype[];
-extern NCURSES_EXPORT_VAR(int) COLORS;
-extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
-extern NCURSES_EXPORT_VAR(int) COLS;
-extern NCURSES_EXPORT_VAR(int) ESCDELAY;
-extern NCURSES_EXPORT_VAR(int) LINES;
-extern NCURSES_EXPORT_VAR(int) TABSIZE;
-
-#endif
-
-/*
- * Pseudo-character tokens outside ASCII range.  The curses wgetch() function
- * will return any given one of these only if the corresponding k- capability
- * is defined in your terminal's terminfo entry.
- *
- * Some keys (KEY_A1, etc) are arranged like this:
- *	a1     up    a3
- *	left   b2    right
- *	c1     down  c3
- *
- * A few key codes do not depend upon the terminfo entry.
- */
-#define KEY_CODE_YES	0400		/* A wchar_t contains a key code */
-#define KEY_MIN		0401		/* Minimum curses key */
-#define KEY_BREAK	0401		/* Break key (unreliable) */
-#define KEY_SRESET	0530		/* Soft (partial) reset (unreliable) */
-#define KEY_RESET	0531		/* Reset or hard reset (unreliable) */
-/*
- * These definitions were generated by ./MKkey_defs.sh ./Caps
- */
-#define KEY_DOWN	0402		/* down-arrow key */
-#define KEY_UP		0403		/* up-arrow key */
-#define KEY_LEFT	0404		/* left-arrow key */
-#define KEY_RIGHT	0405		/* right-arrow key */
-#define KEY_HOME	0406		/* home key */
-#define KEY_BACKSPACE	0407		/* backspace key */
-#define KEY_F0		0410		/* Function keys.  Space for 64 */
-#define KEY_F(n)	(KEY_F0+(n))	/* Value of function key n */
-#define KEY_DL		0510		/* delete-line key */
-#define KEY_IL		0511		/* insert-line key */
-#define KEY_DC		0512		/* delete-character key */
-#define KEY_IC		0513		/* insert-character key */
-#define KEY_EIC		0514		/* sent by rmir or smir in insert mode */
-#define KEY_CLEAR	0515		/* clear-screen or erase key */
-#define KEY_EOS		0516		/* clear-to-end-of-screen key */
-#define KEY_EOL		0517		/* clear-to-end-of-line key */
-#define KEY_SF		0520		/* scroll-forward key */
-#define KEY_SR		0521		/* scroll-backward key */
-#define KEY_NPAGE	0522		/* next-page key */
-#define KEY_PPAGE	0523		/* previous-page key */
-#define KEY_STAB	0524		/* set-tab key */
-#define KEY_CTAB	0525		/* clear-tab key */
-#define KEY_CATAB	0526		/* clear-all-tabs key */
-#define KEY_ENTER	0527		/* enter/send key */
-#define KEY_PRINT	0532		/* print key */
-#define KEY_LL		0533		/* lower-left key (home down) */
-#define KEY_A1		0534		/* upper left of keypad */
-#define KEY_A3		0535		/* upper right of keypad */
-#define KEY_B2		0536		/* center of keypad */
-#define KEY_C1		0537		/* lower left of keypad */
-#define KEY_C3		0540		/* lower right of keypad */
-#define KEY_BTAB	0541		/* back-tab key */
-#define KEY_BEG		0542		/* begin key */
-#define KEY_CANCEL	0543		/* cancel key */
-#define KEY_CLOSE	0544		/* close key */
-#define KEY_COMMAND	0545		/* command key */
-#define KEY_COPY	0546		/* copy key */
-#define KEY_CREATE	0547		/* create key */
-#define KEY_END		0550		/* end key */
-#define KEY_EXIT	0551		/* exit key */
-#define KEY_FIND	0552		/* find key */
-#define KEY_HELP	0553		/* help key */
-#define KEY_MARK	0554		/* mark key */
-#define KEY_MESSAGE	0555		/* message key */
-#define KEY_MOVE	0556		/* move key */
-#define KEY_NEXT	0557		/* next key */
-#define KEY_OPEN	0560		/* open key */
-#define KEY_OPTIONS	0561		/* options key */
-#define KEY_PREVIOUS	0562		/* previous key */
-#define KEY_REDO	0563		/* redo key */
-#define KEY_REFERENCE	0564		/* reference key */
-#define KEY_REFRESH	0565		/* refresh key */
-#define KEY_REPLACE	0566		/* replace key */
-#define KEY_RESTART	0567		/* restart key */
-#define KEY_RESUME	0570		/* resume key */
-#define KEY_SAVE	0571		/* save key */
-#define KEY_SBEG	0572		/* shifted begin key */
-#define KEY_SCANCEL	0573		/* shifted cancel key */
-#define KEY_SCOMMAND	0574		/* shifted command key */
-#define KEY_SCOPY	0575		/* shifted copy key */
-#define KEY_SCREATE	0576		/* shifted create key */
-#define KEY_SDC		0577		/* shifted delete-character key */
-#define KEY_SDL		0600		/* shifted delete-line key */
-#define KEY_SELECT	0601		/* select key */
-#define KEY_SEND	0602		/* shifted end key */
-#define KEY_SEOL	0603		/* shifted clear-to-end-of-line key */
-#define KEY_SEXIT	0604		/* shifted exit key */
-#define KEY_SFIND	0605		/* shifted find key */
-#define KEY_SHELP	0606		/* shifted help key */
-#define KEY_SHOME	0607		/* shifted home key */
-#define KEY_SIC		0610		/* shifted insert-character key */
-#define KEY_SLEFT	0611		/* shifted left-arrow key */
-#define KEY_SMESSAGE	0612		/* shifted message key */
-#define KEY_SMOVE	0613		/* shifted move key */
-#define KEY_SNEXT	0614		/* shifted next key */
-#define KEY_SOPTIONS	0615		/* shifted options key */
-#define KEY_SPREVIOUS	0616		/* shifted previous key */
-#define KEY_SPRINT	0617		/* shifted print key */
-#define KEY_SREDO	0620		/* shifted redo key */
-#define KEY_SREPLACE	0621		/* shifted replace key */
-#define KEY_SRIGHT	0622		/* shifted right-arrow key */
-#define KEY_SRSUME	0623		/* shifted resume key */
-#define KEY_SSAVE	0624		/* shifted save key */
-#define KEY_SSUSPEND	0625		/* shifted suspend key */
-#define KEY_SUNDO	0626		/* shifted undo key */
-#define KEY_SUSPEND	0627		/* suspend key */
-#define KEY_UNDO	0630		/* undo key */
-#define KEY_MOUSE	0631		/* Mouse event has occurred */
-#define KEY_RESIZE	0632		/* Terminal resize event */
-#define KEY_EVENT	0633		/* We were interrupted by an event */
-
-#define KEY_MAX		0777		/* Maximum key value is 0633 */
-/* $Id: curses.tail,v 1.21 2011/10/29 20:03:22 tom Exp $ */
-/*
- * vile:cmode:
- * This file is part of ncurses, designed to be appended after curses.h.in
- * (see that file for the relevant copyright).
- */
-
-/* mouse interface */
-
-#if NCURSES_MOUSE_VERSION > 1
-#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
-#else
-#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
-#endif
-
-#define	NCURSES_BUTTON_RELEASED	001L
-#define	NCURSES_BUTTON_PRESSED	002L
-#define	NCURSES_BUTTON_CLICKED	004L
-#define	NCURSES_DOUBLE_CLICKED	010L
-#define	NCURSES_TRIPLE_CLICKED	020L
-#define	NCURSES_RESERVED_EVENT	040L
-
-/* event masks */
-#define	BUTTON1_RELEASED	NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
-#define	BUTTON1_PRESSED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
-#define	BUTTON1_CLICKED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
-#define	BUTTON1_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
-#define	BUTTON1_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
-
-#define	BUTTON2_RELEASED	NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
-#define	BUTTON2_PRESSED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
-#define	BUTTON2_CLICKED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
-#define	BUTTON2_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
-#define	BUTTON2_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
-
-#define	BUTTON3_RELEASED	NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
-#define	BUTTON3_PRESSED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
-#define	BUTTON3_CLICKED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
-#define	BUTTON3_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
-#define	BUTTON3_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
-
-#define	BUTTON4_RELEASED	NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
-#define	BUTTON4_PRESSED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
-#define	BUTTON4_CLICKED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
-#define	BUTTON4_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
-#define	BUTTON4_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
-
-/*
- * In 32 bits the version-1 scheme does not provide enough space for a 5th
- * button, unless we choose to change the ABI by omitting the reserved-events.
- */
-#if NCURSES_MOUSE_VERSION > 1
-
-#define	BUTTON5_RELEASED	NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
-#define	BUTTON5_PRESSED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
-#define	BUTTON5_CLICKED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
-#define	BUTTON5_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
-#define	BUTTON5_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
-
-#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(6, 0001L)
-#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(6, 0002L)
-#define	BUTTON_ALT		NCURSES_MOUSE_MASK(6, 0004L)
-#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(6, 0010L)
-
-#else
-
-#define	BUTTON1_RESERVED_EVENT	NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
-#define	BUTTON2_RESERVED_EVENT	NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
-#define	BUTTON3_RESERVED_EVENT	NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
-#define	BUTTON4_RESERVED_EVENT	NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
-
-#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(5, 0001L)
-#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(5, 0002L)
-#define	BUTTON_ALT		NCURSES_MOUSE_MASK(5, 0004L)
-#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(5, 0010L)
-
-#endif
-
-#define	ALL_MOUSE_EVENTS	(REPORT_MOUSE_POSITION - 1)
-
-/* macros to extract single event-bits from masks */
-#define	BUTTON_RELEASE(e, x)		((e) & NCURSES_MOUSE_MASK(x, 001))
-#define	BUTTON_PRESS(e, x)		((e) & NCURSES_MOUSE_MASK(x, 002))
-#define	BUTTON_CLICK(e, x)		((e) & NCURSES_MOUSE_MASK(x, 004))
-#define	BUTTON_DOUBLE_CLICK(e, x)	((e) & NCURSES_MOUSE_MASK(x, 010))
-#define	BUTTON_TRIPLE_CLICK(e, x)	((e) & NCURSES_MOUSE_MASK(x, 020))
-#define	BUTTON_RESERVED_EVENT(e, x)	((e) & NCURSES_MOUSE_MASK(x, 040))
-
-typedef struct
-{
-    short id;		/* ID to distinguish multiple devices */
-    int x, y, z;	/* event coordinates (character-cell) */
-    mmask_t bstate;	/* button state bits */
-}
-MEVENT;
-
-extern NCURSES_EXPORT(bool)    has_mouse(void);
-extern NCURSES_EXPORT(int)     getmouse (MEVENT *);
-extern NCURSES_EXPORT(int)     ungetmouse (MEVENT *);
-extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
-extern NCURSES_EXPORT(bool)    wenclose (const WINDOW *, int, int);
-extern NCURSES_EXPORT(int)     mouseinterval (int);
-extern NCURSES_EXPORT(bool)    wmouse_trafo (const WINDOW*, int*, int*, bool);
-extern NCURSES_EXPORT(bool)    mouse_trafo (int*, int*, bool);              /* generated */
-
-#if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(bool)    NCURSES_SP_NAME(has_mouse) (SCREEN*);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *);
-extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(mouseinterval) (SCREEN*, int);
-#endif
-
-#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
-
-/* other non-XSI functions */
-
-extern NCURSES_EXPORT(int) mcprint (char *, int);	/* direct data to printer */
-extern NCURSES_EXPORT(int) has_key (int);		/* do we have given key? */
-
-#if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int);    /* do we have given key? */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int);	/* direct data to printer */
-#endif
-
-/* Debugging : use with libncurses_g.a */
-
-extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *);
-extern NCURSES_EXPORT(char *) _traceattr (attr_t);
-extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype);
-extern NCURSES_EXPORT(char *) _nc_tracebits (void);
-extern NCURSES_EXPORT(char *) _tracechar (int);
-extern NCURSES_EXPORT(char *) _tracechtype (chtype);
-extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype);
-#if NCURSES_WIDECHAR
-#define _tracech_t		_tracecchar_t
-extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *);
-#define _tracech_t2		_tracecchar_t2
-extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *);
-#else
-#define _tracech_t		_tracechtype
-#define _tracech_t2		_tracechtype2
-#endif
-extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *);
-extern NCURSES_EXPORT(void) trace (const unsigned int);
-
-/* trace masks */
-#define TRACE_DISABLE	0x0000	/* turn off tracing */
-#define TRACE_TIMES	0x0001	/* trace user and system times of updates */
-#define TRACE_TPUTS	0x0002	/* trace tputs calls */
-#define TRACE_UPDATE	0x0004	/* trace update actions, old & new screens */
-#define TRACE_MOVE	0x0008	/* trace cursor moves and scrolls */
-#define TRACE_CHARPUT	0x0010	/* trace all character outputs */
-#define TRACE_ORDINARY	0x001F	/* trace all update actions */
-#define TRACE_CALLS	0x0020	/* trace all curses calls */
-#define TRACE_VIRTPUT	0x0040	/* trace virtual character puts */
-#define TRACE_IEVENT	0x0080	/* trace low-level input processing */
-#define TRACE_BITS	0x0100	/* trace state of TTY control bits */
-#define TRACE_ICALLS	0x0200	/* trace internal/nested calls */
-#define TRACE_CCALLS	0x0400	/* trace per-character calls */
-#define TRACE_DATABASE	0x0800	/* trace read/write of terminfo/termcap data */
-#define TRACE_ATTRS	0x1000	/* trace attribute updates */
-
-#define TRACE_SHIFT	13	/* number of bits in the trace masks */
-#define TRACE_MAXIMUM	((1 << TRACE_SHIFT) - 1) /* maximum trace level */
-
-#if defined(TRACE) || defined(NCURSES_TEST)
-extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable;		/* enable optimizations */
-extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
-#define OPTIMIZE_MVCUR		0x01	/* cursor movement optimization */
-#define OPTIMIZE_HASHMAP	0x02	/* diff hashing to detect scrolls */
-#define OPTIMIZE_SCROLL		0x04	/* scroll optimization */
-#define OPTIMIZE_ALL		0xff	/* enable all optimizations (dflt) */
-#endif
-
-#include <unctrl.h>
-
-#ifdef __cplusplus
-
-#ifndef NCURSES_NOMACROS
-
-/* these names conflict with STL */
-#undef box
-#undef clear
-#undef erase
-#undef move
-#undef refresh
-
-#endif /* NCURSES_NOMACROS */
-
-}
-#endif
-
-#endif /* __NCURSES_H */
diff --git a/include/curses.h.in b/include/curses.h.in
index 65eedaa..8cfa0b9 100644
--- a/include/curses.h.in
+++ b/include/curses.h.in
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2023,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,11 +33,40 @@
  *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: curses.h.in,v 1.241 2014/08/09 20:39:44 tom Exp $ */
+/* $Id: curses.h.in,v 1.282 2024/01/19 11:50:07 tom Exp $ */
 
 #ifndef __NCURSES_H
 #define __NCURSES_H
 
+/*
+ The symbols beginning NCURSES_ or USE_ are configuration choices.
+ A few of the former can be overridden by applications at compile-time.
+ Most of the others correspond to configure-script options (or checks
+ by the configure-script for features of the system on which it is built).
+
+ These symbols can be overridden by applications at compile-time:
+ NCURSES_NOMACROS suppresses macro definitions in favor of functions
+ NCURSES_WATTR_MACROS suppresses wattr_* macro definitions
+ NCURSES_WIDECHAR is an alternative for declaring wide-character functions.
+
+ These symbols are used only when building ncurses:
+ NCURSES_ATTR_T
+ NCURSES_FIELD_INTERNALS
+ NCURSES_INTERNALS
+
+ These symbols are set by the configure script:
+ NCURSES_ENABLE_STDBOOL_H
+ NCURSES_EXPANDED
+ NCURSES_EXT_COLORS
+ NCURSES_EXT_FUNCS
+ NCURSES_EXT_PUTWIN
+ NCURSES_NO_PADDING
+ NCURSES_OSPEED_COMPAT
+ NCURSES_PATHSEP
+ NCURSES_REENTRANT
+ NCURSES_SIGWINCH
+ */
+
 #define CURSES 1
 #define CURSES_H 1
 
@@ -59,10 +89,22 @@
  */
 #include <ncurses_dll.h>
 
+/*
+ * Extra headers.
+ */
 #if @HAVE_STDINT_H@
 #include <stdint.h>
 #endif
 
+#ifdef __cplusplus
+#else
+#if @HAVE_STDNORETURN_H@
+#include <stdnoreturn.h>
+#undef GCC_NORETURN
+#define GCC_NORETURN _Noreturn
+#endif
+#endif
+
 /*
  * User-definable tweak to disable the include of <stdbool.h>.
  */
@@ -89,13 +131,13 @@
 #define NCURSES_INLINE @NCURSES_INLINE@
 
 /*
- * The internal type used for color values, and for color-pairs.  The latter
+ * The standard type used for color values, and for color-pairs.  The latter
  * allows the curses library to enumerate the combinations of foreground and
  * background colors used by an application, and is normally the product of the
  * total foreground and background colors.
  *
  * X/Open uses "short" for both of these types, ultimately because they are
- * numbers from the terminal database, which uses 16-bit signed values.
+ * numbers from the SVr4 terminal database, which uses 16-bit signed values.
  */
 #undef	NCURSES_COLOR_T
 #define	NCURSES_COLOR_T short
@@ -104,10 +146,22 @@
 #define	NCURSES_PAIRS_T short
 
 /*
- * Definition used to make WINDOW and similar structs opaque.
+ * Definitions used to make WINDOW and similar structs opaque.
  */
-#ifndef @cf_cv_enable_opaque@
-#define NCURSES_OPAQUE @NCURSES_OPAQUE@
+#ifndef NCURSES_INTERNALS
+#define NCURSES_OPAQUE       @NCURSES_OPAQUE@
+#define NCURSES_OPAQUE_FORM  @NCURSES_OPAQUE_FORM@
+#define NCURSES_OPAQUE_MENU  @NCURSES_OPAQUE_MENU@
+#define NCURSES_OPAQUE_PANEL @NCURSES_OPAQUE_PANEL@
+#endif
+
+/*
+ * Definition used to optionally suppress wattr* macros to help with the
+ * transition from ncurses5 to ncurses6 by allowing the header files to
+ * be shared across development packages for ncursesw in both ABIs.
+ */
+#ifndef NCURSES_WATTR_MACROS
+#define NCURSES_WATTR_MACROS @NCURSES_WATTR_MACROS@
 #endif
 
 /*
@@ -118,6 +172,27 @@
 #endif
 
 /*
+ * KEY_RESIZE is an extended feature that relies upon the SIGWINCH handler
+ * in ncurses.
+ */
+#if @NCURSES_EXT_FUNCS@
+#ifndef NCURSES_SIGWINCH
+#define NCURSES_SIGWINCH @cf_cv_enable_sigwinch@
+#endif
+#else
+#undef NCURSES_SIGWINCH
+#define NCURSES_SIGWINCH 0
+#endif
+
+/*
+ * In certain environments, we must work around linker problems for data
+ */
+#undef NCURSES_BROKEN_LINKER
+#if @BROKEN_LINKER@
+#define NCURSES_BROKEN_LINKER 1
+#endif
+
+/*
  * Control whether bindings for interop support are added.
  */
 #undef	NCURSES_INTEROP_FUNCS
@@ -143,6 +218,13 @@
 #define NCURSES_TPARM_ARG @NCURSES_TPARM_ARG@
 
 /*
+ * Control whether ncurses uses wcwidth() for checking width of line-drawing
+ * characters.
+ */
+#undef NCURSES_WCWIDTH_GRAPHICS
+#define NCURSES_WCWIDTH_GRAPHICS @NCURSES_WCWIDTH_GRAPHICS@
+
+/*
  * NCURSES_CH_T is used in building the library, but not used otherwise in
  * this header file, since that would make the normal/wide-character versions
  * of the header incompatible.
@@ -229,6 +311,8 @@
 #define NCURSES_CAST(type,value) (type)(value)
 #endif
 
+#define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p)))
+
 /*
  * X/Open attributes.  In the ncurses implementation, they are identical to the
  * A_ attributes.
@@ -361,7 +445,14 @@
  */
 #define _NEWINDEX	-1
 
+#ifdef NCURSES_INTERNALS
+#undef SCREEN
+#define SCREEN struct screen
+SCREEN;
+#else
 typedef struct screen  SCREEN;
+#endif
+
 typedef struct _win_st WINDOW;
 
 typedef	chtype	attr_t;		/* ...must be at least as wide as chtype */
@@ -468,55 +559,6 @@
 #endif /* NCURSES_OPAQUE */
 
 /*
- * This is an extension to support events...
- */
-#if @NCURSES_EXT_FUNCS@
-#ifdef NCURSES_WGETCH_EVENTS
-#if !defined(__BEOS__) || defined(__HAIKU__)
-   /* Fix _nc_timed_wait() on BEOS... */
-#  define NCURSES_EVENT_VERSION	1
-#endif	/* !defined(__BEOS__) */
-
-/*
- * Bits to set in _nc_event.data.flags
- */
-#  define _NC_EVENT_TIMEOUT_MSEC	1
-#  define _NC_EVENT_FILE		2
-#  define _NC_EVENT_FILE_READABLE	2
-#  if 0					/* Not supported yet... */
-#    define _NC_EVENT_FILE_WRITABLE	4
-#    define _NC_EVENT_FILE_EXCEPTION	8
-#  endif
-
-typedef struct
-{
-    int type;
-    union
-    {
-	long timeout_msec;	/* _NC_EVENT_TIMEOUT_MSEC */
-	struct
-	{
-	    unsigned int flags;
-	    int fd;
-	    unsigned int result;
-	} fev;				/* _NC_EVENT_FILE */
-    } data;
-} _nc_event;
-
-typedef struct
-{
-    int count;
-    int result_flags;	/* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
-    _nc_event *events[1];
-} _nc_eventlist;
-
-extern NCURSES_EXPORT(int) wgetch_events (WINDOW *, _nc_eventlist *);	/* experimental */
-extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *);/* experimental */
-
-#endif /* NCURSES_WGETCH_EVENTS */
-#endif /* NCURSES_EXT_FUNCS */
-
-/*
  * GCC (and some other compilers) define '__attribute__'; we're using this
  * macro to alert the compiler to flag inconsistencies in printf/scanf-like
  * function calls.  Just in case '__attribute__' isn't defined, make a dummy.
@@ -529,14 +571,10 @@
 
 /*
  * We cannot define these in ncurses_cfg.h, since they require parameters to be
- * passed (that is non-portable).  If you happen to be using gcc with warnings
- * enabled, define
- *	GCC_PRINTF
- *	GCC_SCANF
- * to improve checking of calls to printw(), etc.
+ * passed (that is non-portable).
  */
 #ifndef GCC_PRINTFLIKE
-#if defined(GCC_PRINTF) && !defined(printf)
+#ifndef printf
 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
 #else
 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
@@ -544,7 +582,7 @@
 #endif
 
 #ifndef GCC_SCANFLIKE
-#if defined(GCC_SCANF) && !defined(scanf)
+#ifndef scanf
 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
 #else
 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
@@ -559,6 +597,13 @@
 #define	GCC_UNUSED /* nothing */
 #endif
 
+#undef  GCC_DEPRECATED
+#if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS)
+#define GCC_DEPRECATED(msg) __attribute__((deprecated))
+#else
+#define GCC_DEPRECATED(msg) /* nothing */
+#endif
+
 /*
  * Curses uses a helper function.  Define our type for this to simplify
  * extending it for the sp-funcs feature.
@@ -680,7 +725,7 @@
 extern NCURSES_EXPORT(int) mvinstr (int, int, char *);			/* generated */
 extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...)		/* implemented */
 		GCC_PRINTFLIKE(3,4);
-extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...)	/* implemented */
+extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...)		/* implemented */
 		GCC_SCANFLIKE(3,4);
 extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int);		/* generated */
 extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype);	/* generated */
@@ -705,13 +750,13 @@
 extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *);		/* generated */
 extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...)	/* implemented */
 		GCC_PRINTFLIKE(4,5);
-extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...)	/* implemented */
+extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...)	/* implemented */
 		GCC_SCANFLIKE(4,5);
 extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int);	/* generated */
 extern NCURSES_EXPORT(int) napms (int);					/* implemented */
-extern NCURSES_EXPORT(WINDOW *) newpad (int,int);		       	/* implemented */
-extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *);	/* implemented */
-extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int);	       	/* implemented */
+extern NCURSES_EXPORT(WINDOW *) newpad (int,int);			/* implemented */
+extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *);	/* implemented */
+extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int);		/* implemented */
 extern NCURSES_EXPORT(int) nl (void);					/* implemented */
 extern NCURSES_EXPORT(int) nocbreak (void);				/* implemented */
 extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool);			/* implemented */
@@ -739,7 +784,7 @@
 extern NCURSES_EXPORT(int) reset_shell_mode (void);			/* implemented */
 extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int));	/* implemented */
 extern NCURSES_EXPORT(int) savetty (void);				/* implemented */
-extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...)		/* implemented */
+extern NCURSES_EXPORT(int) scanw (const char *,...)			/* implemented */
 		GCC_SCANFLIKE(1,2);
 extern NCURSES_EXPORT(int) scr_dump (const char *);			/* implemented */
 extern NCURSES_EXPORT(int) scr_init (const char *);			/* implemented */
@@ -765,7 +810,7 @@
 extern NCURSES_EXPORT(int) slk_refresh (void);				/* implemented */
 extern NCURSES_EXPORT(int) slk_restore (void);				/* implemented */
 extern NCURSES_EXPORT(int) slk_set (int,const char *,int);		/* implemented */
-extern NCURSES_EXPORT(int) slk_touch (void);	      	       		/* implemented */
+extern NCURSES_EXPORT(int) slk_touch (void);				/* implemented */
 extern NCURSES_EXPORT(int) standout (void);				/* generated */
 extern NCURSES_EXPORT(int) standend (void);				/* generated */
 extern NCURSES_EXPORT(int) start_color (void);				/* implemented */
@@ -785,10 +830,14 @@
 extern NCURSES_EXPORT(int) vidattr (chtype);				/* implemented */
 extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC);		/* implemented */
 extern NCURSES_EXPORT(int) vline (chtype, int);				/* generated */
-extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list);	/* generated */
-extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list);	/* generated */
+extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_printw)	/* implemented */
+		GCC_PRINTFLIKE(2,0);
+extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *, va_list)	/* implemented */
+		GCC_PRINTFLIKE(2,0);	
+extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *, va_list) GCC_DEPRECATED(use vw_scanw)	/* implemented */
+		GCC_SCANFLIKE(2,0);
+extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *, va_list)	/* implemented */
+		GCC_SCANFLIKE(2,0);
 extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype);		/* implemented */
 extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int);	/* implemented */
 extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *);		/* generated */
@@ -834,7 +883,7 @@
 		GCC_PRINTFLIKE(2,3);
 extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int);		/* implemented */
 extern NCURSES_EXPORT(int) wrefresh (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wscanw (WINDOW *, NCURSES_CONST char *,...)	/* implemented */
+extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...)		/* implemented */
 		GCC_SCANFLIKE(2,3);
 extern NCURSES_EXPORT(int) wscrl (WINDOW *,int);			/* implemented */
 extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int);		/* implemented */
@@ -849,19 +898,20 @@
 /*
  * These are also declared in <term.h>:
  */
-extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);		/* implemented */
+extern NCURSES_EXPORT(int) tigetflag (const char *);			/* implemented */
+extern NCURSES_EXPORT(int) tigetnum (const char *);			/* implemented */
+extern NCURSES_EXPORT(char *) tigetstr (const char *);			/* implemented */
 extern NCURSES_EXPORT(int) putp (const char *);				/* implemented */
 
 #if NCURSES_TPARM_VARARGS
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* special */
+extern NCURSES_EXPORT(char *) tparm (const char *, ...);		/* special */
 #else
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG);	/* special */
-extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* special */
+extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG);	/* special */
 #endif
 
 extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */
+extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...);	/* special */
+extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *);	/* special */
 
 /*
  * These functions are not in X/Open, but we use them in macro definitions:
@@ -891,25 +941,43 @@
 #define NCURSES_EXT_FUNCS @NCURSES_PATCH@
 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
 typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
-extern NCURSES_EXPORT(bool) is_term_resized (int, int);
-extern NCURSES_EXPORT(char *) keybound (int, int);
-extern NCURSES_EXPORT(const char *) curses_version (void);
+extern NCURSES_EXPORT(int) alloc_pair (int, int);
 extern NCURSES_EXPORT(int) assume_default_colors (int, int);
+extern NCURSES_EXPORT(const char *) curses_version (void);
 extern NCURSES_EXPORT(int) define_key (const char *, int);
+extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *);
+extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *);
+extern NCURSES_EXPORT(int) extended_slk_color(int);
+extern NCURSES_EXPORT(int) find_pair (int, int);
+extern NCURSES_EXPORT(int) free_pair (int);
 extern NCURSES_EXPORT(int) get_escdelay (void);
+extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int);
+extern NCURSES_EXPORT(int) init_extended_pair(int, int, int);
+extern NCURSES_EXPORT(int) is_cbreak(void);
+extern NCURSES_EXPORT(int) is_echo(void);
+extern NCURSES_EXPORT(int) is_nl(void);
+extern NCURSES_EXPORT(int) is_raw(void);
+extern NCURSES_EXPORT(bool) is_term_resized (int, int);
 extern NCURSES_EXPORT(int) key_defined (const char *);
+extern NCURSES_EXPORT(char *) keybound (int, int);
 extern NCURSES_EXPORT(int) keyok (int, bool);
+extern NCURSES_EXPORT(void) nofilter(void);
+extern NCURSES_EXPORT(void) reset_color_pairs (void);
 extern NCURSES_EXPORT(int) resize_term (int, int);
 extern NCURSES_EXPORT(int) resizeterm (int, int);
 extern NCURSES_EXPORT(int) set_escdelay (int);
 extern NCURSES_EXPORT(int) set_tabsize (int);
 extern NCURSES_EXPORT(int) use_default_colors (void);
-extern NCURSES_EXPORT(int) use_extended_names (bool);
 extern NCURSES_EXPORT(int) use_legacy_coding (int);
 extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *);
 extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *);
 extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
-extern NCURSES_EXPORT(void) nofilter(void);
+
+#if @NCURSES_XNAMES@
+#undef  NCURSES_XNAMES
+#define NCURSES_XNAMES @NCURSES_XNAMES@
+extern NCURSES_EXPORT(int) use_extended_names (bool);
+#endif
 
 /*
  * These extensions provide access to information stored in the WINDOW even
@@ -981,7 +1049,7 @@
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */
 extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, NCURSES_CONST char *, FILE *, FILE *); /* implemented:SP_FUNC */
+extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */
 extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */
@@ -1024,14 +1092,27 @@
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */
 #if @NCURSES_EXT_FUNCS@
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_cbreak) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_echo) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_nl) (SCREEN*);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(is_raw) (SCREEN*);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *);	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */	/* implemented:EXT_SP_FUNC */
+extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
@@ -1085,7 +1166,7 @@
  * These pseudo functions are always implemented as macros:
  */
 
-#define getyx(win,y,x)   	(y = getcury(win), x = getcurx(win))
+#define getyx(win,y,x)		(y = getcury(win), x = getcurx(win))
 #define getbegyx(win,y,x)	(y = getbegy(win), x = getbegx(win))
 #define getmaxyx(win,y,x)	(y = getmaxy(win), x = getmaxx(win))
 #define getparyx(win,y,x)	(y = getpary(win), x = getparx(win))
@@ -1128,36 +1209,40 @@
 
 /* It seems older SYSV curses versions define these */
 #if !NCURSES_OPAQUE
-#define getattrs(win)		NCURSES_CAST(int, (win) ? (win)->_attrs : A_NORMAL)
-#define getcurx(win)		((win) ? (win)->_curx : ERR)
-#define getcury(win)		((win) ? (win)->_cury : ERR)
-#define getbegx(win)		((win) ? (win)->_begx : ERR)
-#define getbegy(win)		((win) ? (win)->_begy : ERR)
-#define getmaxx(win)		((win) ? ((win)->_maxx + 1) : ERR)
-#define getmaxy(win)		((win) ? ((win)->_maxy + 1) : ERR)
-#define getparx(win)		((win) ? (win)->_parx : ERR)
-#define getpary(win)		((win) ? (win)->_pary : ERR)
+#define getattrs(win)		NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL)
+#define getcurx(win)		(NCURSES_OK_ADDR(win) ? (win)->_curx : ERR)
+#define getcury(win)		(NCURSES_OK_ADDR(win) ? (win)->_cury : ERR)
+#define getbegx(win)		(NCURSES_OK_ADDR(win) ? (win)->_begx : ERR)
+#define getbegy(win)		(NCURSES_OK_ADDR(win) ? (win)->_begy : ERR)
+#define getmaxx(win)		(NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR)
+#define getmaxy(win)		(NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR)
+#define getparx(win)		(NCURSES_OK_ADDR(win) ? (win)->_parx : ERR)
+#define getpary(win)		(NCURSES_OK_ADDR(win) ? (win)->_pary : ERR)
 #endif /* NCURSES_OPAQUE */
 
-#define wstandout(win)      	(wattrset(win,A_STANDOUT))
-#define wstandend(win)      	(wattrset(win,A_NORMAL))
+#define wstandout(win)		(wattrset(win,A_STANDOUT))
+#define wstandend(win)		(wattrset(win,A_NORMAL))
 
 #define wattron(win,at)		wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
 #define wattroff(win,at)	wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
 
 #if !NCURSES_OPAQUE
+#if NCURSES_WATTR_MACROS
 #if NCURSES_WIDECHAR && @NCURSES_EXT_COLORS@
-#define wattrset(win,at)	((win) \
-				  ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \
-                                     (win)->_attrs = NCURSES_CAST(attr_t, at), \
-                                     OK) \
-				  : ERR)
+#define wattrset(win,at) \
+	(NCURSES_OK_ADDR(win) \
+	  ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \
+	     (win)->_attrs = NCURSES_CAST(attr_t, at), \
+	     OK) \
+	  : ERR)
 #else
-#define wattrset(win,at)        ((win) \
-				  ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
-				     OK) \
-				  : ERR)
+#define wattrset(win,at) \
+	(NCURSES_OK_ADDR(win) \
+	  ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
+	     OK) \
+	  : ERR)
 #endif
+#endif /* NCURSES_WATTR_MACROS */
 #endif /* NCURSES_OPAQUE */
 
 #define scroll(win)		wscrl(win,1)
@@ -1176,7 +1261,7 @@
 #define winsstr(w, s)		winsnstr(w, s, -1)
 
 #if !NCURSES_OPAQUE
-#define redrawwin(win)		wredrawln(win, 0, ((win) ? (win)->_maxy+1 : -1))
+#define redrawwin(win)		wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1))
 #endif /* NCURSES_OPAQUE */
 
 #define waddstr(win,str)	waddnstr(win,str,-1)
@@ -1185,7 +1270,7 @@
 /*
  * These apply to the first 256 color pairs.
  */
-#define COLOR_PAIR(n)	NCURSES_BITS((n), 0)
+#define COLOR_PAIR(n)	(NCURSES_BITS((n), 0) & A_COLOR)
 #define PAIR_NUMBER(a)	(NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
 
 /*
@@ -1197,13 +1282,13 @@
 #define addchstr(str)		waddchstr(stdscr,(str))
 #define addnstr(str,n)		waddnstr(stdscr,(str),(n))
 #define addstr(str)		waddnstr(stdscr,(str),-1)
-#define attroff(at)		wattroff(stdscr,(at))
-#define attron(at)		wattron(stdscr,(at))
-#define attrset(at)		wattrset(stdscr,(at))
 #define attr_get(ap,cp,o)	wattr_get(stdscr,(ap),(cp),(o))
 #define attr_off(a,o)		wattr_off(stdscr,(a),(o))
 #define attr_on(a,o)		wattr_on(stdscr,(a),(o))
 #define attr_set(a,c,o)		wattr_set(stdscr,(a),(c),(o))
+#define attroff(at)		wattroff(stdscr,(at))
+#define attron(at)		wattron(stdscr,(at))
+#define attrset(at)		wattrset(stdscr,(at))
 #define bkgd(ch)		wbkgd(stdscr,(ch))
 #define bkgdset(ch)		wbkgdset(stdscr,(ch))
 #define chgat(n,a,c,o)		wchgat(stdscr,(n),(a),(c),(o))
@@ -1246,8 +1331,8 @@
 #define mvwaddchstr(win,y,x,str)	(wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1))
 #define mvwaddnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n)))
 #define mvwaddstr(win,y,x,str)		(wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1))
-#define mvwdelch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wdelch(win))
 #define mvwchgat(win,y,x,n,a,c,o)	(wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o)))
+#define mvwdelch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wdelch(win))
 #define mvwgetch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wgetch(win))
 #define mvwgetnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n)))
 #define mvwgetstr(win,y,x,str)		(wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str)))
@@ -1287,31 +1372,53 @@
  * Some wide-character functions can be implemented without the extensions.
  */
 #if !NCURSES_OPAQUE
-#define getbkgd(win)                    ((win) ? ((win)->_bkgd) : 0)
+#define getbkgd(win)                    (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0)
 #endif /* NCURSES_OPAQUE */
 
 #define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
 #define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
 
 #if !NCURSES_OPAQUE
+#if NCURSES_WATTR_MACROS
 #if NCURSES_WIDECHAR && @NCURSES_EXT_COLORS@
-#define wattr_set(win,a,p,opts)		(((win) \
-					  ? ((win)->_attrs = ((a) & ~A_COLOR), \
-					     (win)->_color = (p)) \
-					  : OK), \
-					 OK)
-#define wattr_get(win,a,p,opts)		((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
-					 (void)(((p) != (void *)0) ? (*(p) = (NCURSES_PAIRS_T) ((win) ? (win)->_color : 0)) : OK), \
-					 OK)
-#else
-#define wattr_set(win,a,p,opts)		(((win) \
-					  ? ((win)->_attrs = (((a) & ~A_COLOR) | (attr_t)COLOR_PAIR(p))) \
-					  : OK), \
-					 OK)
-#define wattr_get(win,a,p,opts)		((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
-					 (void)(((p) != (void *)0) ? (*(p) = (NCURSES_PAIRS_T) ((win) ? PAIR_NUMBER((win)->_attrs) : 0)) : OK), \
-					 OK)
-#endif
+#define wattr_set(win,a,p,opts) \
+	(NCURSES_OK_ADDR(win) \
+	 ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \
+		   (win)->_color = (opts) ? *(int *)(opts) : (p)), \
+	    OK) \
+	 : ERR)
+#define wattr_get(win,a,p,opts) \
+	(NCURSES_OK_ADDR(win) \
+	 ? ((void)(NCURSES_OK_ADDR(a) \
+		   ? (*(a) = (win)->_attrs) \
+		   : OK), \
+	    (void)(NCURSES_OK_ADDR(p) \
+		   ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \
+		   : OK), \
+	    (void)(NCURSES_OK_ADDR(opts) \
+		   ? (*(int *)(opts) = (win)->_color) \
+		   : OK), \
+	    OK) \
+	 : ERR)
+#else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */
+#define wattr_set(win,a,p,opts) \
+	 (NCURSES_OK_ADDR(win) \
+	  ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \
+				     (attr_t)COLOR_PAIR(p))), \
+	     OK) \
+	  : ERR)
+#define wattr_get(win,a,p,opts) \
+	(NCURSES_OK_ADDR(win) \
+	 ? ((void)(NCURSES_OK_ADDR(a) \
+		   ? (*(a) = (win)->_attrs) \
+		   : OK), \
+	    (void)(NCURSES_OK_ADDR(p) \
+		   ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \
+		   : OK), \
+	    OK) \
+	 : ERR)
+#endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */
+#endif /* NCURSES_WATTR_MACROS */
 #endif /* NCURSES_OPAQUE */
 
 /*
@@ -1320,8 +1427,8 @@
  * use POSIX stdarg.h.  The ncurses versions of vwprintw/vwscanw already
  * use stdarg.h, so...
  */
-#define vw_printw		vwprintw
-#define vw_scanw		vwscanw
+/* define vw_printw		vwprintw */
+/* define vw_scanw		vwscanw */
 
 /*
  * Export fallback function for use in C++ binding.
@@ -1336,24 +1443,30 @@
  */
 #if @NCURSES_EXT_FUNCS@
 #if !NCURSES_OPAQUE
-#define is_cleared(win)		((win) ? (win)->_clear : FALSE)
-#define is_idcok(win)		((win) ? (win)->_idcok : FALSE)
-#define is_idlok(win)		((win) ? (win)->_idlok : FALSE)
-#define is_immedok(win)		((win) ? (win)->_immed : FALSE)
-#define is_keypad(win)		((win) ? (win)->_use_keypad : FALSE)
-#define is_leaveok(win)		((win) ? (win)->_leaveok : FALSE)
-#define is_nodelay(win)		((win) ? ((win)->_delay == 0) : FALSE)
-#define is_notimeout(win)	((win) ? (win)->_notimeout : FALSE)
-#define is_pad(win)		((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
-#define is_scrollok(win)	((win) ? (win)->_scroll : FALSE)
-#define is_subwin(win)		((win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE)
-#define is_syncok(win)		((win) ? (win)->_sync : FALSE)
-#define wgetdelay(win)		((win) ? (win)->_delay : 0)
-#define wgetparent(win)		((win) ? (win)->_parent : 0)
-#define wgetscrreg(win,t,b)	((win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
+#define is_cleared(win)		(NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE)
+#define is_idcok(win)		(NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE)
+#define is_idlok(win)		(NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE)
+#define is_immedok(win)		(NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE)
+#define is_keypad(win)		(NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE)
+#define is_leaveok(win)		(NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE)
+#define is_nodelay(win)		(NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE)
+#define is_notimeout(win)	(NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE)
+#define is_pad(win)		(NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
+#define is_scrollok(win)	(NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE)
+#define is_subwin(win)		(NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE)
+#define is_syncok(win)		(NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE)
+#define wgetdelay(win)		(NCURSES_OK_ADDR(win) ? (win)->_delay : 0)
+#define wgetparent(win)		(NCURSES_OK_ADDR(win) ? (win)->_parent : 0)
+#define wgetscrreg(win,t,b)	(NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
 #endif
 #endif
 
+/*
+ * X/Open says this returns a bool; SVr4 also checked for out-of-range line.
+ * The macro provides compatibility:
+ */
+#define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l)))
+
 #endif /* NCURSES_NOMACROS */
 
 /*
diff --git a/include/curses.head b/include/curses.head
deleted file mode 100644
index 1b23e5f..0000000
--- a/include/curses.head
+++ /dev/null
@@ -1,1422 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey                        1996-on                 *
- ****************************************************************************/
-
-/* $Id: curses.h.in,v 1.241 2014/08/09 20:39:44 tom Exp $ */
-
-#ifndef __NCURSES_H
-#define __NCURSES_H
-
-#define CURSES 1
-#define CURSES_H 1
-
-/* These are defined only in curses.h, and are used for conditional compiles */
-#define NCURSES_VERSION_MAJOR 6
-#define NCURSES_VERSION_MINOR 0
-#define NCURSES_VERSION_PATCH 20150808
-
-/* This is defined in more than one ncurses header, for identification */
-#undef  NCURSES_VERSION
-#define NCURSES_VERSION "6.0"
-
-/*
- * Identify the mouse encoding version.
- */
-#define NCURSES_MOUSE_VERSION 2
-
-/*
- * Definitions to facilitate DLL's.
- */
-#include <ncurses_dll.h>
-
-#if 1
-#include <stdint.h>
-#endif
-
-/*
- * User-definable tweak to disable the include of <stdbool.h>.
- */
-#ifndef NCURSES_ENABLE_STDBOOL_H
-#define NCURSES_ENABLE_STDBOOL_H 1
-#endif
-
-/*
- * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
- * configured using --disable-macros.
- */
-#ifndef NCURSES_ATTR_T
-#define NCURSES_ATTR_T int
-#endif
-
-/*
- * Expands to 'const' if ncurses is configured using --enable-const.  Note that
- * doing so makes it incompatible with other implementations of X/Open Curses.
- */
-#undef  NCURSES_CONST
-#define NCURSES_CONST const
-
-#undef NCURSES_INLINE
-#define NCURSES_INLINE inline
-
-/*
- * The internal type used for color values, and for color-pairs.  The latter
- * allows the curses library to enumerate the combinations of foreground and
- * background colors used by an application, and is normally the product of the
- * total foreground and background colors.
- *
- * X/Open uses "short" for both of these types, ultimately because they are
- * numbers from the terminal database, which uses 16-bit signed values.
- */
-#undef	NCURSES_COLOR_T
-#define	NCURSES_COLOR_T short
-
-#undef	NCURSES_PAIRS_T
-#define	NCURSES_PAIRS_T short
-
-/*
- * Definition used to make WINDOW and similar structs opaque.
- */
-#ifndef NCURSES_OPAQUE
-#define NCURSES_OPAQUE 0
-#endif
-
-/*
- * The reentrant code relies on the opaque setting, but adds features.
- */
-#ifndef NCURSES_REENTRANT
-#define NCURSES_REENTRANT 0
-#endif
-
-/*
- * Control whether bindings for interop support are added.
- */
-#undef	NCURSES_INTEROP_FUNCS
-#define	NCURSES_INTEROP_FUNCS 1
-
-/*
- * The internal type used for window dimensions.
- */
-#undef	NCURSES_SIZE_T
-#define	NCURSES_SIZE_T short
-
-/*
- * Control whether tparm() supports varargs or fixed-parameter list.
- */
-#undef NCURSES_TPARM_VARARGS
-#define NCURSES_TPARM_VARARGS 1
-
-/*
- * Control type used for tparm's arguments.  While X/Open equates long and
- * char* values, this is not always workable for 64-bit platforms.
- */
-#undef NCURSES_TPARM_ARG
-#define NCURSES_TPARM_ARG intptr_t
-
-/*
- * NCURSES_CH_T is used in building the library, but not used otherwise in
- * this header file, since that would make the normal/wide-character versions
- * of the header incompatible.
- */
-#undef	NCURSES_CH_T
-#define NCURSES_CH_T chtype
-
-#if 1 && defined(_LP64)
-typedef unsigned chtype;
-typedef unsigned mmask_t;
-#else
-typedef uint32_t chtype;
-typedef uint32_t mmask_t;
-#endif
-
-/*
- * We need FILE, etc.  Include this before checking any feature symbols.
- */
-#include <stdio.h>
-
-/*
- * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or
- * conflicting) when _XOPEN_SOURCE is 500 or greater.  If NCURSES_WIDECHAR is
- * not already defined, e.g., if the platform relies upon nonstandard feature
- * test macros, define it at this point if the standard feature test macros
- * indicate that it should be defined.
- */
-#ifndef NCURSES_WIDECHAR
-#if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
-#define NCURSES_WIDECHAR 1
-#else
-#define NCURSES_WIDECHAR 0
-#endif
-#endif /* NCURSES_WIDECHAR */
-
-#include <stdarg.h>	/* we need va_list */
-#if NCURSES_WIDECHAR
-#include <stddef.h>	/* we want wchar_t */
-#endif
-
-/* X/Open and SVr4 specify that curses implements 'bool'.  However, C++ may also
- * implement it.  If so, we must use the C++ compiler's type to avoid conflict
- * with other interfaces.
- *
- * A further complication is that <stdbool.h> may declare 'bool' to be a
- * different type, such as an enum which is not necessarily compatible with
- * C++.  If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
- * Otherwise, let it remain a typedef to avoid conflicts with other #define's.
- * In either case, make a typedef for NCURSES_BOOL which can be used if needed
- * from either C or C++.
- */
-
-#undef TRUE
-#define TRUE    1
-
-#undef FALSE
-#define FALSE   0
-
-typedef unsigned NCURSES_BOOL;
-
-#if defined(__cplusplus)	/* __cplusplus, etc. */
-
-/* use the C++ compiler's bool type */
-#define NCURSES_BOOL bool
-
-#else			/* c89, c99, etc. */
-
-#if NCURSES_ENABLE_STDBOOL_H
-#include <stdbool.h>
-/* use whatever the C compiler decides bool really is */
-#define NCURSES_BOOL bool
-#else
-/* there is no predefined bool - use our own */
-#undef bool
-#define bool NCURSES_BOOL
-#endif
-
-#endif /* !__cplusplus, etc. */
-
-#ifdef __cplusplus
-extern "C" {
-#define NCURSES_CAST(type,value) static_cast<type>(value)
-#else
-#define NCURSES_CAST(type,value) (type)(value)
-#endif
-
-/*
- * X/Open attributes.  In the ncurses implementation, they are identical to the
- * A_ attributes.
- */
-#define WA_ATTRIBUTES	A_ATTRIBUTES
-#define WA_NORMAL	A_NORMAL
-#define WA_STANDOUT	A_STANDOUT
-#define WA_UNDERLINE	A_UNDERLINE
-#define WA_REVERSE	A_REVERSE
-#define WA_BLINK	A_BLINK
-#define WA_DIM		A_DIM
-#define WA_BOLD		A_BOLD
-#define WA_ALTCHARSET	A_ALTCHARSET
-#define WA_INVIS	A_INVIS
-#define WA_PROTECT	A_PROTECT
-#define WA_HORIZONTAL	A_HORIZONTAL
-#define WA_LEFT		A_LEFT
-#define WA_LOW		A_LOW
-#define WA_RIGHT	A_RIGHT
-#define WA_TOP		A_TOP
-#define WA_VERTICAL	A_VERTICAL
-
-#if 1
-#define WA_ITALIC	A_ITALIC	/* ncurses extension */
-#endif
-
-/* colors */
-#define COLOR_BLACK	0
-#define COLOR_RED	1
-#define COLOR_GREEN	2
-#define COLOR_YELLOW	3
-#define COLOR_BLUE	4
-#define COLOR_MAGENTA	5
-#define COLOR_CYAN	6
-#define COLOR_WHITE	7
-
-/* line graphics */
-
-#if 0 || NCURSES_REENTRANT
-NCURSES_WRAPPED_VAR(chtype*, acs_map);
-#define acs_map NCURSES_PUBLIC_VAR(acs_map())
-#else
-extern NCURSES_EXPORT_VAR(chtype) acs_map[];
-#endif
-
-#define NCURSES_ACS(c)	(acs_map[NCURSES_CAST(unsigned char,(c))])
-
-/* VT100 symbols begin here */
-#define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
-#define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
-#define ACS_URCORNER	NCURSES_ACS('k') /* upper right corner */
-#define ACS_LRCORNER	NCURSES_ACS('j') /* lower right corner */
-#define ACS_LTEE	NCURSES_ACS('t') /* tee pointing right */
-#define ACS_RTEE	NCURSES_ACS('u') /* tee pointing left */
-#define ACS_BTEE	NCURSES_ACS('v') /* tee pointing up */
-#define ACS_TTEE	NCURSES_ACS('w') /* tee pointing down */
-#define ACS_HLINE	NCURSES_ACS('q') /* horizontal line */
-#define ACS_VLINE	NCURSES_ACS('x') /* vertical line */
-#define ACS_PLUS	NCURSES_ACS('n') /* large plus or crossover */
-#define ACS_S1		NCURSES_ACS('o') /* scan line 1 */
-#define ACS_S9		NCURSES_ACS('s') /* scan line 9 */
-#define ACS_DIAMOND	NCURSES_ACS('`') /* diamond */
-#define ACS_CKBOARD	NCURSES_ACS('a') /* checker board (stipple) */
-#define ACS_DEGREE	NCURSES_ACS('f') /* degree symbol */
-#define ACS_PLMINUS	NCURSES_ACS('g') /* plus/minus */
-#define ACS_BULLET	NCURSES_ACS('~') /* bullet */
-/* Teletype 5410v1 symbols begin here */
-#define ACS_LARROW	NCURSES_ACS(',') /* arrow pointing left */
-#define ACS_RARROW	NCURSES_ACS('+') /* arrow pointing right */
-#define ACS_DARROW	NCURSES_ACS('.') /* arrow pointing down */
-#define ACS_UARROW	NCURSES_ACS('-') /* arrow pointing up */
-#define ACS_BOARD	NCURSES_ACS('h') /* board of squares */
-#define ACS_LANTERN	NCURSES_ACS('i') /* lantern symbol */
-#define ACS_BLOCK	NCURSES_ACS('0') /* solid square block */
-/*
- * These aren't documented, but a lot of System Vs have them anyway
- * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
- * The ACS_names may not match AT&T's, our source didn't know them.
- */
-#define ACS_S3		NCURSES_ACS('p') /* scan line 3 */
-#define ACS_S7		NCURSES_ACS('r') /* scan line 7 */
-#define ACS_LEQUAL	NCURSES_ACS('y') /* less/equal */
-#define ACS_GEQUAL	NCURSES_ACS('z') /* greater/equal */
-#define ACS_PI		NCURSES_ACS('{') /* Pi */
-#define ACS_NEQUAL	NCURSES_ACS('|') /* not equal */
-#define ACS_STERLING	NCURSES_ACS('}') /* UK pound sign */
-
-/*
- * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
- * is the right, b is the bottom, and l is the left.  t, r, b, and l might
- * be B (blank), S (single), D (double), or T (thick).  The subset defined
- * here only uses B and S.
- */
-#define ACS_BSSB	ACS_ULCORNER
-#define ACS_SSBB	ACS_LLCORNER
-#define ACS_BBSS	ACS_URCORNER
-#define ACS_SBBS	ACS_LRCORNER
-#define ACS_SBSS	ACS_RTEE
-#define ACS_SSSB	ACS_LTEE
-#define ACS_SSBS	ACS_BTEE
-#define ACS_BSSS	ACS_TTEE
-#define ACS_BSBS	ACS_HLINE
-#define ACS_SBSB	ACS_VLINE
-#define ACS_SSSS	ACS_PLUS
-
-#undef	ERR
-#define ERR     (-1)
-
-#undef	OK
-#define OK      (0)
-
-/* values for the _flags member */
-#define _SUBWIN         0x01	/* is this a sub-window? */
-#define _ENDLINE        0x02	/* is the window flush right? */
-#define _FULLWIN        0x04	/* is the window full-screen? */
-#define _SCROLLWIN      0x08	/* bottom edge is at screen bottom? */
-#define _ISPAD	        0x10	/* is this window a pad? */
-#define _HASMOVED       0x20	/* has cursor moved since last refresh? */
-#define _WRAPPED        0x40	/* cursor was just wrappped */
-
-/*
- * this value is used in the firstchar and lastchar fields to mark
- * unchanged lines
- */
-#define _NOCHANGE       -1
-
-/*
- * this value is used in the oldindex field to mark lines created by insertions
- * and scrolls.
- */
-#define _NEWINDEX	-1
-
-typedef struct screen  SCREEN;
-typedef struct _win_st WINDOW;
-
-typedef	chtype	attr_t;		/* ...must be at least as wide as chtype */
-
-#if NCURSES_WIDECHAR
-
-#if 0
-#ifdef mblen			/* libutf8.h defines it w/o undefining first */
-#undef mblen
-#endif
-#include <libutf8.h>
-#endif
-
-#if 0
-#include <wchar.h>		/* ...to get mbstate_t, etc. */
-#endif
-
-#if 0
-typedef unsigned short wchar_t;
-#endif
-
-#if 0
-typedef unsigned int wint_t;
-#endif
-
-/*
- * cchar_t stores an array of CCHARW_MAX wide characters.  The first is
- * normally a spacing character.  The others are non-spacing.  If those
- * (spacing and nonspacing) do not fill the array, a null L'\0' follows.
- * Otherwise, a null is assumed to follow when extracting via getcchar().
- */
-#define CCHARW_MAX	5
-typedef struct
-{
-    attr_t	attr;
-    wchar_t	chars[CCHARW_MAX];
-#if 0
-#undef NCURSES_EXT_COLORS
-#define NCURSES_EXT_COLORS 20150808
-    int		ext_color;	/* color pair, must be more than 16-bits */
-#endif
-}
-cchar_t;
-
-#endif /* NCURSES_WIDECHAR */
-
-#if !NCURSES_OPAQUE
-struct ldat;
-
-struct _win_st
-{
-	NCURSES_SIZE_T _cury, _curx; /* current cursor position */
-
-	/* window location and size */
-	NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
-	NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
-
-	short   _flags;		/* window state flags */
-
-	/* attribute tracking */
-	attr_t  _attrs;		/* current attribute for non-space character */
-	chtype  _bkgd;		/* current background char/attribute pair */
-
-	/* option values set by user */
-	bool	_notimeout;	/* no time out on function-key entry? */
-	bool	_clear;		/* consider all data in the window invalid? */
-	bool	_leaveok;	/* OK to not reset cursor on exit? */
-	bool	_scroll;	/* OK to scroll this window? */
-	bool	_idlok;		/* OK to use insert/delete line? */
-	bool	_idcok;		/* OK to use insert/delete char? */
-	bool	_immed;		/* window in immed mode? (not yet used) */
-	bool	_sync;		/* window in sync mode? */
-	bool	_use_keypad;	/* process function keys into KEY_ symbols? */
-	int	_delay;		/* 0 = nodelay, <0 = blocking, >0 = delay */
-
-	struct ldat *_line;	/* the actual line data */
-
-	/* global screen state */
-	NCURSES_SIZE_T _regtop;	/* top line of scrolling region */
-	NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
-
-	/* these are used only if this is a sub-window */
-	int	_parx;		/* x coordinate of this window in parent */
-	int	_pary;		/* y coordinate of this window in parent */
-	WINDOW	*_parent;	/* pointer to parent if a sub-window */
-
-	/* these are used only if this is a pad */
-	struct pdat
-	{
-	    NCURSES_SIZE_T _pad_y,      _pad_x;
-	    NCURSES_SIZE_T _pad_top,    _pad_left;
-	    NCURSES_SIZE_T _pad_bottom, _pad_right;
-	} _pad;
-
-	NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
-
-#if NCURSES_WIDECHAR
-	cchar_t  _bkgrnd;	/* current background char/attribute pair */
-#if 0
-	int	_color;		/* current color-pair for non-space character */
-#endif
-#endif
-};
-#endif /* NCURSES_OPAQUE */
-
-/*
- * This is an extension to support events...
- */
-#if 1
-#ifdef NCURSES_WGETCH_EVENTS
-#if !defined(__BEOS__) || defined(__HAIKU__)
-   /* Fix _nc_timed_wait() on BEOS... */
-#  define NCURSES_EVENT_VERSION	1
-#endif	/* !defined(__BEOS__) */
-
-/*
- * Bits to set in _nc_event.data.flags
- */
-#  define _NC_EVENT_TIMEOUT_MSEC	1
-#  define _NC_EVENT_FILE		2
-#  define _NC_EVENT_FILE_READABLE	2
-#  if 0					/* Not supported yet... */
-#    define _NC_EVENT_FILE_WRITABLE	4
-#    define _NC_EVENT_FILE_EXCEPTION	8
-#  endif
-
-typedef struct
-{
-    int type;
-    union
-    {
-	long timeout_msec;	/* _NC_EVENT_TIMEOUT_MSEC */
-	struct
-	{
-	    unsigned int flags;
-	    int fd;
-	    unsigned int result;
-	} fev;				/* _NC_EVENT_FILE */
-    } data;
-} _nc_event;
-
-typedef struct
-{
-    int count;
-    int result_flags;	/* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
-    _nc_event *events[1];
-} _nc_eventlist;
-
-extern NCURSES_EXPORT(int) wgetch_events (WINDOW *, _nc_eventlist *);	/* experimental */
-extern NCURSES_EXPORT(int) wgetnstr_events (WINDOW *,char *,int,_nc_eventlist *);/* experimental */
-
-#endif /* NCURSES_WGETCH_EVENTS */
-#endif /* NCURSES_EXT_FUNCS */
-
-/*
- * GCC (and some other compilers) define '__attribute__'; we're using this
- * macro to alert the compiler to flag inconsistencies in printf/scanf-like
- * function calls.  Just in case '__attribute__' isn't defined, make a dummy.
- * Old versions of G++ do not accept it anyway, at least not consistently with
- * GCC.
- */
-#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__))
-#define __attribute__(p) /* nothing */
-#endif
-
-/*
- * We cannot define these in ncurses_cfg.h, since they require parameters to be
- * passed (that is non-portable).  If you happen to be using gcc with warnings
- * enabled, define
- *	GCC_PRINTF
- *	GCC_SCANF
- * to improve checking of calls to printw(), etc.
- */
-#ifndef GCC_PRINTFLIKE
-#if defined(GCC_PRINTF) && !defined(printf)
-#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
-#else
-#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
-#endif
-#endif
-
-#ifndef GCC_SCANFLIKE
-#if defined(GCC_SCANF) && !defined(scanf)
-#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
-#else
-#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
-#endif
-#endif
-
-#ifndef	GCC_NORETURN
-#define	GCC_NORETURN /* nothing */
-#endif
-
-#ifndef	GCC_UNUSED
-#define	GCC_UNUSED /* nothing */
-#endif
-
-/*
- * Curses uses a helper function.  Define our type for this to simplify
- * extending it for the sp-funcs feature.
- */
-typedef int (*NCURSES_OUTC)(int);
-
-/*
- * Function prototypes.  This is the complete X/Open Curses list of required
- * functions.  Those marked `generated' will have sources generated from the
- * macro definitions later in this file, in order to satisfy XPG4.2
- * requirements.
- */
-
-extern NCURSES_EXPORT(int) addch (const chtype);			/* generated */
-extern NCURSES_EXPORT(int) addchnstr (const chtype *, int);		/* generated */
-extern NCURSES_EXPORT(int) addchstr (const chtype *);			/* generated */
-extern NCURSES_EXPORT(int) addnstr (const char *, int);			/* generated */
-extern NCURSES_EXPORT(int) addstr (const char *);			/* generated */
-extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T);			/* generated */
-extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T);			/* generated */
-extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T);			/* generated */
-extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *);	/* generated */
-extern NCURSES_EXPORT(int) attr_off (attr_t, void *);			/* generated */
-extern NCURSES_EXPORT(int) attr_on (attr_t, void *);			/* generated */
-extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *);		/* generated */
-extern NCURSES_EXPORT(int) baudrate (void);				/* implemented */
-extern NCURSES_EXPORT(int) beep  (void);				/* implemented */
-extern NCURSES_EXPORT(int) bkgd (chtype);				/* generated */
-extern NCURSES_EXPORT(void) bkgdset (chtype);				/* generated */
-extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* generated */
-extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype);		/* generated */
-extern NCURSES_EXPORT(bool) can_change_color (void);			/* implemented */
-extern NCURSES_EXPORT(int) cbreak (void);				/* implemented */
-extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *);	/* generated */
-extern NCURSES_EXPORT(int) clear (void);				/* generated */
-extern NCURSES_EXPORT(int) clearok (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) clrtobot (void);				/* generated */
-extern NCURSES_EXPORT(int) clrtoeol (void);				/* generated */
-extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*);	/* implemented */
-extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*);			/* generated */
-extern NCURSES_EXPORT(int) COLOR_PAIR (int);				/* generated */
-extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int);	/* implemented */
-extern NCURSES_EXPORT(int) curs_set (int);				/* implemented */
-extern NCURSES_EXPORT(int) def_prog_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) def_shell_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) delay_output (int);				/* implemented */
-extern NCURSES_EXPORT(int) delch (void);				/* generated */
-extern NCURSES_EXPORT(void) delscreen (SCREEN *);			/* implemented */
-extern NCURSES_EXPORT(int) delwin (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) deleteln (void);				/* generated */
-extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int);	/* implemented */
-extern NCURSES_EXPORT(int) doupdate (void);				/* implemented */
-extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) echo (void);					/* implemented */
-extern NCURSES_EXPORT(int) echochar (const chtype);			/* generated */
-extern NCURSES_EXPORT(int) erase (void);				/* generated */
-extern NCURSES_EXPORT(int) endwin (void);				/* implemented */
-extern NCURSES_EXPORT(char) erasechar (void);				/* implemented */
-extern NCURSES_EXPORT(void) filter (void);				/* implemented */
-extern NCURSES_EXPORT(int) flash (void);				/* implemented */
-extern NCURSES_EXPORT(int) flushinp (void);				/* implemented */
-extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getch (void);				/* generated */
-extern NCURSES_EXPORT(int) getnstr (char *, int);			/* generated */
-extern NCURSES_EXPORT(int) getstr (char *);				/* generated */
-extern NCURSES_EXPORT(WINDOW *) getwin (FILE *);			/* implemented */
-extern NCURSES_EXPORT(int) halfdelay (int);				/* implemented */
-extern NCURSES_EXPORT(bool) has_colors (void);				/* implemented */
-extern NCURSES_EXPORT(bool) has_ic (void);				/* implemented */
-extern NCURSES_EXPORT(bool) has_il (void);				/* implemented */
-extern NCURSES_EXPORT(int) hline (chtype, int);				/* generated */
-extern NCURSES_EXPORT(void) idcok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(int) idlok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(void) immedok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(chtype) inch (void);				/* generated */
-extern NCURSES_EXPORT(int) inchnstr (chtype *, int);			/* generated */
-extern NCURSES_EXPORT(int) inchstr (chtype *);				/* generated */
-extern NCURSES_EXPORT(WINDOW *) initscr (void);				/* implemented */
-extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T);	/* implemented */
-extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T);		/* implemented */
-extern NCURSES_EXPORT(int) innstr (char *, int);			/* generated */
-extern NCURSES_EXPORT(int) insch (chtype);				/* generated */
-extern NCURSES_EXPORT(int) insdelln (int);				/* generated */
-extern NCURSES_EXPORT(int) insertln (void);				/* generated */
-extern NCURSES_EXPORT(int) insnstr (const char *, int);			/* generated */
-extern NCURSES_EXPORT(int) insstr (const char *);			/* generated */
-extern NCURSES_EXPORT(int) instr (char *);				/* generated */
-extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(bool) isendwin (void);				/* implemented */
-extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int);		/* implemented */
-extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int);		/* implemented */
-extern NCURSES_EXPORT(int) keypad (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(char) killchar (void);				/* implemented */
-extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(char *) longname (void);				/* implemented */
-extern NCURSES_EXPORT(int) meta (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) move (int, int);				/* generated */
-extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);		/* generated */
-extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *);	/* generated */
-extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *);		/* generated */
-extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *);	/* generated */
-extern NCURSES_EXPORT(int) mvcur (int,int,int,int);			/* implemented */
-extern NCURSES_EXPORT(int) mvdelch (int, int);				/* generated */
-extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int);		/* implemented */
-extern NCURSES_EXPORT(int) mvgetch (int, int);				/* generated */
-extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int);		/* generated */
-extern NCURSES_EXPORT(int) mvgetstr (int, int, char *);			/* generated */
-extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int);		/* generated */
-extern NCURSES_EXPORT(chtype) mvinch (int, int);			/* generated */
-extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *);		/* generated */
-extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int);		/* generated */
-extern NCURSES_EXPORT(int) mvinsch (int, int, chtype);			/* generated */
-extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *);		/* generated */
-extern NCURSES_EXPORT(int) mvinstr (int, int, char *);			/* generated */
-extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...)		/* implemented */
-		GCC_PRINTFLIKE(3,4);
-extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...)	/* implemented */
-		GCC_SCANFLIKE(3,4);
-extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype);	/* generated */
-extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */
-extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *);	/* generated */
-extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *);	/* generated */
-extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */
-extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *);	/* generated */
-extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int);			/* implemented */
-extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int);			/* generated */
-extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *);		/* generated */
-extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int);		/* generated */
-extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype);		/* generated */
-extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int);	/* generated */
-extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *);	/* generated */
-extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *);		/* generated */
-extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...)	/* implemented */
-		GCC_PRINTFLIKE(4,5);
-extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...)	/* implemented */
-		GCC_SCANFLIKE(4,5);
-extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int);	/* generated */
-extern NCURSES_EXPORT(int) napms (int);					/* implemented */
-extern NCURSES_EXPORT(WINDOW *) newpad (int,int);		       	/* implemented */
-extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *);	/* implemented */
-extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int);	       	/* implemented */
-extern NCURSES_EXPORT(int) nl (void);					/* implemented */
-extern NCURSES_EXPORT(int) nocbreak (void);				/* implemented */
-extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) noecho (void);				/* implemented */
-extern NCURSES_EXPORT(int) nonl (void);					/* implemented */
-extern NCURSES_EXPORT(void) noqiflush (void);				/* implemented */
-extern NCURSES_EXPORT(int) noraw (void);				/* implemented */
-extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *);		/* implemented */
-extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *);		/* implemented */
-extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*);		/* implemented */
-extern NCURSES_EXPORT(int) PAIR_NUMBER (int);				/* generated */
-extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype);		/* implemented */
-extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */
-extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int);	/* implemented */
-extern NCURSES_EXPORT(int) printw (const char *,...)			/* implemented */
-		GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *);			/* implemented */
-extern NCURSES_EXPORT(void) qiflush (void);				/* implemented */
-extern NCURSES_EXPORT(int) raw (void);					/* implemented */
-extern NCURSES_EXPORT(int) redrawwin (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) refresh (void);				/* generated */
-extern NCURSES_EXPORT(int) resetty (void);				/* implemented */
-extern NCURSES_EXPORT(int) reset_prog_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) reset_shell_mode (void);			/* implemented */
-extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int));	/* implemented */
-extern NCURSES_EXPORT(int) savetty (void);				/* implemented */
-extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...)		/* implemented */
-		GCC_SCANFLIKE(1,2);
-extern NCURSES_EXPORT(int) scr_dump (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) scr_init (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) scrl (int);					/* generated */
-extern NCURSES_EXPORT(int) scroll (WINDOW *);				/* generated */
-extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool);			/* implemented */
-extern NCURSES_EXPORT(int) scr_restore (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) scr_set (const char *);			/* implemented */
-extern NCURSES_EXPORT(int) setscrreg (int,int);				/* generated */
-extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *);			/* implemented */
-extern NCURSES_EXPORT(int) slk_attroff (const chtype);			/* implemented */
-extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *);		/* generated:WIDEC */
-extern NCURSES_EXPORT(int) slk_attron (const chtype);			/* implemented */
-extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*);			/* generated:WIDEC */
-extern NCURSES_EXPORT(int) slk_attrset (const chtype);			/* implemented */
-extern NCURSES_EXPORT(attr_t) slk_attr (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*);	/* implemented */
-extern NCURSES_EXPORT(int) slk_clear (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T);				/* implemented */
-extern NCURSES_EXPORT(int) slk_init (int);				/* implemented */
-extern NCURSES_EXPORT(char *) slk_label (int);				/* implemented */
-extern NCURSES_EXPORT(int) slk_noutrefresh (void);			/* implemented */
-extern NCURSES_EXPORT(int) slk_refresh (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_restore (void);				/* implemented */
-extern NCURSES_EXPORT(int) slk_set (int,const char *,int);		/* implemented */
-extern NCURSES_EXPORT(int) slk_touch (void);	      	       		/* implemented */
-extern NCURSES_EXPORT(int) standout (void);				/* generated */
-extern NCURSES_EXPORT(int) standend (void);				/* generated */
-extern NCURSES_EXPORT(int) start_color (void);				/* implemented */
-extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int);	/* implemented */
-extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int);	/* implemented */
-extern NCURSES_EXPORT(int) syncok (WINDOW *, bool);			/* implemented */
-extern NCURSES_EXPORT(chtype) termattrs (void);				/* implemented */
-extern NCURSES_EXPORT(char *) termname (void);				/* implemented */
-extern NCURSES_EXPORT(void) timeout (int);				/* generated */
-extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int);		/* generated */
-extern NCURSES_EXPORT(int) touchwin (WINDOW *);				/* generated */
-extern NCURSES_EXPORT(int) typeahead (int);				/* implemented */
-extern NCURSES_EXPORT(int) ungetch (int);				/* implemented */
-extern NCURSES_EXPORT(int) untouchwin (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(void) use_env (bool);				/* implemented */
-extern NCURSES_EXPORT(void) use_tioctl (bool);				/* implemented */
-extern NCURSES_EXPORT(int) vidattr (chtype);				/* implemented */
-extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC);		/* implemented */
-extern NCURSES_EXPORT(int) vline (chtype, int);				/* generated */
-extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list);	/* generated */
-extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list);	/* implemented */
-extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list);	/* generated */
-extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype);		/* implemented */
-extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int);	/* implemented */
-extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *);		/* generated */
-extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int);	/* implemented */
-extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *);		/* generated */
-extern NCURSES_EXPORT(int) wattron (WINDOW *, int);			/* generated */
-extern NCURSES_EXPORT(int) wattroff (WINDOW *, int);			/* generated */
-extern NCURSES_EXPORT(int) wattrset (WINDOW *, int);			/* generated */
-extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *);	/* generated */
-extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *);		/* implemented */
-extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *);	/* implemented */
-extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *);	/* generated */
-extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype);			/* implemented */
-extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype);			/* implemented */
-extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* implemented */
-extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */
-extern NCURSES_EXPORT(int) wclear (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wclrtobot (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*);		/* implemented */
-extern NCURSES_EXPORT(void) wcursyncup (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wdelch (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wdeleteln (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype);		/* implemented */
-extern NCURSES_EXPORT(int) werase (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wgetch (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int);		/* implemented */
-extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *);			/* generated */
-extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int);		/* implemented */
-extern NCURSES_EXPORT(chtype) winch (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int);		/* implemented */
-extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *);		/* generated */
-extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int);		/* implemented */
-extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype);			/* implemented */
-extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int);			/* implemented */
-extern NCURSES_EXPORT(int) winsertln (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int);	/* implemented */
-extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *);		/* generated */
-extern NCURSES_EXPORT(int) winstr (WINDOW *, char *);			/* generated */
-extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int);			/* implemented */
-extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...)		/* implemented */
-		GCC_PRINTFLIKE(2,3);
-extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int);		/* implemented */
-extern NCURSES_EXPORT(int) wrefresh (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(int) wscanw (WINDOW *, NCURSES_CONST char *,...)	/* implemented */
-		GCC_SCANFLIKE(2,3);
-extern NCURSES_EXPORT(int) wscrl (WINDOW *,int);			/* implemented */
-extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int);		/* implemented */
-extern NCURSES_EXPORT(int) wstandout (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) wstandend (WINDOW *);			/* generated */
-extern NCURSES_EXPORT(void) wsyncdown (WINDOW *);			/* implemented */
-extern NCURSES_EXPORT(void) wsyncup (WINDOW *);				/* implemented */
-extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int);			/* implemented */
-extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int);		/* implemented */
-extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int);		/* implemented */
-
-/*
- * These are also declared in <term.h>:
- */
-extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);		/* implemented */
-extern NCURSES_EXPORT(int) putp (const char *);				/* implemented */
-
-#if NCURSES_TPARM_VARARGS
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* special */
-#else
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG);	/* special */
-extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* special */
-#endif
-
-extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */
-
-/*
- * These functions are not in X/Open, but we use them in macro definitions:
- */
-extern NCURSES_EXPORT(int) getattrs (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getcurx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getcury (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getbegx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getbegy (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getmaxx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getmaxy (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getparx (const WINDOW *);			/* generated */
-extern NCURSES_EXPORT(int) getpary (const WINDOW *);			/* generated */
-
-/*
- * vid_attr() was implemented originally based on a draft of X/Open curses.
- */
-#if !NCURSES_WIDECHAR
-#define vid_attr(a,pair,opts) vidattr(a)
-#endif
-
-/*
- * These functions are extensions - not in X/Open Curses.
- */
-#if 1
-#undef  NCURSES_EXT_FUNCS
-#define NCURSES_EXT_FUNCS 20150808
-typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
-typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
-extern NCURSES_EXPORT(bool) is_term_resized (int, int);
-extern NCURSES_EXPORT(char *) keybound (int, int);
-extern NCURSES_EXPORT(const char *) curses_version (void);
-extern NCURSES_EXPORT(int) assume_default_colors (int, int);
-extern NCURSES_EXPORT(int) define_key (const char *, int);
-extern NCURSES_EXPORT(int) get_escdelay (void);
-extern NCURSES_EXPORT(int) key_defined (const char *);
-extern NCURSES_EXPORT(int) keyok (int, bool);
-extern NCURSES_EXPORT(int) resize_term (int, int);
-extern NCURSES_EXPORT(int) resizeterm (int, int);
-extern NCURSES_EXPORT(int) set_escdelay (int);
-extern NCURSES_EXPORT(int) set_tabsize (int);
-extern NCURSES_EXPORT(int) use_default_colors (void);
-extern NCURSES_EXPORT(int) use_extended_names (bool);
-extern NCURSES_EXPORT(int) use_legacy_coding (int);
-extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *);
-extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *);
-extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
-extern NCURSES_EXPORT(void) nofilter(void);
-
-/*
- * These extensions provide access to information stored in the WINDOW even
- * when NCURSES_OPAQUE is set:
- */
-extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_pad (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *);	/* generated */
-extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *);		/* generated */
-extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */
-
-#else
-#define curses_version() NCURSES_VERSION
-#endif
-
-/*
- * Extra extension-functions, which pass a SCREEN pointer rather than using
- * a global variable SP.
- */
-#if 1
-#undef  NCURSES_SP_FUNCS
-#define NCURSES_SP_FUNCS 20150808
-#define NCURSES_SP_NAME(name) name##_sp
-
-/* Define the sp-funcs helper function */
-#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)
-typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);
-
-extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */
-
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *);			/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool);	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, NCURSES_CONST char *, FILE *, FILE *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int));	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype);	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */
-#if 1
-extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*);	/* implemented:EXT_SP_FUNC */
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int);	/* implemented:EXT_SP_FUNC */
-#endif
-#else
-#undef  NCURSES_SP_FUNCS
-#define NCURSES_SP_FUNCS 0
-#define NCURSES_SP_NAME(name) name
-#define NCURSES_SP_OUTC NCURSES_OUTC
-#endif
-
-/* attributes */
-
-#define NCURSES_ATTR_SHIFT       8
-#define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT))
-
-#define A_NORMAL	(1U - 1U)
-#define A_ATTRIBUTES	NCURSES_BITS(~(1U - 1U),0)
-#define A_CHARTEXT	(NCURSES_BITS(1U,0) - 1U)
-#define A_COLOR		NCURSES_BITS(((1U) << 8) - 1U,0)
-#define A_STANDOUT	NCURSES_BITS(1U,8)
-#define A_UNDERLINE	NCURSES_BITS(1U,9)
-#define A_REVERSE	NCURSES_BITS(1U,10)
-#define A_BLINK		NCURSES_BITS(1U,11)
-#define A_DIM		NCURSES_BITS(1U,12)
-#define A_BOLD		NCURSES_BITS(1U,13)
-#define A_ALTCHARSET	NCURSES_BITS(1U,14)
-#define A_INVIS		NCURSES_BITS(1U,15)
-#define A_PROTECT	NCURSES_BITS(1U,16)
-#define A_HORIZONTAL	NCURSES_BITS(1U,17)
-#define A_LEFT		NCURSES_BITS(1U,18)
-#define A_LOW		NCURSES_BITS(1U,19)
-#define A_RIGHT		NCURSES_BITS(1U,20)
-#define A_TOP		NCURSES_BITS(1U,21)
-#define A_VERTICAL	NCURSES_BITS(1U,22)
-
-#if 1
-#define A_ITALIC	NCURSES_BITS(1U,23)	/* ncurses extension */
-#endif
-
-/*
- * Most of the pseudo functions are macros that either provide compatibility
- * with older versions of curses, or provide inline functionality to improve
- * performance.
- */
-
-/*
- * These pseudo functions are always implemented as macros:
- */
-
-#define getyx(win,y,x)   	(y = getcury(win), x = getcurx(win))
-#define getbegyx(win,y,x)	(y = getbegy(win), x = getbegx(win))
-#define getmaxyx(win,y,x)	(y = getmaxy(win), x = getmaxx(win))
-#define getparyx(win,y,x)	(y = getpary(win), x = getparx(win))
-
-#define getsyx(y,x) do { if (newscr) { \
-			     if (is_leaveok(newscr)) \
-				(y) = (x) = -1; \
-			     else \
-				 getyx(newscr,(y), (x)); \
-			} \
-		    } while(0)
-
-#define setsyx(y,x) do { if (newscr) { \
-			    if ((y) == -1 && (x) == -1) \
-				leaveok(newscr, TRUE); \
-			    else { \
-				leaveok(newscr, FALSE); \
-				wmove(newscr, (y), (x)); \
-			    } \
-			} \
-		    } while(0)
-
-#ifndef NCURSES_NOMACROS
-
-/*
- * These miscellaneous pseudo functions are provided for compatibility:
- */
-
-#define wgetstr(w, s)		wgetnstr(w, s, -1)
-#define getnstr(s, n)		wgetnstr(stdscr, s, (n))
-
-#define setterm(term)		setupterm(term, 1, (int *)0)
-
-#define fixterm()		reset_prog_mode()
-#define resetterm()		reset_shell_mode()
-#define saveterm()		def_prog_mode()
-#define crmode()		cbreak()
-#define nocrmode()		nocbreak()
-#define gettmode()
-
-/* It seems older SYSV curses versions define these */
-#if !NCURSES_OPAQUE
-#define getattrs(win)		NCURSES_CAST(int, (win) ? (win)->_attrs : A_NORMAL)
-#define getcurx(win)		((win) ? (win)->_curx : ERR)
-#define getcury(win)		((win) ? (win)->_cury : ERR)
-#define getbegx(win)		((win) ? (win)->_begx : ERR)
-#define getbegy(win)		((win) ? (win)->_begy : ERR)
-#define getmaxx(win)		((win) ? ((win)->_maxx + 1) : ERR)
-#define getmaxy(win)		((win) ? ((win)->_maxy + 1) : ERR)
-#define getparx(win)		((win) ? (win)->_parx : ERR)
-#define getpary(win)		((win) ? (win)->_pary : ERR)
-#endif /* NCURSES_OPAQUE */
-
-#define wstandout(win)      	(wattrset(win,A_STANDOUT))
-#define wstandend(win)      	(wattrset(win,A_NORMAL))
-
-#define wattron(win,at)		wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
-#define wattroff(win,at)	wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
-
-#if !NCURSES_OPAQUE
-#if NCURSES_WIDECHAR && 0
-#define wattrset(win,at)	((win) \
-				  ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \
-                                     (win)->_attrs = NCURSES_CAST(attr_t, at), \
-                                     OK) \
-				  : ERR)
-#else
-#define wattrset(win,at)        ((win) \
-				  ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
-				     OK) \
-				  : ERR)
-#endif
-#endif /* NCURSES_OPAQUE */
-
-#define scroll(win)		wscrl(win,1)
-
-#define touchwin(win)		wtouchln((win), 0, getmaxy(win), 1)
-#define touchline(win, s, c)	wtouchln((win), s, c, 1)
-#define untouchwin(win)		wtouchln((win), 0, getmaxy(win), 0)
-
-#define box(win, v, h)		wborder(win, v, v, h, h, 0, 0, 0, 0)
-#define border(ls, rs, ts, bs, tl, tr, bl, br)	wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
-#define hline(ch, n)		whline(stdscr, ch, (n))
-#define vline(ch, n)		wvline(stdscr, ch, (n))
-
-#define winstr(w, s)		winnstr(w, s, -1)
-#define winchstr(w, s)		winchnstr(w, s, -1)
-#define winsstr(w, s)		winsnstr(w, s, -1)
-
-#if !NCURSES_OPAQUE
-#define redrawwin(win)		wredrawln(win, 0, ((win) ? (win)->_maxy+1 : -1))
-#endif /* NCURSES_OPAQUE */
-
-#define waddstr(win,str)	waddnstr(win,str,-1)
-#define waddchstr(win,str)	waddchnstr(win,str,-1)
-
-/*
- * These apply to the first 256 color pairs.
- */
-#define COLOR_PAIR(n)	NCURSES_BITS((n), 0)
-#define PAIR_NUMBER(a)	(NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
-
-/*
- * pseudo functions for standard screen
- */
-
-#define addch(ch)		waddch(stdscr,(ch))
-#define addchnstr(str,n)	waddchnstr(stdscr,(str),(n))
-#define addchstr(str)		waddchstr(stdscr,(str))
-#define addnstr(str,n)		waddnstr(stdscr,(str),(n))
-#define addstr(str)		waddnstr(stdscr,(str),-1)
-#define attroff(at)		wattroff(stdscr,(at))
-#define attron(at)		wattron(stdscr,(at))
-#define attrset(at)		wattrset(stdscr,(at))
-#define attr_get(ap,cp,o)	wattr_get(stdscr,(ap),(cp),(o))
-#define attr_off(a,o)		wattr_off(stdscr,(a),(o))
-#define attr_on(a,o)		wattr_on(stdscr,(a),(o))
-#define attr_set(a,c,o)		wattr_set(stdscr,(a),(c),(o))
-#define bkgd(ch)		wbkgd(stdscr,(ch))
-#define bkgdset(ch)		wbkgdset(stdscr,(ch))
-#define chgat(n,a,c,o)		wchgat(stdscr,(n),(a),(c),(o))
-#define clear()			wclear(stdscr)
-#define clrtobot()		wclrtobot(stdscr)
-#define clrtoeol()		wclrtoeol(stdscr)
-#define color_set(c,o)		wcolor_set(stdscr,(c),(o))
-#define delch()			wdelch(stdscr)
-#define deleteln()		winsdelln(stdscr,-1)
-#define echochar(c)		wechochar(stdscr,(c))
-#define erase()			werase(stdscr)
-#define getch()			wgetch(stdscr)
-#define getstr(str)		wgetstr(stdscr,(str))
-#define inch()			winch(stdscr)
-#define inchnstr(s,n)		winchnstr(stdscr,(s),(n))
-#define inchstr(s)		winchstr(stdscr,(s))
-#define innstr(s,n)		winnstr(stdscr,(s),(n))
-#define insch(c)		winsch(stdscr,(c))
-#define insdelln(n)		winsdelln(stdscr,(n))
-#define insertln()		winsdelln(stdscr,1)
-#define insnstr(s,n)		winsnstr(stdscr,(s),(n))
-#define insstr(s)		winsstr(stdscr,(s))
-#define instr(s)		winstr(stdscr,(s))
-#define move(y,x)		wmove(stdscr,(y),(x))
-#define refresh()		wrefresh(stdscr)
-#define scrl(n)			wscrl(stdscr,(n))
-#define setscrreg(t,b)		wsetscrreg(stdscr,(t),(b))
-#define standend()		wstandend(stdscr)
-#define standout()		wstandout(stdscr)
-#define timeout(delay)		wtimeout(stdscr,(delay))
-#define wdeleteln(win)		winsdelln(win,-1)
-#define winsertln(win)		winsdelln(win,1)
-
-/*
- * mv functions
- */
-
-#define mvwaddch(win,y,x,ch)		(wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch)))
-#define mvwaddchnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n)))
-#define mvwaddchstr(win,y,x,str)	(wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1))
-#define mvwaddnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n)))
-#define mvwaddstr(win,y,x,str)		(wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1))
-#define mvwdelch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wdelch(win))
-#define mvwchgat(win,y,x,n,a,c,o)	(wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o)))
-#define mvwgetch(win,y,x)		(wmove((win),(y),(x)) == ERR ? ERR : wgetch(win))
-#define mvwgetnstr(win,y,x,str,n)	(wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n)))
-#define mvwgetstr(win,y,x,str)		(wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str)))
-#define mvwhline(win,y,x,c,n)		(wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n)))
-#define mvwinch(win,y,x)		(wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
-#define mvwinchnstr(win,y,x,s,n)	(wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n)))
-#define mvwinchstr(win,y,x,s)		(wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s)))
-#define mvwinnstr(win,y,x,s,n)		(wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n)))
-#define mvwinsch(win,y,x,c)		(wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c)))
-#define mvwinsnstr(win,y,x,s,n)		(wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n)))
-#define mvwinsstr(win,y,x,s)		(wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s)))
-#define mvwinstr(win,y,x,s)		(wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s)))
-#define mvwvline(win,y,x,c,n)		(wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n)))
-
-#define mvaddch(y,x,ch)			mvwaddch(stdscr,(y),(x),(ch))
-#define mvaddchnstr(y,x,str,n)		mvwaddchnstr(stdscr,(y),(x),(str),(n))
-#define mvaddchstr(y,x,str)		mvwaddchstr(stdscr,(y),(x),(str))
-#define mvaddnstr(y,x,str,n)		mvwaddnstr(stdscr,(y),(x),(str),(n))
-#define mvaddstr(y,x,str)		mvwaddstr(stdscr,(y),(x),(str))
-#define mvchgat(y,x,n,a,c,o)		mvwchgat(stdscr,(y),(x),(n),(a),(c),(o))
-#define mvdelch(y,x)			mvwdelch(stdscr,(y),(x))
-#define mvgetch(y,x)			mvwgetch(stdscr,(y),(x))
-#define mvgetnstr(y,x,str,n)		mvwgetnstr(stdscr,(y),(x),(str),(n))
-#define mvgetstr(y,x,str)		mvwgetstr(stdscr,(y),(x),(str))
-#define mvhline(y,x,c,n)		mvwhline(stdscr,(y),(x),(c),(n))
-#define mvinch(y,x)			mvwinch(stdscr,(y),(x))
-#define mvinchnstr(y,x,s,n)		mvwinchnstr(stdscr,(y),(x),(s),(n))
-#define mvinchstr(y,x,s)		mvwinchstr(stdscr,(y),(x),(s))
-#define mvinnstr(y,x,s,n)		mvwinnstr(stdscr,(y),(x),(s),(n))
-#define mvinsch(y,x,c)			mvwinsch(stdscr,(y),(x),(c))
-#define mvinsnstr(y,x,s,n)		mvwinsnstr(stdscr,(y),(x),(s),(n))
-#define mvinsstr(y,x,s)			mvwinsstr(stdscr,(y),(x),(s))
-#define mvinstr(y,x,s)			mvwinstr(stdscr,(y),(x),(s))
-#define mvvline(y,x,c,n)		mvwvline(stdscr,(y),(x),(c),(n))
-
-/*
- * Some wide-character functions can be implemented without the extensions.
- */
-#if !NCURSES_OPAQUE
-#define getbkgd(win)                    ((win) ? ((win)->_bkgd) : 0)
-#endif /* NCURSES_OPAQUE */
-
-#define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
-#define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
-
-#if !NCURSES_OPAQUE
-#if NCURSES_WIDECHAR && 0
-#define wattr_set(win,a,p,opts)		(((win) \
-					  ? ((win)->_attrs = ((a) & ~A_COLOR), \
-					     (win)->_color = (p)) \
-					  : OK), \
-					 OK)
-#define wattr_get(win,a,p,opts)		((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
-					 (void)(((p) != (void *)0) ? (*(p) = (NCURSES_PAIRS_T) ((win) ? (win)->_color : 0)) : OK), \
-					 OK)
-#else
-#define wattr_set(win,a,p,opts)		(((win) \
-					  ? ((win)->_attrs = (((a) & ~A_COLOR) | (attr_t)COLOR_PAIR(p))) \
-					  : OK), \
-					 OK)
-#define wattr_get(win,a,p,opts)		((void)(((a) != (void *)0) ? (*(a) = (win) ? (win)->_attrs : 0) : OK), \
-					 (void)(((p) != (void *)0) ? (*(p) = (NCURSES_PAIRS_T) ((win) ? PAIR_NUMBER((win)->_attrs) : 0)) : OK), \
-					 OK)
-#endif
-#endif /* NCURSES_OPAQUE */
-
-/*
- * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
- * varargs.h.  It adds new calls vw_printw/vw_scanw, which are supposed to
- * use POSIX stdarg.h.  The ncurses versions of vwprintw/vwscanw already
- * use stdarg.h, so...
- */
-#define vw_printw		vwprintw
-#define vw_scanw		vwscanw
-
-/*
- * Export fallback function for use in C++ binding.
- */
-#if !1
-#define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
-NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
-#endif
-
-/*
- * These macros are extensions - not in X/Open Curses.
- */
-#if 1
-#if !NCURSES_OPAQUE
-#define is_cleared(win)		((win) ? (win)->_clear : FALSE)
-#define is_idcok(win)		((win) ? (win)->_idcok : FALSE)
-#define is_idlok(win)		((win) ? (win)->_idlok : FALSE)
-#define is_immedok(win)		((win) ? (win)->_immed : FALSE)
-#define is_keypad(win)		((win) ? (win)->_use_keypad : FALSE)
-#define is_leaveok(win)		((win) ? (win)->_leaveok : FALSE)
-#define is_nodelay(win)		((win) ? ((win)->_delay == 0) : FALSE)
-#define is_notimeout(win)	((win) ? (win)->_notimeout : FALSE)
-#define is_pad(win)		((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
-#define is_scrollok(win)	((win) ? (win)->_scroll : FALSE)
-#define is_subwin(win)		((win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE)
-#define is_syncok(win)		((win) ? (win)->_sync : FALSE)
-#define wgetdelay(win)		((win) ? (win)->_delay : 0)
-#define wgetparent(win)		((win) ? (win)->_parent : 0)
-#define wgetscrreg(win,t,b)	((win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
-#endif
-#endif
-
-#endif /* NCURSES_NOMACROS */
-
-/*
- * Public variables.
- *
- * Notes:
- *	a. ESCDELAY was an undocumented feature under AIX curses.
- *	   It gives the ESC expire time in milliseconds.
- *	b. ttytype is needed for backward compatibility
- */
-#if NCURSES_REENTRANT
-
-NCURSES_WRAPPED_VAR(WINDOW *, curscr);
-NCURSES_WRAPPED_VAR(WINDOW *, newscr);
-NCURSES_WRAPPED_VAR(WINDOW *, stdscr);
-NCURSES_WRAPPED_VAR(char *, ttytype);
-NCURSES_WRAPPED_VAR(int, COLORS);
-NCURSES_WRAPPED_VAR(int, COLOR_PAIRS);
-NCURSES_WRAPPED_VAR(int, COLS);
-NCURSES_WRAPPED_VAR(int, ESCDELAY);
-NCURSES_WRAPPED_VAR(int, LINES);
-NCURSES_WRAPPED_VAR(int, TABSIZE);
-
-#define curscr      NCURSES_PUBLIC_VAR(curscr())
-#define newscr      NCURSES_PUBLIC_VAR(newscr())
-#define stdscr      NCURSES_PUBLIC_VAR(stdscr())
-#define ttytype     NCURSES_PUBLIC_VAR(ttytype())
-#define COLORS      NCURSES_PUBLIC_VAR(COLORS())
-#define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS())
-#define COLS        NCURSES_PUBLIC_VAR(COLS())
-#define ESCDELAY    NCURSES_PUBLIC_VAR(ESCDELAY())
-#define LINES       NCURSES_PUBLIC_VAR(LINES())
-#define TABSIZE     NCURSES_PUBLIC_VAR(TABSIZE())
-
-#else
-
-extern NCURSES_EXPORT_VAR(WINDOW *) curscr;
-extern NCURSES_EXPORT_VAR(WINDOW *) newscr;
-extern NCURSES_EXPORT_VAR(WINDOW *) stdscr;
-extern NCURSES_EXPORT_VAR(char) ttytype[];
-extern NCURSES_EXPORT_VAR(int) COLORS;
-extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
-extern NCURSES_EXPORT_VAR(int) COLS;
-extern NCURSES_EXPORT_VAR(int) ESCDELAY;
-extern NCURSES_EXPORT_VAR(int) LINES;
-extern NCURSES_EXPORT_VAR(int) TABSIZE;
-
-#endif
-
-/*
- * Pseudo-character tokens outside ASCII range.  The curses wgetch() function
- * will return any given one of these only if the corresponding k- capability
- * is defined in your terminal's terminfo entry.
- *
- * Some keys (KEY_A1, etc) are arranged like this:
- *	a1     up    a3
- *	left   b2    right
- *	c1     down  c3
- *
- * A few key codes do not depend upon the terminfo entry.
- */
-#define KEY_CODE_YES	0400		/* A wchar_t contains a key code */
-#define KEY_MIN		0401		/* Minimum curses key */
-#define KEY_BREAK	0401		/* Break key (unreliable) */
-#define KEY_SRESET	0530		/* Soft (partial) reset (unreliable) */
-#define KEY_RESET	0531		/* Reset or hard reset (unreliable) */
diff --git a/include/curses.tail b/include/curses.tail
index 5f911ae..9c91356 100644
--- a/include/curses.tail
+++ b/include/curses.tail
@@ -1,4 +1,4 @@
-/* $Id: curses.tail,v 1.21 2011/10/29 20:03:22 tom Exp $ */
+/* $Id: curses.tail,v 1.27 2023/08/05 19:43:46 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -13,12 +13,12 @@
 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
 #endif
 
-#define	NCURSES_BUTTON_RELEASED	001L
-#define	NCURSES_BUTTON_PRESSED	002L
-#define	NCURSES_BUTTON_CLICKED	004L
-#define	NCURSES_DOUBLE_CLICKED	010L
-#define	NCURSES_TRIPLE_CLICKED	020L
-#define	NCURSES_RESERVED_EVENT	040L
+#define	NCURSES_BUTTON_RELEASED	001UL
+#define	NCURSES_BUTTON_PRESSED	002UL
+#define	NCURSES_BUTTON_CLICKED	004UL
+#define	NCURSES_DOUBLE_CLICKED	010UL
+#define	NCURSES_TRIPLE_CLICKED	020UL
+#define	NCURSES_RESERVED_EVENT	040UL
 
 /* event masks */
 #define	BUTTON1_RELEASED	NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
@@ -111,7 +111,9 @@
 extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(mouseinterval) (SCREEN*, int);
 #endif
 
+#ifndef NCURSES_NOMACROS
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
+#endif
 
 /* other non-XSI functions */
 
@@ -126,10 +128,8 @@
 /* Debugging : use with libncurses_g.a */
 
 extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *);
 extern NCURSES_EXPORT(char *) _traceattr (attr_t);
 extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype);
-extern NCURSES_EXPORT(char *) _nc_tracebits (void);
 extern NCURSES_EXPORT(char *) _tracechar (int);
 extern NCURSES_EXPORT(char *) _tracechtype (chtype);
 extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype);
@@ -142,8 +142,8 @@
 #define _tracech_t		_tracechtype
 #define _tracech_t2		_tracechtype2
 #endif
-extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *);
-extern NCURSES_EXPORT(void) trace (const unsigned int);
+extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace");
+extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned);
 
 /* trace masks */
 #define TRACE_DISABLE	0x0000	/* turn off tracing */
@@ -174,6 +174,8 @@
 #define OPTIMIZE_ALL		0xff	/* enable all optimizations (dflt) */
 #endif
 
+extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int);
+
 #include <unctrl.h>
 
 #ifdef __cplusplus
diff --git a/include/curses.wide b/include/curses.wide
index 5d130a9..33adb07 100644
--- a/include/curses.wide
+++ b/include/curses.wide
@@ -1,4 +1,4 @@
-/* $Id: curses.wide,v 1.46 2014/02/01 22:00:32 tom Exp $ */
+/* $Id: curses.wide,v 1.51 2021/05/22 20:28:29 tom Exp $ */
 /*
  * vile:cmode:
  * This file is part of ncurses, designed to be appended after curses.h.in
@@ -204,7 +204,7 @@
 extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *);		/* implemented */
 extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *);		/* generated:WIDEC */
 extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *);		/* generated:WIDEC */
-extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *,wint_t *, int);		/* implemented */
+extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int);	/* implemented */
 extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int);	/* implemented */
 extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *);		/* implemented */
 extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int);	/* implemented */
@@ -219,10 +219,12 @@
 
 #if NCURSES_SP_FUNCS
 extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*);		/* implemented:SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(erasewchar) (SCREEN*, wchar_t *);	/* implemented:SP_FUNC */
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(killwchar) (SCREEN*, wchar_t *);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t);	/* implemented:SP_FUNC */
-extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *);	/* implemented:SP_FUNC */
 extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC);	/* implemented:SP_FUNC */
+extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *);	/* implemented:SP_FUNC */
 #endif
 
 #ifndef NCURSES_NOMACROS
@@ -261,7 +263,7 @@
 #define wins_wstr(w,t)			wins_nwstr((w),(t),-1)
 
 #if !NCURSES_OPAQUE
-#define wgetbkgrnd(win,wch)		((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK)
+#define wgetbkgrnd(win,wch)		(NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR)
 #endif
 
 #define mvadd_wch(y,x,c)		mvwadd_wch(stdscr,(y),(x),(c))
diff --git a/include/edit_cfg.sh b/include/edit_cfg.sh
index 8d64fee..559b157 100755
--- a/include/edit_cfg.sh
+++ b/include/edit_cfg.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
-# $Id: edit_cfg.sh,v 1.12 2001/12/23 00:52:40 tom Exp $
+# $Id: edit_cfg.sh,v 1.16 2022/07/16 18:02:32 tom Exp $
 ##############################################################################
-# Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.                #
+# Copyright 2020,2022 Thomas E. Dickey                                       #
+# Copyright 1998-2001,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -38,15 +39,16 @@
 #
 BAK=save$$
 TMP=edit$$
-trap "rm -f $BAK $TMP" 0 1 2 5 15
+trap "rm -f $BAK $TMP; exit 1" 1 2 3 15
+trap "rm -f $BAK $TMP" 0
 for name in \
 	HAVE_TCGETATTR \
 	HAVE_TERMIOS_H \
 	HAVE_TERMIO_H \
 	BROKEN_LINKER
 do
-	mv $2 $BAK
-	if ( grep "[ 	]$name[ 	]" $1 2>&1 >$TMP )
+	mv "$2" "$BAK"
+	if ( grep "[ 	]${name}[ 	]" "$1" >$TMP 2>&1 )
 	then
 		value=1
 	else
@@ -57,11 +59,11 @@
 		-e "s@#define ${name}.*\$@#define $name $value@" \
 		-e "s@#if $name\$@#if $value /* $name */@" \
 		-e "s@#if !$name\$@#if $value /* !$name */@" \
-		$BAK >$2
-	if (cmp -s $2 $BAK)
+		"$BAK" >"$2"
+	if (cmp -s "$2" "$BAK")
 	then
-		mv $BAK $2
+		mv "$BAK" "$2"
 	else
-		rm -f $BAK
+		rm -f "$BAK"
 	fi
 done
diff --git a/include/eti.h b/include/eti.h
deleted file mode 100644
index baa6190..0000000
--- a/include/eti.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *   Author:  Juergen Pfeifer, 1995,1997                                    *
- ****************************************************************************/
-
-/* $Id: eti.h,v 1.8 2003/10/25 15:24:29 tom Exp $ */
-
-#ifndef NCURSES_ETI_H_incl
-#define NCURSES_ETI_H_incl 1
-
-#define	E_OK			(0)
-#define	E_SYSTEM_ERROR	 	(-1)
-#define	E_BAD_ARGUMENT	 	(-2)
-#define	E_POSTED	 	(-3)
-#define	E_CONNECTED	 	(-4)
-#define	E_BAD_STATE	 	(-5)
-#define	E_NO_ROOM	 	(-6)
-#define	E_NOT_POSTED		(-7)
-#define	E_UNKNOWN_COMMAND	(-8)
-#define	E_NO_MATCH		(-9)
-#define	E_NOT_SELECTABLE	(-10)
-#define	E_NOT_CONNECTED	        (-11)
-#define	E_REQUEST_DENIED	(-12)
-#define	E_INVALID_FIELD	        (-13)
-#define	E_CURRENT		(-14)
-
-#endif
diff --git a/include/form.h b/include/form.h
deleted file mode 100644
index 09856dc..0000000
--- a/include/form.h
+++ /dev/null
@@ -1,428 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *   Author:  Juergen Pfeifer, 1995,1997                                    *
- ****************************************************************************/
-
-/* $Id: form.h,v 0.24 2014/07/26 20:52:28 tom Exp $ */
-
-#ifndef FORM_H
-#define FORM_H
-/* *INDENT-OFF*/
-
-#include <curses.h>
-#include <eti.h>
-
-#ifdef __cplusplus
-  extern "C" {
-#endif
-
-#ifndef FORM_PRIV_H
-typedef void *FIELD_CELL;
-#endif
-
-#ifndef NCURSES_FIELD_INTERNALS
-#define NCURSES_FIELD_INTERNALS /* nothing */
-#endif
-
-typedef int Form_Options;
-typedef int Field_Options;
-
-	/**********
-	*  _PAGE  *
-	**********/
-
-typedef struct {
-  short pmin;		/* index of first field on page			*/
-  short pmax;		/* index of last field on page			*/
-  short smin;		/* index of top leftmost field on page		*/
-  short smax;		/* index of bottom rightmost field on page	*/
-} _PAGE;
-
-	/**********
-	*  FIELD  *
-	**********/
-
-typedef struct fieldnode {
-  unsigned short	status;		/* flags			*/
-  short			rows;		/* size in rows			*/
-  short			cols;		/* size in cols			*/
-  short			frow;		/* first row			*/
-  short			fcol;		/* first col			*/
-  int			drows;		/* dynamic rows			*/
-  int			dcols;		/* dynamic cols			*/
-  int			maxgrow;	/* maximum field growth		*/
-  int			nrow;		/* off-screen rows		*/
-  short			nbuf;		/* additional buffers		*/
-  short			just;		/* justification		*/
-  short			page;		/* page on form			*/
-  short			index;		/* into form -> field		*/
-  int			pad;		/* pad character		*/
-  chtype		fore;		/* foreground attribute		*/
-  chtype		back;		/* background attribute		*/
-  Field_Options		opts;		/* options			*/
-  struct fieldnode *	snext;		/* sorted order pointer		*/
-  struct fieldnode *	sprev;		/* sorted order pointer		*/
-  struct fieldnode *	link;		/* linked field chain		*/
-  struct formnode *	form;		/* containing form		*/
-  struct typenode *	type;		/* field type			*/
-  void *		arg;		/* argument for type		*/
-  FIELD_CELL *		buf;		/* field buffers		*/
-  void *		usrptr;		/* user pointer			*/
-  /*
-   * The wide-character configuration requires extra information.  Because
-   * there are existing applications that manipulate the members of FIELD
-   * directly, we cannot make the struct opaque.  Offsets of members up to
-   * this point are the same in the narrow- and wide-character configuration.
-   * But note that the type of buf depends on the configuration, and is made
-   * opaque for that reason.
-   */
-  NCURSES_FIELD_INTERNALS
-} FIELD;
-
-
-	/*********
-	*  FORM  *
-	*********/
-
-typedef struct formnode {
-  unsigned short	status;	  	/* flags			*/
-  short			rows;		/* size in rows			*/
-  short			cols;		/* size in cols			*/
-  int			currow;		/* current row in field window	*/
-  int			curcol;		/* current col in field window	*/
-  int			toprow;		/* in scrollable field window	*/
-  int			begincol;	/* in horiz. scrollable field	*/
-  short			maxfield;	/* number of fields		*/
-  short			maxpage;	/* number of pages		*/
-  short			curpage;	/* index into page		*/
-  Form_Options		opts;		/* options			*/
-  WINDOW *		win;		/* window			*/
-  WINDOW *		sub;		/* subwindow			*/
-  WINDOW *		w;		/* window for current field	*/
-  FIELD **		field;		/* field [maxfield]		*/
-  FIELD *		current;	/* current field		*/
-  _PAGE *		page;		/* page [maxpage]		*/
-  void *		usrptr;		/* user pointer			*/
-
-  void			(*forminit)(struct formnode *);
-  void			(*formterm)(struct formnode *);
-  void			(*fieldinit)(struct formnode *);
-  void			(*fieldterm)(struct formnode *);
-
-} FORM;
-
-
-	/**************
-	*  FIELDTYPE  *
-	**************/
-
-typedef struct typenode {
-  unsigned short	status;			/* flags		    */
-  long			ref;			/* reference count	    */
-  struct typenode *	left;			/* ptr to operand for |     */
-  struct typenode *	right;			/* ptr to operand for |     */
-
-  void* (*makearg)(va_list *);			/* make fieldtype arg	    */
-  void* (*copyarg)(const void *);		/* copy fieldtype arg 	    */
-  void	(*freearg)(void *);			/* free fieldtype arg	    */
-
-#if NCURSES_INTEROP_FUNCS
-  union {
-    bool (*ofcheck)(FIELD *,const void *);	/* field validation	    */
-    bool (*gfcheck)(FORM*,FIELD *,const void*);	/* generic field validation */
-  } fieldcheck;
-  union {
-    bool (*occheck)(int,const void *);		/* character validation     */
-    bool (*gccheck)(int,FORM*,
-		    FIELD*,const void*);        /* generic char validation  */
-  } charcheck;
-  union {
-    bool (*onext)(FIELD *,const void *);        /* enumerate next value     */
-    bool (*gnext)(FORM*,FIELD*,const void*);    /* generic enumerate next   */
-  } enum_next;
-  union {
-    bool (*oprev)(FIELD *,const void *);	/* enumerate prev value     */
-    bool (*gprev)(FORM*,FIELD*,const void*);    /* generic enumerate prev   */
-  } enum_prev;
-  void* (*genericarg)(void*);                   /* Alternate Arg method     */
-#else
-  bool	(*fcheck)(FIELD *,const void *);	/* field validation	*/
-  bool	(*ccheck)(int,const void *);		/* character validation */
-
-  bool	(*next)(FIELD *,const void *);		/* enumerate next value */
-  bool	(*prev)(FIELD *,const void *);		/* enumerate prev value */
-#endif
-} FIELDTYPE;
-
-typedef void (*Form_Hook)(FORM *);
-
-	/***************************
-	*  miscellaneous #defines  *
-	***************************/
-
-/* field justification */
-#define NO_JUSTIFICATION	(0)
-#define JUSTIFY_LEFT		(1)
-#define JUSTIFY_CENTER		(2)
-#define JUSTIFY_RIGHT		(3)
-
-/* field options */
-#define O_VISIBLE		(0x0001U)
-#define O_ACTIVE		(0x0002U)
-#define O_PUBLIC		(0x0004U)
-#define O_EDIT			(0x0008U)
-#define O_WRAP			(0x0010U)
-#define O_BLANK			(0x0020U)
-#define O_AUTOSKIP		(0x0040U)
-#define O_NULLOK		(0x0080U)
-#define O_PASSOK		(0x0100U)
-#define O_STATIC		(0x0200U)
-#define O_DYNAMIC_JUSTIFY	(0x0400U)	/* ncurses extension	*/
-
-/* form options */
-#define O_NL_OVERLOAD		(0x0001U)
-#define O_BS_OVERLOAD		(0x0002U)
-
-/* form driver commands */
-#define REQ_NEXT_PAGE	 (KEY_MAX + 1)	/* move to next page		*/
-#define REQ_PREV_PAGE	 (KEY_MAX + 2)	/* move to previous page	*/
-#define REQ_FIRST_PAGE	 (KEY_MAX + 3)	/* move to first page		*/
-#define REQ_LAST_PAGE	 (KEY_MAX + 4)	/* move to last page		*/
-
-#define REQ_NEXT_FIELD	 (KEY_MAX + 5)	/* move to next field		*/
-#define REQ_PREV_FIELD	 (KEY_MAX + 6)	/* move to previous field	*/
-#define REQ_FIRST_FIELD	 (KEY_MAX + 7)	/* move to first field		*/
-#define REQ_LAST_FIELD	 (KEY_MAX + 8)	/* move to last field		*/
-#define REQ_SNEXT_FIELD	 (KEY_MAX + 9)	/* move to sorted next field	*/
-#define REQ_SPREV_FIELD	 (KEY_MAX + 10)	/* move to sorted prev field	*/
-#define REQ_SFIRST_FIELD (KEY_MAX + 11)	/* move to sorted first field	*/
-#define REQ_SLAST_FIELD	 (KEY_MAX + 12)	/* move to sorted last field	*/
-#define REQ_LEFT_FIELD	 (KEY_MAX + 13)	/* move to left to field	*/
-#define REQ_RIGHT_FIELD	 (KEY_MAX + 14)	/* move to right to field	*/
-#define REQ_UP_FIELD	 (KEY_MAX + 15)	/* move to up to field		*/
-#define REQ_DOWN_FIELD	 (KEY_MAX + 16)	/* move to down to field	*/
-
-#define REQ_NEXT_CHAR	 (KEY_MAX + 17)	/* move to next char in field	*/
-#define REQ_PREV_CHAR	 (KEY_MAX + 18)	/* move to prev char in field	*/
-#define REQ_NEXT_LINE	 (KEY_MAX + 19)	/* move to next line in field	*/
-#define REQ_PREV_LINE	 (KEY_MAX + 20)	/* move to prev line in field	*/
-#define REQ_NEXT_WORD	 (KEY_MAX + 21)	/* move to next word in field	*/
-#define REQ_PREV_WORD	 (KEY_MAX + 22)	/* move to prev word in field	*/
-#define REQ_BEG_FIELD	 (KEY_MAX + 23)	/* move to first char in field	*/
-#define REQ_END_FIELD	 (KEY_MAX + 24)	/* move after last char in fld	*/
-#define REQ_BEG_LINE	 (KEY_MAX + 25)	/* move to beginning of line	*/
-#define REQ_END_LINE	 (KEY_MAX + 26)	/* move after last char in line	*/
-#define REQ_LEFT_CHAR	 (KEY_MAX + 27)	/* move left in field		*/
-#define REQ_RIGHT_CHAR	 (KEY_MAX + 28)	/* move right in field		*/
-#define REQ_UP_CHAR	 (KEY_MAX + 29)	/* move up in field		*/
-#define REQ_DOWN_CHAR	 (KEY_MAX + 30)	/* move down in field		*/
-
-#define REQ_NEW_LINE	 (KEY_MAX + 31)	/* insert/overlay new line	*/
-#define REQ_INS_CHAR	 (KEY_MAX + 32)	/* insert blank char at cursor	*/
-#define REQ_INS_LINE	 (KEY_MAX + 33)	/* insert blank line at cursor	*/
-#define REQ_DEL_CHAR	 (KEY_MAX + 34)	/* delete char at cursor	*/
-#define REQ_DEL_PREV	 (KEY_MAX + 35)	/* delete char before cursor	*/
-#define REQ_DEL_LINE	 (KEY_MAX + 36)	/* delete line at cursor	*/
-#define REQ_DEL_WORD	 (KEY_MAX + 37)	/* delete word at cursor	*/
-#define REQ_CLR_EOL	 (KEY_MAX + 38)	/* clear to end of line		*/
-#define REQ_CLR_EOF	 (KEY_MAX + 39)	/* clear to end of field	*/
-#define REQ_CLR_FIELD	 (KEY_MAX + 40)	/* clear entire field		*/
-#define REQ_OVL_MODE	 (KEY_MAX + 41)	/* begin overlay mode		*/
-#define REQ_INS_MODE	 (KEY_MAX + 42)	/* begin insert mode		*/
-#define REQ_SCR_FLINE	 (KEY_MAX + 43)	/* scroll field forward a line	*/
-#define REQ_SCR_BLINE	 (KEY_MAX + 44)	/* scroll field backward a line	*/
-#define REQ_SCR_FPAGE	 (KEY_MAX + 45)	/* scroll field forward a page	*/
-#define REQ_SCR_BPAGE	 (KEY_MAX + 46)	/* scroll field backward a page	*/
-#define REQ_SCR_FHPAGE	 (KEY_MAX + 47) /* scroll field forward	 half page */
-#define REQ_SCR_BHPAGE	 (KEY_MAX + 48) /* scroll field backward half page */
-#define REQ_SCR_FCHAR	 (KEY_MAX + 49) /* horizontal scroll char	*/
-#define REQ_SCR_BCHAR	 (KEY_MAX + 50) /* horizontal scroll char	*/
-#define REQ_SCR_HFLINE	 (KEY_MAX + 51) /* horizontal scroll line	*/
-#define REQ_SCR_HBLINE	 (KEY_MAX + 52) /* horizontal scroll line	*/
-#define REQ_SCR_HFHALF	 (KEY_MAX + 53) /* horizontal scroll half line	*/
-#define REQ_SCR_HBHALF	 (KEY_MAX + 54) /* horizontal scroll half line	*/
-
-#define REQ_VALIDATION	 (KEY_MAX + 55)	/* validate field		*/
-#define REQ_NEXT_CHOICE	 (KEY_MAX + 56)	/* display next field choice	*/
-#define REQ_PREV_CHOICE	 (KEY_MAX + 57)	/* display prev field choice	*/
-
-#define MIN_FORM_COMMAND (KEY_MAX + 1)	/* used by form_driver		*/
-#define MAX_FORM_COMMAND (KEY_MAX + 57)	/* used by form_driver		*/
-
-#if defined(MAX_COMMAND)
-#  if (MAX_FORM_COMMAND > MAX_COMMAND)
-#    error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
-#  elif (MAX_COMMAND != (KEY_MAX + 128))
-#    error Something is wrong -- MAX_COMMAND is already inconsistently defined.
-#  endif
-#else
-#  define MAX_COMMAND (KEY_MAX + 128)
-#endif
-
-	/*************************
-	*  standard field types  *
-	*************************/
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
-
-	/************************************
-	*  built-in additional field types  *
-	*  They are not defined in SVr4     *
-	************************************/
-extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4;      /* Internet IP Version 4 address */
-
-	/***********************
-	*  FIELDTYPE routines  *
-	***********************/
-extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
-		    bool (* const field_check)(FIELD *,const void *),
-		    bool (* const char_check)(int,const void *));
-extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
-		    FIELDTYPE *, FIELDTYPE *);
-
-extern NCURSES_EXPORT(int)	free_fieldtype (FIELDTYPE *);
-extern NCURSES_EXPORT(int)	set_fieldtype_arg (FIELDTYPE *,
-		    void * (* const make_arg)(va_list *),
-		    void * (* const copy_arg)(const void *),
-		    void (* const free_arg)(void *));
-extern NCURSES_EXPORT(int)	 set_fieldtype_choice (FIELDTYPE *,
-		    bool (* const next_choice)(FIELD *,const void *),
-	      	    bool (* const prev_choice)(FIELD *,const void *));
-
-	/*******************
-	*  FIELD routines  *
-	*******************/
-extern NCURSES_EXPORT(FIELD *)	new_field (int,int,int,int,int,int);
-extern NCURSES_EXPORT(FIELD *)	dup_field (FIELD *,int,int);
-extern NCURSES_EXPORT(FIELD *)	link_field (FIELD *,int,int);
-
-extern NCURSES_EXPORT(int)	free_field (FIELD *);
-extern NCURSES_EXPORT(int)	field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
-extern NCURSES_EXPORT(int)	dynamic_field_info (const FIELD *,int *,int *,int *);
-extern NCURSES_EXPORT(int)	set_max_field ( FIELD *,int);
-extern NCURSES_EXPORT(int)	move_field (FIELD *,int,int);
-extern NCURSES_EXPORT(int)	set_field_type (FIELD *,FIELDTYPE *,...);
-extern NCURSES_EXPORT(int)	set_new_page (FIELD *,bool);
-extern NCURSES_EXPORT(int)	set_field_just (FIELD *,int);
-extern NCURSES_EXPORT(int)	field_just (const FIELD *);
-extern NCURSES_EXPORT(int)	set_field_fore (FIELD *,chtype);
-extern NCURSES_EXPORT(int)	set_field_back (FIELD *,chtype);
-extern NCURSES_EXPORT(int)	set_field_pad (FIELD *,int);
-extern NCURSES_EXPORT(int)	field_pad (const FIELD *);
-extern NCURSES_EXPORT(int)	set_field_buffer (FIELD *,int,const char *);
-extern NCURSES_EXPORT(int)	set_field_status (FIELD *,bool);
-extern NCURSES_EXPORT(int)	set_field_userptr (FIELD *, void *);
-extern NCURSES_EXPORT(int)	set_field_opts (FIELD *,Field_Options);
-extern NCURSES_EXPORT(int)	field_opts_on (FIELD *,Field_Options);
-extern NCURSES_EXPORT(int)	field_opts_off (FIELD *,Field_Options);
-
-extern NCURSES_EXPORT(chtype)	field_fore (const FIELD *);
-extern NCURSES_EXPORT(chtype)	field_back (const FIELD *);
-
-extern NCURSES_EXPORT(bool)	new_page (const FIELD *);
-extern NCURSES_EXPORT(bool)	field_status (const FIELD *);
-
-extern NCURSES_EXPORT(void *)	field_arg (const FIELD *);
-
-extern NCURSES_EXPORT(void *)	field_userptr (const FIELD *);
-
-extern NCURSES_EXPORT(FIELDTYPE *)	field_type (const FIELD *);
-
-extern NCURSES_EXPORT(char *)	field_buffer (const FIELD *,int);
-
-extern NCURSES_EXPORT(Field_Options)	field_opts (const FIELD *);
-
-	/******************
-	*  FORM routines  *
-	******************/
-
-extern NCURSES_EXPORT(FORM *)	new_form (FIELD **);
-
-extern NCURSES_EXPORT(FIELD **)	form_fields (const FORM *);
-extern NCURSES_EXPORT(FIELD *)	current_field (const FORM *);
-
-extern NCURSES_EXPORT(WINDOW *)	form_win (const FORM *);
-extern NCURSES_EXPORT(WINDOW *)	form_sub (const FORM *);
-
-extern NCURSES_EXPORT(Form_Hook)	form_init (const FORM *);
-extern NCURSES_EXPORT(Form_Hook)	form_term (const FORM *);
-extern NCURSES_EXPORT(Form_Hook)	field_init (const FORM *);
-extern NCURSES_EXPORT(Form_Hook)	field_term (const FORM *);
-
-extern NCURSES_EXPORT(int)	free_form (FORM *);
-extern NCURSES_EXPORT(int)	set_form_fields (FORM *,FIELD **);
-extern NCURSES_EXPORT(int)	field_count (const FORM *);
-extern NCURSES_EXPORT(int)	set_form_win (FORM *,WINDOW *);
-extern NCURSES_EXPORT(int)	set_form_sub (FORM *,WINDOW *);
-extern NCURSES_EXPORT(int)	set_current_field (FORM *,FIELD *);
-extern NCURSES_EXPORT(int)	field_index (const FIELD *);
-extern NCURSES_EXPORT(int)	set_form_page (FORM *,int);
-extern NCURSES_EXPORT(int)	form_page (const FORM *);
-extern NCURSES_EXPORT(int)	scale_form (const FORM *,int *,int *);
-extern NCURSES_EXPORT(int)	set_form_init (FORM *,Form_Hook);
-extern NCURSES_EXPORT(int)	set_form_term (FORM *,Form_Hook);
-extern NCURSES_EXPORT(int)	set_field_init (FORM *,Form_Hook);
-extern NCURSES_EXPORT(int)	set_field_term (FORM *,Form_Hook);
-extern NCURSES_EXPORT(int)	post_form (FORM *);
-extern NCURSES_EXPORT(int)	unpost_form (FORM *);
-extern NCURSES_EXPORT(int)	pos_form_cursor (FORM *);
-extern NCURSES_EXPORT(int)	form_driver (FORM *,int);
-# if NCURSES_WIDECHAR
-extern NCURSES_EXPORT(int)	form_driver_w (FORM *,int,wchar_t);
-# endif
-extern NCURSES_EXPORT(int)	set_form_userptr (FORM *,void *);
-extern NCURSES_EXPORT(int)	set_form_opts (FORM *,Form_Options);
-extern NCURSES_EXPORT(int)	form_opts_on (FORM *,Form_Options);
-extern NCURSES_EXPORT(int)	form_opts_off (FORM *,Form_Options);
-extern NCURSES_EXPORT(int)	form_request_by_name (const char *);
-
-extern NCURSES_EXPORT(const char *)	form_request_name (int);
-
-extern NCURSES_EXPORT(void *)	form_userptr (const FORM *);
-
-extern NCURSES_EXPORT(Form_Options)	form_opts (const FORM *);
-
-extern NCURSES_EXPORT(bool)	data_ahead (const FORM *);
-extern NCURSES_EXPORT(bool)	data_behind (const FORM *);
-
-#if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(FORM *)	NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
-#endif
-
-#ifdef __cplusplus
-  }
-#endif
-/* *INDENT-ON*/
-
-#endif /* FORM_H */
diff --git a/include/hashed_db.h b/include/hashed_db.h
index 1ae29b0..584fd96 100644
--- a/include/hashed_db.h
+++ b/include/hashed_db.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006 Free Software Foundation, Inc.                        *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2006-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -31,12 +32,14 @@
  ****************************************************************************/
 
 /*
- * $Id: hashed_db.h,v 1.6 2014/04/12 22:41:10 tom Exp $
+ * $Id: hashed_db.h,v 1.9 2020/02/02 23:34:34 tom Exp $
  */
 
 #ifndef HASHED_DB_H
 #define HASHED_DB_H 1
 
+#include <ncurses_cfg.h>
+
 #include <curses.h>
 
 #if USE_HASHED_DB
@@ -45,7 +48,7 @@
 
 #include <db.h>
 
-#ifndef DBN_SUFFIX
+#ifndef DBM_SUFFIX
 #define DBM_SUFFIX ".db"
 #endif
 
diff --git a/include/hashsize.h b/include/hashsize.h
deleted file mode 100644
index 478fd59..0000000
--- a/include/hashsize.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * hashsize.h -- hash and token table constants
- */
-
-#define CAPTABSIZE	497
-#define HASHTABSIZE	(497 * 2)
diff --git a/include/headers b/include/headers
index 2f20bed..e1293b2 100644
--- a/include/headers
+++ b/include/headers
@@ -1,6 +1,7 @@
-# $Id: headers,v 1.13 2013/10/20 00:32:21 tom Exp $
+# $Id: headers,v 1.16 2023/04/22 12:09:09 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.                #
+# Copyright 2020,2023 Thomas E. Dickey                                       #
+# Copyright 1998-2012,2013 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -38,15 +39,15 @@
 term.h
 termcap.h
 
-# Headers used only for tic, other programs using internal interfaces
+# Header used by tack 1.08
 @ ticlib
-$(srcdir)/tic.h
 $(srcdir)/term_entry.h
-$(srcdir)/nc_tparm.h
 
 # Porting
 @ port_win32con
 $(srcdir)/ncurses_mingw.h
 $(srcdir)/nc_mingw.h
+@ port_win32
+$(srcdir)/win32_curses.h
 
 # vile:makemode
diff --git a/include/menu.h b/include/menu.h
deleted file mode 100644
index 4eeac01..0000000
--- a/include/menu.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *   Author:  Juergen Pfeifer, 1995,1997                                    *
- ****************************************************************************/
-
-/* $Id: menu.h,v 1.20 2009/04/05 00:28:07 tom Exp $ */
-
-#ifndef ETI_MENU
-#define ETI_MENU
-
-#ifdef AMIGA
-#define TEXT TEXT_ncurses
-#endif
-
-#include <curses.h>
-#include <eti.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef int Menu_Options;
-typedef int Item_Options;
-
-/* Menu options: */
-#define O_ONEVALUE      (0x01)
-#define O_SHOWDESC      (0x02)
-#define O_ROWMAJOR      (0x04)
-#define O_IGNORECASE    (0x08)
-#define O_SHOWMATCH     (0x10)
-#define O_NONCYCLIC     (0x20)
-
-/* Item options: */
-#define O_SELECTABLE    (0x01)
-
-typedef struct
-{
-  const char* str;
-  unsigned short length;
-} TEXT;
-
-typedef struct tagITEM 
-{
-  TEXT           name;        /* name of menu item                         */
-  TEXT           description; /* description of item, optional in display  */ 
-  struct tagMENU *imenu;      /* Pointer to parent menu                    */
-  void           *userptr;    /* Pointer to user defined per item data     */ 
-  Item_Options   opt;         /* Item options                              */ 
-  short          index;       /* Item number if connected to a menu        */
-  short          y;           /* y and x location of item in menu          */
-  short          x;
-  bool           value;       /* Selection value                           */
-                             
-  struct tagITEM *left;       /* neighbor items                            */
-  struct tagITEM *right;
-  struct tagITEM *up;
-  struct tagITEM *down;
-
-} ITEM;
-
-typedef void (*Menu_Hook)(struct tagMENU *);
-
-typedef struct tagMENU 
-{
-  short          height;                /* Nr. of chars high               */
-  short          width;                 /* Nr. of chars wide               */
-  short          rows;                  /* Nr. of items high               */
-  short          cols;                  /* Nr. of items wide               */
-  short          frows;                 /* Nr. of formatted items high     */
-  short          fcols;                 /* Nr. of formatted items wide     */
-  short          arows;                 /* Nr. of items high (actual)      */
-  short          namelen;               /* Max. name length                */
-  short          desclen;               /* Max. description length         */
-  short          marklen;               /* Length of mark, if any          */
-  short          itemlen;               /* Length of one item              */
-  short          spc_desc;              /* Spacing for descriptor          */
-  short          spc_cols;              /* Spacing for columns             */
-  short          spc_rows;              /* Spacing for rows                */ 
-  char          *pattern;               /* Buffer to store match chars     */
-  short          pindex;                /* Index into pattern buffer       */
-  WINDOW        *win;                   /* Window containing menu          */
-  WINDOW        *sub;                   /* Subwindow for menu display      */
-  WINDOW        *userwin;               /* User's window                   */
-  WINDOW        *usersub;               /* User's subwindow                */
-  ITEM          **items;                /* array of items                  */ 
-  short          nitems;                /* Nr. of items in menu            */
-  ITEM          *curitem;               /* Current item                    */
-  short          toprow;                /* Top row of menu                 */
-  chtype         fore;                  /* Selection attribute             */
-  chtype         back;                  /* Nonselection attribute          */
-  chtype         grey;                  /* Inactive attribute              */
-  unsigned char  pad;                   /* Pad character                   */
-
-  Menu_Hook      menuinit;              /* User hooks                      */
-  Menu_Hook      menuterm;
-  Menu_Hook      iteminit;
-  Menu_Hook      itemterm;
-
-  void          *userptr;               /* Pointer to menus user data      */
-  char          *mark;                  /* Pointer to marker string        */
-
-  Menu_Options   opt;                   /* Menu options                    */
-  unsigned short status;                /* Internal state of menu          */
-
-} MENU;
-
-
-/* Define keys */
-
-#define REQ_LEFT_ITEM           (KEY_MAX + 1)
-#define REQ_RIGHT_ITEM          (KEY_MAX + 2)
-#define REQ_UP_ITEM             (KEY_MAX + 3)
-#define REQ_DOWN_ITEM           (KEY_MAX + 4)
-#define REQ_SCR_ULINE           (KEY_MAX + 5)
-#define REQ_SCR_DLINE           (KEY_MAX + 6)
-#define REQ_SCR_DPAGE           (KEY_MAX + 7)
-#define REQ_SCR_UPAGE           (KEY_MAX + 8)
-#define REQ_FIRST_ITEM          (KEY_MAX + 9)
-#define REQ_LAST_ITEM           (KEY_MAX + 10)
-#define REQ_NEXT_ITEM           (KEY_MAX + 11)
-#define REQ_PREV_ITEM           (KEY_MAX + 12)
-#define REQ_TOGGLE_ITEM         (KEY_MAX + 13)
-#define REQ_CLEAR_PATTERN       (KEY_MAX + 14)
-#define REQ_BACK_PATTERN        (KEY_MAX + 15)
-#define REQ_NEXT_MATCH          (KEY_MAX + 16)
-#define REQ_PREV_MATCH          (KEY_MAX + 17)
-
-#define MIN_MENU_COMMAND        (KEY_MAX + 1)
-#define MAX_MENU_COMMAND        (KEY_MAX + 17)
-
-/*
- * Some AT&T code expects MAX_COMMAND to be out-of-band not
- * just for menu commands but for forms ones as well.
- */
-#if defined(MAX_COMMAND)
-#  if (MAX_MENU_COMMAND > MAX_COMMAND)
-#    error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
-#  elif (MAX_COMMAND != (KEY_MAX + 128))
-#    error Something is wrong -- MAX_COMMAND is already inconsistently defined.
-#  endif
-#else
-#  define MAX_COMMAND (KEY_MAX + 128)
-#endif
-
-
-/* --------- prototypes for libmenu functions ----------------------------- */
-
-extern NCURSES_EXPORT(ITEM **)	menu_items (const MENU *);
-extern NCURSES_EXPORT(ITEM *)	current_item (const MENU *);
-extern NCURSES_EXPORT(ITEM *)	new_item (const char *,const char *);
-
-extern NCURSES_EXPORT(MENU *)	new_menu (ITEM **);
-
-extern NCURSES_EXPORT(Item_Options)	item_opts (const ITEM *);
-extern NCURSES_EXPORT(Menu_Options)	menu_opts (const MENU *);
-
-extern NCURSES_EXPORT(Menu_Hook)	item_init (const MENU *);
-extern NCURSES_EXPORT(Menu_Hook)	item_term (const MENU *);
-extern NCURSES_EXPORT(Menu_Hook)	menu_init (const MENU *);
-extern NCURSES_EXPORT(Menu_Hook)	menu_term (const MENU *);
-
-extern NCURSES_EXPORT(WINDOW *)	menu_sub (const MENU *);
-extern NCURSES_EXPORT(WINDOW *)	menu_win (const MENU *);
-
-extern NCURSES_EXPORT(const char *)	item_description (const ITEM *);
-extern NCURSES_EXPORT(const char *)	item_name (const ITEM *);
-extern NCURSES_EXPORT(const char *)	menu_mark (const MENU *);
-extern NCURSES_EXPORT(const char *)	menu_request_name (int);
-
-extern NCURSES_EXPORT(char *)	menu_pattern (const MENU *);
-
-extern NCURSES_EXPORT(void *)	menu_userptr (const MENU *);
-extern NCURSES_EXPORT(void *)	item_userptr (const ITEM *);
-
-extern NCURSES_EXPORT(chtype)	menu_back (const MENU *);
-extern NCURSES_EXPORT(chtype)	menu_fore (const MENU *);
-extern NCURSES_EXPORT(chtype)	menu_grey (const MENU *);
-
-extern NCURSES_EXPORT(int)	free_item (ITEM *);
-extern NCURSES_EXPORT(int)	free_menu (MENU *);
-extern NCURSES_EXPORT(int)	item_count (const MENU *);
-extern NCURSES_EXPORT(int)	item_index (const ITEM *);
-extern NCURSES_EXPORT(int)	item_opts_off (ITEM *,Item_Options);
-extern NCURSES_EXPORT(int)	item_opts_on (ITEM *,Item_Options);
-extern NCURSES_EXPORT(int)	menu_driver (MENU *,int);
-extern NCURSES_EXPORT(int)	menu_opts_off (MENU *,Menu_Options);
-extern NCURSES_EXPORT(int)	menu_opts_on (MENU *,Menu_Options);
-extern NCURSES_EXPORT(int)	menu_pad (const MENU *);
-extern NCURSES_EXPORT(int)	pos_menu_cursor (const MENU *);
-extern NCURSES_EXPORT(int)	post_menu (MENU *);
-extern NCURSES_EXPORT(int)	scale_menu (const MENU *,int *,int *);
-extern NCURSES_EXPORT(int)	set_current_item (MENU *menu,ITEM *item);
-extern NCURSES_EXPORT(int)	set_item_init (MENU *, Menu_Hook);
-extern NCURSES_EXPORT(int)	set_item_opts (ITEM *,Item_Options);
-extern NCURSES_EXPORT(int)	set_item_term (MENU *, Menu_Hook);
-extern NCURSES_EXPORT(int)	set_item_userptr (ITEM *, void *);
-extern NCURSES_EXPORT(int)	set_item_value (ITEM *,bool);
-extern NCURSES_EXPORT(int)	set_menu_back (MENU *,chtype);
-extern NCURSES_EXPORT(int)	set_menu_fore (MENU *,chtype);
-extern NCURSES_EXPORT(int)	set_menu_format (MENU *,int,int);
-extern NCURSES_EXPORT(int)	set_menu_grey (MENU *,chtype);
-extern NCURSES_EXPORT(int)	set_menu_init (MENU *, Menu_Hook);
-extern NCURSES_EXPORT(int)	set_menu_items (MENU *,ITEM **);
-extern NCURSES_EXPORT(int)	set_menu_mark (MENU *, const char *);
-extern NCURSES_EXPORT(int)	set_menu_opts (MENU *,Menu_Options);
-extern NCURSES_EXPORT(int)	set_menu_pad (MENU *,int);
-extern NCURSES_EXPORT(int)	set_menu_pattern (MENU *,const char *);
-extern NCURSES_EXPORT(int)	set_menu_sub (MENU *,WINDOW *);
-extern NCURSES_EXPORT(int)	set_menu_term (MENU *, Menu_Hook);
-extern NCURSES_EXPORT(int)	set_menu_userptr (MENU *,void *);
-extern NCURSES_EXPORT(int)	set_menu_win (MENU *,WINDOW *);
-extern NCURSES_EXPORT(int)	set_top_row (MENU *,int);
-extern NCURSES_EXPORT(int)	top_row (const MENU *);
-extern NCURSES_EXPORT(int)	unpost_menu (MENU *);
-extern NCURSES_EXPORT(int)	menu_request_by_name (const char *);
-extern NCURSES_EXPORT(int)	set_menu_spacing (MENU *,int,int,int);
-extern NCURSES_EXPORT(int)	menu_spacing (const MENU *,int *,int *,int *);
-
-
-extern NCURSES_EXPORT(bool)	item_value (const ITEM *);
-extern NCURSES_EXPORT(bool)	item_visible (const ITEM *);
-
-extern NCURSES_EXPORT(void)	menu_format (const MENU *,int *,int *);
-
-#if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(MENU *)	NCURSES_SP_NAME(new_menu) (SCREEN*, ITEM **);
-#endif
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif /* ETI_MENU */
diff --git a/include/mf_common.h b/include/mf_common.h
deleted file mode 100644
index cff6563..0000000
--- a/include/mf_common.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2004,2012 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *   Author:  Juergen Pfeifer, 1995,1997                                    *
- ****************************************************************************/
-
-/* $Id: mf_common.h,v 0.24 2012/06/10 00:06:54 tom Exp $ */
-
-/* Common internal header for menu and form library */
-
-#ifndef MF_COMMON_H_incl
-#define MF_COMMON_H_incl 1
-
-#include <ncurses_cfg.h>
-#include <curses.h>
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-
-#if DECL_ERRNO
-extern int errno;
-#endif
-
-/* in case of debug version we ignore the suppression of assertions */
-#ifdef TRACE
-#  ifdef NDEBUG
-#    undef NDEBUG
-#  endif
-#endif
-
-#include <nc_alloc.h>
-
-#if USE_RCS_IDS
-#define MODULE_ID(id) static const char Ident[] = id;
-#else
-#define MODULE_ID(id)		/*nothing */
-#endif
-
-/* Maximum regular 8-bit character code */
-#define MAX_REGULAR_CHARACTER (0xff)
-
-#define SET_ERROR(code) (errno=(code))
-#define GET_ERROR()     (errno)
-
-#ifdef TRACE
-#define RETURN(code)    returnCode( SET_ERROR(code) )
-#else
-#define RETURN(code)    return( SET_ERROR(code) )
-#endif
-
-/* The few common values in the status fields for menus and forms */
-#define _POSTED         (0x01U)	/* menu or form is posted                  */
-#define _IN_DRIVER      (0x02U)	/* menu or form is processing hook routine */
-
-#define SetStatus(target,mask) (target)->status |= (unsigned short) (mask)
-#define ClrStatus(target,mask) (target)->status = (unsigned short) (target->status & (~mask))
-
-/* Call object hook */
-#define Call_Hook( object, handler ) \
-   if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
-   {\
-	SetStatus(object, _IN_DRIVER);\
-	(object)->handler(object);\
-	ClrStatus(object, _IN_DRIVER);\
-   }
-
-#endif /* MF_COMMON_H_incl */
diff --git a/include/unctrl.h b/include/nc_access.h
similarity index 63%
rename from include/unctrl.h
rename to include/nc_access.h
index e7767d4..1d2fb0a 100644
--- a/include/unctrl.h
+++ b/include/nc_access.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2021,2023 Thomas E. Dickey                                     *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,42 +26,55 @@
  * authorization.                                                           *
  ****************************************************************************/
 
-/****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- ****************************************************************************/
+/* $Id: nc_access.h,v 1.6 2023/05/06 10:54:55 tom Exp $ */
 
-/*
- * unctrl.h
- *
- * Display a printable version of a control character.
- * Control characters are displayed in caret notation (^x), DELETE is displayed
- * as ^?. Printable characters are displayed as is.
- */
+#ifndef NC_ACCESS_included
+#define NC_ACCESS_included 1
+/* *INDENT-OFF* */
 
-/* $Id: unctrl.h.in,v 1.11 2009/04/18 21:00:52 tom Exp $ */
-
-#ifndef NCURSES_UNCTRL_H_incl
-#define NCURSES_UNCTRL_H_incl	1
-
-#undef  NCURSES_VERSION
-#define NCURSES_VERSION "6.0"
+#include <ncurses_cfg.h>
+#include <curses.h>
+#include <sys/types.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <curses.h>
+/*
+ * Turn off the 'use_terminfo_vars()' symbol to limit access to environment
+ * variables when running with privileges.
+ */
+#if defined(USE_ROOT_ENVIRON) && defined(USE_SETUID_ENVIRON)
+#define use_terminfo_vars() 1
+#else
+#define use_terminfo_vars() _nc_env_access()
+#endif
 
-#undef unctrl
-NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
+extern NCURSES_EXPORT(int) _nc_env_access (void);
 
-#if 1
-NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
+/*
+ * Turn off this symbol to limit access to files when running setuid.
+ */
+#ifdef USE_ROOT_ACCESS
+
+#define safe_fopen(name,mode)       fopen(name,mode)
+#define safe_open2(name,flags)      open(name,flags)
+#define safe_open3(name,flags,mode) open(name,flags,mode)
+
+#else
+
+#define safe_fopen(name,mode)       _nc_safe_fopen(name,mode)
+#define safe_open2(name,flags)      _nc_safe_open3(name,flags,0)
+#define safe_open3(name,flags,mode) _nc_safe_open3(name,flags,mode)
+extern NCURSES_EXPORT(FILE *)       _nc_safe_fopen (const char *, const char *);
+extern NCURSES_EXPORT(int)          _nc_safe_open3 (const char *, int, mode_t);
+
 #endif
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* NCURSES_UNCTRL_H_incl */
+/* *INDENT-ON* */
+
+#endif /* NC_ACCESS_included */
diff --git a/include/nc_alloc.h b/include/nc_alloc.h
index 356f605..cfea2be 100644
--- a/include/nc_alloc.h
+++ b/include/nc_alloc.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2019-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2013,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,12 +30,15 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey                    1996-on                     *
  ****************************************************************************/
-/* $Id: nc_alloc.h,v 1.22 2013/01/26 21:56:51 tom Exp $ */
+/* $Id: nc_alloc.h,v 1.30 2021/11/20 23:33:38 tom Exp $ */
 
 #ifndef NC_ALLOC_included
 #define NC_ALLOC_included 1
 /* *INDENT-OFF* */
 
+#include <ncurses_cfg.h>
+#include <curses.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -69,19 +73,26 @@
 #if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
 #define HAVE_NC_FREEALL 1
 struct termtype;
-extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
-extern NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_NORETURN;
-extern NCURSES_EXPORT(void) _nc_free_tic(int) GCC_NORETURN;
-extern NCURSES_EXPORT(void) _nc_free_tparm(void);
-extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
+extern GCC_NORETURN  NCURSES_EXPORT(void) _nc_free_tinfo(int) GCC_DEPRECATED("use exit_terminfo");
+
+#ifdef NCURSES_INTERNALS
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_tic(int);
+extern void _nc_leaks_dump_entry(void);
 extern NCURSES_EXPORT(void) _nc_leaks_tic(void);
 
 #if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int);
+#endif
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int);
+
+#else /* !NCURSES_INTERNALS */
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses");
 #endif
 
-#define ExitProgram(code) _nc_free_and_exit(code)
+#define ExitProgram(code) exit_curses(code)
 
+#else
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_DEPRECATED("use exit_curses");
 #endif /* NO_LEAKS, etc */
 
 #ifndef HAVE_NC_FREEALL
diff --git a/include/nc_mingw.h b/include/nc_mingw.h
index 3247003..1bfc4b0 100644
--- a/include/nc_mingw.h
+++ b/include/nc_mingw.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2008-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2008-2010,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,19 +28,20 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Thomas Dickey, 2008-on                                           * 
- *                                                                          *
+ * Author: Thomas Dickey, 2008-on                                           *
  ****************************************************************************/
 
-/* $Id: nc_mingw.h,v 1.3 2010/09/25 22:16:12 juergen Exp $ */
+/* $Id: nc_mingw.h,v 1.10 2023/02/25 19:59:24 tom Exp $ */
 
 #ifndef NC_MINGW_H
 #define NC_MINGW_H 1
 
+#ifdef _WIN32
+
 #ifdef WINVER
 #  if WINVER < 0x0501
 #    error WINVER must at least be 0x0501
-#  endif  
+#  endif
 #else
 #  define WINVER 0x0501
 #endif
@@ -48,22 +50,39 @@
 #undef sleep
 #define sleep(n) Sleep((n) * 1000)
 
-#undef gettimeofday
-#define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz)
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>		/* for struct timeval */
+#endif
 
-#include <sys/time.h>	/* for struct timeval */
+#ifdef _MSC_VER
+#include <winsock2.h>		/* for struct timeval */
+#endif
 
-extern int _nc_gettimeofday(struct timeval *, void *);
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+#include <ncurses_dll.h>
+
+#if !HAVE_CLOCK_GETTIME && !HAVE_GETTIMEOFDAY
+NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *);
 #undef HAVE_GETTIMEOFDAY
-#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETTIMEOFDAY 2
+#define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz)
+#endif
 
 #define SIGHUP  1
 #define SIGKILL 9
 #define getlogin() "username"
 
 #undef wcwidth
-#define wcwidth(ucs) _nc_wcwidth(ucs)
-extern int _nc_wcwidth(wchar_t);
+#define wcwidth(ucs) _nc_wcwidth((wchar_t)(ucs))
+NCURSES_EXPORT(int) _nc_wcwidth(wchar_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WIN32 */
 
 #endif /* NC_MINGW_H */
diff --git a/include/nc_panel.h b/include/nc_panel.h
index 6a9ffea..60eb811 100644
--- a/include/nc_panel.h
+++ b/include/nc_panel.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
  ****************************************************************************/
 
 /*
- * $Id: nc_panel.h,v 1.7 2009/07/04 18:20:02 tom Exp $
+ * $Id: nc_panel.h,v 1.10 2020/02/02 23:34:34 tom Exp $
  *
  *	nc_panel.h
  *
@@ -43,6 +44,9 @@
 #ifndef NC_PANEL_H
 #define NC_PANEL_H 1
 
+#include <ncurses_cfg.h>
+#include <curses.h>
+
 #ifdef __cplusplus
 extern "C"
 {
diff --git a/include/nc_string.h b/include/nc_string.h
index 7e6ccd4..546aa06 100644
--- a/include/nc_string.h
+++ b/include/nc_string.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2012,2013 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 2012-2013,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -35,8 +36,12 @@
 
 #include <ncurses_cfg.h>
 
+#if HAVE_BSD_STRING_H
+#include <bsd/string.h>
+#endif
+
 /*
- * $Id: nc_string.h,v 1.4 2013/12/15 01:09:19 tom Exp $
+ * $Id: nc_string.h,v 1.9 2021/04/25 00:10:43 tom Exp $
  *
  * String-hacks.  Use these macros to stifle warnings on (presumably) correct
  * uses of strcat, strcpy and sprintf.
@@ -56,18 +61,26 @@
 
 #if USE_STRING_HACKS && HAVE_STRLCAT
 #define _nc_STRCAT(d,s,n)	NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
+#define _nc_STRNCAT(d,s,m,n)	NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
 #else
 #define _nc_STRCAT(d,s,n)	NCURSES_VOID strcat((d),(s))
+#define _nc_STRNCAT(d,s,m,n)	NCURSES_VOID strncat((d),(s),(n))
 #endif
 
 #if USE_STRING_HACKS && HAVE_STRLCPY
 #define _nc_STRCPY(d,s,n)	NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
+#define _nc_STRNCPY(d,s,n)	NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
 #else
 #define _nc_STRCPY(d,s,n)	NCURSES_VOID strcpy((d),(s))
+#define _nc_STRNCPY(d,s,n)	NCURSES_VOID strncpy((d),(s),(n))
 #endif
 
 #if USE_STRING_HACKS && HAVE_SNPRINTF
+#ifdef __cplusplus
 #define _nc_SPRINTF             NCURSES_VOID snprintf
+#else
+#define _nc_SPRINTF             NCURSES_VOID (snprintf)
+#endif
 #define _nc_SLIMIT(n)           NCURSES_CAST(size_t,n),
 #else
 #define _nc_SPRINTF             NCURSES_VOID sprintf
diff --git a/include/nc_termios.h b/include/nc_termios.h
index 2217f07..13cc0af 100644
--- a/include/nc_termios.h
+++ b/include/nc_termios.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2011,2014 Free Software Foundation, Inc.                   *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 2011-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -30,11 +31,13 @@
  *  Author: Thomas E. Dickey                        2011                    *
  ****************************************************************************/
 
-/* $Id: nc_termios.h,v 1.3 2014/05/03 19:40:10 juergen Exp $ */
+/* $Id: nc_termios.h,v 1.8 2020/08/29 20:53:19 tom Exp $ */
 
 #ifndef NC_TERMIOS_included
 #define NC_TERMIOS_included 1
 
+#include <ncurses_cfg.h>
+
 #if HAVE_TERMIOS_H && HAVE_TCGETATTR
 
 #else /* !HAVE_TERMIOS_H */
@@ -67,9 +70,13 @@
 #define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
 #endif
 
+#if defined(EXP_WIN32_DRIVER)
+#undef TERMIOS
+#endif
+
 #else /* !HAVE_TERMIO_H */
 
-#if __MINGW32__
+#if defined(_WIN32) && !defined(EXP_WIN32_DRIVER)
 
 /* lflag bits */
 #define ISIG	0x0001
@@ -153,7 +160,7 @@
 #undef  ttyname
 #define ttyname(fd) NULL
 
-#endif /* __MINGW32__ */
+#endif /* _WIN32 */
 #endif /* HAVE_TERMIO_H */
 
 #endif /* HAVE_TERMIOS_H */
diff --git a/include/nc_tparm.h b/include/nc_tparm.h
index 248f6c0..7817099 100644
--- a/include/nc_tparm.h
+++ b/include/nc_tparm.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2006-2010,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2006-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -30,11 +31,14 @@
  *  Author: Thomas E. Dickey                        2006                    *
  ****************************************************************************/
 
-/* $Id: nc_tparm.h,v 1.6 2012/02/18 21:34:42 tom Exp $ */
+/* $Id: nc_tparm.h,v 1.12 2023/04/16 17:57:28 tom Exp $ */
 
 #ifndef NC_TPARM_included
 #define NC_TPARM_included 1
 
+#include <ncurses_cfg.h>
+#include <curses.h>
+
 /*
  * Cast parameters past the formatting-string for tparm() to match the
  * assumption of the varargs code.
@@ -70,8 +74,20 @@
 #define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0)
 #define TPARM_2(a,b,c) TPARM_3(a,b,c,0)
 #define TPARM_1(a,b) TPARM_2(a,b,0)
-#define TPARM_1(a,b) TPARM_2(a,b,0)
 #define TPARM_0(a) TPARM_1(a,0)
 #endif
 
+#ifdef NCURSES_INTERNALS
+#define TIPARM_0(s) _nc_tiparm(0,s)
+#define TIPARM_1(s,a) _nc_tiparm(1,s,a)
+#define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b)
+#define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c)
+#define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d)
+#define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e)
+#define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f)
+#define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g)
+#define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h)
+#define TIPARM_9(s,a,b,c,d,e,f,g,h,i) _nc_tiparm(9,s,a,b,c,d,e,f,g,h,i)
+#endif
+
 #endif /* NC_TPARM_included */
diff --git a/include/nc_win32.h b/include/nc_win32.h
new file mode 100644
index 0000000..e67b8e0
--- /dev/null
+++ b/include/nc_win32.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2008-2010,2017 Free Software Foundation, Inc.                  *
+ *                                                                          *
+ * Permission is hereby granted, free of charge, to any person obtaining a  *
+ * copy of this software and associated documentation files (the            *
+ * "Software"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas Dickey, 2008-on                                           *
+ ****************************************************************************/
+
+/* $Id: nc_win32.h,v 1.10 2023/02/25 20:09:23 tom Exp $ */
+
+#ifndef NC_WIN32_H
+#define NC_WIN32_H 1
+
+#if defined(_WIN32) || defined(_WIN64)
+
+#ifndef _NC_WINDOWS
+#define _NC_WINDOWS
+#endif
+
+#ifdef TERMIOS
+#error TERMIOS must not be defined on Windows
+#endif
+
+/* We no longer support WindowsXP.
+   Minimum requirement is Windows Vista or Server2008,
+   aka Windows NT 6.0
+*/
+#ifdef WINVER
+#  if WINVER < 0x0600
+#    error WINVER must at least be 0x0600
+#  endif
+#else
+#  define WINVER 0x0600
+#endif
+
+#undef _NC_CHECK_MINTTY
+#if WINVER >= 0x0600
+#define _NC_CHECK_MINTTY
+#endif
+
+#include <windows.h>
+
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>		/* for struct timeval */
+#endif
+
+#ifdef _NC_MSC
+#include <winsock2.h>		/* for struct timeval */
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses_dll.h>
+
+#if !HAVE_CLOCK_GETTIME && !HAVE_GETTIMEOFDAY
+#undef HAVE_GETTIMEOFDAY
+#define HAVE_GETTIMEOFDAY 2
+extern NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *);
+#endif
+
+#undef wcwidth
+#define wcwidth(ucs)  _nc_wcwidth((wchar_t)(ucs))
+extern NCURSES_EXPORT(int)    _nc_wcwidth(wchar_t);
+
+#ifdef EVENTLIST_2nd /* test.priv.h just needs the preceding */
+
+extern NCURSES_EXPORT(void)   _nc_console_size(int* Lines, int* Cols);
+extern NCURSES_EXPORT(HANDLE) _nc_console_handle(int fd);
+extern NCURSES_EXPORT(int)    _nc_console_isatty(int fd);
+extern NCURSES_EXPORT(int)    _nc_console_test(int fd);
+extern NCURSES_EXPORT(int)    _nc_console_read(SCREEN *sp,HANDLE hdl,int *buf);
+extern NCURSES_EXPORT(int)    _nc_console_twait(SCREEN *, HANDLE,int,int,int * EVENTLIST_2nd(_nc_eventlist * evl));
+extern NCURSES_EXPORT(WORD)   _nc_console_MapColor(bool fore, int color);
+extern NCURSES_EXPORT(void)   _nc_console_selectActiveHandle(void);
+extern NCURSES_EXPORT(bool)   _nc_console_get_SBI(void);
+extern NCURSES_EXPORT(void)   _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info);
+extern NCURSES_EXPORT(int)    _nc_console_testmouse(SCREEN *,HANDLE,int EVENTLIST_2nd(_nc_eventlist*));
+extern NCURSES_EXPORT(int)    _nc_console_keyok(int keycode,int flag);
+extern NCURSES_EXPORT(bool)   _nc_console_keyExist(int keycode);
+extern NCURSES_EXPORT(bool)   _nc_console_checkinit(bool initFlag, bool assumeTermInfo);
+extern NCURSES_EXPORT(int)    _nc_console_vt_supported(void);
+
+#ifdef _NC_CHECK_MINTTY
+extern NCURSES_EXPORT(int)    _nc_console_checkmintty(int fd, LPHANDLE pMinTTY);
+#endif
+
+#undef VALID_TERM_ENV
+#define MS_TERMINAL "ms-terminal"
+#define VALID_TERM_ENV(term_env, no_terminal) \
+	(term_env = (NonEmpty(term_env) \
+		      ? term_env \
+		      : (_nc_console_vt_supported() \
+		         ? MS_TERMINAL \
+		         : no_terminal)), \
+	 NonEmpty(term_env))
+
+  /*
+   * Various Console mode definitions
+   */
+
+  /* Flags to enable virtual Terminal processing */
+#define VT_FLAG_OUT ENABLE_VIRTUAL_TERMINAL_PROCESSING
+#define VT_FLAG_IN  ENABLE_VIRTUAL_TERMINAL_INPUT
+
+  /* Default flags for input/output modes */
+#define CONMODE_IN_DEFAULT (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT)
+#define CONMODE_OUT_DEFAULT (ENABLE_PROCESSED_OUTPUT | DISABLE_NEWLINE_AUTO_RETURN | ENABLE_LVB_GRID_WORLDWIDE)
+
+  /* Flags to reset from RAW/CBREAK */
+#define CONMODE_NORAW    (ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT)
+#define CONMODE_NOCBREAK (ENABLE_LINE_INPUT)
+
+
+#if defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER)
+extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER;
+#endif
+
+#define CON_NUMPAIRS 64
+typedef struct {
+    BOOL initialized;
+    BOOL buffered;
+    BOOL window_only;
+    BOOL progMode;
+    BOOL isMinTTY;
+    BOOL isTermInfoConsole;
+    HANDLE out;
+    HANDLE inp;
+    HANDLE hdl;
+    HANDLE lastOut;
+    int numButtons;
+    LPDWORD ansi_map;
+    LPDWORD map;
+    LPDWORD rmap;
+    WORD pairs[CON_NUMPAIRS];
+    COORD origin;
+    CHAR_INFO *save_screen;
+    COORD save_size;
+    SMALL_RECT save_region;
+    CONSOLE_SCREEN_BUFFER_INFO SBI;
+    CONSOLE_SCREEN_BUFFER_INFO save_SBI;
+    CONSOLE_CURSOR_INFO save_CI;
+    TTY originalMode;
+} ConsoleInfo;
+
+extern NCURSES_EXPORT_VAR(ConsoleInfo) _nc_CONSOLE;
+#define WINCONSOLE _nc_CONSOLE
+
+#define TypeAlloca(type,count)(type*) _alloca(sizeof(type)*(size_t)(count))
+
+#endif /* EVENTLIST_2nd */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WIN32 || _WIN64 */
+
+#endif /* NC_WIN32_H */
diff --git a/include/ncurses.h b/include/ncurses.h
deleted file mode 120000
index 149de6c..0000000
--- a/include/ncurses.h
+++ /dev/null
@@ -1 +0,0 @@
-curses.h
\ No newline at end of file
diff --git a/include/ncurses_cfg.h b/include/ncurses_cfg.h
deleted file mode 100644
index 5c8795d..0000000
--- a/include/ncurses_cfg.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/* include/ncurses_cfg.h.  Generated automatically by configure.  */
-/****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
- ****************************************************************************/
-/*
- * $Id: ncurses_cfg.hin,v 1.7 2005/01/02 01:26:58 tom Exp $
- *
- * This is a template-file used to generate the "ncurses_cfg.h" file.
- *
- * Rather than list every definition, the configuration script substitutes the
- * definitions that it finds using 'sed'.  You need a patch (original date
- * 971222) to autoconf 2.12 or 2.13 to do this.
- *
- * See:
- *	http://invisible-island.net/autoconf/
- *	ftp://invisible-island.net/autoconf/
- */
-#ifndef NC_CONFIG_H
-#define NC_CONFIG_H
-
-#define PACKAGE "ncurses"
-#define NCURSES_VERSION "6.0"
-#define NCURSES_PATCHDATE 20150808
-#define SYSTEM_NAME "linux-androideabi"
-#if 0
-void exit (int);
-#endif
-#define HAVE_LONG_FILE_NAMES 1
-#define MIXEDCASE_FILENAMES 1
-#define TERMINFO_DIRS "/system_ext/etc/terminfo"
-#define TERMINFO "/system_ext/etc/terminfo"
-#define PURE_TERMINFO 1
-#define USE_HOME_TERMINFO 1
-#define USE_ROOT_ENVIRON 1
-#define HAVE_REMOVE 1
-#define HAVE_UNLINK 1
-#define HAVE_LINK 1
-#define HAVE_SYMLINK 1
-#define USE_LINKS 1
-#define _FILE_OFFSET_BITS 64
-#define HAVE_FSEEKO 1
-#define HAVE_ASSUME_DEFAULT_COLORS 1
-#define HAVE_CURSES_VERSION 1
-#define HAVE_HAS_KEY 1
-#define HAVE_RESIZETERM 1
-#define HAVE_RESIZE_TERM 1
-#define HAVE_TERM_ENTRY_H 1
-#define HAVE_USE_DEFAULT_COLORS 1
-#define HAVE_USE_SCREEN 1
-#define HAVE_USE_WINDOW 1
-#define HAVE_WRESIZE 1
-#define NCURSES_EXT_FUNCS 1
-#define NCURSES_SP_FUNCS 1
-#define NCURSES_EXT_PUTWIN 1
-#define NCURSES_NO_PADDING 1
-#define STDC_HEADERS 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_UNISTD_H 1
-#define SIZEOF_SIGNED_CHAR 1
-#define USE_SIGWINCH 1
-#define USE_ASSUMED_COLOR 1
-#define USE_HASHMAP 1
-#define NCURSES_WRAP_PREFIX "_nc_"
-#define GCC_SCANF 1
-#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
-#define GCC_PRINTF 1
-#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
-#define GCC_UNUSED __attribute__((unused))
-#define GCC_NORETURN __attribute__((noreturn))
-#define HAVE_NC_ALLOC_H 1
-#define HAVE_GETTIMEOFDAY 1
-#define STDC_HEADERS 1
-#define HAVE_DIRENT_H 1
-#define TIME_WITH_SYS_TIME 1
-#define HAVE_REGEX_H_FUNCS 1
-#define HAVE_FCNTL_H 1
-#define HAVE_GETOPT_H 1
-#define HAVE_LIMITS_H 1
-#define HAVE_LOCALE_H 1
-#define HAVE_MATH_H 1
-#define HAVE_POLL_H 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_PARAM_H 1
-#define HAVE_SYS_POLL_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TIMES_H 1
-#define HAVE_TTYENT_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_WCTYPE_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_GETOPT_H 1
-#define HAVE_GETOPT_HEADER 1
-#define HAVE_SYS_TIME_SELECT 1
-#define SIG_ATOMIC_T volatile sig_atomic_t
-#define HAVE_GETCWD 1
-#define HAVE_GETEGID 1
-#define HAVE_GETEUID 1
-#define HAVE_GETOPT 1
-#define HAVE_ISSETUGID 1
-#define HAVE_POLL 1
-#define HAVE_PUTENV 1
-#define HAVE_REMOVE 1
-#define HAVE_SELECT 1
-#define HAVE_SETBUF 1
-#define HAVE_SETBUFFER 1
-#define HAVE_SETENV 1
-#define HAVE_SETVBUF 1
-#define HAVE_SIGACTION 1
-#define HAVE_STRDUP 1
-#define HAVE_STRSTR 1
-#define HAVE_TCGETPGRP 1
-#define HAVE_TIMES 1
-#define HAVE_VSNPRINTF 1
-#define HAVE_ISASCII 1
-#define HAVE_TERMIO_H 1
-#define HAVE_TERMIOS_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_TCGETATTR 1
-#define HAVE_VSSCANF 1
-#define HAVE_MKSTEMP 1
-#define HAVE_SIZECHANGE 1
-#define HAVE_VA_COPY 1
-#define HAVE___VA_COPY 1
-#define HAVE_UNISTD_H 1
-#define HAVE_FORK 1
-#define HAVE_VFORK 1
-#define HAVE_WORKING_VFORK 1
-#define HAVE_WORKING_FORK 1
-#define USE_OPENPTY_HEADER <pty.h>
-#define USE_XTERM_PTY 1
-#define HAVE_SLK_COLOR 1
-#define HAVE_PANEL_H 1
-#define HAVE_LIBPANEL 1
-#define HAVE_MENU_H 1
-#define HAVE_LIBMENU 1
-#define HAVE_FORM_H 1
-#define HAVE_LIBFORM 1
-#define NCURSES_PATHSEP ':'
-#define NCURSES_VERSION_STRING "6.0.20150808"
-#define NCURSES_OSPEED_COMPAT 1
-
-#include <ncurses_def.h>
-
-	/* The C compiler may not treat these properly but C++ has to */
-#ifdef __cplusplus
-#undef const
-#undef inline
-#else
-#if defined(lint) || defined(TRACE)
-#undef inline
-#define inline /* nothing */
-#endif
-#endif
-
-	/* On HP-UX, the C compiler doesn't grok mbstate_t without
-	   -D_XOPEN_SOURCE=500. However, this causes problems on
-	   IRIX. So, we #define mbstate_t to int in configure.in
-	   only for the C compiler if needed. */
-#ifndef __cplusplus
-#ifdef NEED_MBSTATE_T_DEF
-#define mbstate_t int
-#endif
-#endif
-
-#endif /* NC_CONFIG_H */
diff --git a/include/ncurses_cfg.hin b/include/ncurses_cfg.hin
index 3f8a482..8d9ed81 100644
--- a/include/ncurses_cfg.hin
+++ b/include/ncurses_cfg.hin
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,10 +28,13 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
+ *  Author: Thomas E. Dickey      1997-on                                   *
  ****************************************************************************/
 /*
- * $Id: ncurses_cfg.hin,v 1.7 2005/01/02 01:26:58 tom Exp $
+ * $Id: ncurses_cfg.hin,v 1.13 2020/03/08 12:37:59 tom Exp $
+ *
+ * Both ncurses_cfg.h and ncurses_def.h are internal header-files used when
+ * building ncurses.
  *
  * This is a template-file used to generate the "ncurses_cfg.h" file.
  *
@@ -39,8 +43,8 @@
  * 971222) to autoconf 2.12 or 2.13 to do this.
  *
  * See:
- *	http://invisible-island.net/autoconf/
- *	ftp://invisible-island.net/autoconf/
+ *	https://invisible-island.net/autoconf/
+ *	ftp://ftp.invisible-island.net/autoconf/
  */
 #ifndef NC_CONFIG_H
 #define NC_CONFIG_H
@@ -52,11 +56,6 @@
 #ifdef __cplusplus
 #undef const
 #undef inline
-#else
-#if defined(lint) || defined(TRACE)
-#undef inline
-#define inline /* nothing */
-#endif
 #endif
 
 	/* On HP-UX, the C compiler doesn't grok mbstate_t without
@@ -69,4 +68,7 @@
 #endif
 #endif
 
+/*
+ * vile:cmode
+ */
 #endif /* NC_CONFIG_H */
diff --git a/include/ncurses_def.h b/include/ncurses_def.h
deleted file mode 100644
index e4ced67..0000000
--- a/include/ncurses_def.h
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * This file is generated by ./MKncurses_def.sh
- */
-
-#ifndef NC_DEFINE_H
-#define NC_DEFINE_H 1
-
-#ifndef BROKEN_LINKER
-#define BROKEN_LINKER 0
-#endif
-
-#ifndef BSD_TPUTS
-#define BSD_TPUTS 0
-#endif
-
-#ifndef CGETENT_CONST
-#define CGETENT_CONST /* nothing */
-#endif
-
-#ifndef CPP_HAS_PARAM_INIT
-#define CPP_HAS_PARAM_INIT 0
-#endif
-
-#ifndef CURSES_ACS_ARRAY
-#define CURSES_ACS_ARRAY acs_map
-#endif
-
-#ifndef CURSES_WACS_ARRAY
-#define CURSES_WACS_ARRAY _nc_wacs
-#endif
-
-#ifndef DECL_ERRNO
-#define DECL_ERRNO 0
-#endif
-
-#ifndef ETIP_NEEDS_MATH_H
-#define ETIP_NEEDS_MATH_H 0
-#endif
-
-#ifndef GCC_NORETURN
-#define GCC_NORETURN /* nothing */
-#endif
-
-#ifndef GCC_UNUSED
-#define GCC_UNUSED /* nothing */
-#endif
-
-#ifndef HAVE_ASSUME_DEFAULT_COLORS
-#define HAVE_ASSUME_DEFAULT_COLORS 0
-#endif
-
-#ifndef HAVE_BIG_CORE
-#define HAVE_BIG_CORE 0
-#endif
-
-#ifndef HAVE_BSD_CGETENT
-#define HAVE_BSD_CGETENT 0
-#endif
-
-#ifndef HAVE_BSD_SIGNAL_H
-#define HAVE_BSD_SIGNAL_H 0
-#endif
-
-#ifndef HAVE_BTOWC
-#define HAVE_BTOWC 0
-#endif
-
-#ifndef HAVE_BUILTIN_H
-#define HAVE_BUILTIN_H 0
-#endif
-
-#ifndef HAVE_CHGAT
-#define HAVE_CHGAT 1
-#endif
-
-#ifndef HAVE_COLOR_SET
-#define HAVE_COLOR_SET 1
-#endif
-
-#ifndef HAVE_DIRENT_H
-#define HAVE_DIRENT_H 0
-#endif
-
-#ifndef HAVE_ERRNO
-#define HAVE_ERRNO 0
-#endif
-
-#ifndef HAVE_FCNTL_H
-#define HAVE_FCNTL_H 0
-#endif
-
-#ifndef HAVE_FILTER
-#define HAVE_FILTER 1
-#endif
-
-#ifndef HAVE_FORM_H
-#define HAVE_FORM_H 0
-#endif
-
-#ifndef HAVE_GETBEGX
-#define HAVE_GETBEGX 1
-#endif
-
-#ifndef HAVE_GETCURX
-#define HAVE_GETCURX 1
-#endif
-
-#ifndef HAVE_GETCWD
-#define HAVE_GETCWD 0
-#endif
-
-#ifndef HAVE_GETEGID
-#define HAVE_GETEGID 0
-#endif
-
-#ifndef HAVE_GETEUID
-#define HAVE_GETEUID 0
-#endif
-
-#ifndef HAVE_GETMAXX
-#define HAVE_GETMAXX 1
-#endif
-
-#ifndef HAVE_GETNSTR
-#define HAVE_GETNSTR 0
-#endif
-
-#ifndef HAVE_GETOPT_H
-#define HAVE_GETOPT_H 0
-#endif
-
-#ifndef HAVE_GETPARX
-#define HAVE_GETPARX 1
-#endif
-
-#ifndef HAVE_GETTIMEOFDAY
-#define HAVE_GETTIMEOFDAY 0
-#endif
-
-#ifndef HAVE_GETTTYNAM
-#define HAVE_GETTTYNAM 0
-#endif
-
-#ifndef HAVE_GETWIN
-#define HAVE_GETWIN 1
-#endif
-
-#ifndef HAVE_GPM_H
-#define HAVE_GPM_H 0
-#endif
-
-#ifndef HAVE_GPP_BUILTIN_H
-#define HAVE_GPP_BUILTIN_H 0
-#endif
-
-#ifndef HAVE_GXX_BUILTIN_H
-#define HAVE_GXX_BUILTIN_H 0
-#endif
-
-#ifndef HAVE_HAS_KEY
-#define HAVE_HAS_KEY 0
-#endif
-
-#ifndef HAVE_INTTYPES_H
-#define HAVE_INTTYPES_H 0
-#endif
-
-#ifndef HAVE_IOSTREAM
-#define HAVE_IOSTREAM 0
-#endif
-
-#ifndef HAVE_ISASCII
-#define HAVE_ISASCII 0
-#endif
-
-#ifndef HAVE_ISSETUGID
-#define HAVE_ISSETUGID 0
-#endif
-
-#ifndef HAVE_LANGINFO_CODESET
-#define HAVE_LANGINFO_CODESET 0
-#endif
-
-#ifndef HAVE_LIBC_H
-#define HAVE_LIBC_H 0
-#endif
-
-#ifndef HAVE_LIBDBMALLOC
-#define HAVE_LIBDBMALLOC 0
-#endif
-
-#ifndef HAVE_LIBDMALLOC
-#define HAVE_LIBDMALLOC 0
-#endif
-
-#ifndef HAVE_LIBFORM
-#define HAVE_LIBFORM 0
-#endif
-
-#ifndef HAVE_LIBGPM
-#define HAVE_LIBGPM 0
-#endif
-
-#ifndef HAVE_LIBMENU
-#define HAVE_LIBMENU 0
-#endif
-
-#ifndef HAVE_LIBMPATROL
-#define HAVE_LIBMPATROL 0
-#endif
-
-#ifndef HAVE_LIBPANEL
-#define HAVE_LIBPANEL 0
-#endif
-
-#ifndef HAVE_LIMITS_H
-#define HAVE_LIMITS_H 0
-#endif
-
-#ifndef HAVE_LINK
-#define HAVE_LINK 0
-#endif
-
-#ifndef HAVE_LOCALE_H
-#define HAVE_LOCALE_H 0
-#endif
-
-#ifndef HAVE_LONG_FILE_NAMES
-#define HAVE_LONG_FILE_NAMES 0
-#endif
-
-#ifndef HAVE_MATH_H
-#define HAVE_MATH_H 0
-#endif
-
-#ifndef HAVE_MBLEN
-#define HAVE_MBLEN 0
-#endif
-
-#ifndef HAVE_MBRLEN
-#define HAVE_MBRLEN 0
-#endif
-
-#ifndef HAVE_MBRTOWC
-#define HAVE_MBRTOWC 0
-#endif
-
-#ifndef HAVE_MBSRTOWCS
-#define HAVE_MBSRTOWCS 0
-#endif
-
-#ifndef HAVE_MBSTOWCS
-#define HAVE_MBSTOWCS 0
-#endif
-
-#ifndef HAVE_MBTOWC
-#define HAVE_MBTOWC 0
-#endif
-
-#ifndef HAVE_MENU_H
-#define HAVE_MENU_H 0
-#endif
-
-#ifndef HAVE_MKSTEMP
-#define HAVE_MKSTEMP 0
-#endif
-
-#ifndef HAVE_MVVLINE
-#define HAVE_MVVLINE 1
-#endif
-
-#ifndef HAVE_MVWVLINE
-#define HAVE_MVWVLINE 1
-#endif
-
-#ifndef HAVE_NANOSLEEP
-#define HAVE_NANOSLEEP 0
-#endif
-
-#ifndef HAVE_NC_ALLOC_H
-#define HAVE_NC_ALLOC_H 0
-#endif
-
-#ifndef HAVE_PANEL_H
-#define HAVE_PANEL_H 0
-#endif
-
-#ifndef HAVE_POLL
-#define HAVE_POLL 0
-#endif
-
-#ifndef HAVE_POLL_H
-#define HAVE_POLL_H 0
-#endif
-
-#ifndef HAVE_PURIFY
-#define HAVE_PURIFY 0
-#endif
-
-#ifndef HAVE_PUTENV
-#define HAVE_PUTENV 0
-#endif
-
-#ifndef HAVE_PUTWC
-#define HAVE_PUTWC 0
-#endif
-
-#ifndef HAVE_PUTWIN
-#define HAVE_PUTWIN 1
-#endif
-
-#ifndef HAVE_REGEXPR_H_FUNCS
-#define HAVE_REGEXPR_H_FUNCS 0
-#endif
-
-#ifndef HAVE_REGEXP_H_FUNCS
-#define HAVE_REGEXP_H_FUNCS 0
-#endif
-
-#ifndef HAVE_REGEX_H_FUNCS
-#define HAVE_REGEX_H_FUNCS 0
-#endif
-
-#ifndef HAVE_REMOVE
-#define HAVE_REMOVE 0
-#endif
-
-#ifndef HAVE_RESIZETERM
-#define HAVE_RESIZETERM 0
-#endif
-
-#ifndef HAVE_RESIZE_TERM
-#define HAVE_RESIZE_TERM 0
-#endif
-
-#ifndef HAVE_RIPOFFLINE
-#define HAVE_RIPOFFLINE 1
-#endif
-
-#ifndef HAVE_SCR_DUMP
-#define HAVE_SCR_DUMP 1
-#endif
-
-#ifndef HAVE_SELECT
-#define HAVE_SELECT 0
-#endif
-
-#ifndef HAVE_SETBUF
-#define HAVE_SETBUF 0
-#endif
-
-#ifndef HAVE_SETBUFFER
-#define HAVE_SETBUFFER 0
-#endif
-
-#ifndef HAVE_SETENV
-#define HAVE_SETENV 0
-#endif
-
-#ifndef HAVE_SETUPTERM
-#define HAVE_SETUPTERM 1
-#endif
-
-#ifndef HAVE_SETVBUF
-#define HAVE_SETVBUF 0
-#endif
-
-#ifndef HAVE_SGTTY_H
-#define HAVE_SGTTY_H 0
-#endif
-
-#ifndef HAVE_SIGACTION
-#define HAVE_SIGACTION 0
-#endif
-
-#ifndef HAVE_SIGVEC
-#define HAVE_SIGVEC 0
-#endif
-
-#ifndef HAVE_SIZECHANGE
-#define HAVE_SIZECHANGE 0
-#endif
-
-#ifndef HAVE_SLK_COLOR
-#define HAVE_SLK_COLOR 0
-#endif
-
-#ifndef HAVE_SLK_INIT
-#define HAVE_SLK_INIT 1
-#endif
-
-#ifndef HAVE_SNPRINTF
-#define HAVE_SNPRINTF 0
-#endif
-
-#ifndef HAVE_STDINT_H
-#define HAVE_STDINT_H 0
-#endif
-
-#ifndef HAVE_STRDUP
-#define HAVE_STRDUP 0
-#endif
-
-#ifndef HAVE_STRLCAT
-#define HAVE_STRLCAT 0
-#endif
-
-#ifndef HAVE_STRLCPY
-#define HAVE_STRLCPY 0
-#endif
-
-#ifndef HAVE_STRSTR
-#define HAVE_STRSTR 0
-#endif
-
-#ifndef HAVE_SYMLINK
-#define HAVE_SYMLINK 0
-#endif
-
-#ifndef HAVE_SYS_BSDTYPES_H
-#define HAVE_SYS_BSDTYPES_H 0
-#endif
-
-#ifndef HAVE_SYS_IOCTL_H
-#define HAVE_SYS_IOCTL_H 0
-#endif
-
-#ifndef HAVE_SYS_PARAM_H
-#define HAVE_SYS_PARAM_H 0
-#endif
-
-#ifndef HAVE_SYS_POLL_H
-#define HAVE_SYS_POLL_H 0
-#endif
-
-#ifndef HAVE_SYS_SELECT_H
-#define HAVE_SYS_SELECT_H 0
-#endif
-
-#ifndef HAVE_SYS_TERMIO_H
-#define HAVE_SYS_TERMIO_H 0
-#endif
-
-#ifndef HAVE_SYS_TIMES_H
-#define HAVE_SYS_TIMES_H 0
-#endif
-
-#ifndef HAVE_SYS_TIME_H
-#define HAVE_SYS_TIME_H 0
-#endif
-
-#ifndef HAVE_SYS_TIME_SELECT
-#define HAVE_SYS_TIME_SELECT 0
-#endif
-
-#ifndef HAVE_TCGETATTR
-#define HAVE_TCGETATTR 0
-#endif
-
-#ifndef HAVE_TCGETPGRP
-#define HAVE_TCGETPGRP 0
-#endif
-
-#ifndef HAVE_TELL
-#define HAVE_TELL 0
-#endif
-
-#ifndef HAVE_TERMATTRS
-#define HAVE_TERMATTRS 1
-#endif
-
-#ifndef HAVE_TERMIOS_H
-#define HAVE_TERMIOS_H 0
-#endif
-
-#ifndef HAVE_TERMIO_H
-#define HAVE_TERMIO_H 0
-#endif
-
-#ifndef HAVE_TERMNAME
-#define HAVE_TERMNAME 1
-#endif
-
-#ifndef HAVE_TERM_ENTRY_H
-#define HAVE_TERM_ENTRY_H 1
-#endif
-
-#ifndef HAVE_TERM_H
-#define HAVE_TERM_H 1
-#endif
-
-#ifndef HAVE_TGETENT
-#define HAVE_TGETENT 1
-#endif
-
-#ifndef HAVE_TIGETNUM
-#define HAVE_TIGETNUM 1
-#endif
-
-#ifndef HAVE_TIGETSTR
-#define HAVE_TIGETSTR 1
-#endif
-
-#ifndef HAVE_TIMES
-#define HAVE_TIMES 0
-#endif
-
-#ifndef HAVE_TTYENT_H
-#define HAVE_TTYENT_H 0
-#endif
-
-#ifndef HAVE_TYPEAHEAD
-#define HAVE_TYPEAHEAD 1
-#endif
-
-#ifndef HAVE_TYPEINFO
-#define HAVE_TYPEINFO 0
-#endif
-
-#ifndef HAVE_TYPE_ATTR_T
-#define HAVE_TYPE_ATTR_T 0
-#endif
-
-#ifndef HAVE_TYPE_SIGACTION
-#define HAVE_TYPE_SIGACTION 0
-#endif
-
-#ifndef HAVE_UNCTRL_H
-#define HAVE_UNCTRL_H 1
-#endif
-
-#ifndef HAVE_UNISTD_H
-#define HAVE_UNISTD_H 0
-#endif
-
-#ifndef HAVE_UNLINK
-#define HAVE_UNLINK 0
-#endif
-
-#ifndef HAVE_USE_DEFAULT_COLORS
-#define HAVE_USE_DEFAULT_COLORS 0
-#endif
-
-#ifndef HAVE_USE_ENV
-#define HAVE_USE_ENV 1
-#endif
-
-#ifndef HAVE_USE_EXTENDED_NAMES
-#define HAVE_USE_EXTENDED_NAMES 0
-#endif
-
-#ifndef HAVE_USE_SCREEN
-#define HAVE_USE_SCREEN 0
-#endif
-
-#ifndef HAVE_USE_WINDOW
-#define HAVE_USE_WINDOW 0
-#endif
-
-#ifndef HAVE_VFSCANF
-#define HAVE_VFSCANF 0
-#endif
-
-#ifndef HAVE_VIDPUTS
-#define HAVE_VIDPUTS 1
-#endif
-
-#ifndef HAVE_VID_PUTS
-#define HAVE_VID_PUTS 1
-#endif
-
-#ifndef HAVE_VSNPRINTF
-#define HAVE_VSNPRINTF 0
-#endif
-
-#ifndef HAVE_VSSCANF
-#define HAVE_VSSCANF 0
-#endif
-
-#ifndef HAVE_WCSRTOMBS
-#define HAVE_WCSRTOMBS 0
-#endif
-
-#ifndef HAVE_WCSTOMBS
-#define HAVE_WCSTOMBS 0
-#endif
-
-#ifndef HAVE_WCTOB
-#define HAVE_WCTOB 0
-#endif
-
-#ifndef HAVE_WCTOMB
-#define HAVE_WCTOMB 0
-#endif
-
-#ifndef HAVE_WCTYPE_H
-#define HAVE_WCTYPE_H 0
-#endif
-
-#ifndef HAVE_WINSSTR
-#define HAVE_WINSSTR 1
-#endif
-
-#ifndef HAVE_WORKING_POLL
-#define HAVE_WORKING_POLL 0
-#endif
-
-#ifndef HAVE_WRESIZE
-#define HAVE_WRESIZE 0
-#endif
-
-#ifndef HAVE_WSYNCDOWN
-#define HAVE_WSYNCDOWN 1
-#endif
-
-#ifndef HAVE__DOSCAN
-#define HAVE__DOSCAN 0
-#endif
-
-#ifndef MIXEDCASE_FILENAMES
-#define MIXEDCASE_FILENAMES 0
-#endif
-
-#ifndef NCURSES_CHAR_EQ
-#define NCURSES_CHAR_EQ 0
-#endif
-
-#ifndef NCURSES_EXPANDED
-#define NCURSES_EXPANDED 0
-#endif
-
-#ifndef NCURSES_EXT_COLORS
-#define NCURSES_EXT_COLORS 0
-#endif
-
-#ifndef NCURSES_EXT_FUNCS
-#define NCURSES_EXT_FUNCS 0
-#endif
-
-#ifndef NCURSES_EXT_PUTWIN
-#define NCURSES_EXT_PUTWIN 0
-#endif
-
-#ifndef NCURSES_NO_PADDING
-#define NCURSES_NO_PADDING 0
-#endif
-
-#ifndef NCURSES_OSPEED_COMPAT
-#define NCURSES_OSPEED_COMPAT 0
-#endif
-
-#ifndef NCURSES_PATHSEP
-#define NCURSES_PATHSEP ':'
-#endif
-
-#ifndef NCURSES_WIDECHAR
-#define NCURSES_WIDECHAR 0
-#endif
-
-#ifndef NEED_PTEM_H
-#define NEED_PTEM_H 0
-#endif
-
-#ifndef NO_LEAKS
-#define NO_LEAKS 0
-#endif
-
-#ifndef PURE_TERMINFO
-#define PURE_TERMINFO 0
-#endif
-
-#ifndef STDC_HEADERS
-#define STDC_HEADERS 0
-#endif
-
-#ifndef SVR4_ACTION
-#define SVR4_ACTION 0
-#endif
-
-#ifndef SVR4_TERMIO
-#define SVR4_TERMIO 0
-#endif
-
-#ifndef SYSTEM_NAME
-#define SYSTEM_NAME "unknown"
-#endif
-
-#ifndef TERMINFO
-#define TERMINFO "none"
-#endif
-
-#ifndef TERMPATH
-#define TERMPATH "none"
-#endif
-
-#ifndef TIME_WITH_SYS_TIME
-#define TIME_WITH_SYS_TIME 0
-#endif
-
-#ifndef TYPEOF_CHTYPE
-#define TYPEOF_CHTYPE 0
-#endif
-
-#ifndef USE_COLORFGBG
-#define USE_COLORFGBG 0
-#endif
-
-#ifndef USE_GETCAP
-#define USE_GETCAP 0
-#endif
-
-#ifndef USE_GETCAP_CACHE
-#define USE_GETCAP_CACHE 0
-#endif
-
-#ifndef USE_HARD_TABS
-#define USE_HARD_TABS 0
-#endif
-
-#ifndef USE_HASHED_DB
-#define USE_HASHED_DB 0
-#endif
-
-#ifndef USE_HASHMAP
-#define USE_HASHMAP 0
-#endif
-
-#ifndef USE_HOME_TERMINFO
-#define USE_HOME_TERMINFO 0
-#endif
-
-#ifndef USE_LINKS
-#define USE_LINKS 0
-#endif
-
-#ifndef USE_MY_MEMMOVE
-#define USE_MY_MEMMOVE 0
-#endif
-
-#ifndef USE_OK_BCOPY
-#define USE_OK_BCOPY 0
-#endif
-
-#ifndef USE_PTHREADS_EINTR
-#define USE_PTHREADS_EINTR 0
-#endif
-
-#ifndef USE_RCS_IDS
-#define USE_RCS_IDS 0
-#endif
-
-#ifndef USE_REENTRANT
-#define USE_REENTRANT 0
-#endif
-
-#ifndef USE_SAFE_SPRINTF
-#define USE_SAFE_SPRINTF 0
-#endif
-
-#ifndef USE_SCROLL_HINTS
-#define USE_SCROLL_HINTS 0
-#endif
-
-#ifndef USE_SIGWINCH
-#define USE_SIGWINCH 0
-#endif
-
-#ifndef USE_STRING_HACKS
-#define USE_STRING_HACKS 0
-#endif
-
-#ifndef USE_SYMLINKS
-#define USE_SYMLINKS 0
-#endif
-
-#ifndef USE_SYSMOUSE
-#define USE_SYSMOUSE 0
-#endif
-
-#ifndef USE_WEAK_SYMBOLS
-#define USE_WEAK_SYMBOLS 0
-#endif
-
-#ifndef USE_WIDEC_SUPPORT
-#define USE_WIDEC_SUPPORT 0
-#endif
-
-#ifndef USE_XMC_SUPPORT
-#define USE_XMC_SUPPORT 0
-#endif
-
-#endif /* NC_DEFINE_H */
diff --git a/include/ncurses_defs b/include/ncurses_defs
index efaf635..c0da3ad 100644
--- a/include/ncurses_defs
+++ b/include/ncurses_defs
@@ -1,6 +1,7 @@
-# $Id: ncurses_defs,v 1.69 2015/03/27 10:47:31 tom Exp $
+# $Id: ncurses_defs,v 1.110 2024/03/02 20:38:23 tom Exp $
 ##############################################################################
-# Copyright (c) 2000-2014,2015 Free Software Foundation, Inc.                #
+# Copyright 2018-2023,2024 Thomas E. Dickey                                  #
+# Copyright 2000-2016,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -41,19 +42,37 @@
 ETIP_NEEDS_MATH_H
 GCC_NORETURN	/* nothing */
 GCC_UNUSED	/* nothing */
+HAVE_ALLOC_PAIR
 HAVE_ASSUME_DEFAULT_COLORS
 HAVE_BIG_CORE
 HAVE_BSD_CGETENT
 HAVE_BSD_SIGNAL_H
-HAVE_BTOWC 
+HAVE_BSD_STRING_H
+HAVE_BTOWC
 HAVE_BUILTIN_H
 HAVE_CHGAT	1
+HAVE_CLOCK_GETTIME
+HAVE_COLOR_CONTENT	1
 HAVE_COLOR_SET	1
+HAVE_CONSISTENT_GETENV
+HAVE_CONSISTENT_MB_LEN_MAX
+HAVE_COPYWIN	1
+HAVE_CURSCR	1
+HAVE_CURSES_DATA_TABSIZE	1
+HAVE_CURSES_DATA_TTYTYPE	1
+HAVE_CURSES_TRACE	1
+HAVE_DELSCREEN	1
+HAVE_DERWIN	1
 HAVE_DIRENT_H
+HAVE_DUPWIN	1
 HAVE_ERRNO
+HAVE_EXIT_CURSES	1
+HAVE_EXIT_TERMINFO	1
 HAVE_FCNTL_H
 HAVE_FILTER	1
 HAVE_FORM_H
+HAVE_FPATHCONF
+HAVE_GETAUXVAL
 HAVE_GETBEGX	1
 HAVE_GETCURX	1
 HAVE_GETCWD
@@ -65,11 +84,14 @@
 HAVE_GETPARX	1
 HAVE_GETTIMEOFDAY
 HAVE_GETTTYNAM
+HAVE_GETUID
 HAVE_GETWIN	1
 HAVE_GPM_H
 HAVE_GPP_BUILTIN_H
 HAVE_GXX_BUILTIN_H
+HAVE_HALFDELAY	1
 HAVE_HAS_KEY
+HAVE_INIT_EXTENDED_COLOR
 HAVE_INTTYPES_H
 HAVE_IOSTREAM
 HAVE_ISASCII
@@ -83,10 +105,13 @@
 HAVE_LIBMENU
 HAVE_LIBMPATROL
 HAVE_LIBPANEL
+HAVE_LIB_PCRE2
 HAVE_LIMITS_H
 HAVE_LINK
+HAVE_LOCALECONV
 HAVE_LOCALE_H
 HAVE_LONG_FILE_NAMES
+HAVE_MATH_FUNCS
 HAVE_MATH_H
 HAVE_MBLEN
 HAVE_MBRLEN
@@ -96,29 +121,39 @@
 HAVE_MBTOWC
 HAVE_MENU_H
 HAVE_MKSTEMP
+HAVE_MVDERWIN	1
 HAVE_MVVLINE	1
+HAVE_MVWIN	1
 HAVE_MVWVLINE	1
 HAVE_NANOSLEEP
+HAVE_NAPMS	1
 HAVE_NC_ALLOC_H
+HAVE_NEWPAD	1
 HAVE_PANEL_H
+HAVE_PATH_TTYS
+HAVE_PCRE2POSIX_H
+HAVE_PCREPOSIX_H
 HAVE_POLL
 HAVE_POLL_H
 HAVE_PURIFY
 HAVE_PUTENV
-HAVE_PUTWC 
+HAVE_PUTWC
 HAVE_PUTWIN	1
 HAVE_REGEXPR_H_FUNCS
 HAVE_REGEXP_H_FUNCS
 HAVE_REGEX_H_FUNCS
 HAVE_REMOVE
+HAVE_RESET_COLOR_PAIRS
 HAVE_RESIZETERM
 HAVE_RESIZE_TERM
+HAVE_RESTARTTERM	1
 HAVE_RIPOFFLINE	1
 HAVE_SCR_DUMP 1
 HAVE_SELECT
 HAVE_SETBUF
 HAVE_SETBUFFER
 HAVE_SETENV
+HAVE_SETFSUID
 HAVE_SETUPTERM	1
 HAVE_SETVBUF
 HAVE_SGTTY_H
@@ -134,7 +169,9 @@
 HAVE_STRLCPY
 HAVE_STRSTR
 HAVE_SYMLINK
+HAVE_SYSCONF
 HAVE_SYS_BSDTYPES_H
+HAVE_SYS_AUXV_H
 HAVE_SYS_IOCTL_H
 HAVE_SYS_PARAM_H
 HAVE_SYS_POLL_H
@@ -147,6 +184,7 @@
 HAVE_TCGETPGRP
 HAVE_TELL
 HAVE_TERMATTRS	1
+HAVE_TERMCAP_H	1
 HAVE_TERMIOS_H
 HAVE_TERMIO_H
 HAVE_TERMNAME	1
@@ -155,18 +193,23 @@
 HAVE_TGETENT	1
 HAVE_TIGETNUM	1
 HAVE_TIGETSTR	1
+HAVE_TIPARM	1
+HAVE_TIPARM_S	1
+HAVE_TISCAN_S	1
 HAVE_TIMES
-HAVE_TTYENT_H
+HAVE_TPUTS_SP
+HAVE_TSEARCH
 HAVE_TYPEAHEAD	1
 HAVE_TYPEINFO
 HAVE_TYPE_ATTR_T
 HAVE_TYPE_SIGACTION
 HAVE_UNCTRL_H	1
+HAVE_UNGET_WCH	1
 HAVE_UNISTD_H
 HAVE_UNLINK
 HAVE_USE_DEFAULT_COLORS
 HAVE_USE_ENV	1
-HAVE_USE_EXTENDED_NAMES
+HAVE_USE_EXTENDED_NAMES	NCURSES_XNAMES
 HAVE_USE_SCREEN
 HAVE_USE_WINDOW
 HAVE_VFSCANF
@@ -174,16 +217,22 @@
 HAVE_VID_PUTS	1
 HAVE_VSNPRINTF
 HAVE_VSSCANF
+HAVE_VW_PRINTW	1
+HAVE_WCHGAT	1
 HAVE_WCSRTOMBS
 HAVE_WCSTOMBS
-HAVE_WCTOB 
+HAVE_WCTOB
 HAVE_WCTOMB
 HAVE_WCTYPE_H
+HAVE_WINSDELLN	1
 HAVE_WINSSTR	1
+HAVE_WMEMCHR
 HAVE_WORKING_POLL
 HAVE_WRESIZE
 HAVE_WSYNCDOWN	1
 HAVE__DOSCAN
+HAVE__TRACEF
+HAVE__NC_TPARM_ANALYZE 1
 MIXEDCASE_FILENAMES
 NCURSES_CHAR_EQ
 NCURSES_EXPANDED
@@ -206,6 +255,7 @@
 TIME_WITH_SYS_TIME
 TYPEOF_CHTYPE
 USE_COLORFGBG
+USE_FOPEN_BIN_R
 USE_GETCAP
 USE_GETCAP_CACHE
 USE_HARD_TABS
diff --git a/include/ncurses_dll.h b/include/ncurses_dll.h
deleted file mode 100644
index 249493f..0000000
--- a/include/ncurses_dll.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-/* $Id: ncurses_dll.h.in,v 1.9 2014/08/02 21:30:20 tom Exp $ */
-
-#ifndef NCURSES_DLL_H_incl
-#define NCURSES_DLL_H_incl 1
-
-/* 2014-08-02 workaround for broken MinGW compiler.
- * Oddly, only TRACE is mapped to trace - the other -D's are okay.
- * suggest TDM as an alternative.
- */
-#if defined(__MINGW64__)
-#elif defined(__MINGW32__)
-#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-
-#ifdef trace
-#undef trace
-#define TRACE
-#endif
-
-#endif	/* broken compiler */
-#endif	/* MingW */
-
-/*
- * For reentrant code, we map the various global variables into SCREEN by
- * using functions to access them.
- */
-#define NCURSES_PUBLIC_VAR(name) _nc_##name
-#define NCURSES_WRAPPED_VAR(type,name) extern type NCURSES_PUBLIC_VAR(name)(void)
-
-/* no longer needed on cygwin or mingw, thanks to auto-import       */
-/* but this structure may be useful at some point for an MSVC build */
-/* so, for now unconditionally define the important flags           */
-/* "the right way" for proper static and dll+auto-import behavior   */
-#undef NCURSES_DLL
-#define NCURSES_STATIC
-
-#if defined(__CYGWIN__) || defined(__MINGW32__)
-#  if defined(NCURSES_DLL)
-#    if defined(NCURSES_STATIC)
-#      undef NCURSES_STATIC
-#    endif
-#  endif
-#  undef NCURSES_IMPEXP
-#  undef NCURSES_API
-#  undef NCURSES_EXPORT
-#  undef NCURSES_EXPORT_VAR
-#  if defined(NCURSES_DLL)
-/* building a DLL */
-#    define NCURSES_IMPEXP __declspec(dllexport)
-#  elif defined(NCURSES_STATIC)
-/* building or linking to a static library */
-#    define NCURSES_IMPEXP /* nothing */
-#  else
-/* linking to the DLL */
-#    define NCURSES_IMPEXP __declspec(dllimport)
-#  endif
-#  define NCURSES_API __cdecl
-#  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
-#  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
-#endif
-
-/* Take care of non-cygwin platforms */
-#if !defined(NCURSES_IMPEXP)
-#  define NCURSES_IMPEXP /* nothing */
-#endif
-#if !defined(NCURSES_API)
-#  define NCURSES_API /* nothing */
-#endif
-#if !defined(NCURSES_EXPORT)
-#  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
-#endif
-#if !defined(NCURSES_EXPORT_VAR)
-#  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
-#endif
-
-#endif /* NCURSES_DLL_H_incl */
diff --git a/include/ncurses_dll.h.in b/include/ncurses_dll.h.in
index 676850c..401d47a 100644
--- a/include/ncurses_dll.h.in
+++ b/include/ncurses_dll.h.in
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2009,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2023 Thomas E. Dickey                                *
+ * Copyright 2009,2014 Free Software Foundation, Inc.                       *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -25,17 +26,30 @@
  * sale, use or other dealings in this Software without prior written       *
  * authorization.                                                           *
  ****************************************************************************/
-/* $Id: ncurses_dll.h.in,v 1.9 2014/08/02 21:30:20 tom Exp $ */
+/* $Id: ncurses_dll.h.in,v 1.18 2023/05/06 20:12:43 tom Exp $ */
 
 #ifndef NCURSES_DLL_H_incl
 #define NCURSES_DLL_H_incl 1
 
+/*
+ * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64.
+ */
+#if defined(__MINGW64__)
+
+#ifndef _WIN64
+#define _WIN64 1
+#endif
+
+#elif defined(__MINGW32__)
+
+#ifndef _WIN32
+#define _WIN32 1
+#endif
+
 /* 2014-08-02 workaround for broken MinGW compiler.
  * Oddly, only TRACE is mapped to trace - the other -D's are okay.
  * suggest TDM as an alternative.
  */
-#if defined(__MINGW64__)
-#elif defined(__MINGW32__)
 #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
 
 #ifdef trace
@@ -44,6 +58,7 @@
 #endif
 
 #endif	/* broken compiler */
+
 #endif	/* MingW */
 
 /*
@@ -51,52 +66,38 @@
  * using functions to access them.
  */
 #define NCURSES_PUBLIC_VAR(name) @NCURSES_WRAP_PREFIX@##name
-#define NCURSES_WRAPPED_VAR(type,name) extern type NCURSES_PUBLIC_VAR(name)(void)
 
-/* no longer needed on cygwin or mingw, thanks to auto-import       */
-/* but this structure may be useful at some point for an MSVC build */
-/* so, for now unconditionally define the important flags           */
-/* "the right way" for proper static and dll+auto-import behavior   */
-#undef NCURSES_DLL
-#define NCURSES_STATIC
-
-#if defined(__CYGWIN__) || defined(__MINGW32__)
-#  if defined(NCURSES_DLL)
-#    if defined(NCURSES_STATIC)
-#      undef NCURSES_STATIC
-#    endif
-#  endif
-#  undef NCURSES_IMPEXP
-#  undef NCURSES_API
-#  undef NCURSES_EXPORT
-#  undef NCURSES_EXPORT_VAR
-#  if defined(NCURSES_DLL)
-/* building a DLL */
-#    define NCURSES_IMPEXP __declspec(dllexport)
-#  elif defined(NCURSES_STATIC)
-/* building or linking to a static library */
-#    define NCURSES_IMPEXP /* nothing */
-#  else
-/* linking to the DLL */
-#    define NCURSES_IMPEXP __declspec(dllimport)
-#  endif
-#  define NCURSES_API __cdecl
-#  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
-#  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
+#if defined(BUILDING_NCURSES)
+# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
+#else
+# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
 #endif
 
-/* Take care of non-cygwin platforms */
-#if !defined(NCURSES_IMPEXP)
-#  define NCURSES_IMPEXP /* nothing */
-#endif
-#if !defined(NCURSES_API)
-#  define NCURSES_API /* nothing */
-#endif
-#if !defined(NCURSES_EXPORT)
-#  define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
-#endif
-#if !defined(NCURSES_EXPORT_VAR)
-#  define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
+#define NCURSES_WRAPPED_VAR(type,name) extern NCURSES_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
+
+#define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
+#define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
+
+/*
+ * These symbols hide dllimport/dllexport, for compilers which care about it.
+ */
+#if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64))
+# if defined(NCURSES_STATIC)	/* "static" here only implies "not-a-DLL" */
+#   define NCURSES_EXPORT_GENERAL_IMPORT
+#   define NCURSES_EXPORT_GENERAL_EXPORT
+# else
+#   define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport)
+#   define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport)
+# endif
+# define NCURSES_API __cdecl
+#else
+# define NCURSES_EXPORT_GENERAL_IMPORT
+# if (__GNUC__ >= 4) && !defined(__cplusplus)
+#   define NCURSES_EXPORT_GENERAL_EXPORT __attribute__((visibility ("default")))
+# else
+#   define NCURSES_EXPORT_GENERAL_EXPORT
+# endif
+# define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */
 #endif
 
 #endif /* NCURSES_DLL_H_incl */
diff --git a/include/ncurses_mingw.h b/include/ncurses_mingw.h
index 2bbad76..8b11272 100644
--- a/include/ncurses_mingw.h
+++ b/include/ncurses_mingw.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2008-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,18 +28,17 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Juergen Pfeifer, 2008-on                                         * 
- *                                                                          *
+ * Author: Juergen Pfeifer, 2008-on                                         *
  ****************************************************************************/
 
-/* $Id: ncurses_mingw.h,v 1.3 2014/05/03 19:40:19 juergen Exp $ */
+/* $Id: ncurses_mingw.h,v 1.7 2021/06/17 21:26:02 tom Exp $ */
 
 /*
  * This is a placeholder up to now and describes what needs to be implemented
  * to support I/O to external terminals with ncurses on the Windows OS.
  */
 
-#if __MINGW32__
+#ifdef _WIN32
 #ifndef _NC_MINGWH
 #define _NC_MINGWH
 
@@ -67,16 +67,16 @@
 };
 
 extern NCURSES_EXPORT(int)  _nc_mingw_tcsetattr(
-    int fd, 
-    int optional_actions, 
+    int fd,
+    int optional_actions,
     const struct termios* arg);
 extern NCURSES_EXPORT(int)  _nc_mingw_tcgetattr(
-    int fd, 
+    int fd,
     struct termios* arg);
 extern NCURSES_EXPORT(int)  _nc_mingw_tcflush(
-    int fd, 
+    int fd,
     int queue);
 extern NCURSES_EXPORT(void) _nc_set_term_driver(void* term);
 
 #endif /* _NC_MINGWH */
-#endif /* __MINGW32__ */
+#endif /* _WIN32 */
diff --git a/include/panel.h b/include/panel.h
deleted file mode 100644
index 6ed2061..0000000
--- a/include/panel.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Juergen Pfeifer                         1996-1999,2008          *
- ****************************************************************************/
-
-/* $Id: panel.h,v 1.11 2009/04/11 19:50:40 tom Exp $ */
-
-/* panel.h -- interface file for panels library */
-
-#ifndef NCURSES_PANEL_H_incl
-#define NCURSES_PANEL_H_incl 1
-
-#include <curses.h>
-
-typedef struct panel
-{
-  WINDOW *win;
-  struct panel *below;
-  struct panel *above;
-  NCURSES_CONST void *user;
-} PANEL;
-
-#if	defined(__cplusplus)
-extern "C" {
-#endif
-
-extern NCURSES_EXPORT(WINDOW*) panel_window (const PANEL *);
-extern NCURSES_EXPORT(void)    update_panels (void);
-extern NCURSES_EXPORT(int)     hide_panel (PANEL *);
-extern NCURSES_EXPORT(int)     show_panel (PANEL *);
-extern NCURSES_EXPORT(int)     del_panel (PANEL *);
-extern NCURSES_EXPORT(int)     top_panel (PANEL *);
-extern NCURSES_EXPORT(int)     bottom_panel (PANEL *);
-extern NCURSES_EXPORT(PANEL*)  new_panel (WINDOW *);
-extern NCURSES_EXPORT(PANEL*)  panel_above (const PANEL *);
-extern NCURSES_EXPORT(PANEL*)  panel_below (const PANEL *);
-extern NCURSES_EXPORT(int)     set_panel_userptr (PANEL *, NCURSES_CONST void *);
-extern NCURSES_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *);
-extern NCURSES_EXPORT(int)     move_panel (PANEL *, int, int);
-extern NCURSES_EXPORT(int)     replace_panel (PANEL *,WINDOW *);
-extern NCURSES_EXPORT(int)     panel_hidden (const PANEL *);
-
-#if NCURSES_SP_FUNCS
-extern NCURSES_EXPORT(PANEL *) ground_panel(SCREEN *);
-extern NCURSES_EXPORT(PANEL *) ceiling_panel(SCREEN *);
-
-extern NCURSES_EXPORT(void)    NCURSES_SP_NAME(update_panels) (SCREEN*);
-#endif
-
-#if	defined(__cplusplus)
-}
-#endif
-
-#endif /* NCURSES_PANEL_H_incl */
-
-/* end of panel.h */
diff --git a/include/parametrized.h b/include/parametrized.h
deleted file mode 100644
index 273e051..0000000
--- a/include/parametrized.h
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * parametrized.h --- is a termcap capability parametrized?
- *
- * Note: this file is generated using MKparametrized.sh, do not edit by hand.
- * A value of -1 in the table means suppress both pad and % translations.
- * A value of 0 in the table means do pad but not % translations.
- * A value of 1 in the table means do both pad and % translations.
- */
-
-static short const parametrized[] = {
-0,	/*  cbt  */
-0,	/*  bel  */
-0,	/*  cr  */
-1,	/*  csr  */
-0,	/*  tbc  */
-0,	/*  clear  */
-0,	/*  el  */
-0,	/*  ed  */
-1,	/*  hpa  */
-0,	/*  cmdch  */
-1,	/*  cup  */
-0,	/*  cud1  */
-0,	/*  home  */
-0,	/*  civis  */
-0,	/*  cub1  */
-1,	/*  mrcup  */
-0,	/*  cnorm  */
-0,	/*  cuf1  */
-0,	/*  ll  */
-0,	/*  cuu1  */
-0,	/*  cvvis  */
-0,	/*  dch1  */
-0,	/*  dl1  */
-0,	/*  dsl  */
-0,	/*  hd  */
-0,	/*  smacs  */
-0,	/*  blink  */
-0,	/*  bold  */
-0,	/*  smcup  */
-0,	/*  smdc  */
-0,	/*  dim  */
-0,	/*  smir  */
-0,	/*  invis  */
-0,	/*  prot  */
-0,	/*  rev  */
-0,	/*  smso  */
-0,	/*  smul  */
-1,	/*  ech  */
-0,	/*  rmacs  */
-0,	/*  sgr0  */
-0,	/*  rmcup  */
-0,	/*  rmdc  */
-0,	/*  rmir  */
-0,	/*  rmso  */
-0,	/*  rmul  */
-0,	/*  flash  */
-0,	/*  ff  */
-0,	/*  fsl  */
-0,	/*  is1  */
-0,	/*  is2  */
-0,	/*  is3  */
-0,	/*  if  */
-0,	/*  ich1  */
-0,	/*  il1  */
-0,	/*  ip  */
-0,	/*  kbs  */
-0,	/*  ktbc  */
-0,	/*  kclr  */
-0,	/*  kctab  */
-0,	/*  kdch1  */
-0,	/*  kdl1  */
-0,	/*  kcud1  */
-0,	/*  krmir  */
-0,	/*  kel  */
-0,	/*  ked  */
-0,	/*  kf0  */
-0,	/*  kf1  */
-0,	/*  kf10  */
-0,	/*  kf2  */
-0,	/*  kf3  */
-0,	/*  kf4  */
-0,	/*  kf5  */
-0,	/*  kf6  */
-0,	/*  kf7  */
-0,	/*  kf8  */
-0,	/*  kf9  */
-0,	/*  khome  */
-0,	/*  kich1  */
-0,	/*  kil1  */
-0,	/*  kcub1  */
-0,	/*  kll  */
-0,	/*  knp  */
-0,	/*  kpp  */
-0,	/*  kcuf1  */
-0,	/*  kind  */
-0,	/*  kri  */
-0,	/*  khts  */
-0,	/*  kcuu1  */
-0,	/*  rmkx  */
-0,	/*  smkx  */
-0,	/*  lf0  */
-0,	/*  lf1  */
-0,	/*  lf10  */
-0,	/*  lf2  */
-0,	/*  lf3  */
-0,	/*  lf4  */
-0,	/*  lf5  */
-0,	/*  lf6  */
-0,	/*  lf7  */
-0,	/*  lf8  */
-0,	/*  lf9  */
-0,	/*  rmm  */
-0,	/*  smm  */
-0,	/*  nel  */
-0,	/*  pad  */
-1,	/*  dch  */
-1,	/*  dl  */
-1,	/*  cud  */
-1,	/*  ich  */
-1,	/*  indn  */
-1,	/*  il  */
-1,	/*  cub  */
-1,	/*  cuf  */
-1,	/*  rin  */
-1,	/*  cuu  */
-1,	/*  pfkey  */
-1,	/*  pfloc  */
-1,	/*  pfx  */
-0,	/*  mc0  */
-0,	/*  mc4  */
-0,	/*  mc5  */
-1,	/*  rep  */
-0,	/*  rs1  */
-0,	/*  rs2  */
-0,	/*  rs3  */
-0,	/*  rf  */
-0,	/*  rc  */
-1,	/*  vpa  */
-0,	/*  sc  */
-0,	/*  ind  */
-0,	/*  ri  */
-1,	/*  sgr  */
-0,	/*  hts  */
-1,	/*  wind  */
-0,	/*  ht  */
-1,	/*  tsl  */
-0,	/*  uc  */
-0,	/*  hu  */
-0,	/*  iprog  */
-0,	/*  ka1  */
-0,	/*  ka3  */
-0,	/*  kb2  */
-0,	/*  kc1  */
-0,	/*  kc3  */
-1,	/*  mc5p  */
-0,	/*  rmp  */
--1,	/*  acsc  */
-1,	/*  pln  */
-0,	/*  kcbt  */
-0,	/*  smxon  */
-0,	/*  rmxon  */
-0,	/*  smam  */
-0,	/*  rmam  */
-0,	/*  xonc  */
-0,	/*  xoffc  */
-0,	/*  enacs  */
-0,	/*  smln  */
-0,	/*  rmln  */
-0,	/*  kbeg  */
-0,	/*  kcan  */
-0,	/*  kclo  */
-0,	/*  kcmd  */
-0,	/*  kcpy  */
-0,	/*  kcrt  */
-0,	/*  kend  */
-0,	/*  kent  */
-0,	/*  kext  */
-0,	/*  kfnd  */
-0,	/*  khlp  */
-0,	/*  kmrk  */
-0,	/*  kmsg  */
-0,	/*  kmov  */
-0,	/*  knxt  */
-0,	/*  kopn  */
-0,	/*  kopt  */
-0,	/*  kprv  */
-0,	/*  kprt  */
-0,	/*  krdo  */
-0,	/*  kref  */
-0,	/*  krfr  */
-0,	/*  krpl  */
-0,	/*  krst  */
-0,	/*  kres  */
-0,	/*  ksav  */
-0,	/*  kspd  */
-0,	/*  kund  */
-0,	/*  kBEG  */
-0,	/*  kCAN  */
-0,	/*  kCMD  */
-0,	/*  kCPY  */
-0,	/*  kCRT  */
-0,	/*  kDC  */
-0,	/*  kDL  */
-0,	/*  kslt  */
-0,	/*  kEND  */
-0,	/*  kEOL  */
-0,	/*  kEXT  */
-0,	/*  kFND  */
-1,	/*  kHLP  */
-1,	/*  kHOM  */
-1,	/*  kIC  */
-1,	/*  kLFT  */
-0,	/*  kMSG  */
-0,	/*  kMOV  */
-0,	/*  kNXT  */
-0,	/*  kOPT  */
-0,	/*  kPRV  */
-0,	/*  kPRT  */
-0,	/*  kRDO  */
-0,	/*  kRPL  */
-0,	/*  kRIT  */
-0,	/*  kRES  */
-0,	/*  kSAV  */
-0,	/*  kSPD  */
-0,	/*  kUND  */
-0,	/*  rfi  */
-0,	/*  kf11  */
-0,	/*  kf12  */
-0,	/*  kf13  */
-0,	/*  kf14  */
-0,	/*  kf15  */
-0,	/*  kf16  */
-0,	/*  kf17  */
-0,	/*  kf18  */
-0,	/*  kf19  */
-0,	/*  kf20  */
-0,	/*  kf21  */
-0,	/*  kf22  */
-0,	/*  kf23  */
-0,	/*  kf24  */
-0,	/*  kf25  */
-0,	/*  kf26  */
-0,	/*  kf27  */
-0,	/*  kf28  */
-0,	/*  kf29  */
-0,	/*  kf30  */
-0,	/*  kf31  */
-0,	/*  kf32  */
-0,	/*  kf33  */
-0,	/*  kf34  */
-0,	/*  kf35  */
-0,	/*  kf36  */
-0,	/*  kf37  */
-0,	/*  kf38  */
-0,	/*  kf39  */
-0,	/*  kf40  */
-0,	/*  kf41  */
-0,	/*  kf42  */
-0,	/*  kf43  */
-0,	/*  kf44  */
-0,	/*  kf45  */
-0,	/*  kf46  */
-0,	/*  kf47  */
-0,	/*  kf48  */
-0,	/*  kf49  */
-0,	/*  kf50  */
-0,	/*  kf51  */
-0,	/*  kf52  */
-0,	/*  kf53  */
-0,	/*  kf54  */
-0,	/*  kf55  */
-0,	/*  kf56  */
-0,	/*  kf57  */
-0,	/*  kf58  */
-0,	/*  kf59  */
-0,	/*  kf60  */
-0,	/*  kf61  */
-0,	/*  kf62  */
-0,	/*  kf63  */
-0,	/*  el1  */
-0,	/*  mgc  */
-0,	/*  smgl  */
-0,	/*  smgr  */
--1,	/*  fln  */
-1,	/*  sclk  */
-0,	/*  dclk  */
-0,	/*  rmclk  */
-1,	/*  cwin  */
-1,	/*  wingo  */
-0,	/*  hup  */
-1,	/*  dial  */
-1,	/*  qdial  */
-0,	/*  tone  */
-0,	/*  pulse  */
-0,	/*  hook  */
-0,	/*  pause  */
-0,	/*  wait  */
-1,	/*  u0  */
-1,	/*  u1  */
-1,	/*  u2  */
-1,	/*  u3  */
-1,	/*  u4  */
-1,	/*  u5  */
-1,	/*  u6  */
-1,	/*  u7  */
-1,	/*  u8  */
-1,	/*  u9  */
-0,	/*  op  */
-0,	/*  oc  */
-1,	/*  initc  */
-1,	/*  initp  */
-1,	/*  scp  */
-1,	/*  setf  */
-1,	/*  setb  */
-1,	/*  cpi  */
-1,	/*  lpi  */
-1,	/*  chr  */
-1,	/*  cvr  */
-1,	/*  defc  */
-0,	/*  swidm  */
-0,	/*  sdrfq  */
-0,	/*  sitm  */
-0,	/*  slm  */
-0,	/*  smicm  */
-0,	/*  snlq  */
-0,	/*  snrmq  */
-0,	/*  sshm  */
-0,	/*  ssubm  */
-0,	/*  ssupm  */
-0,	/*  sum  */
-0,	/*  rwidm  */
-0,	/*  ritm  */
-0,	/*  rlm  */
-0,	/*  rmicm  */
-0,	/*  rshm  */
-0,	/*  rsubm  */
-0,	/*  rsupm  */
-0,	/*  rum  */
-0,	/*  mhpa  */
-0,	/*  mcud1  */
-0,	/*  mcub1  */
-0,	/*  mcuf1  */
-1,	/*  mvpa  */
-0,	/*  mcuu1  */
-0,	/*  porder  */
-0,	/*  mcud  */
-0,	/*  mcub  */
-0,	/*  mcuf  */
-0,	/*  mcuu  */
-1,	/*  scs  */
-0,	/*  smgb  */
-1,	/*  smgbp  */
-1,	/*  smglp  */
-1,	/*  smgrp  */
-0,	/*  smgt  */
-1,	/*  smgtp  */
-0,	/*  sbim  */
-1,	/*  scsd  */
-0,	/*  rbim  */
-1,	/*  rcsd  */
-0,	/*  subcs  */
-0,	/*  supcs  */
-0,	/*  docr  */
-0,	/*  zerom  */
-1,	/*  csnm  */
-0,	/*  kmous  */
-0,	/*  minfo  */
-0,	/*  reqmp  */
-1,	/*  getm  */
-1,	/*  setaf  */
-1,	/*  setab  */
-1,	/*  pfxl  */
-0,	/*  devt  */
-0,	/*  csin  */
-0,	/*  s0ds  */
-0,	/*  s1ds  */
-0,	/*  s2ds  */
-0,	/*  s3ds  */
-1,	/*  smglr  */
-1,	/*  smgtb  */
-1,	/*  birep  */
-0,	/*  binel  */
-0,	/*  bicr  */
-1,	/*  colornm  */
-0,	/*  defbi  */
-0,	/*  endbi  */
-1,	/*  setcolor  */
-1,	/*  slines  */
-1,	/*  dispc  */
-0,	/*  smpch  */
-0,	/*  rmpch  */
-0,	/*  smsc  */
-0,	/*  rmsc  */
-0,	/*  pctrm  */
-0,	/*  scesc  */
-0,	/*  scesa  */
-0,	/*  ehhlm  */
-0,	/*  elhlm  */
-0,	/*  elohlm  */
-0,	/*  erhlm  */
-0,	/*  ethlm  */
-0,	/*  evhlm  */
-1,	/*  sgr1  */
-1,	/*  slength  */
-0,	/*  OTi2  */
-0,	/*  OTrs  */
-0,	/*  OTnl  */
-0,	/*  OTbc  */
-0,	/*  OTko  */
-0,	/*  OTma  */
--1,	/*  OTG2  */
--1,	/*  OTG3  */
--1,	/*  OTG1  */
--1,	/*  OTG4  */
--1,	/*  OTGR  */
--1,	/*  OTGL  */
--1,	/*  OTGU  */
--1,	/*  OTGD  */
--1,	/*  OTGH  */
--1,	/*  OTGV  */
--1,	/*  OTGC  */
-0,	/*  meml  */
-0,	/*  memu  */
-1,	/*  pln  */
-0,	/*  smln  */
-0,	/*  rmln  */
-0,	/*  kf11  */
-0,	/*  kf12  */
-0,	/*  kf13  */
-0,	/*  kf14  */
-0,	/*  kf15  */
-0,	/*  kf16  */
-0,	/*  kf17  */
-0,	/*  kf18  */
-0,	/*  kf19  */
-0,	/*  kf20  */
-0,	/*  kf21  */
-0,	/*  kf22  */
-0,	/*  kf23  */
-0,	/*  kf24  */
-0,	/*  kf25  */
-0,	/*  kf26  */
-0,	/*  kf27  */
-0,	/*  kf28  */
-0,	/*  kf29  */
-0,	/*  kf30  */
-0,	/*  kf31  */
-0,	/*  kf32  */
-0,	/*  kf33  */
-0,	/*  kf34  */
-0,	/*  kf35  */
-0,	/*  kf36  */
-0,	/*  kf37  */
-0,	/*  kf38  */
-0,	/*  kf39  */
-0,	/*  kf40  */
-0,	/*  kf41  */
-0,	/*  kf42  */
-0,	/*  kf43  */
-0,	/*  kf44  */
-0,	/*  kf45  */
-0,	/*  kf46  */
-0,	/*  kf47  */
-0,	/*  kf48  */
-0,	/*  kf49  */
-0,	/*  kf50  */
-0,	/*  kf51  */
-0,	/*  kf52  */
-0,	/*  kf53  */
-0,	/*  kf54  */
-0,	/*  kf55  */
-0,	/*  kf56  */
-0,	/*  kf57  */
-0,	/*  kf58  */
-0,	/*  kf59  */
-0,	/*  kf60  */
-0,	/*  kf61  */
-0,	/*  kf62  */
-0,	/*  kf63  */
-0,	/*  box1  */
-0,	/*  box2  */
-0,	/*  batt1  */
-0,	/*  batt2  */
-0,	/*  colb0  */
-0,	/*  colb1  */
-0,	/*  colb2  */
-0,	/*  colb3  */
-0,	/*  colb4  */
-0,	/*  colb5  */
-0,	/*  colb6  */
-0,	/*  colb7  */
-0,	/*  colf0  */
-0,	/*  colf1  */
-0,	/*  colf2  */
-0,	/*  colf3  */
-0,	/*  colf4  */
-0,	/*  colf5  */
-0,	/*  colf6  */
-0,	/*  colf7  */
-0,	/*  font0  */
-0,	/*  font1  */
-0,	/*  font2  */
-0,	/*  font3  */
-0,	/*  font4  */
-0,	/*  font5  */
-0,	/*  font6  */
-0,	/*  font7  */
-0,	/*  kbtab  */
-0,	/*  kdo  */
-0,	/*  kcmd  */
-0,	/*  kcpn  */
-0,	/*  kend  */
-0,	/*  khlp  */
-0,	/*  knl  */
-0,	/*  knpn  */
-0,	/*  kppn  */
-0,	/*  kppn  */
-0,	/*  kquit  */
-0,	/*  ksel  */
-0,	/*  kscl  */
-0,	/*  kscr  */
-0,	/*  ktab  */
-0,	/*  kmpf1  */
-0,	/*  kmpt1  */
-0,	/*  kmpf2  */
-0,	/*  kmpt2  */
-0,	/*  kmpf3  */
-0,	/*  kmpt3  */
-0,	/*  kmpf4  */
-0,	/*  kmpt4  */
-0,	/*  kmpf5  */
-0,	/*  kmpt5  */
-0,	/*  apstr  */
-0,	/*  kmpf6  */
-0,	/*  kmpt6  */
-0,	/*  kmpf7  */
-0,	/*  kmpt7  */
-0,	/*  kmpf8  */
-0,	/*  kmpt8  */
-0,	/*  kmpf9  */
-0,	/*  kmpt9  */
-0,	/*  ksf1  */
-0,	/*  ksf2  */
-0,	/*  ksf3  */
-0,	/*  ksf4  */
-0,	/*  ksf5  */
-0,	/*  ksf6  */
-0,	/*  ksf7  */
-0,	/*  ksf8  */
-0,	/*  ksf9  */
-0,	/*  ksf10  */
-0,	/*  kf11  */
-0,	/*  kf12  */
-0,	/*  kact  */
-0,	/*  topl  */
-0,	/*  btml  */
-0,	/*  rvert  */
-0,	/*  lvert  */
-} /* 548 entries */;
-
diff --git a/include/term.h b/include/term.h
deleted file mode 100644
index f3d5783..0000000
--- a/include/term.h
+++ /dev/null
@@ -1,806 +0,0 @@
-/****************************************************************************
- * Copyright (c) 1998-2011,2013 Free Software Foundation, Inc.              *
- *                                                                          *
- * Permission is hereby granted, free of charge, to any person obtaining a  *
- * copy of this software and associated documentation files (the            *
- * "Software"), to deal in the Software without restriction, including      *
- * without limitation the rights to use, copy, modify, merge, publish,      *
- * distribute, distribute with modifications, sublicense, and/or sell       *
- * copies of the Software, and to permit persons to whom the Software is    *
- * furnished to do so, subject to the following conditions:                 *
- *                                                                          *
- * The above copyright notice and this permission notice shall be included  *
- * in all copies or substantial portions of the Software.                   *
- *                                                                          *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
- *                                                                          *
- * Except as contained in this notice, the name(s) of the above copyright   *
- * holders shall not be used in advertising or otherwise to promote the     *
- * sale, use or other dealings in this Software without prior written       *
- * authorization.                                                           *
- ****************************************************************************/
-
-/****************************************************************************/
-/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */
-/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */
-/*    and: Thomas E. Dickey                        1995-on                  */
-/****************************************************************************/
-
-/* $Id: MKterm.h.awk.in,v 1.62 2013/08/17 19:21:56 tom Exp $ */
-
-/*
-**	term.h -- Definition of struct term
-*/
-
-#ifndef NCURSES_TERM_H_incl
-#define NCURSES_TERM_H_incl 1
-
-#undef  NCURSES_VERSION
-#define NCURSES_VERSION "6.0"
-
-#include <ncurses_dll.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H
- * definition (based on the system for which this was configured).
- */
-
-#undef  NCURSES_CONST
-#define NCURSES_CONST const
-
-#undef  NCURSES_SBOOL
-#define NCURSES_SBOOL char
-
-#undef  NCURSES_USE_DATABASE
-#define NCURSES_USE_DATABASE 1
-
-#undef  NCURSES_USE_TERMCAP
-#define NCURSES_USE_TERMCAP 0
-
-#undef  NCURSES_XNAMES
-#define NCURSES_XNAMES 1
-
-/* We will use these symbols to hide differences between
- * termios/termio/sgttyb interfaces.
- */
-#undef  TTY
-#undef  SET_TTY
-#undef  GET_TTY
-
-/* Assume POSIX termio if we have the header and function */
-/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */
-#if 1 && 1
-
-#undef  TERMIOS
-#define TERMIOS 1
-
-#include <termios.h>
-#define TTY struct termios
-
-#else /* !HAVE_TERMIOS_H */
-
-/* #if HAVE_TERMIO_H */
-#if 1
-
-#undef  TERMIOS
-#define TERMIOS 1
-
-#include <termio.h>
-#define TTY struct termio
-
-#else /* !HAVE_TERMIO_H */
-
-#if __MINGW32__
-#  include <ncurses_mingw.h>
-#  define TTY struct termios
-#else
-#undef TERMIOS
-#include <sgtty.h>
-#include <sys/ioctl.h>
-#define TTY struct sgttyb
-#endif /* MINGW32 */
-#endif /* HAVE_TERMIO_H */
-
-#endif /* HAVE_TERMIOS_H */
-
-#ifdef TERMIOS
-#define GET_TTY(fd, buf) tcgetattr(fd, buf)
-#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)
-#else
-#define GET_TTY(fd, buf) gtty(fd, buf)
-#define SET_TTY(fd, buf) stty(fd, buf)
-#endif
-
-#define NAMESIZE 256
-
-#define CUR cur_term->type.
-
-#define auto_left_margin               CUR Booleans[0]
-#define auto_right_margin              CUR Booleans[1]
-#define no_esc_ctlc                    CUR Booleans[2]
-#define ceol_standout_glitch           CUR Booleans[3]
-#define eat_newline_glitch             CUR Booleans[4]
-#define erase_overstrike               CUR Booleans[5]
-#define generic_type                   CUR Booleans[6]
-#define hard_copy                      CUR Booleans[7]
-#define has_meta_key                   CUR Booleans[8]
-#define has_status_line                CUR Booleans[9]
-#define insert_null_glitch             CUR Booleans[10]
-#define memory_above                   CUR Booleans[11]
-#define memory_below                   CUR Booleans[12]
-#define move_insert_mode               CUR Booleans[13]
-#define move_standout_mode             CUR Booleans[14]
-#define over_strike                    CUR Booleans[15]
-#define status_line_esc_ok             CUR Booleans[16]
-#define dest_tabs_magic_smso           CUR Booleans[17]
-#define tilde_glitch                   CUR Booleans[18]
-#define transparent_underline          CUR Booleans[19]
-#define xon_xoff                       CUR Booleans[20]
-#define needs_xon_xoff                 CUR Booleans[21]
-#define prtr_silent                    CUR Booleans[22]
-#define hard_cursor                    CUR Booleans[23]
-#define non_rev_rmcup                  CUR Booleans[24]
-#define no_pad_char                    CUR Booleans[25]
-#define non_dest_scroll_region         CUR Booleans[26]
-#define can_change                     CUR Booleans[27]
-#define back_color_erase               CUR Booleans[28]
-#define hue_lightness_saturation       CUR Booleans[29]
-#define col_addr_glitch                CUR Booleans[30]
-#define cr_cancels_micro_mode          CUR Booleans[31]
-#define has_print_wheel                CUR Booleans[32]
-#define row_addr_glitch                CUR Booleans[33]
-#define semi_auto_right_margin         CUR Booleans[34]
-#define cpi_changes_res                CUR Booleans[35]
-#define lpi_changes_res                CUR Booleans[36]
-#define columns                        CUR Numbers[0]
-#define init_tabs                      CUR Numbers[1]
-#define lines                          CUR Numbers[2]
-#define lines_of_memory                CUR Numbers[3]
-#define magic_cookie_glitch            CUR Numbers[4]
-#define padding_baud_rate              CUR Numbers[5]
-#define virtual_terminal               CUR Numbers[6]
-#define width_status_line              CUR Numbers[7]
-#define num_labels                     CUR Numbers[8]
-#define label_height                   CUR Numbers[9]
-#define label_width                    CUR Numbers[10]
-#define max_attributes                 CUR Numbers[11]
-#define maximum_windows                CUR Numbers[12]
-#define max_colors                     CUR Numbers[13]
-#define max_pairs                      CUR Numbers[14]
-#define no_color_video                 CUR Numbers[15]
-#define buffer_capacity                CUR Numbers[16]
-#define dot_vert_spacing               CUR Numbers[17]
-#define dot_horz_spacing               CUR Numbers[18]
-#define max_micro_address              CUR Numbers[19]
-#define max_micro_jump                 CUR Numbers[20]
-#define micro_col_size                 CUR Numbers[21]
-#define micro_line_size                CUR Numbers[22]
-#define number_of_pins                 CUR Numbers[23]
-#define output_res_char                CUR Numbers[24]
-#define output_res_line                CUR Numbers[25]
-#define output_res_horz_inch           CUR Numbers[26]
-#define output_res_vert_inch           CUR Numbers[27]
-#define print_rate                     CUR Numbers[28]
-#define wide_char_size                 CUR Numbers[29]
-#define buttons                        CUR Numbers[30]
-#define bit_image_entwining            CUR Numbers[31]
-#define bit_image_type                 CUR Numbers[32]
-#define back_tab                       CUR Strings[0]
-#define bell                           CUR Strings[1]
-#define carriage_return                CUR Strings[2]
-#define change_scroll_region           CUR Strings[3]
-#define clear_all_tabs                 CUR Strings[4]
-#define clear_screen                   CUR Strings[5]
-#define clr_eol                        CUR Strings[6]
-#define clr_eos                        CUR Strings[7]
-#define column_address                 CUR Strings[8]
-#define command_character              CUR Strings[9]
-#define cursor_address                 CUR Strings[10]
-#define cursor_down                    CUR Strings[11]
-#define cursor_home                    CUR Strings[12]
-#define cursor_invisible               CUR Strings[13]
-#define cursor_left                    CUR Strings[14]
-#define cursor_mem_address             CUR Strings[15]
-#define cursor_normal                  CUR Strings[16]
-#define cursor_right                   CUR Strings[17]
-#define cursor_to_ll                   CUR Strings[18]
-#define cursor_up                      CUR Strings[19]
-#define cursor_visible                 CUR Strings[20]
-#define delete_character               CUR Strings[21]
-#define delete_line                    CUR Strings[22]
-#define dis_status_line                CUR Strings[23]
-#define down_half_line                 CUR Strings[24]
-#define enter_alt_charset_mode         CUR Strings[25]
-#define enter_blink_mode               CUR Strings[26]
-#define enter_bold_mode                CUR Strings[27]
-#define enter_ca_mode                  CUR Strings[28]
-#define enter_delete_mode              CUR Strings[29]
-#define enter_dim_mode                 CUR Strings[30]
-#define enter_insert_mode              CUR Strings[31]
-#define enter_secure_mode              CUR Strings[32]
-#define enter_protected_mode           CUR Strings[33]
-#define enter_reverse_mode             CUR Strings[34]
-#define enter_standout_mode            CUR Strings[35]
-#define enter_underline_mode           CUR Strings[36]
-#define erase_chars                    CUR Strings[37]
-#define exit_alt_charset_mode          CUR Strings[38]
-#define exit_attribute_mode            CUR Strings[39]
-#define exit_ca_mode                   CUR Strings[40]
-#define exit_delete_mode               CUR Strings[41]
-#define exit_insert_mode               CUR Strings[42]
-#define exit_standout_mode             CUR Strings[43]
-#define exit_underline_mode            CUR Strings[44]
-#define flash_screen                   CUR Strings[45]
-#define form_feed                      CUR Strings[46]
-#define from_status_line               CUR Strings[47]
-#define init_1string                   CUR Strings[48]
-#define init_2string                   CUR Strings[49]
-#define init_3string                   CUR Strings[50]
-#define init_file                      CUR Strings[51]
-#define insert_character               CUR Strings[52]
-#define insert_line                    CUR Strings[53]
-#define insert_padding                 CUR Strings[54]
-#define key_backspace                  CUR Strings[55]
-#define key_catab                      CUR Strings[56]
-#define key_clear                      CUR Strings[57]
-#define key_ctab                       CUR Strings[58]
-#define key_dc                         CUR Strings[59]
-#define key_dl                         CUR Strings[60]
-#define key_down                       CUR Strings[61]
-#define key_eic                        CUR Strings[62]
-#define key_eol                        CUR Strings[63]
-#define key_eos                        CUR Strings[64]
-#define key_f0                         CUR Strings[65]
-#define key_f1                         CUR Strings[66]
-#define key_f10                        CUR Strings[67]
-#define key_f2                         CUR Strings[68]
-#define key_f3                         CUR Strings[69]
-#define key_f4                         CUR Strings[70]
-#define key_f5                         CUR Strings[71]
-#define key_f6                         CUR Strings[72]
-#define key_f7                         CUR Strings[73]
-#define key_f8                         CUR Strings[74]
-#define key_f9                         CUR Strings[75]
-#define key_home                       CUR Strings[76]
-#define key_ic                         CUR Strings[77]
-#define key_il                         CUR Strings[78]
-#define key_left                       CUR Strings[79]
-#define key_ll                         CUR Strings[80]
-#define key_npage                      CUR Strings[81]
-#define key_ppage                      CUR Strings[82]
-#define key_right                      CUR Strings[83]
-#define key_sf                         CUR Strings[84]
-#define key_sr                         CUR Strings[85]
-#define key_stab                       CUR Strings[86]
-#define key_up                         CUR Strings[87]
-#define keypad_local                   CUR Strings[88]
-#define keypad_xmit                    CUR Strings[89]
-#define lab_f0                         CUR Strings[90]
-#define lab_f1                         CUR Strings[91]
-#define lab_f10                        CUR Strings[92]
-#define lab_f2                         CUR Strings[93]
-#define lab_f3                         CUR Strings[94]
-#define lab_f4                         CUR Strings[95]
-#define lab_f5                         CUR Strings[96]
-#define lab_f6                         CUR Strings[97]
-#define lab_f7                         CUR Strings[98]
-#define lab_f8                         CUR Strings[99]
-#define lab_f9                         CUR Strings[100]
-#define meta_off                       CUR Strings[101]
-#define meta_on                        CUR Strings[102]
-#define newline                        CUR Strings[103]
-#define pad_char                       CUR Strings[104]
-#define parm_dch                       CUR Strings[105]
-#define parm_delete_line               CUR Strings[106]
-#define parm_down_cursor               CUR Strings[107]
-#define parm_ich                       CUR Strings[108]
-#define parm_index                     CUR Strings[109]
-#define parm_insert_line               CUR Strings[110]
-#define parm_left_cursor               CUR Strings[111]
-#define parm_right_cursor              CUR Strings[112]
-#define parm_rindex                    CUR Strings[113]
-#define parm_up_cursor                 CUR Strings[114]
-#define pkey_key                       CUR Strings[115]
-#define pkey_local                     CUR Strings[116]
-#define pkey_xmit                      CUR Strings[117]
-#define print_screen                   CUR Strings[118]
-#define prtr_off                       CUR Strings[119]
-#define prtr_on                        CUR Strings[120]
-#define repeat_char                    CUR Strings[121]
-#define reset_1string                  CUR Strings[122]
-#define reset_2string                  CUR Strings[123]
-#define reset_3string                  CUR Strings[124]
-#define reset_file                     CUR Strings[125]
-#define restore_cursor                 CUR Strings[126]
-#define row_address                    CUR Strings[127]
-#define save_cursor                    CUR Strings[128]
-#define scroll_forward                 CUR Strings[129]
-#define scroll_reverse                 CUR Strings[130]
-#define set_attributes                 CUR Strings[131]
-#define set_tab                        CUR Strings[132]
-#define set_window                     CUR Strings[133]
-#define tab                            CUR Strings[134]
-#define to_status_line                 CUR Strings[135]
-#define underline_char                 CUR Strings[136]
-#define up_half_line                   CUR Strings[137]
-#define init_prog                      CUR Strings[138]
-#define key_a1                         CUR Strings[139]
-#define key_a3                         CUR Strings[140]
-#define key_b2                         CUR Strings[141]
-#define key_c1                         CUR Strings[142]
-#define key_c3                         CUR Strings[143]
-#define prtr_non                       CUR Strings[144]
-#define char_padding                   CUR Strings[145]
-#define acs_chars                      CUR Strings[146]
-#define plab_norm                      CUR Strings[147]
-#define key_btab                       CUR Strings[148]
-#define enter_xon_mode                 CUR Strings[149]
-#define exit_xon_mode                  CUR Strings[150]
-#define enter_am_mode                  CUR Strings[151]
-#define exit_am_mode                   CUR Strings[152]
-#define xon_character                  CUR Strings[153]
-#define xoff_character                 CUR Strings[154]
-#define ena_acs                        CUR Strings[155]
-#define label_on                       CUR Strings[156]
-#define label_off                      CUR Strings[157]
-#define key_beg                        CUR Strings[158]
-#define key_cancel                     CUR Strings[159]
-#define key_close                      CUR Strings[160]
-#define key_command                    CUR Strings[161]
-#define key_copy                       CUR Strings[162]
-#define key_create                     CUR Strings[163]
-#define key_end                        CUR Strings[164]
-#define key_enter                      CUR Strings[165]
-#define key_exit                       CUR Strings[166]
-#define key_find                       CUR Strings[167]
-#define key_help                       CUR Strings[168]
-#define key_mark                       CUR Strings[169]
-#define key_message                    CUR Strings[170]
-#define key_move                       CUR Strings[171]
-#define key_next                       CUR Strings[172]
-#define key_open                       CUR Strings[173]
-#define key_options                    CUR Strings[174]
-#define key_previous                   CUR Strings[175]
-#define key_print                      CUR Strings[176]
-#define key_redo                       CUR Strings[177]
-#define key_reference                  CUR Strings[178]
-#define key_refresh                    CUR Strings[179]
-#define key_replace                    CUR Strings[180]
-#define key_restart                    CUR Strings[181]
-#define key_resume                     CUR Strings[182]
-#define key_save                       CUR Strings[183]
-#define key_suspend                    CUR Strings[184]
-#define key_undo                       CUR Strings[185]
-#define key_sbeg                       CUR Strings[186]
-#define key_scancel                    CUR Strings[187]
-#define key_scommand                   CUR Strings[188]
-#define key_scopy                      CUR Strings[189]
-#define key_screate                    CUR Strings[190]
-#define key_sdc                        CUR Strings[191]
-#define key_sdl                        CUR Strings[192]
-#define key_select                     CUR Strings[193]
-#define key_send                       CUR Strings[194]
-#define key_seol                       CUR Strings[195]
-#define key_sexit                      CUR Strings[196]
-#define key_sfind                      CUR Strings[197]
-#define key_shelp                      CUR Strings[198]
-#define key_shome                      CUR Strings[199]
-#define key_sic                        CUR Strings[200]
-#define key_sleft                      CUR Strings[201]
-#define key_smessage                   CUR Strings[202]
-#define key_smove                      CUR Strings[203]
-#define key_snext                      CUR Strings[204]
-#define key_soptions                   CUR Strings[205]
-#define key_sprevious                  CUR Strings[206]
-#define key_sprint                     CUR Strings[207]
-#define key_sredo                      CUR Strings[208]
-#define key_sreplace                   CUR Strings[209]
-#define key_sright                     CUR Strings[210]
-#define key_srsume                     CUR Strings[211]
-#define key_ssave                      CUR Strings[212]
-#define key_ssuspend                   CUR Strings[213]
-#define key_sundo                      CUR Strings[214]
-#define req_for_input                  CUR Strings[215]
-#define key_f11                        CUR Strings[216]
-#define key_f12                        CUR Strings[217]
-#define key_f13                        CUR Strings[218]
-#define key_f14                        CUR Strings[219]
-#define key_f15                        CUR Strings[220]
-#define key_f16                        CUR Strings[221]
-#define key_f17                        CUR Strings[222]
-#define key_f18                        CUR Strings[223]
-#define key_f19                        CUR Strings[224]
-#define key_f20                        CUR Strings[225]
-#define key_f21                        CUR Strings[226]
-#define key_f22                        CUR Strings[227]
-#define key_f23                        CUR Strings[228]
-#define key_f24                        CUR Strings[229]
-#define key_f25                        CUR Strings[230]
-#define key_f26                        CUR Strings[231]
-#define key_f27                        CUR Strings[232]
-#define key_f28                        CUR Strings[233]
-#define key_f29                        CUR Strings[234]
-#define key_f30                        CUR Strings[235]
-#define key_f31                        CUR Strings[236]
-#define key_f32                        CUR Strings[237]
-#define key_f33                        CUR Strings[238]
-#define key_f34                        CUR Strings[239]
-#define key_f35                        CUR Strings[240]
-#define key_f36                        CUR Strings[241]
-#define key_f37                        CUR Strings[242]
-#define key_f38                        CUR Strings[243]
-#define key_f39                        CUR Strings[244]
-#define key_f40                        CUR Strings[245]
-#define key_f41                        CUR Strings[246]
-#define key_f42                        CUR Strings[247]
-#define key_f43                        CUR Strings[248]
-#define key_f44                        CUR Strings[249]
-#define key_f45                        CUR Strings[250]
-#define key_f46                        CUR Strings[251]
-#define key_f47                        CUR Strings[252]
-#define key_f48                        CUR Strings[253]
-#define key_f49                        CUR Strings[254]
-#define key_f50                        CUR Strings[255]
-#define key_f51                        CUR Strings[256]
-#define key_f52                        CUR Strings[257]
-#define key_f53                        CUR Strings[258]
-#define key_f54                        CUR Strings[259]
-#define key_f55                        CUR Strings[260]
-#define key_f56                        CUR Strings[261]
-#define key_f57                        CUR Strings[262]
-#define key_f58                        CUR Strings[263]
-#define key_f59                        CUR Strings[264]
-#define key_f60                        CUR Strings[265]
-#define key_f61                        CUR Strings[266]
-#define key_f62                        CUR Strings[267]
-#define key_f63                        CUR Strings[268]
-#define clr_bol                        CUR Strings[269]
-#define clear_margins                  CUR Strings[270]
-#define set_left_margin                CUR Strings[271]
-#define set_right_margin               CUR Strings[272]
-#define label_format                   CUR Strings[273]
-#define set_clock                      CUR Strings[274]
-#define display_clock                  CUR Strings[275]
-#define remove_clock                   CUR Strings[276]
-#define create_window                  CUR Strings[277]
-#define goto_window                    CUR Strings[278]
-#define hangup                         CUR Strings[279]
-#define dial_phone                     CUR Strings[280]
-#define quick_dial                     CUR Strings[281]
-#define tone                           CUR Strings[282]
-#define pulse                          CUR Strings[283]
-#define flash_hook                     CUR Strings[284]
-#define fixed_pause                    CUR Strings[285]
-#define wait_tone                      CUR Strings[286]
-#define user0                          CUR Strings[287]
-#define user1                          CUR Strings[288]
-#define user2                          CUR Strings[289]
-#define user3                          CUR Strings[290]
-#define user4                          CUR Strings[291]
-#define user5                          CUR Strings[292]
-#define user6                          CUR Strings[293]
-#define user7                          CUR Strings[294]
-#define user8                          CUR Strings[295]
-#define user9                          CUR Strings[296]
-#define orig_pair                      CUR Strings[297]
-#define orig_colors                    CUR Strings[298]
-#define initialize_color               CUR Strings[299]
-#define initialize_pair                CUR Strings[300]
-#define set_color_pair                 CUR Strings[301]
-#define set_foreground                 CUR Strings[302]
-#define set_background                 CUR Strings[303]
-#define change_char_pitch              CUR Strings[304]
-#define change_line_pitch              CUR Strings[305]
-#define change_res_horz                CUR Strings[306]
-#define change_res_vert                CUR Strings[307]
-#define define_char                    CUR Strings[308]
-#define enter_doublewide_mode          CUR Strings[309]
-#define enter_draft_quality            CUR Strings[310]
-#define enter_italics_mode             CUR Strings[311]
-#define enter_leftward_mode            CUR Strings[312]
-#define enter_micro_mode               CUR Strings[313]
-#define enter_near_letter_quality      CUR Strings[314]
-#define enter_normal_quality           CUR Strings[315]
-#define enter_shadow_mode              CUR Strings[316]
-#define enter_subscript_mode           CUR Strings[317]
-#define enter_superscript_mode         CUR Strings[318]
-#define enter_upward_mode              CUR Strings[319]
-#define exit_doublewide_mode           CUR Strings[320]
-#define exit_italics_mode              CUR Strings[321]
-#define exit_leftward_mode             CUR Strings[322]
-#define exit_micro_mode                CUR Strings[323]
-#define exit_shadow_mode               CUR Strings[324]
-#define exit_subscript_mode            CUR Strings[325]
-#define exit_superscript_mode          CUR Strings[326]
-#define exit_upward_mode               CUR Strings[327]
-#define micro_column_address           CUR Strings[328]
-#define micro_down                     CUR Strings[329]
-#define micro_left                     CUR Strings[330]
-#define micro_right                    CUR Strings[331]
-#define micro_row_address              CUR Strings[332]
-#define micro_up                       CUR Strings[333]
-#define order_of_pins                  CUR Strings[334]
-#define parm_down_micro                CUR Strings[335]
-#define parm_left_micro                CUR Strings[336]
-#define parm_right_micro               CUR Strings[337]
-#define parm_up_micro                  CUR Strings[338]
-#define select_char_set                CUR Strings[339]
-#define set_bottom_margin              CUR Strings[340]
-#define set_bottom_margin_parm         CUR Strings[341]
-#define set_left_margin_parm           CUR Strings[342]
-#define set_right_margin_parm          CUR Strings[343]
-#define set_top_margin                 CUR Strings[344]
-#define set_top_margin_parm            CUR Strings[345]
-#define start_bit_image                CUR Strings[346]
-#define start_char_set_def             CUR Strings[347]
-#define stop_bit_image                 CUR Strings[348]
-#define stop_char_set_def              CUR Strings[349]
-#define subscript_characters           CUR Strings[350]
-#define superscript_characters         CUR Strings[351]
-#define these_cause_cr                 CUR Strings[352]
-#define zero_motion                    CUR Strings[353]
-#define char_set_names                 CUR Strings[354]
-#define key_mouse                      CUR Strings[355]
-#define mouse_info                     CUR Strings[356]
-#define req_mouse_pos                  CUR Strings[357]
-#define get_mouse                      CUR Strings[358]
-#define set_a_foreground               CUR Strings[359]
-#define set_a_background               CUR Strings[360]
-#define pkey_plab                      CUR Strings[361]
-#define device_type                    CUR Strings[362]
-#define code_set_init                  CUR Strings[363]
-#define set0_des_seq                   CUR Strings[364]
-#define set1_des_seq                   CUR Strings[365]
-#define set2_des_seq                   CUR Strings[366]
-#define set3_des_seq                   CUR Strings[367]
-#define set_lr_margin                  CUR Strings[368]
-#define set_tb_margin                  CUR Strings[369]
-#define bit_image_repeat               CUR Strings[370]
-#define bit_image_newline              CUR Strings[371]
-#define bit_image_carriage_return      CUR Strings[372]
-#define color_names                    CUR Strings[373]
-#define define_bit_image_region        CUR Strings[374]
-#define end_bit_image_region           CUR Strings[375]
-#define set_color_band                 CUR Strings[376]
-#define set_page_length                CUR Strings[377]
-#define display_pc_char                CUR Strings[378]
-#define enter_pc_charset_mode          CUR Strings[379]
-#define exit_pc_charset_mode           CUR Strings[380]
-#define enter_scancode_mode            CUR Strings[381]
-#define exit_scancode_mode             CUR Strings[382]
-#define pc_term_options                CUR Strings[383]
-#define scancode_escape                CUR Strings[384]
-#define alt_scancode_esc               CUR Strings[385]
-#define enter_horizontal_hl_mode       CUR Strings[386]
-#define enter_left_hl_mode             CUR Strings[387]
-#define enter_low_hl_mode              CUR Strings[388]
-#define enter_right_hl_mode            CUR Strings[389]
-#define enter_top_hl_mode              CUR Strings[390]
-#define enter_vertical_hl_mode         CUR Strings[391]
-#define set_a_attributes               CUR Strings[392]
-#define set_pglen_inch                 CUR Strings[393]
-
-#define BOOLWRITE 37
-#define NUMWRITE  33
-#define STRWRITE  394
-
-/* older synonyms for some capabilities */
-#define beehive_glitch	no_esc_ctlc
-#define teleray_glitch	dest_tabs_magic_smso
-#define micro_char_size micro_col_size
-
-#ifdef __INTERNAL_CAPS_VISIBLE
-#define termcap_init2                  CUR Strings[394]
-#define termcap_reset                  CUR Strings[395]
-#define magic_cookie_glitch_ul         CUR Numbers[33]
-#define backspaces_with_bs             CUR Booleans[37]
-#define crt_no_scrolling               CUR Booleans[38]
-#define no_correctly_working_cr        CUR Booleans[39]
-#define carriage_return_delay          CUR Numbers[34]
-#define new_line_delay                 CUR Numbers[35]
-#define linefeed_if_not_lf             CUR Strings[396]
-#define backspace_if_not_bs            CUR Strings[397]
-#define gnu_has_meta_key               CUR Booleans[40]
-#define linefeed_is_newline            CUR Booleans[41]
-#define backspace_delay                CUR Numbers[36]
-#define horizontal_tab_delay           CUR Numbers[37]
-#define number_of_function_keys        CUR Numbers[38]
-#define other_non_function_keys        CUR Strings[398]
-#define arrow_key_map                  CUR Strings[399]
-#define has_hardware_tabs              CUR Booleans[42]
-#define return_does_clr_eol            CUR Booleans[43]
-#define acs_ulcorner                   CUR Strings[400]
-#define acs_llcorner                   CUR Strings[401]
-#define acs_urcorner                   CUR Strings[402]
-#define acs_lrcorner                   CUR Strings[403]
-#define acs_ltee                       CUR Strings[404]
-#define acs_rtee                       CUR Strings[405]
-#define acs_btee                       CUR Strings[406]
-#define acs_ttee                       CUR Strings[407]
-#define acs_hline                      CUR Strings[408]
-#define acs_vline                      CUR Strings[409]
-#define acs_plus                       CUR Strings[410]
-#define memory_lock                    CUR Strings[411]
-#define memory_unlock                  CUR Strings[412]
-#define box_chars_1                    CUR Strings[413]
-#endif /* __INTERNAL_CAPS_VISIBLE */
-
-
-/*
- * Predefined terminfo array sizes
- */
-#define BOOLCOUNT 44
-#define NUMCOUNT  39
-#define STRCOUNT  414
-
-/* used by code for comparing entries */
-#define acs_chars_index	 146
-
-typedef struct termtype {	/* in-core form of terminfo data */
-    char  *term_names;		/* str_table offset of term names */
-    char  *str_table;		/* pointer to string table */
-    NCURSES_SBOOL  *Booleans;	/* array of boolean values */
-    short *Numbers;		/* array of integer values */
-    char  **Strings;		/* array of string offsets */
-
-#if NCURSES_XNAMES
-    char  *ext_str_table;	/* pointer to extended string table */
-    char  **ext_Names;		/* corresponding names */
-
-    unsigned short num_Booleans;/* count total Booleans */
-    unsigned short num_Numbers;	/* count total Numbers */
-    unsigned short num_Strings;	/* count total Strings */
-
-    unsigned short ext_Booleans;/* count extensions to Booleans */
-    unsigned short ext_Numbers;	/* count extensions to Numbers */
-    unsigned short ext_Strings;	/* count extensions to Strings */
-#endif /* NCURSES_XNAMES */
-
-} TERMTYPE;
-
-typedef struct term {		/* describe an actual terminal */
-    TERMTYPE	type;		/* terminal type description */
-    short	Filedes;	/* file description being written to */
-    TTY		Ottyb,		/* original state of the terminal */
-		Nttyb;		/* current state of the terminal */
-    int		_baudrate;	/* used to compute padding */
-    char *      _termname;      /* used for termname() */
-} TERMINAL;
-
-#if 0 && !0
-extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
-#elif 0
-NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);
-#define cur_term   NCURSES_PUBLIC_VAR(cur_term())
-#else
-extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
-#endif
-
-#if 0 || 0
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);
-NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);
-
-#define boolnames  NCURSES_PUBLIC_VAR(boolnames())
-#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())
-#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())
-#define numnames   NCURSES_PUBLIC_VAR(numnames())
-#define numcodes   NCURSES_PUBLIC_VAR(numcodes())
-#define numfnames  NCURSES_PUBLIC_VAR(numfnames())
-#define strnames   NCURSES_PUBLIC_VAR(strnames())
-#define strcodes   NCURSES_PUBLIC_VAR(strcodes())
-#define strfnames  NCURSES_PUBLIC_VAR(strfnames())
-
-#else
-
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];
-extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];
-
-#endif
-
-/* internals */
-extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);
-extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);
-extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);
-extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);
-extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE *const);
-extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);
-extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);
-extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);
-extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);
-
-/* entry points */
-extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);
-extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);
-
-/* miscellaneous entry points */
-extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);
-extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);
-
-/* terminfo entry points, also declared in curses.h */
-#if !defined(__NCURSES_H)
-extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);
-extern NCURSES_EXPORT_VAR(char) ttytype[];
-extern NCURSES_EXPORT(int) putp (const char *);
-extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
-extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);
-
-#if 1 /* NCURSES_TPARM_VARARGS */
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* special */
-#else
-extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* special */
-extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* special */
-#endif
-
-extern NCURSES_EXPORT(char *) tiparm (const char *, ...);		/* special */
-
-#endif /* __NCURSES_H */
-
-/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
-#if !defined(NCURSES_TERMCAP_H_incl)
-extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
-extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
-extern NCURSES_EXPORT(int) tgetent (char *, const char *);
-extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
-extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
-extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
-#endif /* NCURSES_TERMCAP_H_incl */
-
-/*
- * Include curses.h before term.h to enable these extensions.
- */
-#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)
-
-extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);
-
-#if 1 /* NCURSES_TPARM_VARARGS */
-extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...);	/* special */
-#else
-extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* special */
-extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...);	/* special */
-#endif
-
-/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
-extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);
-extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);
-
-extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);
-
-extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);
-#endif /* NCURSES_SP_FUNCS */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* NCURSES_TERM_H_incl */
diff --git a/include/term_entry.h b/include/term_entry.h
index b12710d..24389ad 100644
--- a/include/term_entry.h
+++ b/include/term_entry.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -32,7 +33,7 @@
  *     and: Thomas E. Dickey                        1998-on                 *
  ****************************************************************************/
 
-/* $Id: term_entry.h,v 1.45 2014/11/01 14:47:00 tom Exp $ */
+/* $Id: term_entry.h,v 1.64 2023/04/22 13:37:14 tom Exp $ */
 
 /*
  *	term_entry.h -- interface to entry-manipulation code
@@ -40,53 +41,18 @@
 
 #ifndef NCURSES_TERM_ENTRY_H_incl
 #define NCURSES_TERM_ENTRY_H_incl 1
+/* *INDENT-OFF* */
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#include <curses.h>
 #include <term.h>
 
-    /*
-     * see db_iterator.c - this enumeration lists the places searched for a
-     * terminal description and defines the order in which they are searched.
-     */
-    typedef enum {
-	dbdTIC = 0,		/* special, used by tic when writing entry */
-#if NCURSES_USE_DATABASE
-	dbdEnvOnce,		/* the $TERMINFO environment variable */
-	dbdHome,		/* $HOME/.terminfo */
-	dbdEnvList,		/* the $TERMINFO_DIRS environment variable */
-	dbdCfgList,		/* the compiled-in TERMINFO_DIRS value */
-	dbdCfgOnce,		/* the compiled-in TERMINFO value */
-#endif
-#if NCURSES_USE_TERMCAP
-	dbdEnvOnce2,		/* the $TERMCAP environment variable */
-	dbdEnvList2,		/* the $TERMPATH environment variable */
-	dbdCfgList2,		/* the compiled-in TERMPATH */
-#endif
-	dbdLAST
-    } DBDIRS;
-
-#define MAX_USES	32
-#define MAX_CROSSLINKS	16
-
-    typedef struct entry {
-	TERMTYPE tterm;
-	unsigned nuses;
-	struct {
-	    char *name;
-	    struct entry *link;
-	    long line;
-	} uses[MAX_USES];
-	int ncrosslinks;
-	struct entry *crosslinks[MAX_CROSSLINKS];
-	long cstart, cend;
-	long startline;
-	struct entry *next;
-	struct entry *last;
-    } ENTRY;
-/* *INDENT-OFF* */
+/*
+ * These macros may be used by programs that know about TERMTYPE:
+ */
 #if NCURSES_XNAMES
 #define NUM_BOOLEANS(tp) (tp)->num_Booleans
 #define NUM_NUMBERS(tp)  (tp)->num_Numbers
@@ -106,18 +72,70 @@
 #define for_each_string(n,tp)  for(n = 0; n < NUM_STRINGS(tp);  n++)
 
 #if NCURSES_XNAMES
-#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; n < NUM_BOOLEANS(tp); n++)
-#define for_each_ext_number(n,tp)  for(n = NUMCOUNT; n < NUM_NUMBERS(tp);  n++)
-#define for_each_ext_string(n,tp)  for(n = STRCOUNT; n < NUM_STRINGS(tp);  n++)
+#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++)
+#define for_each_ext_number(n,tp)  for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp);  n++)
+#define for_each_ext_string(n,tp)  for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp);  n++)
 #endif
 
 #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
 #define ExtNumname(tp,i,names)  EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
 #define ExtStrname(tp,i,names)  EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
 
+/*
+ * The remaining type-definitions and macros are used only internally by the
+ * ncurses utilities.
+ */
+#ifdef NCURSES_INTERNALS
+
+/*
+ * see db_iterator.c - this enumeration lists the places searched for a
+ * terminal description and defines the order in which they are searched.
+ */
+typedef enum {
+	dbdTIC = 0,		/* special, used by tic when writing entry */
+#if NCURSES_USE_DATABASE
+	dbdEnvOnce,		/* the $TERMINFO environment variable */
+	dbdHome,		/* $HOME/.terminfo */
+	dbdEnvList,		/* the $TERMINFO_DIRS environment variable */
+	dbdCfgList,		/* the compiled-in TERMINFO_DIRS value */
+	dbdCfgOnce,		/* the compiled-in TERMINFO value */
+#endif
+#if NCURSES_USE_TERMCAP
+	dbdEnvOnce2,		/* the $TERMCAP environment variable */
+	dbdEnvList2,		/* the $TERMPATH environment variable */
+	dbdCfgList2,		/* the compiled-in TERMPATH */
+#endif
+	dbdLAST
+} DBDIRS;
+
+#define MAX_USES	32
+#define MAX_CROSSLINKS	16
+
+typedef struct entry ENTRY;
+
+typedef struct {
+	char *name;
+	ENTRY *link;
+	long line;
+} ENTRY_USES;
+
+struct entry {
+	TERMTYPE2 tterm;
+	unsigned nuses;
+	ENTRY_USES uses[MAX_USES];
+	int ncrosslinks;
+	ENTRY *crosslinks[MAX_CROSSLINKS];
+	long cstart;
+	long cend;
+	long startline;
+	ENTRY *next;
+	ENTRY *last;
+};
+
 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
 extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
 #define for_entry_list(qp)	for (qp = _nc_head; qp; qp = qp->next)
+#define for_entry_list2(qp,q0)	for (qp = q0; qp; qp = qp->next)
 
 #define MAX_LINE	132
 
@@ -125,13 +143,16 @@
 
 /*
  * Note that WANTED and PRESENT are not simple inverses!  If a capability
- * has been explicitly cancelled, it's not considered WANTED.
+ * has been explicitly cancelled, it is not considered WANTED.
  */
 #define WANTED(s)	((s) == ABSENT_STRING)
 #define PRESENT(s)	(((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
 
 #define ANDMISSING(p,q) \
-		{if (PRESENT(p) && !PRESENT(q)) _nc_warning(#p " but no " #q);}
+		{ \
+		if (PRESENT(p) && !PRESENT(q)) \
+			_nc_warning(#p " but no " #q); \
+		}
 
 #define PAIRED(p,q) \
 		{ \
@@ -141,25 +162,27 @@
 			_nc_warning(#p " but no " #q); \
 		}
 
+/*
+ * These entrypoints are used only by the ncurses utilities such as tic.
+ */
+
 /* alloc_entry.c: elementary allocation code */
 extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
 extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
-extern NCURSES_EXPORT(void) _nc_init_entry (TERMTYPE *const);
-extern NCURSES_EXPORT(void) _nc_merge_entry (TERMTYPE *const, TERMTYPE *const);
+extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const);
+extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const);
 extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
 
 /* alloc_ttype.c: elementary allocation code */
-extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE *, TERMTYPE *);
-extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *);
 
 /* free_ttype.c: elementary allocation code */
 extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *);
-
-/* lib_acs.c */
-extern NCURSES_EXPORT(void) _nc_init_acs (void);	/* corresponds to traditional 'init_acs()' */
+extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *);
+extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *);
 
 /* lib_termcap.c: trim sgr0 string for termcap users */
-extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE *);
+extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *);
 
 /* parse_entry.c: entry-parsing code */
 #if NCURSES_XNAMES
@@ -171,7 +194,8 @@
 
 /* write_entry.c: writing an entry to the file system */
 extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
-extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE *const);
+extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const);
+extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned);
 
 /* comp_parse.c: entry list handling */
 extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
@@ -179,14 +203,18 @@
 extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
 extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
 extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
-extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
-extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
+extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
+extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool);
 
 /* trace_xnames.c */
 extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
-/* *INDENT-ON* */
+
+#endif /* NCURSES_INTERNALS */
 
 #ifdef __cplusplus
 }
 #endif
-#endif				/* NCURSES_TERM_ENTRY_H_incl */
+
+/* *INDENT-ON* */
+
+#endif /* NCURSES_TERM_ENTRY_H_incl */
diff --git a/include/termcap.h.in b/include/termcap.h.in
index 6adc312..7b7c703 100644
--- a/include/termcap.h.in
+++ b/include/termcap.h.in
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2000,2001 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -31,7 +32,7 @@
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  ****************************************************************************/
 
-/* $Id: termcap.h.in,v 1.16 2001/03/24 21:53:27 tom Exp $ */
+/* $Id: termcap.h.in,v 1.20 2021/06/17 21:26:02 tom Exp $ */
 
 #ifndef NCURSES_TERMCAP_H_incl
 #define NCURSES_TERMCAP_H_incl	1
@@ -48,23 +49,20 @@
 
 #include <sys/types.h>
 
-#undef  NCURSES_CONST 
-#define NCURSES_CONST @NCURSES_CONST@ 
-
-#undef  NCURSES_OSPEED 
-#define NCURSES_OSPEED @NCURSES_OSPEED@ 
+#undef  NCURSES_OSPEED
+#define NCURSES_OSPEED @NCURSES_OSPEED@
 
 extern NCURSES_EXPORT_VAR(char) PC;
 extern NCURSES_EXPORT_VAR(char *) UP;
 extern NCURSES_EXPORT_VAR(char *) BC;
-extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; 
+extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed;
 
 #if !defined(NCURSES_TERM_H_incl)
-extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
+extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);
 extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
 extern NCURSES_EXPORT(int) tgetent (char *, const char *);
-extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
-extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
+extern NCURSES_EXPORT(int) tgetflag (const char *);
+extern NCURSES_EXPORT(int) tgetnum (const char *);
 extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
 #endif
 
diff --git a/include/tic.h b/include/tic.h
index 528a1b7..7569aae 100644
--- a/include/tic.h
+++ b/include/tic.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2012,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -33,9 +34,8 @@
  ****************************************************************************/
 
 /*
- * $Id: tic.h,v 1.69 2012/03/17 18:22:10 tom Exp $
- *	tic.h - Global variables and structures for the terminfo
- *			compiler.
+ * $Id: tic.h,v 1.87 2023/04/22 13:37:21 tom Exp $
+ *	tic.h - Global variables and structures for the terminfo compiler.
  */
 
 #ifndef __TIC_H
@@ -45,10 +45,12 @@
 extern "C" {
 #endif
 
+#include <ncurses_cfg.h>
+
 #include <curses.h>	/* for the _tracef() prototype, ERR/OK, bool defs */
 
 /*
-** The format of compiled terminfo files is as follows:
+** The format of SVr2 compiled terminfo files is as follows:
 **
 **		Header (12 bytes), containing information given below
 **		Names Section, containing the names of the terminal
@@ -64,6 +66,11 @@
 **		String Table, containing the actual characters of the string
 **				capabilities.
 **
+** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes
+** inconvenient.  The numbers are signed, to provide for absent and canceled
+** values.  ncurses6.1 introduced an extension to this compiled format, by
+** making the Number Section a list of signed 32-bit integers.
+**
 **	NOTE that all short integers in the file are stored using VAX/PDP-style
 **	byte-order, i.e., least-significant byte first.
 **
@@ -76,6 +83,7 @@
 */
 
 #define MAGIC		0432	/* first two bytes of a compiled entry */
+#define MAGIC2		01036	/* first two bytes of a compiled 32-bit entry */
 
 #undef  BYTE
 #define BYTE(p,n)	(unsigned char)((p)[n])
@@ -84,14 +92,23 @@
 #define IS_NEG2(p)	((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377))
 #define LOW_MSB(p)	(BYTE(p,0) + 256*BYTE(p,1))
 
-#define IS_TIC_MAGIC(p)	(LOW_MSB(p) == MAGIC)
+#define IS_TIC_MAGIC(p)	(LOW_MSB(p) == MAGIC || LOW_MSB(p) == MAGIC2)
+
+#define quick_prefix(s) (!strncmp((s), "b64:", (size_t)4) || !strncmp((s), "hex:", (size_t)4))
 
 /*
  * The "maximum" here is misleading; XSI guarantees minimum values, which a
  * given implementation may exceed.
  */
 #define MAX_NAME_SIZE	512	/* maximum legal name field size (XSI:127) */
-#define MAX_ENTRY_SIZE	4096	/* maximum legal entry size */
+#define MAX_ENTRY_SIZE1	4096	/* maximum legal entry size (SVr2) */
+#define MAX_ENTRY_SIZE2	32768	/* maximum legal entry size (ncurses6.1) */
+
+#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR
+#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2
+#else
+#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1
+#endif
 
 /*
  * The maximum size of individual name or alias is guaranteed in XSI to be at
@@ -118,7 +135,7 @@
 #define DEBUG_LEVEL(n)	((n) << TRACE_SHIFT)
 
 #define set_trace_level(n) \
-	_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
+	_nc_tracing &= TRACE_MAXIMUM, \
 	_nc_tracing |= DEBUG_LEVEL(n)
 
 #ifdef TRACE
@@ -127,11 +144,6 @@
 #define DEBUG(n, a)	/*nothing*/
 #endif
 
-extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
-extern NCURSES_EXPORT(void) _nc_tracef (char *, ...) GCC_PRINTFLIKE(1,2);
-extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
-extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
-
 /*
  * These are the types of tokens returned by the scanner.  The first
  * three are also used in the hash table of capability names.  The scanner
@@ -148,49 +160,33 @@
 
 #define NO_PUSHBACK	-1	/* used in pushtype to indicate no pushback */
 
-	/*
-	 *	The global structure in which the specific parts of a
-	 *	scanned token are returned.
-	 *
-	 */
+/*
+ * The global structure in which the specific parts of a
+ * scanned token are returned.
+ */
 
 struct token
 {
-	char	*tk_name;		/* name of capability */
+	char	*tk_name;	/* name of capability */
 	int	tk_valnumber;	/* value of capability (if a number) */
 	char	*tk_valstring;	/* value of capability (if a string) */
 };
 
-extern NCURSES_EXPORT_VAR(struct token)	_nc_curr_token;
-
-	/*
-	 * Offsets to string capabilities, with the corresponding functionkey
-	 * codes.
-	 */
+/*
+ * Offsets to string capabilities, with the corresponding functionkey codes.
+ */
 struct tinfo_fkeys {
 	unsigned offset;
 	chtype code;
 	};
 
-#if	BROKEN_LINKER
-
-#define	_nc_tinfo_fkeys	_nc_tinfo_fkeysf()
-extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
-
-#else
-
-extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[];
-
-#endif
-
 typedef short HashValue;
 
-	/*
-	 * The file comp_captab.c contains an array of these structures, one
-	 * per possible capability.  These are indexed by a hash table array of
-	 * pointers to the same structures for use by the parser.
-	 */
-
+/*
+ * The file comp_captab.c contains an array of these structures, one per
+ * possible capability.  These are indexed by a hash table array of pointers to
+ * the same structures for use by the parser.
+ */
 struct name_table_entry
 {
 	const char *nte_name;	/* name to hash on */
@@ -199,10 +195,9 @@
 	HashValue nte_link;	/* index in table of next hash, or -1 */
 };
 
-	/*
-	 * Use this structure to hide differences between terminfo and termcap
-	 * tables.
-	 */
+/*
+ * Use this structure to hide differences between terminfo and termcap tables.
+ */
 typedef struct {
 	unsigned table_size;
 	const HashValue *table_data;
@@ -217,14 +212,24 @@
 	const char	*source;
 };
 
-extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
-extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool);
-extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool);
-extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool);
-
 #define NOTFOUND	((struct name_table_entry *) 0)
 
 /*
+ * The file comp_userdefs.c contains an array of these structures, one per
+ * possible capability.  These are indexed by a hash table array of pointers to
+ * the same structures for use by the parser.
+ */
+struct user_table_entry
+{
+	const char *ute_name;	/* name to hash on */
+	int	ute_type;	/* mask (BOOLEAN, NUMBER, STRING) */
+	unsigned ute_argc;	/* number of parameters */
+	unsigned ute_args;	/* bit-mask for string parameters */
+	HashValue ute_index;	/* index of associated variable in its array */
+	HashValue ute_link;	/* index in table of next hash, or -1 */
+};
+
+/*
  * The casts are required for correct sign-propagation with systems such as
  * AIX, IRIX64, Solaris which default to unsigned characters.  The C standard
  * leaves this detail unspecified.
@@ -256,6 +261,10 @@
 
 #ifdef NCURSES_TERM_ENTRY_H_incl
 
+/*
+ * These entrypoints are used only by the ncurses utilities such as tic.
+ */
+#ifdef NCURSES_INTERNALS
 /* access.c */
 extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *);
 extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *);
@@ -264,17 +273,21 @@
 extern NCURSES_EXPORT(char *) _nc_basename (char *);
 extern NCURSES_EXPORT(char *) _nc_rootname (char *);
 
+/* comp_captab.c */
+extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
+extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool);
+extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool);
+
 /* comp_hash.c: name lookup */
-extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
-	(const char *, const HashValue *);
 extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry
 	(const char *, int, bool);
+extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry
+	(const char *);
 
 /* comp_scan.c: lexical analysis */
 extern NCURSES_EXPORT(int)  _nc_get_token (bool);
 extern NCURSES_EXPORT(void) _nc_panic_mode (char);
 extern NCURSES_EXPORT(void) _nc_push_token (int);
-extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *);
 extern NCURSES_EXPORT_VAR(int) _nc_curr_col;
 extern NCURSES_EXPORT_VAR(int) _nc_curr_line;
 extern NCURSES_EXPORT_VAR(int) _nc_syntax;
@@ -288,19 +301,20 @@
 
 /* comp_error.c: warning & abort messages */
 extern NCURSES_EXPORT(const char *) _nc_get_source (void);
-extern NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2);
 extern NCURSES_EXPORT(void) _nc_get_type (char *name);
 extern NCURSES_EXPORT(void) _nc_set_source (const char *const);
 extern NCURSES_EXPORT(void) _nc_set_type (const char *const);
-extern NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2);
 extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2);
 extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
 
-/* comp_expand.c: expand string into readable form */
-extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
+/* comp_scan.c */
+extern NCURSES_EXPORT_VAR(struct token)	_nc_curr_token;
 
-/* comp_scan.c: decode string from readable form */
-extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
+/* comp_userdefs.c */
+NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void);
+NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void);
 
 /* captoinfo.c: capability conversion */
 extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
@@ -309,15 +323,37 @@
 /* home_terminfo.c */
 extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
 
+/* init_keytry.c */
+#if	BROKEN_LINKER
+#define	_nc_tinfo_fkeys	_nc_tinfo_fkeysf()
+extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
+#else
+extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[];
+#endif
+
 /* lib_tparm.c */
 #define NUM_PARM 9
 
 extern NCURSES_EXPORT_VAR(int) _nc_tparm_err;
 
-extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *);
+extern NCURSES_EXPORT(int) _nc_tparm_analyze(TERMINAL *, const char *, char **, int *);
+extern NCURSES_EXPORT(void) _nc_reset_tparm(TERMINAL *);
+
+/* lib_trace.c */
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
+extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
+extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
 
 /* lib_tputs.c */
-extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent;		/* Add one for every null sent */
+extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent;	/* Add one for every null sent */
+
+/* comp_expand.c: expand string into readable form */
+extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
+
+/* comp_hash.c: name lookup */
+extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
+	(const char *, const HashValue *);
+extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool);
 
 /* comp_main.c: compiler main */
 extern const char * _nc_progname;
@@ -331,6 +367,8 @@
 /* write_entry.c */
 extern NCURSES_EXPORT(int) _nc_tic_written (void);
 
+#endif /* NCURSES_INTERNALS */
+
 #endif /* NCURSES_TERM_ENTRY_H_incl */
 
 #ifdef __cplusplus
diff --git a/include/unctrl.h.in b/include/unctrl.h.in
index e08bc81..f76f443 100644
--- a/include/unctrl.h.in
+++ b/include/unctrl.h.in
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2001,2009 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -39,7 +40,7 @@
  * as ^?. Printable characters are displayed as is.
  */
 
-/* $Id: unctrl.h.in,v 1.11 2009/04/18 21:00:52 tom Exp $ */
+/* $Id: unctrl.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */
 
 #ifndef NCURSES_UNCTRL_H_incl
 #define NCURSES_UNCTRL_H_incl	1
diff --git a/include/termcap.h b/include/win32_curses.h
similarity index 64%
rename from include/termcap.h
rename to include/win32_curses.h
index 909c708..0c807a0 100644
--- a/include/termcap.h
+++ b/include/win32_curses.h
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 2008-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -27,49 +28,48 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ * Author: Juergen Pfeifer, 2008-on                                         *
  ****************************************************************************/
 
-/* $Id: termcap.h.in,v 1.16 2001/03/24 21:53:27 tom Exp $ */
+/* $Id: win32_curses.h,v 1.3 2021/06/17 21:26:02 tom Exp $ */
 
-#ifndef NCURSES_TERMCAP_H_incl
-#define NCURSES_TERMCAP_H_incl	1
+/*
+ * This is the interface we use on Windows to mimic the control of the settings
+ * of what acts like the classic TTY - the Windows Console.
+ */
 
-#undef  NCURSES_VERSION
-#define NCURSES_VERSION "6.0"
+#if (defined(_WIN32) || defined(_WIN64))
+#ifndef _NC_WIN32_CURSES_H
+#define _NC_WIN32_CURSES_H 1
 
-#include <ncurses_dll.h>
-
-#ifdef __cplusplus
-extern "C"
+struct winconmode
 {
-#endif /* __cplusplus */
+  unsigned long dwFlagIn;
+  unsigned long dwFlagOut;
+};
 
-#include <sys/types.h>
+extern NCURSES_EXPORT(void*) _nc_console_fd2handle(int fd);
+extern NCURSES_EXPORT(int)   _nc_console_setmode(void* handle, const struct winconmode* arg);
+extern NCURSES_EXPORT(int)   _nc_console_getmode(void* handle, struct winconmode* arg);
+extern NCURSES_EXPORT(int)   _nc_console_flush(void* handle);
 
-#undef  NCURSES_CONST 
-#define NCURSES_CONST const 
+/*
+  A few definitions of Unix functions we need to emulate
+*/
+#define SIGHUP  1
+#define SIGKILL 9
 
-#undef  NCURSES_OSPEED 
-#define NCURSES_OSPEED short 
+#undef  getlogin
+#define getlogin() getenv("USERNAME")
 
-extern NCURSES_EXPORT_VAR(char) PC;
-extern NCURSES_EXPORT_VAR(char *) UP;
-extern NCURSES_EXPORT_VAR(char *) BC;
-extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; 
+#undef  ttyname
+#define ttyname(fd) NULL
 
-#if !defined(NCURSES_TERM_H_incl)
-extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);
-extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
-extern NCURSES_EXPORT(int) tgetent (char *, const char *);
-extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);
-extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);
-extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
-#endif
+#undef sleep
+#define sleep(n) Sleep((n) * 1000)
 
-#ifdef __cplusplus
-}
-#endif
+#undef gettimeofday
+#define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz)
 
-#endif /* NCURSES_TERMCAP_H_incl */
+#endif /* _NC_WIN32_CURSES_H */
+#endif /* _WIN32||_WIN64 */