Home | History | Annotate | only in /src/lib/libcurses
History log of /src/lib/libcurses
RevisionDateAuthorComments
 1.96 06-Sep-2021  rin Always autogen fileio.h.

Bump CURSES_LIB_MAJOR.CURSES_LIB_MINOR to 9.0 belatedly.
 1.95 27-Jun-2021  christos Fix SSP build
 1.94 23-Mar-2020  roy curses: Add stubs for mouse functions

No mouse support actually included.
But that doesn't matter because most terms don't actually support a mouse.

We should look into hooking these into wsmouse(4) and xterm mouse
in the future.

Compatable with nCurses mouse API version 2.
 1.93 03-Sep-2019  roy curses: believe in unicorns

Hopefully this ends the bikeshed.
If you don't believe in unicorns, please #if 0 it out to preserve
the humour.
 1.92 03-Sep-2019  roy curses: Add __NetBSD_Curses_Version__

Similar to __NetBSD_Version__ from sys/param.h but has no
correlation to it or the ELF symver libcurses is built as.

If we say that v1 was everything prior to this, it makes sense to
start this from v2.
 1.91 02-Sep-2019  roy curses(3): add curses_version()

Returns NetBSD-Curses %s
Where %s is the NetBSD version taken from sys/param.h

Discussed on tech-net@, only for ncurses compat.
 1.90 22-Nov-2018  uwe We need insstr.c for !HAVE_WCHAR too.
 1.89 19-Nov-2018  uwe Provide basic documentation on getcchar(3) and setcchar(3).

Looks like we don't have any of wide curses stuff documented, so this
seems to be a good place to start. Needs more exposition on wide
attr_t and how it's related to non-wide chtype, etc, etc.
 1.88 18-Nov-2018  uwe Oops, revert previous. Wrong tree.
 1.87 18-Nov-2018  uwe Comment out LIBDPLIBS so that this can be built outside of the tree.
 1.86 25-Oct-2018  uwe Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.85 10-Jun-2018  christos branches: 1.85.2;
use SUBDIR.roff suggested by uwe@
 1.84 24-Jan-2017  roy branches: 1.84.10;
Implement POSIX Curses Soft Label Key functions.
 1.83 11-Jan-2017  roy branches: 1.83.2;
Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.82 10-Jan-2017  roy Implement POSIX curses function ripoffline(3).
 1.81 05-Jan-2017  roy Implement ncurses is_pad(3).
Correct documentation about is_keypad(3).
 1.80 05-Jan-2017  roy Implement is_term_resized and resize_term(3) ncurses extensions.
resizeterm(3) is now a wrapper for resize_term(3).
 1.79 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.78 03-Jan-2017  roy Add missing man pages for wsyncup.3 and wcursyncup.3
 1.77 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.76 01-Jan-2017  roy Implement ncurses extension has_key.
 1.75 31-Dec-2016  roy Implement POSIX Curses typeahead function.
 1.74 31-Dec-2016  roy Implement POSIX curses use_env function.
 1.73 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.72 30-Dec-2016  roy Add the POSIX filter() function to libcurses.
 1.71 05-Jul-2014  dholland branches: 1.71.6;
Remove stray .if make(insatll).

I would really like to know why this didn't fail the clean build I ran
last night.
 1.70 13-Jun-2014  mrg remove the build support for GCC 4.1, and any hacks i found for it.

there could still be more -- i only looked for lines matching
both "HAVE_GCC" and "4" as words (grep -w.)
 1.69 21-May-2014  abs Add workaround for lib/48827 for vax to avoid segv in sysinst for now
 1.68 21-Apr-2012  roy branches: 1.68.2; 1.68.8;
Fix build
 1.67 21-Apr-2012  roy Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.66 04-Oct-2011  roy branches: 1.66.2;
Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.65 04-Apr-2011  blymn Add man page link for define_key
 1.64 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.63 06-Jul-2009  joerg Add support for the chgat(3) family. It is a useful extension from
ncurses, supporting it dramatically reduces the need for ncurses in
pkgsrc.
 1.62 06-Apr-2009  christos make fileio.h work with objdir.
 1.61 27-Oct-2008  apb branches: 1.61.4;
s/AWK/TOOL_AWK/. Problem reported by Greg Oster.
 1.60 13-May-2008  tsutsui Use WARNS=2, which just works.
 1.59 27-Apr-2008  tsutsui branches: 1.59.2;
Use WARNS=1 rather than adding warning options to COPTS.
Tested on several MACHINE_ARCHs.
 1.58 27-Apr-2008  tsutsui Enable gcc optimization on m68000 (sun2) again with minimum hacks.
gcc -O0 generates a bit fat binaries.
 1.57 15-Apr-2008  jdc branches: 1.57.2;
Add getwin and putwin mlinks.
 1.56 14-Apr-2008  jdc Add new file IO functions.
Define DISABLE_WCHAR, so that we can build without HAVE_WCHAR.
 1.55 09-Feb-2008  mrg only use -Wuninitialized with -O>0.
 1.54 29-May-2007  blymn branches: 1.54.4;
Change debug handling, now we write debug out iff CURSES_TRACE_FILE
has been set in the environment, this prevents people using MKDEBUGLIB
getting more than they bargained for.

Tidied up the debug settings in the Makefile to reflect the above change,
we no longer need to have FULL_DEBUG since nothing is written by default.
 1.53 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.52 21-Apr-2004  jdc branches: 1.52.12;
Add missing mvin* and mvwin* manual pages.
 1.51 28-Mar-2004  jdc branches: 1.51.4;
Changes to support *echochar().
Should fix PR lib/24927.
 1.50 23-Mar-2004  jdc Add (missing) mvgetch() and mvwgetch() manual pages.
 1.49 16-Mar-2004  jdc s/can_change_colors/can_change_color/
 1.48 18-Oct-2003  wiz Link curses_cursor(3) to getmaxyx(3); from Steve Rumble in PR 23183.
 1.47 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.46 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.45 21-May-2003  jdc Add addchstr() family of functions.
Based on mail from Douwe Kiela.
Fixes PR lib/21285 by Thomas Klausner.
 1.44 21-May-2003  jdc Add missing *printw manual page links.
Patch provided in PR lib/21446 by Douwe Kiela.
 1.43 20-May-2003  jdc Add missing manual page links.
 1.42 08-Apr-2003  jdc Add mvwin manual pages.
From PR 21041.
 1.41 30-Mar-2003  jdc Add attr_set() group of functions.
Fixes PR lib/20034 by Thomas Klausner.
 1.40 09-Jan-2003  blymn Added halfdelay() function.
 1.39 24-Dec-2002  jdc Add curses pad manual pages.
Forgot to commit this. Pointed out by wiz.
 1.38 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.37 19-Aug-2002  lukem Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path (etc).
(Reduces make output by ~ 20%)
 1.36 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.35 11-Dec-2001  blymn * Remove termcap globals from public interface
* Clean up commented out code
 1.34 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.33 20-Sep-2001  blymn Add code to allow resizing of windows and the underlying terminal.
 1.32 10-Jan-2001  blymn Fixed casting bug in array indexing, a signed char was being sign
extended when cast to unsigned, made the cast "unsigned char"
 1.31 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.30 13-Aug-2000  itojun build a trace version of libcurses, with "make -DDEBUG_CURSES"
(commented out as it is very uncommon)
 1.29 03-Jun-2000  blymn * Added libterm to the include path - tgoto requires it for the private
structure definition.
 1.28 11-May-2000  jdc branches: 1.28.2;
Add pause.c.
 1.27 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.26 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.25 20-Apr-2000  kleink * Move <wchar.h> from libcurses to include (for the missing functionality
is to be provided by libc).
* Define wint_t and size_t in <wchar.h> as well.
 1.24 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.23 12-Apr-2000  jdc Add color.c, background.c, getyx.c.
 1.22 11-Apr-2000  blymn Made data structures opaque
 1.21 28-Jun-1999  simonb branches: 1.21.6;
Get rid of the evil trailing spaces and tabs.
 1.20 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.19 18-Feb-1998  jtc Ncurses (like SysV/XOpen based curses implementations) includes
the termcap API. This changes bsd-curses to do the same, so we
can update program Makefiles and the like *before* ncurses 4.2
is integrated.
 1.18 22-Oct-1997  lukem use CPPFLAGS instead of CFLAGS
 1.17 11-Oct-1997  mycroft branches: 1.17.2;
Use bsd.subdir.mk as appropriate.
 1.16 09-Oct-1997  lukem - define WARNS?=1 in the top-level Makefile.inc, and don't define
anywhere else.
- for now, override WARNS=0 in librpcsvc and libwrap, until they're
cleaned up
- rcsid police

lib is now clean (except for librpcsvc and libwrap) on the i386, and
this should motivate the other ports to fix any other minor problems
that their compilers pick up that the i386 version doesn't.
 1.15 23-Jul-1997  mikel RCSid police, set WARNS?=1
 1.14 23-May-1997  jtc Moved unctrl.h from games/mille.
Install it, as it's part of the curses interface.
 1.13 24-Mar-1997  christos Makefile cleanups:
use INCS variable to install includes and FILES to install objects.
 1.12 18-Oct-1996  thorpej Use ${INSTALL}.
 1.11 25-Apr-1996  jtc Use 'includes' instead of 'beforeinstall' target to install curses.h header
 1.10 22-Dec-1994  cgd specify man pages the new way.
 1.9 17-Aug-1994  cgd branches: 1.9.2;
clean up import
 1.8 30-Jun-1994  cgd deal with new share/doc strategy
 1.7 25-Jun-1994  cgd update for new doc-make/install strategy
 1.6 24-Jan-1994  cgd changes from branch
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd branches: 1.4.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 24-Jan-1994  cgd minor fixups
 1.9.2.2 17-Aug-1994  cgd clean up import
 1.9.2.1 17-Aug-1994  cgd file Makefile was added on branch netbsd-1-0 on 1994-08-17 21:51:42 +0000
 1.17.2.1 09-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.21.6.2 05-Mar-2000  jdc Add acs.c, border.c and insdelln.c.
 1.21.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.28.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.51.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.52.12.4 21-Mar-2007  jdc We don't need the same setting in CFLAGS and CPPFLAGS.
Don't install keymap.h (in `make includes`).
 1.52.12.3 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.52.12.2 21-Jan-2007  jdc Remove trailing whitespace.
 1.52.12.1 21-Jan-2007  blymn Wide curses merge
 1.54.4.1 23-Mar-2008  matt sync with HEAD
 1.57.2.1 18-May-2008  yamt sync with head.
 1.59.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.61.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.66.2.1 23-May-2012  yamt sync with head.
 1.68.8.1 10-Aug-2014  tls Rebase.
 1.68.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.6.2 20-Mar-2017  pgoyette Sync with HEAD
 1.71.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.83.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.84.10.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.84.10.1 25-Jun-2018  pgoyette Sync with HEAD
 1.85.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.85.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.85.2.1 10-Jun-2019  christos Sync with HEAD
 1.1 02-Apr-2013  agc branches: 1.1.2;
file Version.map was initially added on branch agc-symver.
 1.1.2.1 02-Apr-2013  agc add symbol versioning info for:

libcrypt
libcurses
libedit
libmenu
libossaudio
libposix
libskey
 1.22 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.21 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.20 21-Apr-2012  roy branches: 1.20.14;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.19 25-Feb-2010  drochner branches: 1.19.6;
fix wrong widechar assignment for "up arrow"
 1.18 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.17 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.16 04-Jul-2008  tnozaki use nl_langinfo(CODESET) instead of setlocale(LC_ALL, "").
 1.15 28-Apr-2008  martin branches: 1.15.2;
Remove clause 3 and 4 from TNF licenses
 1.14 11-Jul-2007  jdc branches: 1.14.10;
Add additional line drawing and characters.
Pointed out by pooka@.
 1.13 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.12 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.11 11-Apr-2002  mycroft branches: 1.11.20;
Make sure _acs_char[] is copied to screen->acs_char[] even when there is no
ac attribute. This fixes box-drawing on displays with no ac.
 1.10 04-Jan-2002  blymn Only reference termcap capabilities in the screen struct in __init_acs
Also changed tputs to t_puts to output acs init string to correct device.
 1.9 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.8 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.7 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.6 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.5 12-Apr-2000  jdc Make ACS array index unsigned.
 1.4 11-Apr-2000  simonb Use "unsigned char" instead of "int" in previous, from Christos Zoulas.
 1.3 11-Apr-2000  simonb Cast array subscript to int - fixes compile barf on (at least) alpha.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 05-Mar-2000  jdc branches: 1.1.2;
file acs.c was initially added on branch curses-v3.
 1.1.2.2 30-Mar-2000  jdc ACS terminal representations can be 8bit.
 1.1.2.1 05-Mar-2000  jdc Alternate character set initialisation routine.
 1.11.20.3 30-Jan-2007  blymn Don't core dump if setlocale returns NULL - we punt and go for unicode
instead
 1.11.20.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.11.20.1 21-Jan-2007  blymn Wide curses merge
 1.14.10.1 18-May-2008  yamt sync with head.
 1.15.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.19.6.1 23-May-2012  yamt sync with head.
 1.20.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.9 09-Jun-2019  blymn branches: 1.9.12;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.8 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.7 24-Apr-2019  blymn Add/improve debug output for some routines.
 1.6 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.5 07-Jan-2016  jdc branches: 1.5.14; 1.5.16;
Add missing new line in debug print.
 1.4 09-Nov-2013  blymn Rename the old __waddbytes function to _cursesi_waddbytes and add a
parameter that controls whether or not certain characters in the
string are interpreted or not (things like tab being expanded).

Make __waddbytes a wrapper for _cursesi_waddbytes that passes all
parameters and sets the flag for character interpretation for backward
compatibility.

Fix an incipient bug in _cursesi_waddbytes where garbage would have
been written to the terminal if the terminal TABSIZE was set > 8 and
character interpretation is on.

Convert all internal __waddbytes calls to use _cursesi_waddbytes, fix
the function prototypes and add a new flag that will be used later.

Fix the addchstr family functions so that they call _cursesi_waddbytes
with character interpretation off as per SUSV2.
 1.3 22-Jul-2009  roy branches: 1.3.6; 1.3.12;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.7 18-Mar-2007  jdc Make this compile without DEBUG defined.
 1.1.2.6 26-Feb-2007  blymn * commonalise adding a wide character so it can be reused
* make __waddbytes add wide characters if libcurses is built in wide
character mode.
* make waddch add wide characters if libcurses is built in wide character
mode.
 1.1.2.5 22-Jan-2007  jdc We only need to include <assert.h> when debugging.
 1.1.2.4 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.1.2.3 21-Jan-2007  jdc We need to include <assert.h> when debugging.
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Wide curses merge.
 1.3.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.16.1 10-Jun-2019  christos Sync with HEAD
 1.5.14.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.9.12.1 02-Aug-2025  perseant Sync with HEAD
 1.15 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.14 19-Oct-2022  blymn branches: 1.14.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.13 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.12 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.11 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.10 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.9 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.8 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.7 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.6 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.5 22-Oct-2016  christos branches: 1.5.12; 1.5.14;
remove bogus malloc casts
 1.4 23-Feb-2010  drochner branches: 1.4.28;
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.3 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.3 04-Feb-2007  blymn Fix bug where multicell characters were not being added correctly.
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.4.28.1 04-Nov-2016  pgoyette Sync with HEAD
 1.5.14.1 10-Jun-2019  christos Sync with HEAD
 1.5.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.14.4.1 02-Aug-2025  perseant Sync with HEAD
 1.70 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.69 05-Oct-2023  blymn branches: 1.69.2;
Fix for install/56467

Set x to 0 before calling scroll based on a proposed fix by RVP (thanks!)
 1.68 20-Dec-2022  blymn Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.
 1.67 12-Dec-2022  blymn branches: 1.67.2;
Default the character width to 1 if wcwidth fails.
 1.66 07-Nov-2022  blymn Count character widths not number of bytes when calculating number
of characters to add. Fixes an error detected by slk tests where
a label containing wide characters was not correctly printed.
 1.65 19-Oct-2022  blymn Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.64 19-May-2022  blymn Set the last change pointer after adding a character at the bottom right
of a window. This fixes the character missing in the LR of a window.
Thanks to uwe@ for pointing this out.
 1.63 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.62 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.61 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.60 16-Jan-2022  rillig libcurses: remove unreachable statements

Found by lint.

No binary change.
 1.59 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.58 06-Sep-2021  rin Unifdef DEBUG for CTRACE().
 1.57 22-Jun-2021  blymn Rework the fix for lib/56224.
Move the scroll check to _cursesi_addwchar
Perform the scroll check before updating the cursor location when
processing \n.
 1.56 15-Jun-2021  blymn Correct a previous fix for PR lib/56224.
Use wdwitch to determine the width of a wide character on the screen not
the number from mbrtowc which is the number of bytes in the character.
Thanks to Michael Forney for spotting this.
 1.55 06-Jun-2021  blymn Fix for PR lib/56224
Correct addstr behaviour so it truncates the string in the case where
a string is added on the bottom line of a window where scrolling is
disabled as per the SUSv2 specification.
 1.54 13-Feb-2021  rillig branches: 1.54.4;
libcurses: fix wrong tab width for addch

In sysinst, the installation screen is indented with tabs. Sysinst uses
msgc, which brings its own text layout engine. This engine does not use
addbytes but addch. In addch, the x position for each tab was advanced
twice as much as needed. The menu items were thus not indented by 8
spaces but by 16, which caused an ugly line break in the German
translation.

This bug largely went unnoticed because most other applications use
addbytes instead, which worked fine all the time. It had been
introduced somewhere between NetBSD 8.0 and NetBSD 9.0.

The code around this bug used aliased variables for win->curx and
win->cury a lot. Getting this right is difficult and needs a thorough
test suite. Even though libcurses has 201 tests, that is not nearly
enough to cover all the relations between the various functions in
libcurses that call each other, crossing API boundaries from internal
to external, doing character conversions on the way and juggling around
4 different types of characters (char, wchar_t, chtype, cchar_t).

The simplest fix was to remove all this aliasing, while keeping the
API the same. If _cursesi_waddbytes is not considered part of the API,
it would be possible to replace px with win->curx in all places, same
for py and win->cury.

The complicated code with the aliasing may have been meant for
performance reasons, but it's hard to see any advantage if both points
of truth need to be synchronized all the time.

Libcurses can be built in 2 modes: with wide character support or
without (-DDISABLE_WCHAR). The test suite only covers the variant with
wide characters. The single-byte variant has to be tested manually.
Running sysinst with the single-byte libcurses produces the correct
layout.
 1.53 06-Feb-2021  rillig libcurses: fix spelling in comment
 1.52 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.51 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.50 12-May-2019  blymn Fix _cursesi_addwchar so that it performs line wrap. SUSv2 says
add_wch line wraps and updates position. Since wrap is done we are
not past EOL.
 1.49 15-Nov-2018  uwe _cursesi_addbyte - fix function comment after what looks like an
editing accident.
 1.48 08-Aug-2018  simonb Avoid curx going beyond end of window when adding a wide character to the
last column.

OK @blymn.
 1.47 06-Jan-2017  roy branches: 1.47.6; 1.47.12; 1.47.14;
KNF
 1.46 06-Jan-2017  roy KNF
 1.45 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.44 28-Nov-2016  christos If we are inserting spaces to account for a tab, move the x position of the
cursor, otherwise this is a no-op (Carsten Kunze)
 1.43 22-Oct-2016  christos remove bogus malloc casts
 1.42 10-Nov-2013  christos branches: 1.42.4; 1.42.8;
remove unused variable
 1.41 09-Nov-2013  blymn Rename the old __waddbytes function to _cursesi_waddbytes and add a
parameter that controls whether or not certain characters in the
string are interpreted or not (things like tab being expanded).

Make __waddbytes a wrapper for _cursesi_waddbytes that passes all
parameters and sets the flag for character interpretation for backward
compatibility.

Fix an incipient bug in _cursesi_waddbytes where garbage would have
been written to the terminal if the terminal TABSIZE was set > 8 and
character interpretation is on.

Convert all internal __waddbytes calls to use _cursesi_waddbytes, fix
the function prototypes and add a new flag that will be used later.

Fix the addchstr family functions so that they call _cursesi_waddbytes
with character interpretation off as per SUSV2.
 1.40 16-Oct-2013  roy Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.39 01-Jul-2011  joerg branches: 1.39.2; 1.39.8;
Fix memset usage.
 1.38 16-Dec-2010  wiz Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
 1.37 23-Nov-2010  tnozaki to initialize mbstate_t, use memset instead mbrtowc.
 1.36 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.35 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.34 04-Jul-2008  tnozaki use mbrtowc() instead of mbtowc().
 1.33 08-Nov-2007  jdc branches: 1.33.8;
Fix the handling for added carriage return characters.

Should fix the "staircase effect" part of PR 36560.
 1.32 28-May-2007  blymn branches: 1.32.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.31 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.30 15-Jan-2006  jdc branches: 1.30.6;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.29 10-Aug-2003  dsl Revert most of rev 1.27 of addbytes.c and associated changes.
Posix requires that adding '\n' does clrtoeol() and 'x = 0'.
(Making "\r\n" erase the text that has just been displayed.)
Remove __NONL test from addbytes, __NONL is a property of the output device.
 1.28 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.27 31-Jul-2003  dsl Do something more sensible for waddbytes(..., "\r\n", ...);
I'm not sure about the clrtoeol() at all though - maybe it should
be done as part of scroll()?
Leave 'x' alone when __NONL set.
 1.26 26-Jun-2003  dsl Stop blank line being added when newline is processed with __ISPASTEOL set.
 1.25 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.24 23-Dec-2002  jdc Always update the change pointers. Otherwise, we could end up not
displaying 'blank' characters when overlapping windows are displayed.
(Exposed by changes in revision 1.49 of refresh.c.)
 1.23 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.22 20-Apr-2001  jdc Implement scrolling regions :
has_ic()
has_il()
setscrreg()
wsetscrreg()
 1.21 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.20 28-Apr-2000  mycroft Massively simplify some logic.
 1.19 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.18 15-Apr-2000  jdc Don't reset firstchp and lastchp even if this line was not dirty.
They could have been set previously by a parent window or sub-window.
 1.17 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.16 12-Apr-2000  jdc Add color attribute manipulation.
 1.15 11-Apr-2000  blymn Made data structures opaque
 1.14 28-Jun-1999  simonb branches: 1.14.6;
Get rid of the evil trailing spaces and tabs.
 1.13 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.12 03-Feb-1998  perry remove obsolete register declarations
 1.11 22-Jul-1997  mikel RCSid police, fix warnings
 1.10 17-Aug-1994  cgd branches: 1.10.2;
clean up import
 1.9 24-Jan-1994  cgd changes from branch
 1.8 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.7 09-Nov-1993  cgd branches: 1.7.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.6 15-Aug-1993  mycroft waddbytes() is private; make the rest of *addbytes() be.
Make waddbytes() and waddstr() take a `const char *'.
 1.5 07-Aug-1993  mycroft New version from uunet.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.2 23-Apr-1993  mycroft Make tabs actually work.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 24-Jan-1994  cgd minor fixups
 1.10.2.2 17-Aug-1994  cgd clean up import
 1.10.2.1 17-Aug-1994  cgd file addbytes.c was added on branch netbsd-1-0 on 1994-08-17 21:51:44 +0000
 1.14.6.2 05-Mar-2000  jdc Add alternate character set support.
 1.14.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.30.6.7 18-Mar-2007  jdc Mark subsequent cells of multi-column characters with __WCWIDTH and
their attributes and only display them once.
 1.30.6.6 26-Feb-2007  blymn * commonalise adding a wide character so it can be reused
* make __waddbytes add wide characters if libcurses is built in wide
character mode.
* make waddch add wide characters if libcurses is built in wide character
mode.
 1.30.6.5 22-Jan-2007  jdc We only need to include <assert.h> when debugging.
 1.30.6.4 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.30.6.3 22-Jan-2007  jdc We only need to include <assert.h> when debugging.
 1.30.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.30.6.1 21-Jan-2007  blymn Wide curses merge
 1.32.4.1 09-Jan-2008  matt sync with HEAD
 1.33.8.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.39.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.8.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.42.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.42.4.1 09-Aug-2018  martin Pull up following revision(s) (requested by simonb in ticket #1627):

lib/libcurses/addbytes.c: revision 1.48

Avoid curx going beyond end of window when adding a wide character to the
last column.

OK @blymn.
 1.47.14.1 10-Jun-2019  christos Sync with HEAD
 1.47.12.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.47.12.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.47.6.1 08-Aug-2018  martin Pull up following revision(s) (requested by simonb in ticket #964):

lib/libcurses/addbytes.c: revision 1.48

Avoid curx going beyond end of window when adding a wide character to the
last column.

OK @blymn.
- --
 1.54.4.1 06-Jun-2021  cjep sync with head
 1.67.2.2 10-Oct-2023  martin Pull up following revision(s) (requested by kim in ticket #402):

tests/lib/libcurses/check_files/waddstr2.chk: revision 1.2
tests/lib/libcurses/check_files/addstr3.chk: revision 1.5
lib/libcurses/addbytes.c: revision 1.69
lib/libcurses/tty.c: revision 1.50

Fix for install/56467

Set x to 0 before calling scroll based on a proposed fix by RVP (thanks!)
Update check files affected by a fix to addbyte.c in libcurses.

Correct the fd closed check so we actually check the outfd as per
the comment. Thanks for jdc%netbsd.org@localhost for catching this one.
 1.67.2.1 21-Dec-2022  martin Pull up following revision(s) (requested by blymn in ticket #15):

lib/libcurses/slk.c: revision 1.21
lib/libcurses/addbytes.c: revision 1.68

Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.
 1.69.2.1 02-Aug-2025  perseant Sync with HEAD
 1.23 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.22 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.21 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.20 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.19 29-Oct-2018  uwe waddch - instead of enclosing every statement in #ifdef HAVE_WCHAR
just provide two separate definitions.

Same object code is generated for all four combinations of debug/wchar.
 1.18 06-Jan-2017  roy branches: 1.18.12; 1.18.14;
KNF
 1.17 09-Nov-2013  blymn branches: 1.17.8;
Rename the old __waddbytes function to _cursesi_waddbytes and add a
parameter that controls whether or not certain characters in the
string are interpreted or not (things like tab being expanded).

Make __waddbytes a wrapper for _cursesi_waddbytes that passes all
parameters and sets the flag for character interpretation for backward
compatibility.

Fix an incipient bug in _cursesi_waddbytes where garbage would have
been written to the terminal if the terminal TABSIZE was set > 8 and
character interpretation is on.

Convert all internal __waddbytes calls to use _cursesi_waddbytes, fix
the function prototypes and add a new flag that will be used later.

Fix the addchstr family functions so that they call _cursesi_waddbytes
with character interpretation off as per SUSV2.
 1.16 23-Feb-2010  drochner branches: 1.16.6; 1.16.12;
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.15 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.14 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.13 07-Aug-2003  agc branches: 1.13.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg branches: 1.9.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file addch.c was added on branch netbsd-1-0 on 1994-08-17 21:51:47 +0000
 1.9.6.2 05-Mar-2000  jdc Strip attributes from buf.ch.
Print attributes in hex when debugging.
 1.9.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.13.18.2 26-Feb-2007  blymn * commonalise adding a wide character so it can be reused
* make __waddbytes add wide characters if libcurses is built in wide
character mode.
* make waddch add wide characters if libcurses is built in wide character
mode.
 1.13.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.16.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.14.1 10-Jun-2019  christos Sync with HEAD
 1.18.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.10 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.9 06-Sep-2021  rin branches: 1.9.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.8 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.7 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.6 09-Nov-2013  blymn branches: 1.6.26;
Rename the old __waddbytes function to _cursesi_waddbytes and add a
parameter that controls whether or not certain characters in the
string are interpreted or not (things like tab being expanded).

Make __waddbytes a wrapper for _cursesi_waddbytes that passes all
parameters and sets the flag for character interpretation for backward
compatibility.

Fix an incipient bug in _cursesi_waddbytes where garbage would have
been written to the terminal if the terminal TABSIZE was set > 8 and
character interpretation is on.

Convert all internal __waddbytes calls to use _cursesi_waddbytes, fix
the function prototypes and add a new flag that will be used later.

Fix the addchstr family functions so that they call _cursesi_waddbytes
with character interpretation off as per SUSV2.
 1.5 28-Sep-2012  blymn Truncate string to RHS of the window - SUSv2 says we should.
 1.4 28-Apr-2008  martin branches: 1.4.4; 1.4.26;
Remove clause 3 and 4 from TNF licenses
 1.3 21-Jan-2007  jdc branches: 1.3.10;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.2 22-May-2003  wiz branches: 1.2.18;
Make i an int to please lint and remove a cast.
 1.1 21-May-2003  jdc Add addchstr() family of functions.
Based on mail from Douwe Kiela.
Fixes PR lib/21285 by Thomas Klausner.
 1.2.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.3.10.1 18-May-2008  yamt sync with head.
 1.4.26.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.26.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.4.1 30-Oct-2012  yamt sync with head
 1.6.26.1 10-Jun-2019  christos Sync with HEAD
 1.9.4.1 02-Aug-2025  perseant Sync with HEAD
 1.21 21-Dec-2022  blymn Add more debug so a call to waddbytes can be traced to the caller.
 1.20 19-Oct-2021  blymn Add a bit more debug.
 1.19 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.18 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.17 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.16 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.15 06-Jan-2017  roy branches: 1.15.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.14 13-Jul-2014  blymn branches: 1.14.6;
Remove bogus length check - SUSV2 says add(n)str wraps and performs
special character processing so we should not be trying to limit the
length to the screen edge. This partially fixes PR 48827, the test case
works now.
 1.13 28-Sep-2012  blymn branches: 1.13.6;
Don't wrap added string
 1.12 28-May-2007  blymn branches: 1.12.34; 1.12.40;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.11 07-Aug-2003  agc branches: 1.11.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 13-Aug-2000  itojun change behavior of waddnstr(w, s, 0) to be more conformant to XCURSES.
(see comment for detail)
 1.9 17-Apr-2000  blymn branches: 1.9.4;
Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.8 15-Apr-2000  jdc Add waddstr() macro replacement.
 1.7 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.6 11-Apr-2000  blymn Made data structures opaque
 1.5 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.4 22-Jul-1997  mikel RCSid police, fix warnings
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file addnstr.c was added on branch netbsd-1-0 on 1994-08-17 21:51:49 +0000
 1.9.4.1 05-Sep-2000  itojun pullup 1.9 -> 1.10 (approved by releng-1-5)

change behavior of waddnstr(w, s, 0) to be more conformant to XCURSES.
(see comment for detail)
 1.11.18.1 26-Feb-2007  blymn Add more debug.
 1.12.40.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.40.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.12.34.1 30-Oct-2012  yamt sync with head
 1.13.6.1 10-Aug-2014  tls Rebase.
 1.14.6.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15.14.1 10-Jun-2019  christos Sync with HEAD
 1.6 09-Nov-1993  mycroft Clean up deleted files.
 1.5 15-Aug-1993  mycroft waddbytes() is private; make the rest of *addbytes() be.
Make waddbytes() and waddstr() take a `const char *'.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.8 06-Sep-2021  rin branches: 1.8.4;
Style fixes most for __CTRACE().
 1.7 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.6 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.5 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.4 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.3 06-Jan-2017  roy branches: 1.3.12; 1.3.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.2 28-May-2007  blymn branches: 1.2.58;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.3 21-Jan-2007  jdc Add a cast (len should fit in long here).
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.2.58.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.3.14.1 10-Jun-2019  christos Sync with HEAD
 1.3.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.8.4.1 02-Aug-2025  perseant Sync with HEAD
 1.36 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.35 25-Oct-2022  blymn branches: 1.35.4;
Fix for lib/57050
Perform a sanity check on the window parameter being passed and return
ERR if it is null. This prevents buggy code crashing.
 1.34 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.33 08-Dec-2021  andvar fix various typos in comments and log messages.
 1.32 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.31 25-Jul-2019  uwe #ifdef HAVE_WCHAR around enhanced curses stuff.
 1.30 24-Nov-2018  uwe attron(), attroff() - don't take a shortcut.
 1.29 23-Nov-2018  uwe wattr_set - turn off all wide attributes (fix unedited copy/paste).
 1.28 23-Nov-2018  uwe Rename the reserved argument from "opt" to "opts" to match SUS text.
 1.27 23-Nov-2018  uwe Refactor. Move code to turn attributes on/off into separate
functions. Express both old and new functions to manipulate
attributes using those functions. Check that the the new API's opts
argument (reserved by the standard for future use) is NULL and error
out if not (like getcchar/setcchar). No functional change intended.
 1.26 22-Nov-2018  uwe Drop a few redundant casts of a variable to its own type.
 1.25 22-Nov-2018  uwe Move getattrs() and wcolor_set() so that they are with their peers and
so that wide and non-wide functions are in the same order. While here,
make __wcolor_set() static. No functional change intended.
 1.24 29-Oct-2018  uwe Fix indentation.
 1.23 10-Jan-2017  roy branches: 1.23.12; 1.23.14;
Use the terminal of the SCREEN of the WINDOW rather than cur_term
for window attribute functions.
 1.22 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.21 25-Dec-2010  blymn branches: 1.21.28;
Little bit more debug information.
 1.20 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.19 13-Jun-2008  yamt avoid c99 on DEBUG.
 1.18 28-Apr-2008  martin branches: 1.18.2;
Remove clause 3 and 4 from TNF licenses
 1.17 14-Apr-2008  jdc branches: 1.17.2;
Make this compile when HAVE_WCHAR is not defined.
 1.16 21-Mar-2008  jdc Add termattrs() and term_attrs() (requested by wiz@).
Only allow standout and underline if the terminal can do them.
 1.15 28-May-2007  blymn branches: 1.15.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.14 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.13 21-Oct-2003  fvdl branches: 1.13.18;
Don't use NULL to compare against an int.
 1.12 30-Mar-2003  jdc Add attr_set() group of functions.
Fixes PR lib/20034 by Thomas Klausner.
 1.11 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.10 27-Jan-2003  jdc Remove check for attribute/colour conflict.
This is now handled in refresh.c as it's not possible to handle the
conflict with background colour here.
 1.9 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.8 11-May-2000  jdc New function getattrs().
Add win to debug output.
 1.7 28-Apr-2000  mycroft Clean up a bunch more logic.
 1.6 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.5 16-Apr-2000  jdc Add extra debug output (for wattrset()).
 1.4 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.3 12-Apr-2000  jdc Copyright assgned to TNF.
Add check for conflict with colour.
Remove code duplication in wattrset().
Shrink one line comments.
Consolidate DEBUG output.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 13-Apr-1999  mrg branches: 1.1.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.1.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.13.18.4 28-May-2007  blymn Bump shlib version.
 1.13.18.3 29-Jan-2007  blymn Mask off wide char width when returning attributes.
 1.13.18.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.13.18.1 21-Jan-2007  blymn Wide curses merge
 1.15.4.1 23-Mar-2008  matt sync with HEAD
 1.17.2.2 17-Jun-2008  yamt sync with head.
 1.17.2.1 18-May-2008  yamt sync with head.
 1.18.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.21.28.2 20-Mar-2017  pgoyette Sync with HEAD
 1.21.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.23.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.23.14.1 10-Jun-2019  christos Sync with HEAD
 1.23.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.35.4.1 02-Aug-2025  perseant Sync with HEAD
 1.34 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.33 19-Oct-2022  blymn branches: 1.33.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.32 05-May-2022  blymn Don't force the refresh, it doesn't really need it.
 1.31 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.30 19-Apr-2022  blymn fix for PR 55496

* Fix bkgrndset so that it actually sets the background character in
in line with the SUSv2 specification.

* Add an internal function to copy a complex character

* Make the previously static celleq function into a libcurses private
function so that it can be called in other files.
 1.29 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.28 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.27 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.26 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.25 19-Nov-2018  uwe wbkgd - when updating window rendition for the new background character,
it's the old background characters that need to be updated, not spaces.

While here, simplify and also fix the bug introduced in 1.20 (that
lost the default color) - actually use the results of wbkgdset().
 1.24 18-Nov-2018  uwe wbkgrnd - do not duplicate code that's already in wbkgrndset()
 1.23 18-Nov-2018  uwe When we remove default color from attributes, just clear all __COLOR.
It's both a nono-optmization and matches the test used in counterpart
code that adds default color when none is set.
 1.22 18-Nov-2018  uwe Reorder "bkgrnd" functions to match the order of old "bkgd" functions.
 1.21 18-Nov-2018  uwe Don't fuse HAVE_WCHAR and (trivial) !HAVE_WCHAR bodies into single
function definition. Instead provide two sets of definitions under
single #ifdef. Same object code is generated for both HAVE_WCHAR and
!HAVE_WCHAR.
 1.20 18-Nov-2018  uwe wbkgd - do not duplicate the code that's already in wbkgdset()
that we do call anyway.
 1.19 18-Nov-2018  uwe Fix comments on bkgdset() and friends to match reality.
 1.18 18-Nov-2018  uwe Don't mix private and public names for the same thing in one statement.
While here, fix harmless edito in a debug call.
 1.17 06-Jan-2017  roy branches: 1.17.12; 1.17.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.16 22-Oct-2016  christos remove bogus malloc casts
 1.15 22-Jul-2009  roy branches: 1.15.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.14 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.13 19-Sep-2007  jdc branches: 1.13.6;
Set the column width when changing the background using wbkgd(), otherwise
we will see zero width characters in refresh.c:makech().
 1.12 29-May-2007  blymn branches: 1.12.4;
Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.11 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.10 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.9 15-Jan-2006  jdc branches: 1.9.6;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.8 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.7 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.6 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.5 18-Apr-2000  jdc Don't replace background character with null character.
Set new background character and attributes in wbkgd().
 1.4 16-Apr-2000  jdc Add bkgd() and bkgdset() (which were previously just macros).
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 13-Apr-2000  simonb Nuke unused variables.
 1.1 12-Apr-2000  jdc Background manipulation routines.
 1.9.6.4 26-Feb-2007  blymn * set the background column width.
 1.9.6.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.9.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.9.6.1 21-Jan-2007  blymn Wide curses merge
 1.12.4.1 06-Nov-2007  matt sync with HEAD
 1.13.6.1 18-May-2008  yamt sync with head.
 1.15.28.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15.28.1 04-Nov-2016  pgoyette Sync with HEAD
 1.17.14.1 10-Jun-2019  christos Sync with HEAD
 1.17.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.33.4.1 02-Aug-2025  perseant Sync with HEAD
 1.10 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.9 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.8 03-Feb-2010  roy branches: 1.8.28;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 21-Jan-2007  jdc branches: 1.6.10;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.5 19-Dec-2000  jdc branches: 1.5.20;
Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.4 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 20-Apr-2000  blymn * Fix longname behaviour so it returns the last alias for the terminal
name which, by convention, is the verbose terminal description.
* Fix compile errors when DEBUG defined.
 1.2 12-Apr-2000  jdc Copyright assgned to TNF.
 1.1 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.5.20.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.6.10.1 18-May-2008  yamt sync with head.
 1.8.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.26 25-Dec-2024  christos make it compile again.
 1.25 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.24 03-May-2022  blymn branches: 1.24.4;

* Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.23 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.22 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.21 19-Oct-2021  blymn Add a bit more debug.
 1.20 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.19 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.18 09-Jan-2017  blymn Checks for bottom right corner were reversed.
 1.17 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.16 22-Oct-2016  christos remove bogus malloc casts
 1.15 05-May-2013  jdc branches: 1.15.10;
Also merge in background attributes.
 1.14 25-Dec-2010  blymn branches: 1.14.6; 1.14.8; 1.14.12;
Allow attributes to be applied to the default line drawing characters
by just passing attributes as arguments to the wborder call.
 1.13 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.12 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.11 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10 28-May-2007  blymn branches: 1.10.10;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.9 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.8 15-Jan-2006  jdc branches: 1.8.6;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.7 05-Feb-2001  jdc Don't delete attributes when character 0 (default) is passed in.
Minor KNF.
 1.6 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.5 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.4 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.3 12-Apr-2000  jdc Remove attributes of characters displayed with -DDEBUG.
Add color manipulation.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 05-Mar-2000  jdc branches: 1.1.2;
file border.c was initially added on branch curses-v3.
 1.1.2.2 06-Mar-2000  jdc Better debug output. Merge existing attributes. Draw corners on sub-windows.
 1.1.2.1 05-Mar-2000  jdc wborder() implementation - draw border around window, c.f. box().
 1.8.6.3 22-Jan-2007  jdc We need to SET_WCOL() in wborder() too.
 1.8.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.8.6.1 21-Jan-2007  blymn Wide curses merge
 1.10.10.1 18-May-2008  yamt sync with head.
 1.14.12.1 23-Jun-2013  tls resync from head
 1.14.8.1 11-May-2013  riz Pull up following revision(s) (requested by jdc in ticket #884):
lib/libcurses/border.c: revision 1.15
Also merge in background attributes.
 1.14.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.10.3 20-Mar-2017  pgoyette Sync with HEAD
 1.15.10.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15.10.1 04-Nov-2016  pgoyette Sync with HEAD
 1.24.4.1 02-Aug-2025  perseant Sync with HEAD
 1.15 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.14 28-May-2007  blymn branches: 1.14.58;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.13 07-Aug-2003  agc branches: 1.13.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file box.c was added on branch netbsd-1-0 on 1994-08-17 21:51:51 +0000
 1.10.6.3 16-Mar-2000  jdc Get the argumesnts to wborder() the correct way round.
 1.10.6.2 05-Mar-2000  jdc Now uses wborder().
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.13.18.1 21-Jan-2007  blymn Wide curses merge
 1.14.58.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12 02-Jul-2020  uwe setcchar - don't lose combining marks to a typo.

We copy len wchars but set the length field to 1, instead of len.
From Naman Jain in PR lib/55443
 1.11 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.10 20-Nov-2018  uwe Compare pointers to NULL, not to zero.
 1.9 20-Nov-2018  uwe Drop bogus cast.
 1.8 20-Nov-2018  uwe Don't hide assignments inside tests.
 1.7 20-Nov-2018  uwe Fix color pair handling. color_pair argument is a pair number.
 1.6 06-Jan-2017  roy branches: 1.6.12; 1.6.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.5 16-Dec-2010  wiz branches: 1.5.28;
Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
 1.4 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.3 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.5.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.14.1 10-Jun-2019  christos Sync with HEAD
 1.6.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.10 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.9 19-Oct-2022  blymn branches: 1.9.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.8 22-Nov-2021  blymn Don't waste time setting the dirty flag multiple times.
 1.7 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.6 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.5 28-Sep-2012  blymn Add more debug to mvchgat.
 1.4 22-Jul-2009  roy branches: 1.4.6; 1.4.12;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.3 09-Jul-2009  joerg Ensure that y,x are valid coordinates before using them.
 1.2 07-Jul-2009  joerg Be strict on xcurses support:
- Do not perform wrapping at all by setting the line flags.
- Do not alter the cursor position, even for mv(w)chgat.
 1.1 06-Jul-2009  joerg Add support for the chgat(3) family. It is a useful extension from
ncurses, supporting it dramatically reduces the need for ncurses in
pkgsrc.
 1.4.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.6.1 30-Oct-2012  yamt sync with head
 1.9.4.1 02-Aug-2025  perseant Sync with HEAD
 1.14 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.13 07-Aug-2003  agc branches: 1.13.110;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file clear.c was added on branch netbsd-1-0 on 1994-08-17 21:51:52 +0000
 1.13.110.1 02-Aug-2025  perseant Sync with HEAD
 1.6 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.5 28-Apr-2008  martin branches: 1.5.74;
Remove clause 3 and 4 from TNF licenses
 1.4 24-Apr-2000  blymn branches: 1.4.38;
* Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 09-Jan-2000  jdc branches: 1.1.2;
file clearok.c was initially added on branch curses-v3.
 1.1.2.1 09-Jan-2000  jdc New files for SUS v2 curses:
Move macros from curses.h
Add prototype for wchar_t
 1.4.38.1 18-May-2008  yamt sync with head.
 1.5.74.1 02-Aug-2025  perseant Sync with HEAD
 1.32 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.31 19-Oct-2022  blymn branches: 1.31.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.30 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.29 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.28 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.27 15-Mar-2020  uwe werase, wclrtobot, wclrtoeol - make code even more similar.
Rename attr to battr to match bch and WINDOW::battr.
No functional change intended.
 1.26 13-Mar-2020  roy curses: wrap the erase logic in a macro

Easier to use, it's in one place and now hopefully everyone is happy.

X
 1.25 12-Mar-2020  roy curses: normalise erase logic with clrtoeol and clrtobot

Define WA_ATTRIBUTES as 0 for the non wide case just to make our code
easier to write.
 1.24 06-Jan-2017  roy branches: 1.24.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.23 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.22 19-Feb-2012  christos branches: 1.22.14;
PR/46049: Tim van der Molen:
clrtobot() and clrtoeol() do not set background attributes
 1.21 22-Jul-2009  roy branches: 1.21.6; 1.21.8;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.20 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.19 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.18 05-Feb-2006  jdc branches: 1.18.6;
Handle both background character and background attribute.
 1.17 26-Jan-2006  jdc Use the window background colour, not the default colour.
Should fix PR install/32617
 1.16 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 20-May-2000  mycroft GC __FORCEPAINT.
 1.13 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file clrtobot.c was added on branch netbsd-1-0 on 1994-08-17 21:51:53 +0000
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.18.6.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.18.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.18.6.1 21-Jan-2007  blymn Wide curses merge
 1.21.8.1 17-Mar-2012  bouyer Pull up following revision(s) (requested by blymn in ticket #121):
lib/libcurses/clrtoeol.c: revision 1.26
lib/libcurses/clrtobot.c: revision 1.22
PR/46049: Tim van der Molen:
clrtobot() and clrtoeol() do not set background attributes
 1.21.6.1 17-Apr-2012  yamt sync with head
 1.22.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.31.4.1 02-Aug-2025  perseant Sync with HEAD
 1.36 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.35 12-May-2022  blymn branches: 1.35.4;
Make clrtoeol match the ncurses behaviour where it seems to make the
rest of line foreground. This fixes a display oddity in mutt.
 1.34 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.33 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.32 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.31 15-Mar-2020  uwe werase, wclrtobot, wclrtoeol - make code even more similar.
Rename attr to battr to match bch and WINDOW::battr.
No functional change intended.
 1.30 13-Mar-2020  roy curses: wrap the erase logic in a macro

Easier to use, it's in one place and now hopefully everyone is happy.

X
 1.29 12-Mar-2020  roy curses: normalise erase logic with clrtoeol and clrtobot

Define WA_ATTRIBUTES as 0 for the non wide case just to make our code
easier to write.
 1.28 06-Jan-2017  roy branches: 1.28.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.27 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.26 19-Feb-2012  christos branches: 1.26.14;
PR/46049: Tim van der Molen:
clrtobot() and clrtoeol() do not set background attributes
 1.25 22-Jul-2009  roy branches: 1.25.6; 1.25.8;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.24 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.23 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.22 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.21 05-Feb-2006  jdc branches: 1.21.6;
Handle both background character and background attribute.
 1.20 26-Jan-2006  jdc Use the window background colour, not the default colour.
Should fix PR install/32617
 1.19 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.18 05-Oct-2003  jdc Fix __CTRACE arguments.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 04-Aug-2002  jdc Make sure we always update curx, cury and __ISPASTEOL.
From Onno van der Linden in PR lib/16532.
 1.15 02-Jan-2002  blymn branches: 1.15.2;
Remove extraneous tabs from blank lines.
 1.14 20-May-2000  mycroft GC __FORCEPAINT.
 1.13 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file clrtoeol.c was added on branch netbsd-1-0 on 1994-08-17 21:51:54 +0000
 1.15.2.1 05-Aug-2002  lukem Pull up revision 1.16 (requested by jdc in ticket #620):
Make sure we always update curx, cury and __ISPASTEOL.
From Onno van der Linden in PR lib/16532.
 1.21.6.4 04-Feb-2007  blymn Make sure partial multicell characters get cleared
Add the row number to debug output
 1.21.6.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.21.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.21.6.1 21-Jan-2007  blymn Wide curses merge
 1.25.8.1 17-Mar-2012  bouyer Pull up following revision(s) (requested by blymn in ticket #121):
lib/libcurses/clrtoeol.c: revision 1.26
lib/libcurses/clrtobot.c: revision 1.22
PR/46049: Tim van der Molen:
clrtobot() and clrtoeol() do not set background attributes
 1.25.6.1 17-Apr-2012  yamt sync with head
 1.26.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.28.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.4.1 02-Aug-2025  perseant Sync with HEAD
 1.48 11-Jul-2024  blymn PR lib/58282

This is a partial fix for the issues raised. This change will
reduce the output by preventing the foreground and background
colours being set on each cell. The current colour pair applied
is tracked and requests to set the colour to the same pair is now
a no-op.
 1.47 19-Oct-2022  blymn branches: 1.47.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.46 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.45 17-Dec-2021  uwe curses: spell "foreground" correctly in comments
 1.44 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.43 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.42 06-Sep-2021  rin Fix old-style definition: use_default_colors() --> use_default_colors(void)
 1.41 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.40 06-Jan-2017  roy u_int -> unsigned int, u_int32_t -> uint32_t.
 1.39 03-Jan-2017  roy Now that we have the initialize_color capability,
init_color can be made to work.

From: rofl0r <retnyg@gmx.net>
 1.38 03-Oct-2011  roy branches: 1.38.24;
Use tiparm instead of vtparm.
 1.37 06-Jan-2011  blymn Back out change for assume_default_colors as it was not correct.
 1.36 25-Dec-2010  blymn Ignore request to change the values of colour pair 0
Explicitly set foreground and/or background colours when -1 is passed
to assume_default_colors()
 1.35 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.34 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.33 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.32 21-Jan-2007  jdc branches: 1.32.10;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.31 23-Aug-2006  jdc branches: 1.31.4;
Make sure we update the correct window when changing colour pairs.
 1.30 15-Jan-2006  jdc branches: 1.30.2;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.29 22-Mar-2004  jdc branches: 1.29.6;
Because we are changing the libcurses major number, remove can_change_colors()
and change the attribute definitions so that we can support more colour pairs.
 1.28 16-Mar-2004  jdc Accept any negative number of init_pair(). Noticed by Peter Bex.
Swap red/blue and yellow/cyan if necessary in assume_default_colors().
 1.27 21-Oct-2003  fvdl Don't compare an int against NULL.
 1.26 05-Oct-2003  jdc Fix __CTRACE arguments.
 1.25 30-Jul-2003  dsl Use _cursesi_screen->winlistp (depracating __winlistp)
Optimise and adjust layout so that fewer line breaks are required.
 1.24 06-Apr-2003  jdc Swap red/blue and yellow/cyan when working with Sb/Sf colour. Problem noticed
when working on PR 21000.
 1.23 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.22 27-Jan-2003  jdc Rename can_change_colors() to can_change_color().
Add can_change_colors() (that just calls can_change_color()).
Add no_color_video().
Replace __nca with _cursesi_screen->nca.
 1.21 25-Nov-2002  jdc Don't allow default colour setting to be overwritten in init_pair().
(Also noticed by Pooka).
 1.20 22-Oct-2002  blymn Fix lint nits mainly with the len parameter type in hash_more.
 1.19 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.18 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.17 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.16 11-Dec-2001  blymn * Remove termcap globals from public interface
* Clean up commented out code
 1.15 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.14 05-Jan-2001  christos de-lint:
- bad arithmetic shift
- const castaways.
 1.13 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.12 06-May-2000  jdc Only return TRUE if we can actually manipulate colours.
 1.11 29-Apr-2000  mycroft Use the mask here too.
 1.10 27-Apr-2000  mycroft Fix obvious bugs in init_pair().
 1.9 27-Apr-2000  jdc Use '__TERMATTR'.
Reorder initialisation to make debugging easier to parse.
Use t_getent() not tgetent().
 1.8 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.7 21-Apr-2000  jdc Initialise colour pairs to default (white on black).
Move colour initialisation so we don't reinitialise the first 8 colours.
 1.6 18-Apr-2000  jdc Use Sb/Sf if AB/AF not present.
Missed a "\n" in debugging printf.
 1.5 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.4 15-Apr-2000  jdc Don't reset firstchp and lastchp even if this line was not dirty.
They could have been set previously by a parent window or sub-window.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 14-Apr-2000  jdc Use the window list so that redefinition of a colour pair can be flagged on
all affected windows.
 1.1 12-Apr-2000  jdc Colour specific routines.
 1.29.6.1 25-Aug-2006  ghen Pull up following revision(s) (requested by jdc in ticket #1475):
lib/libcurses/color.c: revision 1.31
lib/libcurses/screen.c: revision 1.18
lib/libcurses/delwin.c: revision 1.14
Make sure we update the correct window when changing colour pairs.
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.30.2.1 25-Aug-2006  ghen Pull up following revision(s) (requested by jdc in ticket #54):
lib/libcurses/color.c: revision 1.31
lib/libcurses/screen.c: revision 1.18
lib/libcurses/delwin.c: revision 1.14
Make sure we update the correct window when changing colour pairs.
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.31.4.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.32.10.1 18-May-2008  yamt sync with head.
 1.38.24.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.47.4.1 02-Aug-2025  perseant Sync with HEAD
 1.22 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.21 12-Apr-2022  blymn branches: 1.21.4;
Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.20 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.19 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.18 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.17 06-Jan-2017  roy branches: 1.17.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.16 11-Dec-2016  blymn Improve debug information.
 1.15 22-Jul-2009  roy branches: 1.15.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.14 08-Nov-2007  jdc Make sure we copy the relevant cell (and not the first cell) for
each line that we copy.

We also need to touch the destination window here.

Fixes display bug in atc(6). Bug reported by and fix tested by
David Holland.
 1.13 28-May-2007  blymn branches: 1.13.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.12 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.11 02-Aug-2004  dsl branches: 1.11.12;
Fix (I hope) the bounding checks against the source window.
 1.10 01-Aug-2004  dsl overwrite() wasn't copying enough lines or columns.
copywin() couldn't seem to decide whether it should work in window or
screen coordinates - and managed to do neither.
Change copywin() to use window relative coords (as ncurses and solaris do),
and change overwrite() and overlay() to use the modified interface.
It is now possible to use overwrite() to save part of curscr while a
temporary window is drawn.
Fixes PR/26506
 1.9 02-Jan-2002  blymn branches: 1.9.6;
Remove extraneous tabs from blank lines.
 1.8 04-Nov-2001  lukem fix WARNS=2 (-Wshadow) warning
 1.7 13-Jun-2001  wiz withough -> without
 1.6 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.5 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.4 23-Apr-2000  blymn * Fixed bug in copywin which was copying more than it should.
* Changed call to wrefresh in wgetch to be before input read.
* Changed default old cursor mode to be high vis in curs_set
* Added documentation for various new functions to fns.doc.
 1.3 20-Apr-2000  blymn * Added new function dupwin.
* Fixed bug in copywin overwrite code.
 1.2 18-Apr-2000  jdc Include <string.h> - prototype for memcpy. Thanks due to Tim Rightnour.
 1.1 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.9.6.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.11.12.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.11.12.1 21-Jan-2007  blymn Wide curses merge
 1.13.4.1 09-Jan-2008  matt sync with HEAD
 1.15.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17.14.1 10-Jun-2019  christos Sync with HEAD
 1.21.4.1 02-Aug-2025  perseant Sync with HEAD
 1.40 19-Oct-2022  blymn Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.39 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.38 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.37 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.36 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.35 27-Jun-2021  blymn Fix PR lib/55931
Only reset outcol if we actually emit a \n as cursor_down may not may
not put the cursor at the start of the next line.
 1.34 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.33 20-Mar-2017  christos branches: 1.33.12;
comment out unused code.
 1.32 06-Jan-2017  roy branches: 1.32.2;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.31 03-Oct-2011  roy branches: 1.31.24;
Use tiparm instead of vtparm.
 1.30 12-Feb-2010  roy Change from scroll_forward to cursor_down.
cursor_down is more similar to our old termcap use of nl.
Fixes PR lib/42770.
 1.29 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.28 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.27 23-Jul-2008  tnozaki add workaround for PR/39175(Curses regression causes disoptimal and
confusing output), act as rev1.25 does when wcwidth == 1.
 1.26 04-Jul-2008  tnozaki fix cursor position problem with the character wcwidth > 1.
discussed in tech-userlevel, ok'ed by jdc@ thanks!
 1.25 28-May-2007  blymn branches: 1.25.12;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.24 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.23 24-Jul-2004  blymn branches: 1.23.12;
Remove _cursesi_genbuf, it was not being set and caused a SIGSEGV
in getcap(). Fixed getcap() to use screen->cursesi_genbuf.
Thanks to Peter Bex for spotting this. This closes pr lib/26404.
 1.22 07-Aug-2003  agc branches: 1.22.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.21 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.20 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.19 01-Aug-2000  itojun use __cputchar(), not putchar().
otherwise, __CTRACE() will not be useful for debugging curses internals.
 1.18 19-May-2000  mycroft branches: 1.18.4;
We already initialize UP and BC when we fire up Curses, so pass a null pointer
to t_goto() to avoid doing it again... and again... and...
 1.17 19-Apr-2000  blymn Converted all termcap library calls to the "new" interface, this fixes
a problem with curses crashing when the CM capability was larger than
64 bytes and eliminates some possible buffer overflow problems.
 1.16 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.15 11-Apr-2000  blymn Made data structures opaque
 1.14 04-Oct-1999  lukem branches: 1.14.4;
update post change to return value of tputs() third argument
 1.13 28-Jun-1999  simonb branches: 1.13.2;
Get rid of the evil trailing spaces and tabs.
 1.12 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.11 19-Aug-1998  thorpej Add some braces to make egcs happy.
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 22-Jul-1997  mikel RCSid police, fix warnings
 1.8 17-Aug-1994  cgd branches: 1.8.2;
clean up import
 1.7 24-Jan-1994  cgd changes from branch
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd branches: 1.5.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 24-Jan-1994  cgd minor fixups
 1.8.2.2 17-Aug-1994  cgd clean up import
 1.8.2.1 17-Aug-1994  cgd file cr_put.c was added on branch netbsd-1-0 on 1994-08-17 21:51:56 +0000
 1.13.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.4.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.18.4.1 03-Aug-2000  itojun pullup (approved by releng-1-5)

> use __cputchar(), not putchar().
> otherwise, __CTRACE() will not be useful for debugging curses internals.

1.18 -> 1.19 basesrc/lib/libcurses/cr_put.c
1.38 -> 1.39 basesrc/lib/libcurses/refresh.c
1.12 -> 1.13 basesrc/lib/libcurses/scroll.c
 1.22.2.1 26-Jul-2004  tron Pull up revision 1.23 (requested by blymn in ticket #716):
Remove _cursesi_genbuf, it was not being set and caused a SIGSEGV
in getcap(). Fixed getcap() to use screen->cursesi_genbuf.
Thanks to Peter Bex for spotting this. This closes pr lib/26404.
 1.23.12.4 28-Feb-2007  blymn Output the non-spacing characters to the screen.
 1.23.12.3 06-Feb-2007  blymn * Always use putwchar in wide character case when plod'ing
* Removed variable that was only used once.
* Note added to revisit plod due to wide characters outputting more bytes
 1.23.12.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.23.12.1 21-Jan-2007  blymn Wide curses merge
 1.25.12.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.31.24.2 26-Apr-2017  pgoyette Sync with HEAD
 1.31.24.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.32.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.12.1 10-Jun-2019  christos Sync with HEAD
 1.3 07-Aug-1993  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.24 09-Jun-2024  rillig libcurses: fix lint warning about function without header prototype
 1.23 29-Oct-2018  uwe __CTRACE - don't call gettimeofday() twice.
 1.22 29-Oct-2018  uwe Make __CTRACE_init() static and ANSIfy its definition.
 1.21 06-Jan-2017  roy branches: 1.21.12; 1.21.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.20 17-Jan-2009  christos branches: 1.20.30;
fix debugging build.
 1.19 29-May-2007  blymn Change debug handling, now we write debug out iff CURSES_TRACE_FILE
has been set in the environment, this prevents people using MKDEBUGLIB
getting more than they bargained for.

Tidied up the debug settings in the Makefile to reflect the above change,
we no longer need to have FULL_DEBUG since nothing is written by default.
 1.18 22-Jan-2007  jdc Pull down the following from the wcurses branch:
ctrace.c: revision 1.16.2.2
initscr.c: revision 1.27.18.2
Orginal commit message:

Do the debug initialisation only in ctrace.c. Otherwise, it might not
get done, for example, if we start curses with setterm() and not initscr().
 1.17 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.16 17-Jan-2007  hubertf branches: 1.16.2;
Remove more duplicate #includes, and a few spurious whitespaces at EOL
From Slava Semushin <slava.semushin@gmail.com>
 1.15 18-Feb-2005  dsl Change first arg of __hash_more to const void * to remove need for double casts
 1.14 07-Aug-2003  agc branches: 1.14.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.12 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.11 24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.10 20-Apr-2000  blymn * Fix longname behaviour so it returns the last alias for the terminal
name which, by convention, is the verbose terminal description.
* Fix compile errors when DEBUG defined.
 1.9 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.8 16-Apr-2000  thorpej Make the lint hack compile (missing prototype).
 1.7 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.6 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.5 22-Jul-1997  mikel RCSid police, fix warnings
 1.4 17-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 24-Jan-1994  cgd changes from branch
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1; 1.1.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1.2.1 24-Jan-1994  cgd minor fixups
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.4.2.2 17-Aug-1994  cgd clean up import
 1.4.2.1 17-Aug-1994  cgd file ctrace.c was added on branch netbsd-1-0 on 1994-08-17 21:51:58 +0000
 1.14.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.16.2.2 22-Jan-2007  jdc Do the debug initialisation only in ctrace.c. Otherwise, it might not
get done, for example, if we start curses with setterm() and not initscr().
 1.16.2.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.20.30.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.21.14.1 10-Jun-2019  christos Sync with HEAD
 1.21.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.14 07-Sep-2021  rin PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.
 1.13 06-Jan-2017  roy u_int -> unsigned int, u_int32_t -> uint32_t.
 1.12 18-Feb-2005  dsl branches: 1.12.74;
Change first arg of __hash_more to const void * to remove need for double casts
 1.11 07-Aug-2003  agc branches: 1.11.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.9 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.8 13-Apr-2000  simonb Include "curses_private.h" to get function declarations.
 1.7 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.6 03-Feb-1998  perry remove obsolete register declarations
 1.5 22-Jul-1997  mikel RCSid police, fix warnings
 1.4 17-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 24-Jan-1994  cgd changes from branch
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1; 1.1.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1.2.1 24-Jan-1994  cgd minor fixups
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.4.2.2 17-Aug-1994  cgd clean up import
 1.4.2.1 17-Aug-1994  cgd file cur_hash.c was added on branch netbsd-1-0 on 1994-08-17 21:52:00 +0000
 1.11.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.12.74.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.11 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.10 30-Mar-2011  blymn fflush the outfd after setting the cursor visibility so it takes effect
immediately.
 1.9 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.8 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.7 11-Dec-2001  blymn branches: 1.7.20;
* Remove termcap globals from public interface
* Clean up commented out code
 1.6 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.5 13-Jun-2001  wiz withough -> without
 1.4 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.3 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.2 23-Apr-2000  blymn This time commit the curs_set change...
 1.1 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.7.20.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.74 02-Sep-2019  roy curses(3): add curses_version()

Returns NetBSD-Curses %s
Where %s is the NetBSD version taken from sys/param.h

Discussed on tech-net@, only for ncurses compat.
 1.73 25-Oct-2018  uwe Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.72 18-May-2017  abhinav branches: 1.72.8; 1.72.10;
Fix typo in the man page reference
 1.71 25-Jan-2017  roy branches: 1.71.2;
Document baudrate(3).
 1.70 25-Jan-2017  roy And more functions ....
 1.69 25-Jan-2017  roy Note the substantial work by others on the curses library.
 1.68 25-Jan-2017  roy Document recently added functions in curses.3
 1.67 25-Jan-2017  roy Reference curses_slk(3).
 1.66 08-Jan-2017  wiz branches: 1.66.2;
Use more markup, sort ENVIRONMENT.
 1.65 05-Jan-2017  roy Implement is_term_resized and resize_term(3) ncurses extensions.
resizeterm(3) is now a wrapper for resize_term(3).
 1.64 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.63 21-Apr-2012  roy branches: 1.63.14;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.62 04-Oct-2011  roy branches: 1.62.2;
Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.61 09-Dec-2010  njoly s/curses_fileo/curses_fileio/ in xrefs.
 1.60 12-Jul-2009  wiz Bump date for *chgat*.
 1.59 06-Jul-2009  joerg Add support for the chgat(3) family. It is a useful extension from
ncurses, supporting it dramatically reduces the need for ncurses in
pkgsrc.
 1.58 23-Feb-2009  wiz Sort sections.
 1.57 22-Feb-2009  christos Document curses environment variables.
 1.56 14-Apr-2008  jdc branches: 1.56.10;
Add new file IO functions.
 1.55 21-Mar-2008  jdc Add termattrs() and term_attrs().
 1.54 16-Mar-2004  jdc branches: 1.54.24;
s/can_change_colors/can_change_color/
 1.53 20-Jan-2004  wiz Add mv{,w}inch{,n}str and mvwscanw.
 1.52 05-Oct-2003  jdc Add redrawwin() and wredrawln().
Fixes PR lib/20038.
 1.51 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.50 04-Jul-2003  wiz Sort list of functions.
 1.49 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.48 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.47 21-May-2003  jdc Add addchstr() family of functions.
Based on mail from Douwe Kiela.
Fixes PR lib/21285 by Thomas Klausner.
 1.46 21-May-2003  wiz Bump date for last.
 1.45 21-May-2003  jdc Add missing *printw manual page links.
Patch provided in PR lib/21446 by Douwe Kiela.
 1.44 30-Mar-2003  jdc Add attr_set() group of functions.
Fixes PR lib/20034 by Thomas Klausner.
 1.43 23-Dec-2002  jdc Add entries for newpad(), subpad(), prefresh() and pnoutrefresh().
 1.42 22-Oct-2002  blymn Added the ncurses extensions define_key and keyok.
 1.41 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.40 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.39 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.38 19-Jul-2002  blymn Add idcok to documentation.
 1.37 25-Mar-2002  wiz Two formatting fixes.
 1.36 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.35 14-Oct-2001  wiz Whitespace, section name, and punctuation fixes.
 1.34 14-Oct-2001  blymn Added 2 new functions and a macro:
- getparx
- getpary
- getparyx (macro)
Also minor tweak to the man page to correct grammar on a couple of items.
 1.33 08-Oct-2001  blymn Add mvderwin function.
 1.32 20-Sep-2001  blymn Add code to allow resizing of windows and the underlying terminal.
 1.31 20-Apr-2001  jdc Add entries for scrolling regions and getnstr() functions.
 1.30 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.29 04-Jun-2000  simonb Minor formatting nit.
 1.28 11-May-2000  jdc branches: 1.28.2;
Documemt getattrs(), delay_output() and napms().
Document functions (get*).
 1.27 05-May-2000  blymn * Fixed lack of win arg in wattr* man entries.
 1.26 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.25 27-Apr-2000  jdc Add wnoutrefresh() and doupdate().
 1.24 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.23 24-Apr-2000  pk Fix `.Fn' call.
 1.22 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.21 22-Apr-2000  blymn * Added ungetch
* Converted inkey and getch to use getchar instead of read so ungetch
will work.
 1.20 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.19 20-Apr-2000  blymn * Added new function dupwin.
* Fixed bug in copywin overwrite code.
 1.18 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.17 12-Apr-2000  jdc Add colour capabilities and functions.
Add background manipulation functions.
Add def/reset_prog/shell_mode().
 1.16 11-Apr-2000  blymn Made data structures opaque
 1.15 17-Aug-1999  enami branches: 1.15.6;
In name section, use .Dq macro rather than writing double quote directly.
 1.14 28-Jun-1999  simonb Get rid of the evil trailing spaces and tabs.
 1.13 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.12 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.11 05-Feb-1998  perry add LIBRARY section to man page
 1.10 05-Nov-1997  fair add addnstr() to curses.3 man page per PR#2305
 1.9 23-Jul-1997  mikel branches: 1.9.2;
RCSid police
 1.8 23-May-1997  jtc Fix tipo: flusok -> flushok
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 06-Aug-1994  jtc Fix typo, wdelch() only takes on arg (PR 392)
 1.5 09-Nov-1993  cgd branches: 1.5.2;
repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 06-Aug-1994  mycroft update from trunk
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file curses.3 was added on branch netbsd-1-0 on 1994-08-17 21:52:04 +0000
 1.9.2.1 06-Nov-1997  mellon Pull rev 1.10 up from trunk (fair)
 1.15.6.1 05-Mar-2000  jdc Document new functions.
 1.28.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.54.24.1 23-Mar-2008  matt sync with HEAD
 1.56.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.62.2.1 23-May-2012  yamt sync with head.
 1.63.14.2 20-Mar-2017  pgoyette Sync with HEAD
 1.63.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.66.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.71.2.1 19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.72.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.72.10.1 10-Jun-2019  christos Sync with HEAD
 1.72.8.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.31 19-Oct-2022  blymn Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.30 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.29 19-Apr-2022  blymn fix for PR 55496

* Fix bkgrndset so that it actually sets the background character in
in line with the SUSv2 specification.

* Add an internal function to copy a complex character

* Make the previously static celleq function into a libcurses private
function so that it can be called in other files.
 1.28 31-Jan-2017  roy Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.27 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.26 22-Oct-2016  christos branches: 1.26.2;
remove bogus malloc casts
 1.25 16-Oct-2013  roy branches: 1.25.8;
Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.24 03-Feb-2010  roy branches: 1.24.6; 1.24.12;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.23 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.22 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.21 07-Aug-2003  agc branches: 1.21.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.20 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.19 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.18 22-Dec-2000  jdc Revert the change to the `pc' capability from the previous change. Pointed
out in email by Thomas Dickey.
 1.17 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.16 27-Apr-2000  jdc Background colour erase is 'ut' not 'be'.
Add virtual screen for wnoutrefresh()/doupdate().
 1.15 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.14 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.13 12-Apr-2000  jdc Add colour capabilities and variables.
 1.12 11-Apr-2000  blymn Made data structures opaque
 1.11 28-Jun-1999  simonb branches: 1.11.6;
Get rid of the evil trailing spaces and tabs.
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 22-Jul-1997  mikel RCSid police, fix warnings
 1.8 17-Aug-1994  cgd branches: 1.8.2;
clean up import
 1.7 24-Jan-1994  cgd changes from branch
 1.6 04-Dec-1993  cgd update from branch
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd branches: 1.4.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.2 24-Jan-1994  cgd minor fixups
 1.4.2.1 04-Dec-1993  cgd update from latest
 1.8.2.2 17-Aug-1994  cgd clean up import
 1.8.2.1 17-Aug-1994  cgd file curses.c was added on branch netbsd-1-0 on 1994-08-17 21:52:08 +0000
 1.11.6.1 05-Mar-2000  jdc Add alternate character set support.
 1.21.18.2 07-Feb-2007  blymn Add helper functions to deallocate non-spacing character storage.
 1.21.18.1 21-Jan-2007  blymn Wide curses merge
 1.24.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.8.2 20-Mar-2017  pgoyette Sync with HEAD
 1.25.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.26.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.2 05-Dec-2024  blymn branches: 1.2.4;

Fixes PR lib/58823

Implement the ncurses extension wgetscrreg which returns the
scrolling region of the given window. Also implement getscrreg to
get the scrolling region of stdscr which appears to be missing from
ncurses but does follow the convention of having a non w prefixed
function that applies to stdscr.

Due to the addtion of a new function a minor library version bump has
been done.
 1.1 21-Nov-2024  riastradh libcurses: Add expected symbols list.

PR lib/58838: shared libraries in base should all have expsym lists
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 05-Dec-2024  perseant file curses.expsym was added on branch perseant-exfatfs on 2025-08-02 05:54:45 +0000
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 07-Aug-1993  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.133 05-Dec-2024  blymn Fixes PR lib/58823

Implement the ncurses extension wgetscrreg which returns the
scrolling region of the given window. Also implement getscrreg to
get the scrolling region of stdscr which appears to be missing from
ncurses but does follow the convention of having a non w prefixed
function that applies to stdscr.

Due to the addtion of a new function a minor library version bump has
been done.
 1.132 17-May-2024  uwe branches: 1.132.2;
curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@
 1.131 14-May-2024  uwe curse: constify define_key() argument

define_key() is ncurses extension and ncurses defines its first
argument as "const char *". Follow suit.

PR lib/58254
 1.130 13-Feb-2021  rillig curses.h: proofread, indent a bit more consistently
 1.129 23-Mar-2020  roy curses: Add stubs for mouse functions

No mouse support actually included.
But that doesn't matter because most terms don't actually support a mouse.

We should look into hooking these into wsmouse(4) and xterm mouse
in the future.

Compatable with nCurses mouse API version 2.
 1.128 13-Mar-2020  roy curses: wrap the erase logic in a macro

Easier to use, it's in one place and now hopefully everyone is happy.

X
 1.127 12-Mar-2020  roy curses: normalise erase logic with clrtoeol and clrtobot

Define WA_ATTRIBUTES as 0 for the non wide case just to make our code
easier to write.
 1.126 03-Sep-2019  roy curses: believe in unicorns

Hopefully this ends the bikeshed.
If you don't believe in unicorns, please #if 0 it out to preserve
the humour.
 1.125 03-Sep-2019  roy curses: Add __NetBSD_Curses_Version__

Similar to __NetBSD_Version__ from sys/param.h but has no
correlation to it or the ELF symver libcurses is built as.

If we say that v1 was everything prior to this, it makes sense to
start this from v2.
 1.124 02-Sep-2019  roy curses(3): add curses_version()

Returns NetBSD-Curses %s
Where %s is the NetBSD version taken from sys/param.h

Discussed on tech-net@, only for ncurses compat.
 1.123 30-Sep-2018  kamil curses.h: Fix typo in a comment of the word 'handling'

No functional change intended.
 1.122 30-Sep-2018  kamil Fix addchnstr() macro in curses.h

Add a missing argument 'n'.
 1.121 24-Jan-2017  roy branches: 1.121.10; 1.121.12;
Implement POSIX Curses Soft Label Key functions.
 1.120 10-Jan-2017  roy branches: 1.120.2;
Implement POSIX curses function ripoffline(3).
 1.119 06-Jan-2017  roy u_int -> unsigned int, u_int32_t -> uint32_t.
 1.118 05-Jan-2017  roy Implement ncurses is_pad(3).
Correct documentation about is_keypad(3).
 1.117 05-Jan-2017  roy Implement is_term_resized and resize_term(3) ncurses extensions.
resizeterm(3) is now a wrapper for resize_term(3).
 1.116 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.115 04-Jan-2017  roy White space police
 1.114 04-Jan-2017  roy Allow C++ to link with all curses parts.
 1.113 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.112 01-Jan-2017  roy Implement ncurses extension has_key.
 1.111 31-Dec-2016  roy Implement POSIX Curses typeahead function.
 1.110 31-Dec-2016  roy Implement POSIX curses use_env function.
 1.109 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.108 30-Dec-2016  roy Add the POSIX filter() function to libcurses.
 1.107 08-Jun-2015  joerg branches: 1.107.2;
mvgetnstr should have a length argument as the name implies.
 1.106 16-Oct-2013  roy branches: 1.106.4;
Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.105 16-Oct-2013  roy Define WA_NORMAL
 1.104 21-Apr-2012  roy branches: 1.104.2;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.103 04-Oct-2011  roy branches: 1.103.2; 1.103.4;
Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.102 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.101 16-Dec-2010  wiz Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
 1.100 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.99 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.98 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.97 07-Jul-2009  joerg Add vw_printw and vw_scanw as mandated by SUSv2's xcurses. Follow
ncurses and just make the historic vwprintw and vwscanw functions
aliases, ignoring that they should take a varargs.h va_list argument.
 1.96 07-Jul-2009  joerg Use __printflike/__scanflike.
 1.95 06-Jul-2009  joerg Add support for the chgat(3) family. It is a useful extension from
ncurses, supporting it dramatically reduces the need for ncurses in
pkgsrc.
 1.94 01-Apr-2009  cube Make keypad return an int instead of nothing, as the SUS and even
curses_input(3) [!] say it should.

OK'd jdc@. ABI lawyers say this doesn't need major bump.
 1.93 14-Apr-2008  jdc branches: 1.93.8; 1.93.10; 1.93.14;
Add new file IO functions.
 1.92 24-Mar-2008  jdc Don't define HAVE_WCHAR if DISABLE_WCHAR is defined.
Pointed out by martin@.
 1.91 21-Mar-2008  jdc Add termattrs() and term_attrs().
Conditionally define HAVE_WCHAR, so that userland programs can see wide
definitions and functions.
 1.90 11-Jul-2007  jdc branches: 1.90.4;
Add additional line drawing and characters.
Pointed out by pooka@.
 1.89 01-Jul-2007  xtraeme Do not typedef bool as char, just include stdbool.h. Fixes a build
failure with regress/include/okheaders.

Suggestion by mlelstv@ and ok by blymn@.
 1.88 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.87 09-Aug-2005  christos branches: 1.87.4; 1.87.6; 1.87.8;
Deal with modern c++ casts.
 1.86 28-Mar-2004  jdc Changes to support *echochar().
Should fix PR lib/24927.
 1.85 23-Mar-2004  jdc Change the values of ERR and OK.
This makes our getch() and related functions conform to SUSv2.
Also fixes PR lib/15920.

XXX: This causes an API incompatability, but comes less than 27 hours after
the libcurses major number was incremented, so should have minimal impact.
 1.84 22-Mar-2004  jdc Because we are changing the libcurses major number, remove can_change_colors()
and change the attribute definitions so that we can support more colour pairs.
 1.83 16-Mar-2004  jdc s/colour/color/. From Douwe Keila.
 1.82 14-Feb-2004  christos Fix the non working unctrl mess:
1. delete the incorrect duplicate macro from unctrl.h
2. move unctrl macros from curses.h to unctrl.h and make curses.h include
unctrl.h in curses.h instead of duplicating their definition.
3. constify unctrl arrays; make length unsigned.
 1.81 23-Dec-2003  christos Avoid array type is char warning.
 1.80 04-Dec-2003  jdc Make nodelay() return an int.
Now conforms to the Single Unix Specification.
Fixes PR lib/23531 by usa at garbagecollect dot jp.
 1.79 05-Oct-2003  jdc Add redrawwin() and wredrawln().
Fixes PR lib/20038.
 1.78 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.77 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.76 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.75 21-May-2003  jdc Add addchstr() family of functions.
Based on mail from Douwe Kiela.
Fixes PR lib/21285 by Thomas Klausner.
 1.74 08-Apr-2003  jdc Add ESCDELAY variable to control the inter-key delay in escape sequences.
Fixes PR 20031 by Thomas Klausner.
 1.73 30-Mar-2003  jdc Add attr_set() group of functions.
Fixes PR lib/20034 by Thomas Klausner.
 1.72 27-Jan-2003  jdc Add can_change_color() and no_color_video().
 1.71 09-Jan-2003  blymn Added halfdelay() function.
 1.70 23-Dec-2002  jdc Add entries for newpad(), subpad(), prefresh() and pnoutrefresh().
 1.69 22-Oct-2002  blymn Added the ncurses extensions define_key and keyok.
 1.68 14-Oct-2002  jdc Remove duplicate definitions of getyx, getbegyx and getmaxyx.
 1.67 04-Aug-2002  jdc Sort attr* functions/macros.
 1.66 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.65 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.64 11-Dec-2001  blymn * Remove termcap globals from public interface
* Clean up commented out code
 1.63 02-Dec-2001  christos lib/14813: Jason R. Thorpe: worm(6) no longer builds w/ new libcurses
Make baudrate a function, gc old variables, implement ospeed in terms of
baudrate, bump major number to 5, since we don't have __baset anymore.
 1.62 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.61 14-Oct-2001  blymn Added 2 new functions and a macro:
- getparx
- getpary
- getparyx (macro)
Also minor tweak to the man page to correct grammar on a couple of items.
 1.60 08-Oct-2001  blymn Add mvderwin function.
 1.59 20-Sep-2001  blymn Add code to allow resizing of windows and the underlying terminal.
 1.58 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.57 11-Jun-2001  wiz Fix various misspellings of compatible/compatibility.
 1.56 21-Apr-2001  jdc Add missing prototypes.
Fixes PR lib/12714.
 1.55 20-Apr-2001  jdc Implement scrolling regions :
has_ic()
has_il()
setscrreg()
wsetscrreg()
 1.54 05-Jan-2001  christos de-lint:
- bad arithmetic shift
- const castaways.
 1.53 05-Jan-2001  christos remove redundant declarations.
 1.52 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.51 31-Dec-2000  jdc Libcurses-4.0
Removal of termcap capabilities requires major bump. Pointed out by Itojun.
Capabilities are still available if `_CURSES_TERMCAP_COMPAT' is defined.
 1.50 22-Dec-2000  jdc Revert the change to the `pc' capability from the previous change. Pointed
out in email by Thomas Dickey.
 1.49 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.48 11-May-2000  jdc Add getattrs(), delay_output() and napms().
 1.47 11-May-2000  blymn * Applied patch by mrg to remove variable names from function
prototypes to prevent name space collisions.
 1.46 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.45 27-Apr-2000  mycroft Fix a silly bit-shifting error that causes color pairs >=8 to fail.
 1.44 27-Apr-2000  jdc Background colour erase is 'ut' not 'be'.
Add extra KEY_* definition.
Wrap definition of 'bool' with "#ifndef __cplusplus".
Add __attributes(...) to *printw() and *scanw().
Add wnoutrefresh()/doupdate() definitions.
 1.43 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.42 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.41 22-Apr-2000  blymn * Added ungetch
* Converted inkey and getch to use getchar instead of read so ungetch
will work.
 1.40 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.39 20-Apr-2000  blymn * Added new function dupwin.
* Fixed bug in copywin overwrite code.
 1.38 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.37 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.36 16-Apr-2000  jdc Add bkgd() and bkgdset() (which were previously just macros).
 1.35 16-Apr-2000  thorpej Add a couple of missing prototypes.
 1.34 15-Apr-2000  jdc Add prototype for waddstr()
 1.33 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.32 13-Apr-2000  jdc Restore const after the Open Group decided it was OK.
Thanks due to Brett Lymn.
 1.31 12-Apr-2000  jdc Add colour capabilities and functions.
Add background manipulation functions.
Add def/reset_prog/shell_mode().
Remove __TERMATTR.
Tidy up tab vs. space.
Macros get...y and get...x are now functions.
Private functions/variables moved to curses_private.h
Replace character/attribute definitions from curses_private.h
 1.30 11-Apr-2000  blymn Made data structures opaque
 1.29 07-Dec-1999  simonb branches: 1.29.2;
Use unsigned offsets into __unctrl and __unctrllen.
Only prototype __CTRACE if DEBUG is defined.
 1.28 04-Oct-1999  lukem update post change to return value of tputs() third argument
 1.27 29-Sep-1999  simonb Change attr in __LDATA from a char to an int. Fixes a few annoying
screen update problems (particularly on the pmax, sparc and alpha,
and i386 to a lesser extent). It seems that because __LDATA wasn't a
fully packed structure (and hashes to check for screen updates hashed
unused areas in the structure as well) that under some circumstances the
compiler filled the unused areas with garbage.

Doesn't break binary compatibiliy - no shared library version number
changes.
 1.26 08-Aug-1999  simonb branches: 1.26.2;
Remove extra semicolons that crept in previous. Noted by Julian Coleman.
 1.25 08-Aug-1999  simonb Use waddnstr() instead of __waddbytes() in *addstr(), so we don't need
strlen() in scope.

Reviewed by Julian Coleman and Matthew Green.
 1.24 28-Jun-1999  simonb Get rid of the evil trailing spaces and tabs.
 1.23 28-Jun-1999  simonb In struct __window, change flags back to an "unsigned int" from an
"u_int32_t", and move new member "delay" to the end of the structure.
Restores binary compatibility with older curses-based programs that
called any macros that modified window flags (like clearok, which
bites vi).

Fixes PR lib/7863 from Ross Harvey.
 1.22 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.21 30-Jan-1998  perry merge with lite-2
 1.20 13-Oct-1997  lukem use <termcap.h> instead of defining termcap(3) stuff here
 1.19 12-Sep-1997  phil Make endwin() save state so a subsequent call to wrefresh restores curses
and makes endwin()/wrefresh() act like a SIGTSTP.
 1.18 22-Jul-1997  mikel RCSid police, fix warnings
 1.17 24-May-1997  jtc Add get{beg,max}yx and get{cur,beg,max}[yx] macros like XPG4.2 curses.
 1.16 26-Mar-1996  jtc Expand "u_int" to "unsigned int" so that curses.h can be used when
_XOPEN_SOURCE or _POSIX_SOURCE is defined.
 1.15 06-Jun-1995  pk Declare tputs() as void.
 1.14 07-Sep-1994  jtc branches: 1.14.2;
Add __BEGIN_DECLS, __END_DECLS around public functions so curses library
can be used by C++ programs (PR #401).
 1.13 17-Aug-1994  cgd clean up import
 1.12 23-May-1994  cgd ansi type renaming
 1.11 24-Jan-1994  cgd changes from branch
 1.10 04-Dec-1993  cgd update from branch
 1.9 09-Nov-1993  cgd oops; forgot this bit
 1.8 09-Nov-1993  cgd rcs id's and don't include "compat.h"
 1.7 09-Nov-1993  cgd branches: 1.7.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.6 15-Aug-1993  mycroft Remove spurious `)'.
 1.5 15-Aug-1993  mycroft waddbytes() is private; make the rest of *addbytes() be.
Make waddbytes() and waddstr() take a `const char *'.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 30-Jan-1998  perry import lite-2
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 24-Jan-1994  cgd minor fixups
 1.7.2.1 04-Dec-1993  cgd update from latest
 1.14.2.2 07-Sep-1994  jtc Add __BEGIN_DECLS, __END_DECLS around public functions so curses library
can be used by C++ programs (PR #401).
 1.14.2.1 07-Sep-1994  jtc file curses.h was added on branch netbsd-1-0 on 1994-09-07 21:28:06 +0000
 1.26.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.29.2.2 05-Mar-2000  jdc Add alternate character set support.
Add scrl(), wscrl() and insdelln().
Removed suspendwin - what was it?
 1.29.2.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.87.8.1 30-Sep-2007  wrstuden Catch up on netbsd-4 as of a few days ago.
 1.87.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.87.6.1 21-Jan-2007  blymn Wide curses merge
 1.87.4.1 27-Sep-2007  xtraeme Pull up following revision(s) (requested by joerg in ticket #891):
lib/libcurses/curses.h: revision 1.89 (via patch)

Do not typedef bool as char, just include stdbool.h. Fixes a build
failure with regress/include/okheaders.
Suggestion by mlelstv@ and ok by blymn@.
 1.90.4.1 23-Mar-2008  matt sync with HEAD
 1.93.14.1 21-Apr-2010  matt sync to netbsd-5
 1.93.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.93.8.2 19-Jun-2015  snj Pull up following revision(s) (requested by joerg in ticket #1970):
lib/libcurses/curses.h: revision 1.107
mvgetnstr should have a length argument as the name implies.
 1.93.8.1 10-Dec-2009  snj Pull up following revision(s) (requested by drochner in ticket #1190):
lib/libcurses/keypad.c: revision 1.11
lib/libcurses/curses.h: revision 1.94
Make keypad return an int instead of nothing, as the SUS and even
curses_input(3) [!] say it should.
OK'd jdc@. ABI lawyers say this doesn't need major bump.
 1.103.4.1 19-Jun-2015  snj Pull up following revision(s) (requested by joerg in ticket #1307):
lib/libcurses/curses.h: revision 1.107
mvgetnstr should have a length argument as the name implies.
 1.103.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.103.2.1 23-May-2012  yamt sync with head.
 1.104.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.106.4.1 10-Jun-2015  snj Pull up following revision(s) (requested by joerg in ticket #836):
lib/libcurses/curses.h: revision 1.107
mvgetnstr should have a length argument as the name implies.
 1.107.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.107.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.120.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.121.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.121.12.1 10-Jun-2019  christos Sync with HEAD
 1.121.10.1 20-Oct-2018  pgoyette Sync with head
 1.132.2.1 02-Aug-2025  perseant Sync with HEAD
 1.8 21-May-2003  jdc Remove erroneouly added file.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.5 21-Oct-2002  wiz Use \-1 instead of -1.
 1.4 21-Oct-2002  wiz No functions returning pointers in this man page.
 1.3 21-Oct-2002  grant New sentence, new line.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.2 21-Oct-2002  wiz No catted pages in CVS.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.11 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.10 25-Oct-2018  uwe branches: 1.10.12;
Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.9 03-Jul-2017  wiz branches: 1.9.4; 1.9.6;
Remove workaround for ancient HTML generation code.
 1.8 15-Jul-2007  wiz Use HTML escapes. Use Ss for subsection. Correct date.
 1.7 13-Jul-2007  jdc Note that the additional characters are for ncurses compatibility.
Pointed out by Thomas Dickey.
 1.6 11-Jul-2007  jdc Document line drawing and graphics characters.
 1.5 21-May-2003  jdc Cross reference curses_addchstr.3.
 1.4 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.2 21-Oct-2002  wiz curses_delch, not curses_deletech.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.9.6.1 10-Jun-2019  christos Sync with HEAD
 1.9.4.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.10.12.1 02-Aug-2025  perseant Sync with HEAD
 1.4 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.3 30-Apr-2008  martin branches: 1.3.74;
Convert TNF licenses to new 2 clause variant
 1.2 22-May-2003  wiz branches: 1.2.32;
Grammar fix; no functions returnint pointers here, so remove section
about those functions from RETURN VALUES section.
 1.1 21-May-2003  jdc Add addchstr() family of functions.
Based on mail from Douwe Kiela.
Fixes PR lib/21285 by Thomas Klausner.
 1.2.32.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Aug-2025  perseant Sync with HEAD
 1.8 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.7 28-Jul-2019  sevan branches: 1.7.12;
typo
 1.6 27-Jul-2019  sevan nit
 1.5 27-Jul-2019  sevan list the wide variant of functions.
 1.4 21-May-2003  jdc branches: 1.4.98;
Cross reference curses_addchstr.3.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.98.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.12.1 02-Aug-2025  perseant Sync with HEAD
 1.12 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.11 03-Aug-2021  nia branches: 1.11.4;
curses: clarify standout as the "best" _supported_ highlighting mode
of the current terminal
 1.10 02-Aug-2021  nia curses: clarify documentation regarding the standout attribute
 1.9 25-Oct-2018  uwe Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.8 30-Apr-2008  martin branches: 1.8.60; 1.8.62;
Convert TNF licenses to new 2 clause variant
 1.7 21-Mar-2008  jdc branches: 1.7.2;
Add termattrs() and term_attrs().
Order the descriptions so that functions handling normal and functions
handling wide attributes are grouped together.
 1.6 21-May-2003  jdc branches: 1.6.24;
Cross reference curses_addchstr.3.
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 16-Apr-2003  wiz New sentence, new line.
 1.3 30-Mar-2003  jdc Add attr_set() group of functions.
Fixes PR lib/20034 by Thomas Klausner.
 1.2 21-Oct-2002  wiz Punctuation fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.6.24.1 23-Mar-2008  matt sync with HEAD
 1.7.2.1 18-May-2008  yamt sync with head.
 1.8.62.1 10-Jun-2019  christos Sync with HEAD
 1.8.60.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.11.4.1 02-Aug-2025  perseant Sync with HEAD
 1.8 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.7 29-Sep-2018  kamil branches: 1.7.12;
Correct function prototypes in curses_background(3)

Fix prototypes for: bkgdset(3), wbkgd(3) and wbkgdset(3).
 1.6 30-Apr-2008  martin branches: 1.6.60; 1.6.62;
Convert TNF licenses to new 2 clause variant
 1.5 15-Jan-2006  wiz branches: 1.5.20;
Fix Xref, bump date for previous.
 1.4 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 21-Oct-2002  wiz Punctuation fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.5.20.1 18-May-2008  yamt sync with head.
 1.6.62.1 10-Jun-2019  christos Sync with HEAD
 1.6.60.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.7.12.1 02-Aug-2025  perseant Sync with HEAD
 1.5 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.4 16-Mar-2004  snj branches: 1.4.110;
Spelling fix.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.110.1 02-Aug-2025  perseant Sync with HEAD
 1.3 04-Oct-2021  andvar remove duplicate the article in documentation.
 1.2 24-Nov-2018  wiz branches: 1.2.2; 1.2.4;
Grammar improvements.
 1.1 19-Nov-2018  uwe Provide basic documentation on getcchar(3) and setcchar(3).

Looks like we don't have any of wide curses stuff documented, so this
seems to be a good place to start. Needs more exposition on wide
attr_t and how it's related to non-wide chtype, etc, etc.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 24-Nov-2018  christos file curses_cchar.3 was added on branch phil-wifi on 2019-06-10 22:05:22 +0000
 1.2.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2.2.1 24-Nov-2018  pgoyette file curses_cchar.3 was added on branch pgoyette-compat on 2018-11-26 01:52:12 +0000
 1.5 10-Feb-2011  blymn Fix typo.
 1.4 12-Jul-2009  wiz branches: 1.4.2;
Add RCS Id. Fill in name in license. New sentence, new line.
Add comma in enumeration.
 1.3 07-Jul-2009  joerg Be strict on xcurses support:
- Do not perform wrapping at all by setting the line flags.
- Do not alter the cursor position, even for mv(w)chgat.
 1.2 07-Jul-2009  joerg chgat() and friends are in X/Open. Noticed by Thomas Dickey.
 1.1 06-Jul-2009  joerg Add support for the chgat(3) family. It is a useful extension from
ncurses, supporting it dramatically reduces the need for ncurses in
pkgsrc.
 1.4.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.5 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.4 11-Jan-2019  dholland branches: 1.4.12;
At some point we lost the text that explains the difference between
clear() and erase(). Or possibly we never had any. Put some back.
Bump date.
 1.3 16-Apr-2003  wiz branches: 1.3.96; 1.3.98;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.3.98.1 10-Jun-2019  christos Sync with HEAD
 1.3.96.1 18-Jan-2019  pgoyette Synch with HEAD
 1.4.12.1 02-Aug-2025  perseant Sync with HEAD
 1.14 11-Apr-2025  uwe curses_color(3): tweak markup a bit
 1.13 03-Jul-2017  wiz branches: 1.13.18;
Remove workaround for ancient HTML generation code.
 1.12 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.11 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.10 23-Apr-2004  simonb branches: 1.10.26;
s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
 1.9 16-Mar-2004  wiz branches: 1.9.4;
Fix off-by-one, okayed by jdc.
 1.8 16-Mar-2004  wiz Drop trailing space.
 1.7 16-Mar-2004  jdc Clarify colour values that can be passed to init_pair().
 1.6 26-Jun-2003  wiz Work around a warning from groff-1.19.
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 11-Apr-2003  jdc Add spacing around variable definitions.
From a discussion with Thomas Klausner.
 1.3 27-Jan-2003  jdc Rename can_change_colors() to can_change_color().
Add no_color_video().
 1.2 21-Oct-2002  wiz Punctuation fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.9.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.10.26.1 18-May-2008  yamt sync with head.
 1.13.18.1 02-Aug-2025  perseant Sync with HEAD
 1.9 05-Jan-2017  wiz Whitespace.
 1.8 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.7 24-Feb-2010  drochner branches: 1.7.28;
document wsyncup/wsyncdown/wcursyncup
 1.6 23-Jul-2004  wiz getcurx, getcury, getparx, and getpary also seem to be extensions.
 1.5 23-Jul-2004  wiz Note that getbegx, getbegy, getmaxx, and getmaxy are extensions
to X/Open Curses. From Peter Bex in PR 26352.
 1.4 16-Mar-2004  snj branches: 1.4.4;
Spelling fix.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.7.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.5 16-Apr-2003  wiz branches: 1.5.32;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 19-Jan-2003  wiz End sentence with a dot.
 1.3 19-Jan-2003  atatat The next release will be 2.0, not 1.7.
 1.2 21-Oct-2002  wiz Punctuation fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.5.32.1 18-May-2008  yamt sync with head.
 1.5 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.4 25-Oct-2018  uwe branches: 1.4.12;
Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.3 16-Apr-2003  wiz branches: 1.3.96; 1.3.98;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.3.98.1 10-Jun-2019  christos Sync with HEAD
 1.3.96.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.4.12.1 02-Aug-2025  perseant Sync with HEAD
 1.5 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.4 16-Apr-2003  wiz branches: 1.4.110;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.110.1 02-Aug-2025  perseant Sync with HEAD
 1.4 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.3 30-Apr-2008  martin branches: 1.3.74;
Convert TNF licenses to new 2 clause variant
 1.2 28-Mar-2004  wiz branches: 1.2.32;
Add a newline, remove a comma, and reword STANDARDS section
slightly.
 1.1 28-Mar-2004  jdc Implement *echochar().
Should fix PR lib/24927.
 1.2.32.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Aug-2025  perseant Sync with HEAD
 1.4 09-Dec-2010  njoly Add missing space in fread xref.
 1.3 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.2 14-Apr-2008  jdc branches: 1.2.2;
Remove unused BUGS section header.
 1.1 14-Apr-2008  jdc File IO functions getwin() and putwin().
Should fix PR lib/24928.
 1.2.2.1 18-May-2008  yamt sync with head.
 1.15 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.14 29-Oct-2018  wiz branches: 1.14.12;
Add comma in enumeration.
 1.13 25-Oct-2018  uwe Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.12 07-Aug-2011  wiz branches: 1.12.40; 1.12.42;
Add serial comma, remove trailing whitespace, bump date for previous.
 1.11 07-Aug-2011  blymn Document the return values for innstr and friends.
 1.10 21-Apr-2004  jdc Add missing mvin* and mvwin* manual pages.
 1.9 16-Mar-2004  wiz branches: 1.9.4;
Remove duplicate article.
 1.8 16-Mar-2004  snj Spelling fix.
 1.7 16-Mar-2004  snj Drop trailing whitespace.
 1.6 20-Jan-2004  wiz Add mv{,w}inch{,n}str. From Douwe Kiela.
 1.5 25-May-2003  wiz Fix typo reported by Douwe Kiela in PR 21677.
 1.4 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.2 21-Oct-2002  wiz Fix typo in Dt.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.9.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.12.42.1 10-Jun-2019  christos Sync with HEAD
 1.12.40.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.14.12.1 02-Aug-2025  perseant Sync with HEAD
 1.33 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.32 14-May-2024  uwe branches: 1.32.2;
curses_input(3): bump date for define_key() change
 1.31 14-May-2024  uwe curse: constify define_key() argument

define_key() is ncurses extension and ncurses defines its first
argument as "const char *". Follow suit.

PR lib/58254
 1.30 21-May-2022  uwe curses_input.3: wtimeout() returns void too
 1.29 21-May-2022  charlotte curses_input.3: timeout() actually returns void
 1.28 16-May-2022  rillig curses_input.3: fix argument type for keypad, notimeout, nodelay

There is no type named 'boolf', there's only 'bool'.
 1.27 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.26 08-Jan-2017  wiz Whitespace fix, bump date for previous.
 1.25 05-Jan-2017  roy Implement ncurses is_pad(3).
Correct documentation about is_keypad(3).
 1.24 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.23 01-Jan-2017  roy Implement ncurses extension has_key.
 1.22 21-Apr-2012  roy branches: 1.22.14;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.21 06-Aug-2010  dholland branches: 1.21.6;
avoid writing in parseltongue
 1.20 29-Jul-2006  wiz Bump date for previous.
 1.19 25-Jul-2006  christos PR/34011: Julian Coleman: Limit timeout to 25.5 seconds.
 1.18 13-Dec-2004  yamt fix mvgetch prototype.
 1.17 26-Mar-2004  wiz branches: 1.17.4;
Add comma in enumerations, grammar fix, and replace &
with \*[Am] for html output.
 1.16 23-Mar-2004  jdc Clarify the getch() family return values.
Add (missing) mvgetch() and mvwgetch().
 1.15 22-Mar-2004  jdc Add KEY_RESIZE support and a SIGWINCH handler.
Fixes PR bin/20032.
This requires a change to KEY_MAX, which affects libform and libmenu, so we
need to change libcurses major number.
 1.14 16-Mar-2004  snj Spelling fix.
 1.13 18-Oct-2003  wiz mvgetstr and mvwgetstr do not have a limit argument; from Steve Rumble in PR 23183.
 1.12 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 11-Apr-2003  jdc Add spacing around variable definitions.
From a discussion with Thomas Klausner.
 1.9 08-Apr-2003  wiz Better mdoc; add a missing 'is'.
 1.8 08-Apr-2003  jdc Add ESCDELAY variable to control the inter-key delay in escape sequences.
Fixes PR 20031 by Thomas Klausner.
 1.7 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.6 22-Oct-2002  wiz Whitespace cleanup.
 1.5 22-Oct-2002  blymn Added the ncurses extensions define_key and keyok.
 1.4 21-Oct-2002  wiz Use \-1 instead of -1.
 1.3 21-Oct-2002  wiz Punctuation fixes.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.17.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.21.6.1 23-May-2012  yamt sync with head.
 1.22.14.2 20-Mar-2017  pgoyette Sync with HEAD
 1.22.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.32.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.2 25-Oct-2018  uwe branches: 1.2.2; 1.2.4; 1.2.16;
Oops, update name in .Dt, bump date.
 1.1 25-Oct-2018  uwe Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.2.16.1 02-Aug-2025  perseant Sync with HEAD
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 25-Oct-2018  christos file curses_insch.3 was added on branch phil-wifi on 2019-06-10 22:05:22 +0000
 1.2.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2.2.1 25-Oct-2018  pgoyette file curses_insch.3 was added on branch pgoyette-compat on 2018-11-26 01:52:12 +0000
 1.4 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.3 16-Apr-2003  wiz branches: 1.3.110;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.3.110.1 02-Aug-2025  perseant Sync with HEAD
 1.5 25-Oct-2018  uwe Rename curses_insertch.3 to curses_insch.3 to match the function names
documented in that manpage. With the letter salad used in curses
function names naming consistency is very important and this page was
the only one that didn't match.

Add mvinsch and mvwinsch links. Update xrefs in other man pages.
 1.4 05-Feb-2006  jdc branches: 1.4.84; 1.4.86;
Curses_insert has been split into curses_insertch and curses_insertln for
a while now. Adjust names to suit.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.86.1 10-Jun-2019  christos Sync with HEAD
 1.4.84.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.5 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.4 05-Feb-2006  jdc branches: 1.4.98;
Curses_insert has been split into curses_insertch and curses_insertln for
a while now. Adjust names to suit.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.98.1 02-Aug-2025  perseant Sync with HEAD
 1.5 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.4 25-Oct-2007  jdc branches: 1.4.6;
Return "-1" for unknown keys and only return NULL for errors.

Make the key name string a static buffer. The specification allows this,
so the previous behaviour would leak a small amount of memory, as the
application wouldn't free the returned string.

Fixes one part of PR pkg/37062.
 1.3 16-Mar-2004  snj branches: 1.3.24;
Spelling fixes.
 1.2 04-Jul-2003  wiz Fix Dd string and remove trailing whitespace.
 1.1 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.3.24.1 06-Nov-2007  matt sync with HEAD
 1.4.6.1 18-May-2008  yamt sync with head.
 1.7 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.6 20-Feb-2010  wiz branches: 1.6.58;
Bump date for previous.
 1.5 19-Feb-2010  drochner explain a non-portable behavior
 1.4 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.6.58.1 02-Aug-2025  perseant Sync with HEAD
 1.2 23-Mar-2020  wiz branches: 1.2.2;
Fix synopsis, use more markup.
 1.1 23-Mar-2020  roy Add missing man page for curses mouse functions.
 1.2.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.2.1 23-Mar-2020  martin file curses_mouse.3 was added on branch phil-wifi on 2020-04-08 14:07:14 +0000
 1.6 05-Jan-2017  roy Implement ncurses is_pad(3).
Correct documentation about is_keypad(3).
 1.5 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.4 30-Apr-2008  martin branches: 1.4.44;
Convert TNF licenses to new 2 clause variant
 1.3 16-Apr-2003  wiz branches: 1.3.32;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 23-Dec-2002  wiz Remove trailing whitespace and a superfluous Pp, and end a sentence with a dot.
 1.1 23-Dec-2002  jdc Document pad-related functions - newpad(), subpad(), prefresh() and
pnoutrefresh().
 1.3.32.1 18-May-2008  yamt sync with head.
 1.4.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.7 06-Apr-2011  jruoho branches: 1.7.56;
Fix PR # 41894.
 1.6 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.5 15-Mar-2003  wiz Use "its" instead of "it's" where appropriate.
From Soren Jacobsen in PR 20730.
 1.4 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.3 21-Oct-2002  wiz curses_scanw, not curses_scan.
 1.2 21-Oct-2002  wiz Sort SECTIONS. Punctuation fix.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.7.56.1 02-Aug-2025  perseant Sync with HEAD
 1.82 11-Jul-2024  blymn PR lib/58282

This is a partial fix for the issues raised. This change will
reduce the output by preventing the foreground and background
colours being set on each cell. The current colour pair applied
is tracked and requests to set the colour to the same pair is now
a no-op.
 1.81 17-May-2024  uwe branches: 1.81.2;
curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@
 1.80 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.79 19-Apr-2022  blymn fix for PR 55496

* Fix bkgrndset so that it actually sets the background character in
in line with the SUSv2 specification.

* Add an internal function to copy a complex character

* Make the previously static celleq function into a libcurses private
function so that it can be called in other files.
 1.78 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.77 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.76 07-Sep-2021  rin PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.
 1.75 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.74 15-Aug-2021  christos This is a mess; always define MB_LEN_MAX so both the regular and libhack
version of curses compiles. Really we should not be defining MB_LEN_MAX here,
and include <limits.h> in curses_private.h to get it.
 1.73 15-Mar-2020  uwe __NEED_ERASE - don't shadow __LDATA::attr with macro parameter name.
 1.72 13-Mar-2020  roy curses: wrap the erase logic in a macro

Easier to use, it's in one place and now hopefully everyone is happy.

X
 1.71 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.70 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.69 01-Apr-2019  roy printw: rework vw_printw so it uses open_memstream rather than funopen2

This makes it more portable as open_memstream is POSIX and fixes a
potential issue with wide characters not fully being printed
due to any buffer overflow.
 1.68 16-Nov-2018  blymn Fix for PR lib/52063
Many thanks to Onno van der Linden (o.vd.linden@quicknet.nl) for providing
the bulk of the patch that fixes the issue.
 1.67 29-Oct-2018  uwe Make __CTRACE_init() static and ANSIfy its definition.
 1.66 04-Oct-2018  roy curses: declare SLK format as invalid until slk_init(3) called

If we don't, then when __slk_init with a valid format of 0 it sets
up labels to be drawn without a window.
 1.65 03-Oct-2018  roy curses: resize ripped off windows

The application must still redraw them though.
 1.64 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.63 27-Sep-2018  roy curses: unify resize handling in getch

Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
 1.62 31-Jan-2017  roy branches: 1.62.4; 1.62.10; 1.62.12;
Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.61 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.60 24-Jan-2017  roy Implement POSIX Curses Soft Label Key functions.
 1.59 11-Jan-2017  roy branches: 1.59.2;
Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.58 10-Jan-2017  roy Implement POSIX curses function ripoffline(3).
 1.57 06-Jan-2017  roy u_int -> unsigned int, u_int32_t -> uint32_t.
 1.56 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.55 03-Jan-2017  roy Support 256 colour terms.

From: rofl0r <retnyg@gmx.net>
 1.54 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.53 31-Dec-2016  roy Implement POSIX Curses typeahead function.
 1.52 30-Dec-2016  roy Add the POSIX filter() function to libcurses.
 1.51 23-Oct-2016  christos It is expensive to open and close files for every printf, keep it around.
 1.50 20-Feb-2014  blymn branches: 1.50.8;
Correct the implementation of mvderwin, it now works as specified by
SUSv2.
 1.49 09-Nov-2013  blymn Rename the old __waddbytes function to _cursesi_waddbytes and add a
parameter that controls whether or not certain characters in the
string are interpreted or not (things like tab being expanded).

Make __waddbytes a wrapper for _cursesi_waddbytes that passes all
parameters and sets the flag for character interpretation for backward
compatibility.

Fix an incipient bug in _cursesi_waddbytes where garbage would have
been written to the terminal if the terminal TABSIZE was set > 8 and
character interpretation is on.

Convert all internal __waddbytes calls to use _cursesi_waddbytes, fix
the function prototypes and add a new flag that will be used later.

Fix the addchstr family functions so that they call _cursesi_waddbytes
with character interpretation off as per SUSV2.
 1.48 16-Oct-2013  roy Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.47 04-Oct-2011  roy branches: 1.47.2; 1.47.8;
Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.46 16-Dec-2010  wiz Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
 1.45 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.44 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.43 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.42 14-Apr-2008  jdc Add FILEIO ctrace definition.
Remove unneeded function.
 1.41 08-Dec-2007  jdc Keep pushed-back characters locally. Fixes problems where KEY_* symbols
are pushed back. Should fix the arrow keys part of PR pkg/37173.

While we are here, make getch() and get_wch() check for resize immediately,
instead of reading a key, checking for resize and then having to push-back
the just read key.
 1.40 28-May-2007  blymn branches: 1.40.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.39 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.38 15-Jan-2006  jdc branches: 1.38.6;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.37 18-Feb-2005  dsl Change first arg of __hash_more to const void * to remove need for double casts
 1.36 28-Mar-2004  jdc branches: 1.36.4;
Changes to support *echochar().
Should fix PR lib/24927.
 1.35 22-Mar-2004  jdc Because we are changing the libcurses major number, remove can_change_colors()
and change the attribute definitions so that we can support more colour pairs.
 1.34 10-Aug-2003  dsl Revert most of rev 1.27 of addbytes.c and associated changes.
Posix requires that adding '\n' does clrtoeol() and 'x = 0'.
(Making "\r\n" erase the text that has just been displayed.)
Remove __NONL test from addbytes, __NONL is a property of the output device.
 1.33 31-Jul-2003  dsl Do something more sensible for waddbytes(..., "\r\n", ...);
I'm not sure about the clrtoeol() at all though - maybe it should
be done as part of scroll()?
Leave 'x' alone when __NONL set.
 1.32 30-Jul-2003  dsl Remove __winlistp, add *screen to WINDOW and initialise in newwin().
Make delwin() remove window from list of windows on its screen.
Free win->lspace and win->lines for subwins (they only share text space).
Free things in the correct (and same) order if malloc() fails in __makenew().
Adjust delscreen() for delwin() removing itself from winlist.
Fixes potential massive corruptions if delwin() called on a main window.
NB: not responsible for the sysinst core dumps :-(
 1.31 26-Jun-2003  dsl Stop refresh(subwin) doing refresh on the other subwin's created before it.
(If nothing else the cursor would get left in the wrong place).
Fix some if (!flags & MASK) checks.
 1.30 05-Apr-2003  jdc Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.

Fixes PR 20834 by Stephen Borrill.
 1.29 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.28 27-Jan-2003  jdc ARemove (no longer used) __nca.
 1.27 09-Jan-2003  blymn Added halfdelay() function.
 1.26 23-Dec-2002  jdc Changes for pad support - changed function signatures and _ISPAD flag.
 1.25 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.24 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.23 26-Jun-2002  itojun minor KNF (prototype decls should carry no variable name, otherwise macro
expansion will get you weird problem) and #define pedant (have paren).
 1.22 26-Jun-2002  itojun handle non-tty cases more gracefully.
 1.21 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.20 02-Jan-2002  blymn branches: 1.20.2;
Remove extraneous tabs from blank lines.
 1.19 31-Dec-2001  blymn fix __startwin() so it outputs the init strings to the correct device.
 1.18 11-Dec-2001  blymn * Remove termcap globals from public interface
* Clean up commented out code
 1.17 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.16 13-Jun-2001  wiz withough -> without
 1.15 21-Apr-2001  jdc Add missing prototypes.
Fixes PR lib/12714.
 1.14 20-Apr-2001  jdc Implement scrolling regions :
has_ic()
has_il()
setscrreg()
wsetscrreg()
 1.13 31-Dec-2000  jdc Libcurses-4.0
Removal of termcap capabilities requires major bump. Pointed out by Itojun.
Capabilities are still available if `_CURSES_TERMCAP_COMPAT' is defined.
 1.12 22-Dec-2000  jdc Revert the change to the `pc' capability from the previous change. Pointed
out in email by Thomas Dickey.
 1.11 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.10 20-May-2000  mycroft GC __FORCEPAINT.
 1.9 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.8 29-Apr-2000  mycroft Speed up refresh in the presence of attributes by precalculating a mask for
each `end' command to turn off other attributes in the case of conflicts.
 1.7 27-Apr-2000  jdc Add virtual screen for wnoutrefresh()/doupdate().
Add definition for __unsetattr().
 1.6 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.5 18-Apr-2000  jdc Add __TERMATTR definition. This makes the code in refresh.c much easier to
follow.
Add background character and attributes to line data.
 1.4 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.3 14-Apr-2000  jdc Add a list of windows (used when a colour pair changes).
 1.2 12-Apr-2000  jdc Private functions/variables moved from curses.h
Move character/attribute definitions to curses.h
 1.1 11-Apr-2000  blymn Made data structures opaque
 1.20.2.1 16-Jun-2003  grant Apply patch (requested by jdc in ticket #1244):

Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.
 1.36.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.38.6.5 28-Feb-2007  blymn Output the non-spacing characters to the screen.
 1.38.6.4 26-Feb-2007  blymn * commonalise adding a wide character so it can be reused
* make __waddbytes add wide characters if libcurses is built in wide
character mode.
* make waddch add wide characters if libcurses is built in wide character
mode.
 1.38.6.3 07-Feb-2007  blymn Add helper functions to deallocate non-spacing character storage.
 1.38.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.38.6.1 21-Jan-2007  blymn Wide curses merge
 1.40.4.1 09-Jan-2008  matt sync with HEAD
 1.47.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.47.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.50.8.3 20-Mar-2017  pgoyette Sync with HEAD
 1.50.8.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.50.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.59.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.62.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.62.12.1 10-Jun-2019  christos Sync with HEAD
 1.62.10.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.62.10.2 20-Oct-2018  pgoyette Sync with head
 1.62.10.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.62.4.3 08-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1048):

lib/libcurses/curses_private.h: revision 1.66
lib/libcurses/slk.c: revision 1.3
lib/libcurses/slk.c: revision 1.4

curses: declare SLK format as invalid until slk_init(3) called

If we don't, then when __slk_init with a valid format of 0 it sets
up labels to be drawn without a window.

-

curses: once __slk_init is called, reset slk_fmt

This allows soft label keys to be used on more than one terminal.
 1.62.4.2 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.62.4.1 27-Sep-2018  martin Pull up following revision(s) (requested by roy in ticket #1042):
lib/libcurses/getch.c: revision 1.68
lib/libcurses/getch.c: revision 1.69
lib/libcurses/get_wch.c: revision 1.17
lib/libcurses/get_wch.c: revision 1.18
lib/libcurses/curses_private.h: revision 1.63
curses: unify resize handling in getch
Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
curses: call resizeterm if getch issues KEY_RESIZE
This fixes PR #53633.
 1.81.2.1 02-Aug-2025  perseant Sync with HEAD
 1.14 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.13 05-Jan-2017  wiz branches: 1.13.26;
Whitespace.
 1.12 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.11 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.10 16-Apr-2003  wiz branches: 1.10.80;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 16-Apr-2003  wiz getch(3), not curses_getch(3). New sentence, new line.
 1.8 29-Mar-2003  jdc Now refresh() refreshes subwindows too.
Fixes PR lib/20544 by rtr.
 1.7 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.6 23-Dec-2002  wiz Sort SEE ALSO.
 1.5 23-Dec-2002  jdc Reference curses_pad(3).
 1.4 05-Dec-2002  jdc Correct cross references.
 1.3 22-Oct-2002  wiz Sort SEE ALSO.
 1.2 21-Oct-2002  wiz getch, not curses_getch.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.10.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.13.26.1 02-Aug-2025  perseant Sync with HEAD
 1.6 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.5 16-Apr-2003  wiz branches: 1.5.110;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.3 21-Oct-2002  wiz curses_scanw, not curses_scan.
 1.2 21-Oct-2002  wiz Merge two SEE ALSO sections.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.5.110.1 02-Aug-2025  perseant Sync with HEAD
 1.30 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.29 17-May-2024  uwe branches: 1.29.2;
curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@
 1.28 07-Feb-2021  rillig curses_screen.3: fix typo
 1.27 06-Feb-2021  rillig libncurses: fix grammar in manual page
 1.26 12-Mar-2020  roy curses: note the change in initscr in our fine man page.
 1.25 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.24 28-Sep-2018  kamil Fix typos in curses_screen.3

Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.23 24-Jan-2017  roy branches: 1.23.4; 1.23.10; 1.23.12;
Note an issue with our cursor movement in 1 line size window.
 1.22 10-Jan-2017  roy branches: 1.22.2;
Implement POSIX curses function ripoffline(3).
 1.21 05-Jan-2017  roy Implement is_term_resized and resize_term(3) ncurses extensions.
resizeterm(3) is now a wrapper for resize_term(3).
 1.20 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.19 05-Jan-2017  wiz Fix typo.
 1.18 05-Jan-2017  wiz Use Ev for environment variables.
 1.17 31-Dec-2016  roy Implement POSIX curses use_env function.
 1.16 30-Dec-2016  roy Add the POSIX filter() function to libcurses.
 1.15 21-Apr-2012  roy branches: 1.15.14;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.14 25-Oct-2007  jdc branches: 1.14.28;
Only resize curscr, __virtscr and stdscr when the screen is resized.

Note the behaviour of sub-windows when the parent window is resized.

Fixes PR pkg/37129.
 1.13 13-Jul-2007  jdc branches: 1.13.4;
Emphasise `ncurses'.
 1.12 22-Mar-2004  wiz No comma in an enumeration of only two elements.
 1.11 22-Mar-2004  jdc Add KEY_RESIZE support and a SIGWINCH handler.
Fixes PR bin/20032.
This requires a change to KEY_MAX, which affects libform and libmenu, so we
need to change libcurses major number.
 1.10 16-Mar-2004  snj Spelling fixes.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 11-Apr-2003  jdc Add spacing around variable definitions.
From a discussion with Thomas Klausner.
 1.7 08-Apr-2003  wiz Improve mdoc a bit.
 1.6 08-Apr-2003  jdc Document LINES and COLS environment variables.
 1.5 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.4 15-Jan-2003  kristerw Correct return type for initscr().
From Joel Wilsson in PR 19809.
 1.3 05-Dec-2002  jdc Correct cross references.
 1.2 21-Oct-2002  grant New sentence, new line.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.13.4.1 06-Nov-2007  matt sync with HEAD
 1.14.28.1 23-May-2012  yamt sync with head.
 1.15.14.2 20-Mar-2017  pgoyette Sync with HEAD
 1.15.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.23.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.23.12.1 10-Jun-2019  christos Sync with HEAD
 1.23.10.2 20-Oct-2018  pgoyette Sync with head
 1.23.10.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.23.4.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.29.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.6 01-Jan-2025  jnemeth - s/setscrreg/getscrreg/ for new getscrreg function
- while here, bump date for new functions
 1.5 05-Dec-2024  blymn Fixes PR lib/58823

Implement the ncurses extension wgetscrreg which returns the
scrolling region of the given window. Also implement getscrreg to
get the scrolling region of stdscr which appears to be missing from
ncurses but does follow the convention of having a non w prefixed
function that applies to stdscr.

Due to the addtion of a new function a minor library version bump has
been done.
 1.4 16-Apr-2003  wiz branches: 1.4.110;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.110.1 02-Aug-2025  perseant Sync with HEAD
 1.3 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.2 29-Sep-2018  kamil branches: 1.2.12;
Fix the documented function prototype of slk_attr_set(3)

Note the missing argument short pair.
 1.1 24-Jan-2017  roy branches: 1.1.2; 1.1.4; 1.1.14; 1.1.16;
Implement POSIX Curses Soft Label Key functions.
 1.1.16.1 10-Jun-2019  christos Sync with HEAD
 1.1.14.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.1.4.2 21-Apr-2017  bouyer Sync with HEAD
 1.1.4.1 24-Jan-2017  bouyer file curses_slk.3 was added on branch bouyer-socketcan on 2017-04-21 16:53:10 +0000
 1.1.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.2.1 24-Jan-2017  pgoyette file curses_slk.3 was added on branch pgoyette-localcount on 2017-03-20 06:56:59 +0000
 1.2.12.1 02-Aug-2025  perseant Sync with HEAD
 1.11 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.10 03-Aug-2021  nia branches: 1.10.4;
curses: clarify standout as the "best" _supported_ highlighting mode
of the current terminal
 1.9 02-Aug-2021  nia curses: clarify documentation regarding the standout attribute
 1.8 26-Jul-2021  nia The BUGS sections is incorrect again for "modern" terminals.

For example, wscons and xterm both display standout differently to bold.
 1.7 29-Nov-2016  christos PR/51673: Carsten Kunze: curses: standend() does not turn off A_BOLD;
according the X/Open it needs to turn off all attributes.
 1.6 02-May-2012  agc branches: 1.6.14;
re-work the previous to make it format correctly
 1.5 01-May-2012  agc document the correct argument to wstandout(3) and wstandend(3)
 1.4 30-Apr-2008  martin branches: 1.4.4;
Convert TNF licenses to new 2 clause variant
 1.3 16-Apr-2003  wiz branches: 1.3.32;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.3.32.1 18-May-2008  yamt sync with head.
 1.4.4.1 23-May-2012  yamt sync with head.
 1.6.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 14-May-2024  uwe curses_termcap(3): fullname() termbuf argument is const
 1.6 21-Apr-2012  roy Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.5 04-Oct-2011  roy branches: 1.5.2;
Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.4 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.2 21-Oct-2002  wiz Sort SECTIONS.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.5.2.1 23-May-2012  yamt sync with head.
 1.10 08-Feb-2018  dholland Typos.
 1.9 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.8 24-Feb-2010  drochner branches: 1.8.28;
document wsyncup/wsyncdown/wcursyncup
 1.7 04-Mar-2005  wiz Bump date for touchline() correction, and drop trailing whitespace.
 1.6 04-Mar-2005  blymn Fixed incorrect documentation of the touchln() function. (thanks Wiz)
 1.5 16-Mar-2004  snj branches: 1.5.4;
Spelling fix.
 1.4 05-Oct-2003  jdc Add redrawwin() and wredrawln().
Fixes PR lib/20038.
 1.3 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.2 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.5.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.8.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15 11-Apr-2025  uwe curses_tty(3): tweak markup a bit
 1.14 18-Sep-2017  wiz branches: 1.14.16;
Use Dv for non-errno return values (instead of Er).
 1.13 17-Sep-2017  abhinav Fix typo
 1.12 17-Feb-2017  roy Note that typeahead(3) is no longer set to infd by default.
 1.11 25-Jan-2017  roy Document baudrate(3).
 1.10 31-Dec-2016  roy branches: 1.10.2;
Implement POSIX Curses typeahead function.
 1.9 29-Dec-2016  wiz Fix some prototypes.
 1.8 16-Mar-2004  snj branches: 1.8.80;
Spelling fixes.
 1.7 27-Jun-2003  wiz Fix typo in macro name, and remove a trailing comma.
 1.6 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.5 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.4 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.3 09-Jan-2003  wiz Bump date for halfdelay, and slightly improve wording.
 1.2 09-Jan-2003  blymn Added halfdelay() function.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.8.80.2 20-Mar-2017  pgoyette Sync with HEAD
 1.8.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.14.16.1 02-Aug-2025  perseant Sync with HEAD
 1.7 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.6 29-Sep-2018  kamil branches: 1.6.12;
Fix function prototypes in curses_underscore.3

Correct function prototype of wunderscore(3) and wunderend(3).
 1.5 30-Apr-2008  martin branches: 1.5.60; 1.5.62;
Convert TNF licenses to new 2 clause variant
 1.4 16-Apr-2003  wiz branches: 1.4.32;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.3 21-Oct-2002  wiz Punctuation fixes.
 1.2 21-Oct-2002  wiz Drop trailing whitespace.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.4.32.1 18-May-2008  yamt sync with head.
 1.5.62.1 10-Jun-2019  christos Sync with HEAD
 1.5.60.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.6.12.1 02-Aug-2025  perseant Sync with HEAD
 1.1 02-Sep-2019  roy branches: 1.1.4;
curses(3): add curses_version()

Returns NetBSD-Curses %s
Where %s is the NetBSD version taken from sys/param.h

Discussed on tech-net@, only for ncurses compat.
 1.1.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.1 02-Sep-2019  martin file curses_version.3 was added on branch phil-wifi on 2020-04-13 08:03:12 +0000
 1.18 11-Apr-2025  uwe curses: use .Va stdscr in manpages
 1.17 13-Oct-2024  rillig lib: sync some manual pages with reality
 1.16 15-Oct-2013  roy branches: 1.16.38;
Note that delwin(3) is a null-op if win is NULL.
 1.15 15-Sep-2011  wiz branches: 1.15.2; 1.15.8;
Remove trailing whitespace. Bump date for previous.
 1.14 15-Sep-2011  blymn - Make mvderwin work as per the SUSv2 specification and other curses
implementations.
 1.13 18-May-2009  wiz Sort SEE ALSO. New sentence, new line.
 1.12 14-Apr-2008  jdc Cross reference curses_fileio(3).
Bump date.
 1.11 25-Oct-2007  jdc Only resize curscr, __virtscr and stdscr when the screen is resized.

Note the behaviour of sub-windows when the parent window is resized.

Fixes PR pkg/37129.
 1.10 15-Jan-2006  jdc branches: 1.10.12;
Note that subwindows inherit the background character and attributes
of the parent window.
 1.9 22-Mar-2004  jdc "New sentence, new line".
 1.8 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.7 08-Apr-2003  jdc Document mvwin().
Fixes PR 21041 by Tyler Retzlaff.
 1.6 17-Mar-2003  wiz Fix typo.
 1.5 03-Mar-2003  dsl Describe use of -ve window sizes
 1.4 14-Feb-2003  grant 'NetBSD.org' and some mdoc fixes.
 1.3 23-Dec-2002  jdc Reference curses_pad(3).
 1.2 21-Oct-2002  wiz Punctuation fixes.
 1.1 21-Oct-2002  blymn Added separate man pages for curses functions to provide better
documentation of the curses functions.
 1.10.12.1 06-Nov-2007  matt sync with HEAD
 1.15.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.38.1 02-Aug-2025  perseant Sync with HEAD
 1.2 03-Sep-2019  roy curses: believe in unicorns

Hopefully this ends the bikeshed.
If you don't believe in unicorns, please #if 0 it out to preserve
the humour.
 1.1 03-Sep-2019  roy curses: Add __NetBSD_Curses_Version__

Similar to __NetBSD_Version__ from sys/param.h but has no
correlation to it or the ELF symver libcurses is built as.

If we say that v1 was everything prior to this, it makes sense to
start this from v2.
 1.31 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.30 19-Oct-2022  blymn branches: 1.30.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.29 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.28 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.27 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.26 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.25 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.24 06-Jan-2017  roy branches: 1.24.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.23 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.22 22-Jul-2009  roy branches: 1.22.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.21 06-Oct-2007  martin Make the non-WCHAR variant compilable.
 1.20 28-May-2007  blymn branches: 1.20.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.19 05-Feb-2006  jdc branches: 1.19.6;
Handle both background character and background attribute.
 1.18 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.17 20-Jan-2004  wiz Fix recurring typo in comments. From Douwe Kiela.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 20-Apr-2001  jdc Make comments match reality (delete-char instead of insert-char).
 1.14 20-May-2000  mycroft GC __FORCEPAINT.
 1.13 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file delch.c was added on branch netbsd-1-0 on 1994-08-17 21:52:12 +0000
 1.19.6.4 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.19.6.3 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.19.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.19.6.1 21-Jan-2007  blymn Wide curses merge
 1.20.4.1 06-Nov-2007  matt sync with HEAD
 1.22.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.14.1 10-Jun-2019  christos Sync with HEAD
 1.30.4.1 02-Aug-2025  perseant Sync with HEAD
 1.15 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.14 07-Aug-2003  agc branches: 1.14.80;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.12 11-Apr-2000  blymn Made data structures opaque
 1.11 17-Sep-1999  simonb branches: 1.11.6;
Include current line number in CTRACE of line being deleted.
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file deleteln.c was added on branch netbsd-1-0 on 1994-08-17 21:52:13 +0000
 1.11.6.2 05-Mar-2000  jdc Now uses insdelln().
 1.11.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.14.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.21 01-Apr-2019  roy printw: rework vw_printw so it uses open_memstream rather than funopen2

This makes it more portable as open_memstream is POSIX and fixes a
potential issue with wide characters not fully being printed
due to any buffer overflow.
 1.20 06-Jan-2017  roy branches: 1.20.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.19 23-Oct-2016  christos It is expensive to open and close files for every printf, keep it around.
 1.18 15-Oct-2013  roy branches: 1.18.8;
Note that delwin(3) is a null-op if win is NULL.
 1.17 22-Jul-2009  roy branches: 1.17.6; 1.17.12;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.16 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.15 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.14 23-Aug-2006  jdc branches: 1.14.4;
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.13 07-Aug-2003  agc branches: 1.13.6; 1.13.12;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 30-Jul-2003  dsl Remove __winlistp, add *screen to WINDOW and initialise in newwin().
Make delwin() remove window from list of windows on its screen.
Free win->lspace and win->lines for subwins (they only share text space).
Free things in the correct (and same) order if malloc() fails in __makenew().
Adjust delscreen() for delwin() removing itself from winlist.
Fixes potential massive corruptions if delwin() called on a main window.
NB: not responsible for the sysinst core dumps :-(
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file delwin.c was added on branch netbsd-1-0 on 1994-08-17 21:52:15 +0000
 1.13.12.1 25-Aug-2006  ghen Pull up following revision(s) (requested by jdc in ticket #54):
lib/libcurses/color.c: revision 1.31
lib/libcurses/screen.c: revision 1.18
lib/libcurses/delwin.c: revision 1.14
Make sure we update the correct window when changing colour pairs.
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.13.6.1 25-Aug-2006  ghen Pull up following revision(s) (requested by jdc in ticket #1475):
lib/libcurses/color.c: revision 1.31
lib/libcurses/screen.c: revision 1.18
lib/libcurses/delwin.c: revision 1.14
Make sure we update the correct window when changing colour pairs.
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.14.4.2 07-Feb-2007  blymn Plug memory leak - non-spacing character storage was not being deleted.
 1.14.4.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.17.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18.8.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.20.14.1 10-Jun-2019  christos Sync with HEAD
 1.3 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.2 28-May-2007  blymn branches: 1.2.74; 1.2.76;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.2.76.1 10-Jun-2019  christos Sync with HEAD
 1.2.74.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.2 29-Apr-2008  martin Convert to new 2 clause license
 1.1 28-Mar-2004  jdc branches: 1.1.32;
Implement *echochar().
Should fix PR lib/24927.
 1.1.32.1 18-May-2008  yamt sync with head.
 1.3 07-Aug-1993  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.38 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.37 19-Oct-2022  blymn branches: 1.37.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.36 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.35 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.34 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.33 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.32 15-Mar-2020  uwe werase, wclrtobot, wclrtoeol - make code even more similar.
Rename attr to battr to match bch and WINDOW::battr.
No functional change intended.
 1.31 13-Mar-2020  roy curses: wrap the erase logic in a macro

Easier to use, it's in one place and now hopefully everyone is happy.

X
 1.30 12-Mar-2020  roy curses: normalise erase logic with clrtoeol and clrtobot

Define WA_ATTRIBUTES as 0 for the non wide case just to make our code
easier to write.
 1.29 11-Mar-2020  roy curses: Fix werase(3) wide character support

We need to consider erasing all attributes, not just WA_ATTRIBUTES.
Fixes PR lib/23910.

While here, make the function a little more readable.
 1.28 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.27 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.26 06-Jan-2017  roy branches: 1.26.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.25 10-Jul-2011  blymn branches: 1.25.24;
Set the background attributes when erasing.
 1.24 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.23 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.22 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.21 05-Feb-2006  jdc branches: 1.21.6;
Handle both background character and background attribute.
 1.20 26-Jan-2006  jdc Use the window background colour, not the default colour.
Should fix PR install/32617
 1.19 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.18 27-Jul-2005  jdc Make sure that werase() always marks the window as dirty. This fixes a
problem (reported by David Bariod on netbsd-help), where erasing an already
blank window would not clear the screen contents of overlapping windows.
 1.17 07-Aug-2003  agc branches: 1.17.4; 1.17.6;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.15 20-May-2000  mycroft GC __FORCEPAINT.
 1.14 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.13 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.12 11-Apr-2000  blymn Made data structures opaque
 1.11 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 22-Jul-1997  mikel RCSid police, fix warnings
 1.8 22-May-1997  kleink As per PSD:19, section 8, move to (0,0) when clearing/erasing a window.
From Peter Seebach <seebs@solon.com> in PRs lib/2094 and lib/3648.
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file erase.c was added on branch netbsd-1-0 on 1994-08-17 21:52:16 +0000
 1.17.6.1 30-Jul-2005  tron Pull up revision 1.18 (requested by jdc in ticket #628):
Make sure that werase() always marks the window as dirty. This fixes a
problem (reported by David Bariod on netbsd-help), where erasing an already
blank window would not clear the screen contents of overlapping windows.
 1.17.4.1 07-Aug-2005  riz Pull up revision 1.18 (requested by jdc in ticket #5537):
Make sure that werase() always marks the window as dirty. This fixes a
problem (reported by David Bariod on netbsd-help), where erasing an already
blank window would not clear the screen contents of overlapping windows.
 1.21.6.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.21.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.21.6.1 21-Jan-2007  blymn Wide curses merge
 1.25.24.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.26.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.26.14.1 10-Jun-2019  christos Sync with HEAD
 1.37.4.1 02-Aug-2025  perseant Sync with HEAD
 1.10 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.9 07-Sep-2021  rin branches: 1.9.4;
Do not compile in whole fileio.c for LIBHACK.

Fix build failure when built as libhack, due to missing fileio.h.

IMO, this should be cleaner than generating fileio.h for {get,put}win(3),
that are useless for install media.
 1.8 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.7 24-Feb-2020  rin 0x%p --> %p for non-external codes.
 1.6 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.5 22-Oct-2016  christos branches: 1.5.6; 1.5.12; 1.5.14;
remove bogus malloc casts
 1.4 22-Jul-2009  roy branches: 1.4.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.3 24-May-2008  christos Coverity CID 5024: Fix double free on error path.
 1.2 02-May-2008  martin branches: 1.2.2;
Move to 2 clause TNF license (was: strange 3 clause version)
 1.1 14-Apr-2008  jdc branches: 1.1.2;
File IO functions getwin() and putwin().
Should fix PR lib/24928.
 1.1.2.2 04-Jun-2008  yamt sync with head
 1.1.2.1 18-May-2008  yamt sync with head.
 1.2.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.28.1 04-Nov-2016  pgoyette Sync with HEAD
 1.5.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.14.1 10-Jun-2019  christos Sync with HEAD
 1.5.12.1 20-Oct-2018  pgoyette Sync with head
 1.5.6.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.9.4.1 02-Aug-2025  perseant Sync with HEAD
 1.8 06-Sep-2021  rin Always autogen fileio.h.

Bump CURSES_LIB_MAJOR.CURSES_LIB_MINOR to 9.0 belatedly.
 1.7 30-Jun-2019  blymn Fix return for mvscanw to return ERR/OK instead of the number of
elements scanned, now matches SUSv2 specification

Bump lib major due to return change.
 1.6 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.5 16-Nov-2018  blymn Fix for PR lib/52063
Many thanks to Onno van der Linden (o.vd.linden@quicknet.nl) for providing
the bulk of the patch that fixes the issue.
 1.4 02-Jan-2017  roy branches: 1.4.12; 1.4.14;
Bump libcurses to 7.1 for prior additions.
 1.3 22-Oct-2016  christos remove bogus malloc casts
 1.2 06-Apr-2009  christos branches: 1.2.28;
regen
 1.1 14-Apr-2008  jdc branches: 1.1.10;
File IO functions header file.
 1.1.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.2.28.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.28.1 04-Nov-2016  pgoyette Sync with HEAD
 1.4.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.14.1 10-Jun-2019  christos Sync with HEAD
 1.4.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.7 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.6 06-Jan-2017  roy branches: 1.6.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.5 28-Apr-2008  martin branches: 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 24-Apr-2000  blymn branches: 1.4.38;
* Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 09-Jan-2000  jdc branches: 1.1.2;
file flushok.c was initially added on branch curses-v3.
 1.1.2.1 09-Jan-2000  jdc New files for SUS v2 curses:
Move macros from curses.h
Add prototype for wchar_t
 1.4.38.1 18-May-2008  yamt sync with head.
 1.5.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.26.1 02-Aug-2025  perseant Sync with HEAD
 1.12 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.11 07-Aug-2003  agc branches: 1.11.80;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file fullname.c was added on branch netbsd-1-0 on 1994-08-17 21:52:17 +0000
 1.11.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2 02-May-2008  martin Move to 2 clause TNF license (was: strange 3 clause version)
 1.1 14-Apr-2008  jdc branches: 1.1.2;
Header (fileio.h) generation script for file IO functions.
 1.1.2.1 18-May-2008  yamt sync with head.
 1.28 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.27 24-Aug-2024  christos Check for returning ERR to avoid negative array index later (CID-1617248)
 1.26 06-Sep-2021  rin branches: 1.26.2; 1.26.4;
Style fixes most for __CTRACE().
 1.25 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.24 06-Jul-2020  uwe Pads are not to be automatically refreshed on input.

X/Open Curses says in the documentation for newpad():

Automatic refreshes of pads (e.g., from scrolling or echoing of
input) do not occur.

And in the documentation for get*():

If the current or specified window is not a pad, and it has been
moved or modified since the last refresh operation, then it will be
refreshed before another character is read.

From Michael Forney in PR lib/55457
 1.23 09-Jun-2019  blymn branches: 1.23.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.22 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.21 14-Mar-2019  rin Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
 1.20 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.19 28-Sep-2018  roy curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@
 1.18 27-Sep-2018  roy curses: call resizeterm if getch issues KEY_RESIZE

This fixes PR #53633.
 1.17 27-Sep-2018  roy curses: unify resize handling in getch

Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
 1.16 26-Sep-2018  kamil Correct detecting of terminal resize in curses(3) with keypad(,TRUE)

A previous change fixed only keypad(,FALSE) scenarios.

Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.

PR lib/53615
 1.15 18-Sep-2018  rin PR lib/53615

getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWINCH.

OK roy
 1.14 31-Jan-2017  roy branches: 1.14.4; 1.14.10; 1.14.12;
Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.13 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.12 06-Jan-2017  roy branches: 1.12.2;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.11 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.10 29-Jun-2012  blymn branches: 1.10.10; 1.10.14;
* Size argument for memset when clearing cbuf was wrong, cbuf is an array
of char not int so memset was stomping memory past the end of the array.
Use sizeof properly to correctly determine the amount of memory to clear.
 1.9 16-Dec-2010  wiz branches: 1.9.6; 1.9.8;
Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
 1.8 04-Nov-2009  dsl Read input from the correct FILE.
 1.7 01-Nov-2009  dsl Move calls to __restore_termios() into the failing path of the functions
that fail - instead of in most of the callers.
All rather pointless if tcsetattr() fails to set the mode we want we
are very unlikely to be able to restore any later on.
 1.6 14-Apr-2008  jdc branches: 1.6.8;
Make this compile when HAVE_WCHAR is not defined.
 1.5 08-Dec-2007  jdc Keep pushed-back characters locally. Fixes problems where KEY_* symbols
are pushed back. Should fix the arrow keys part of PR pkg/37173.

While we are here, make getch() and get_wch() check for resize immediately,
instead of reading a key, checking for resize and then having to push-back
the just read key.
 1.4 18-Nov-2007  jdc We don't need to call __init_getch here, as it is called from
screen.c:newterm().
 1.3 29-May-2007  blymn branches: 1.3.4;
Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.4 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.1.2.3 21-Jan-2007  jdc Add a cast (mlen should fit in long here).
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.4.1 09-Jan-2008  matt sync with HEAD
 1.6.8.1 30-Sep-2012  bouyer Pull up following revision(s) (requested by blymn in ticket #1791):
lib/libcurses/get_wch.c: revision 1.10
* Size argument for memset when clearing cbuf was wrong, cbuf is an array
of char not int so memset was stomping memory past the end of the array.
Use sizeof properly to correctly determine the amount of memory to clear.
 1.9.8.1 09-Aug-2012  jdc Pull up revisions:
src/lib/libcurses/get_wch.c revision 1.10
src/lib/libmenu/internals.c revisions 1.14,1.15
(requested by blymn in ticket #459).

* Size argument for memset when clearing cbuf was wrong, cbuf is an array
of char not int so memset was stomping memory past the end of the array.
Use sizeof properly to correctly determine the amount of memory to clear.

Extraneous whitespace removal.

* Corrected menu drawing when O_ROWMAJOR is not set
* Corrected menu item neighbour calculation so it works when O_ROWMAJOR
is set and unset. This corrects item navigation which was previously
broken when O_ROWMAJOR was not set.

This resolves lib/46620.
 1.9.6.1 30-Oct-2012  yamt sync with head
 1.10.14.2 20-Mar-2017  pgoyette Sync with HEAD
 1.10.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.10.1 15-Mar-2019  martin Pull up following revision(s) (requested by rin in ticket #1686):

lib/libcurses/get_wch.c: revision 1.21
lib/libcurses/getch.c: revision 1.71

Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
 1.12.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.14.12.1 10-Jun-2019  christos Sync with HEAD
 1.14.10.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.14.10.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.14.4.4 15-Mar-2019  martin Pull up following revision(s) (requested by rin in ticket #1214):

lib/libcurses/get_wch.c: revision 1.21
lib/libcurses/getch.c: revision 1.71

Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
 1.14.4.3 03-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1043):

lib/libcurses/resize.c: revision 1.27
lib/libcurses/get_wch.c: revision 1.19
lib/libcurses/getch.c: revision 1.70

curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@
 1.14.4.2 27-Sep-2018  martin Pull up following revision(s) (requested by roy in ticket #1042):
lib/libcurses/getch.c: revision 1.68
lib/libcurses/getch.c: revision 1.69
lib/libcurses/get_wch.c: revision 1.17
lib/libcurses/get_wch.c: revision 1.18
lib/libcurses/curses_private.h: revision 1.63
curses: unify resize handling in getch
Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
curses: call resizeterm if getch issues KEY_RESIZE
This fixes PR #53633.
 1.14.4.1 27-Sep-2018  martin Pull up following revision(s) (requested by kamil in ticket #1039):

lib/libcurses/getch.c: revision 1.66
lib/libcurses/getch.c: revision 1.67
lib/libcurses/tstp.c: revision 1.43
lib/libcurses/get_wch.c: revision 1.15
lib/libcurses/get_wch.c: revision 1.16

PR lib/53615
getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWIN=
CH.

OK roy

-

PR lib/53615
Before invoking a previous signal handler, make sure it is not SIG_*.
Fix potential crash with SIGWINCH.

OK roy

-

Correct detecting of terminal resize in curses(3) with keypad(,TRUE)
A previous change fixed only keypad(,FALSE) scenarios.

-

Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.

PR lib/53615
 1.23.2.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #987):

lib/libcurses/get_wch.c: revision 1.24
lib/libcurses/getch.c: revision 1.75

Pads are not to be automatically refreshed on input.

X/Open Curses says in the documentation for newpad():
Automatic refreshes of pads (e.g., from scrolling or echoing of
input) do not occur.

And in the documentation for get*():
If the current or specified window is not a pad, and it has been
moved or modified since the last refresh operation, then it will be
refreshed before another character is read.

From Michael Forney in PR lib/55457
 1.26.4.1 02-Aug-2025  perseant Sync with HEAD
 1.26.2.1 13-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #855):

lib/libcurses/get_wch.c: revision 1.27

Check for returning ERR to avoid negative array index later (CID-1617248)
 1.12 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.11 12-Apr-2022  blymn branches: 1.11.4;
Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.10 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.9 15-Aug-2021  rillig libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed. Removing the extra semicolon fixes the lint
warnings about empty declarations. These empty declarations are a GCC
extension.
 1.8 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.7 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.6 24-Feb-2019  roy Fix warn macro usage.

Thanks to rofl0r.
 1.5 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.4 06-Jan-2017  roy branches: 1.4.12; 1.4.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.3 14-Apr-2008  jdc branches: 1.3.46;
Make this compile when HAVE_WCHAR is not defined.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.46.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.14.1 10-Jun-2019  christos Sync with HEAD
 1.4.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.11.4.1 02-Aug-2025  perseant Sync with HEAD
 1.79 14-May-2024  uwe curse: constify define_key() argument

define_key() is ncurses extension and ncurses defines its first
argument as "const char *". Follow suit.

PR lib/58254
 1.78 19-Oct-2021  blymn Fix for PR pkg/55931
Don't move the cursor when getch is called if input is not going to
be echoed. Lynx uses the cursor to mark the current selection in a
pop-up, previously the cursor was being relocated when getch was called
which broke the Lynx item marking.
 1.77 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.76 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.75 06-Jul-2020  uwe Pads are not to be automatically refreshed on input.

X/Open Curses says in the documentation for newpad():

Automatic refreshes of pads (e.g., from scrolling or echoing of
input) do not occur.

And in the documentation for get*():

If the current or specified window is not a pad, and it has been
moved or modified since the last refresh operation, then it will be
refreshed before another character is read.

From Michael Forney in PR lib/55457
 1.74 14-May-2020  simonb KNF nit.
 1.73 09-Jun-2019  blymn branches: 1.73.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.72 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.71 14-Mar-2019  rin Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
 1.70 28-Sep-2018  roy curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@
 1.69 27-Sep-2018  roy curses: call resizeterm if getch issues KEY_RESIZE

This fixes PR #53633.
 1.68 27-Sep-2018  roy curses: unify resize handling in getch

Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
 1.67 26-Sep-2018  kamil Correct detecting of terminal resize in curses(3) with keypad(,TRUE)

A previous change fixed only keypad(,FALSE) scenarios.

Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.

PR lib/53615
 1.66 18-Sep-2018  rin PR lib/53615

getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWINCH.

OK roy
 1.65 31-Jan-2017  roy branches: 1.65.4; 1.65.10; 1.65.12;
Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.64 30-Jan-2017  roy Check _cursesi_term is set in a few places and sprinkle some static.
 1.63 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.62 06-Jan-2017  roy branches: 1.62.2;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.61 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.60 01-Jan-2017  roy Implement ncurses extension has_key.
 1.59 21-Apr-2012  roy branches: 1.59.10; 1.59.14;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.58 21-Apr-2011  blymn branches: 1.58.4;
Fix deleting a key definition, it did not work. Also improve tracing
of key definition deletion.
 1.57 07-Dec-2010  joerg Since limit and l are both unsigned, comparing to 0 doesn't work, so compare
the values directly.
 1.56 05-Nov-2010  blymn Don't echo key symbols.
 1.55 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.54 04-Nov-2009  dsl Read input from the correct FILE.
 1.53 01-Nov-2009  dsl Move calls to __restore_termios() into the failing path of the functions
that fail - instead of in most of the callers.
All rather pointless if tcsetattr() fails to set the mode we want we
are very unlikely to be able to restore any later on.
 1.52 09-Feb-2009  jdc Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.
 1.51 14-Apr-2008  jdc branches: 1.51.8; 1.51.10;
Add extra debugging information.
 1.50 08-Dec-2007  jdc Keep pushed-back characters locally. Fixes problems where KEY_* symbols
are pushed back. Should fix the arrow keys part of PR pkg/37173.

While we are here, make getch() and get_wch() check for resize immediately,
instead of reading a key, checking for resize and then having to push-back
the just read key.
 1.49 28-Aug-2007  blymn Fix a crash caused by having a single NULL character as a string capability.
This fix is about the best we can do given the current interfaces. We
could extend the cgetcap(3) interfaces with a function that would return
a character count and handle this in libterm which would provide a more
complete fix and allow a NULL character in a string capability.
 1.48 28-May-2007  blymn branches: 1.48.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.47 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.46 25-Jul-2006  christos branches: 1.46.6;
PR/34011: Julian Coleman: Limit timeout to 25.5 seconds.
 1.45 19-Mar-2006  christos Coverity CID 1246: Don't allow getc == -1 to propagate as an array index.
 1.44 22-Mar-2004  jdc Add KEY_RESIZE support and a SIGWINCH handler.
Fixes PR bin/20032.
This requires a change to KEY_MAX, which affects libform and libmenu, so we
need to change libcurses major number.
 1.43 16-Mar-2004  jdc Minor style change.
 1.42 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.41 08-Apr-2003  jdc Add ESCDELAY variable to control the inter-key delay in escape sequences.
Fixes PR 20031 by Thomas Klausner.
 1.40 05-Apr-2003  jdc Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.

Fixes PR 20834 by Stephen Borrill.
 1.39 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.38 23-Dec-2002  jdc Increase default delay when assembling key sequences. This seems to
eliminate the occasional non-recognition of key sequences over remote
connections.
Okayed by blymn.
 1.37 22-Oct-2002  blymn Added the ncurses extensions define_key and keyok.
 1.36 02-Jan-2002  blymn branches: 1.36.2;
Remove extraneous tabs from blank lines.
 1.35 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.34 01-Nov-2001  tron Remove bogus call to free(3) which caused several warning messages in
application using our "curses" library after the latest change to
memory management in the "c" library.
 1.33 10-Jan-2001  blymn Fixed casting bug in array indexing, a signed char was being sign
extended when cast to unsigned, made the cast "unsigned char"
 1.32 23-Sep-2000  itojun do not call wrefresh() uncondintionally from wgetch(). call it only
when the window was touched (is_wintouched()).
the previous behavior damaged existing applications, especially when it issues
lots of subwindow manipulation and mvcur().

it was introduced in 1.23 -> 1.24 or sometime before.
 1.31 31-Jul-2000  itojun free region got from t_getstr(). we will experience memory leak if
we call initscr() multiple times (rare, but it's better to be pedant).
 1.30 31-Jul-2000  itojun fix 8bit cleanness of getch() and wgetch(). never use char variable against
stdio functions which return "int" (including getchar()).
the bug was introduced in 1.9 -> 1.10. fixes PR10723.
 1.29 25-May-2000  jdc branches: 1.29.4;
Send 'ks' sequence from first call to keypad(win, TRUE) only and not from
wgetch(). Don't send 'ke' sequence from keypad(win, FALSE) or wgetch().
This makes us compatible with Solaris.
Suggested by ITOH Yasufumi.
 1.28 17-May-2000  jdc Send, if necessary, 'ks' or 'ke' sequences from keypad() and wgetch().
Fixes PR 10116.
 1.27 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.26 27-Apr-2000  mycroft No, really, make sure ECHO is cleared in cbreak() mode too.
 1.25 27-Apr-2000  jdc Add extra KEY_* definitions (from SUSv2).
Fix `gcc -Wuninitialized`.
 1.24 23-Apr-2000  blymn * Fixed bug in copywin which was copying more than it should.
* Changed call to wrefresh in wgetch to be before input read.
* Changed default old cursor mode to be high vis in curs_set
* Added documentation for various new functions to fns.doc.
 1.23 22-Apr-2000  thorpej Fully initialize the structure allocated in new_keymap().
 1.22 22-Apr-2000  blymn * Added ungetch
* Converted inkey and getch to use getchar instead of read so ungetch
will work.
 1.21 18-Apr-2000  jdc Make sure we don't read a negative character value (again).
 1.20 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.19 15-Apr-2000  jdc Add a missing __restore_termios() in an error return.
Don't display the character on curscr if the terminal has echo on :
- doing so will break the tracking of curscr->cury|x if we've just refreshed
a non-fullscreen window
- with echo on, the terminal displays the character for us anyway
 1.18 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.17 12-Apr-2000  jdc Make sure we don't read a negative character value.
 1.16 11-Apr-2000  blymn Made data structures opaque
 1.15 07-Dec-1999  simonb branches: 1.15.2;
Only unctrl() the first 256 input values.

This and the previous curses patches were from Brett Lymn.
 1.14 28-Jun-1999  simonb branches: 1.14.4;
Get rid of the evil trailing spaces and tabs.
 1.13 15-Jun-1999  simonb Make a few private variables and functions static.
 1.12 06-Jun-1999  pk Re-arrange some code to approach our regular style.
 1.11 06-Jun-1999  pk Hang on to the termcap buffer that we have tgetent() fill.
(someone ows me two hours worth of beer for this... :-)
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file getch.c was added on branch netbsd-1-0 on 1994-08-17 21:52:18 +0000
 1.14.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.15.2.2 27-Mar-2000  jdc Handle characters with top bit set.
 1.15.2.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.29.4.3 29-Sep-2000  itojun pullup 1.31 -> 1.32 (approved by releng-1-5)

>do not call wrefresh() uncondintionally from wgetch(). call it only
>when the window was touched (is_wintouched()).
>the previous behavior damaged existing applications, especially when it issues
>lots of subwindow manipulation and mvcur().
>
>it was introduced in 1.23 -> 1.24 or sometime before.
 1.29.4.2 03-Aug-2000  itojun pullup 1.30 -> 1.31 (approved by releng-1-5)

> free region got from t_getstr(). we will experience memory leak if
> we call initscr() multiple times (rare, but it's better to be pedant).
 1.29.4.1 03-Aug-2000  itojun pullup 1.29 -> 1.30 (approved by releng-1-5)

> fix 8bit cleanness of getch() and wgetch(). never use char variable against
> stdio functions which return "int" (including getchar()).
> the bug was introduced in 1.9 -> 1.10. fixes PR10723.
 1.36.2.1 16-Jun-2003  grant Apply patch (requested by jdc in ticket #1244):

Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.
 1.46.6.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.46.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.46.6.1 21-Jan-2007  blymn Wide curses merge
 1.48.4.2 09-Jan-2008  matt sync with HEAD
 1.48.4.1 06-Nov-2007  matt sync with HEAD
 1.51.10.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.51.8.1 18-Feb-2009  snj Pull up following revision(s) (requested by jdc in ticket #451):
lib/libcurses/getch.c: revision 1.52
Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.
 1.58.4.1 23-May-2012  yamt sync with head.
 1.59.14.2 20-Mar-2017  pgoyette Sync with HEAD
 1.59.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.59.10.1 15-Mar-2019  martin Pull up following revision(s) (requested by rin in ticket #1686):

lib/libcurses/get_wch.c: revision 1.21
lib/libcurses/getch.c: revision 1.71

Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
 1.62.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.65.12.1 10-Jun-2019  christos Sync with HEAD
 1.65.10.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.65.4.4 15-Mar-2019  martin Pull up following revision(s) (requested by rin in ticket #1214):

lib/libcurses/get_wch.c: revision 1.21
lib/libcurses/getch.c: revision 1.71

Rename global variable "state" to "_cursesi_state".

Until now, if application happens to have a global variable of the same
name, it was overridden by curses routines. This is the scenario in
which aspell crashes when linked to our curses, reported in pkg/44005.

We need to wipe out global/static variables like "_cursesi_state" or
"wstate" for thread safety. But it would be a future task...

XXX pullup to netbsd-8 and netbsd-7
 1.65.4.3 03-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1043):

lib/libcurses/resize.c: revision 1.27
lib/libcurses/get_wch.c: revision 1.19
lib/libcurses/getch.c: revision 1.70

curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@
 1.65.4.2 27-Sep-2018  martin Pull up following revision(s) (requested by roy in ticket #1042):
lib/libcurses/getch.c: revision 1.68
lib/libcurses/getch.c: revision 1.69
lib/libcurses/get_wch.c: revision 1.17
lib/libcurses/get_wch.c: revision 1.18
lib/libcurses/curses_private.h: revision 1.63
curses: unify resize handling in getch
Instead of testing each fgetc call for resize event, add the wrapper
__fgetc_resize to simplify the logic.
While here, ensure that get_wch uses the correct input stream which
may or may not be stdin.
curses: call resizeterm if getch issues KEY_RESIZE
This fixes PR #53633.
 1.65.4.1 27-Sep-2018  martin Pull up following revision(s) (requested by kamil in ticket #1039):

lib/libcurses/getch.c: revision 1.66
lib/libcurses/getch.c: revision 1.67
lib/libcurses/tstp.c: revision 1.43
lib/libcurses/get_wch.c: revision 1.15
lib/libcurses/get_wch.c: revision 1.16

PR lib/53615
getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWIN=
CH.

OK roy

-

PR lib/53615
Before invoking a previous signal handler, make sure it is not SIG_*.
Fix potential crash with SIGWINCH.

OK roy

-

Correct detecting of terminal resize in curses(3) with keypad(,TRUE)
A previous change fixed only keypad(,FALSE) scenarios.

-

Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.

PR lib/53615
 1.73.2.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #987):

lib/libcurses/get_wch.c: revision 1.24
lib/libcurses/getch.c: revision 1.75

Pads are not to be automatically refreshed on input.

X/Open Curses says in the documentation for newpad():
Automatic refreshes of pads (e.g., from scrolling or echoing of
input) do not occur.

And in the documentation for get*():
If the current or specified window is not a pad, and it has been
moved or modified since the last refresh operation, then it will be
refreshed before another character is read.

From Michael Forney in PR lib/55457
 1.30 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.29 06-Sep-2021  rin branches: 1.29.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.28 15-Aug-2021  rillig libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed. Removing the extra semicolon fixes the lint
warnings about empty declarations. These empty declarations are a GCC
extension.
 1.27 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.26 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.25 24-Feb-2019  roy Fix warn macro usage.

Thanks to rofl0r.
 1.24 06-Jan-2017  roy branches: 1.24.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.23 01-Oct-2013  blymn branches: 1.23.8;
Use the internal version of touchline to update the line.
 1.22 27-Jan-2012  christos branches: 1.22.6;
handle the case where we have no space properly (Nat Sloss)
 1.21 06-Jan-2012  christos PR/45791: Nat Sloss: getnstr erase character weirdness
Fix processing of backspace erase char and char left.
 1.20 28-May-2007  blymn branches: 1.20.34;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.19 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.18 07-Aug-2003  agc branches: 1.18.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.16 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.15 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.14 20-Apr-2001  jdc Forget to mention: This fixes PR lib/12565.
 1.13 20-Apr-2001  jdc Implement the getnstr() functions.
Add __warn_references() for getstr().
Move getstr() family closer to SUSv2 :
add checks for <carriage return>, the kill character, KEY_LEFT and
KEY_BACKSPACE
ignore other KEY_* characters
 1.12 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file getstr.c was added on branch netbsd-1-0 on 1994-08-17 21:52:20 +0000
 1.18.18.3 22-Jan-2007  jdc Needs <assert.h> for _DIAGASSERT().
 1.18.18.2 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.18.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.20.34.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.34.1 17-Apr-2012  yamt sync with head
 1.22.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.14.1 10-Jun-2019  christos Sync with HEAD
 1.29.4.1 02-Aug-2025  perseant Sync with HEAD
 1.8 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.7 08-Apr-2022  andvar branches: 1.7.4;
s/postion/position/
 1.6 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.5 28-Apr-2008  martin branches: 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 14-Oct-2001  blymn branches: 1.4.34;
Added 2 new functions and a macro:
- getparx
- getpary
- getparyx (macro)
Also minor tweak to the man page to correct grammar on a couple of items.
 1.3 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.2 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.1 12-Apr-2000  jdc get...y() and get...x() routines.
 1.4.34.1 18-May-2008  yamt sync with head.
 1.5.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.4.1 02-Aug-2025  perseant Sync with HEAD
 1.14 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 16-Apr-2000  mycroft Make subwindows scroll correctly.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file id_subwins.c was added on branch netbsd-1-0 on 1994-08-17 21:52:22 +0000
 1.3 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.2 06-Jan-2017  roy branches: 1.2.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.1 19-Jul-2002  blymn branches: 1.1.80;
* Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.1.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.26.1 02-Aug-2025  perseant Sync with HEAD
 1.13 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.12 06-Jan-2017  roy branches: 1.12.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.11 07-Aug-2003  agc branches: 1.11.80;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.9 11-Apr-2000  blymn Made data structures opaque
 1.8 13-Apr-1999  mrg branches: 1.8.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file idlok.c was added on branch netbsd-1-0 on 1994-08-17 21:52:23 +0000
 1.8.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.11.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12.26.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.2 06-Jan-2017  roy branches: 1.2.2; 1.2.28;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.1 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.2.28.1 02-Aug-2025  perseant Sync with HEAD
 1.2.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.1 06-Jan-2017  pgoyette file immedok.c was added on branch pgoyette-localcount on 2017-01-07 08:56:04 +0000
 1.9 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.8 25-Jan-2022  blymn branches: 1.8.4;
Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.7 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.6 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.5 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.4 06-Jan-2017  roy branches: 1.4.12; 1.4.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.3 22-Jul-2009  roy branches: 1.3.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.14.1 10-Jun-2019  christos Sync with HEAD
 1.4.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.8.4.1 02-Aug-2025  perseant Sync with HEAD
 1.11 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.10 25-Jan-2022  blymn branches: 1.10.4;
Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.9 15-Aug-2021  rillig libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed. Removing the extra semicolon fixes the lint
warnings about empty declarations. These empty declarations are a GCC
extension.
 1.8 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.7 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.6 24-Feb-2019  roy Fix warn macro usage.

Thanks to rofl0r.
 1.5 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.4 06-Jan-2017  roy branches: 1.4.12; 1.4.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.3 22-Jul-2009  roy branches: 1.3.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.14.1 10-Jun-2019  christos Sync with HEAD
 1.4.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.10.4.1 02-Aug-2025  perseant Sync with HEAD
 1.15 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.14 09-Jun-2019  blymn branches: 1.14.12;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.13 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.12 18-Nov-2018  uwe When we remove default color from attributes, just clear all __COLOR.
It's both a nono-optmization and matches the test used in counterpart
code that adds default color when none is set.
 1.11 06-Jan-2017  roy branches: 1.11.12; 1.11.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.10 06-Oct-2009  jdc branches: 1.10.28;
Return the same information whether or not we have wide characters.
Problem pointed out by Rhialto on current-users.
 1.9 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 28-May-2007  blymn branches: 1.7.10;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.6 20-Jan-2004  wiz branches: 1.6.18;
Mini KNF. From Douwe Kiela.
 1.5 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.4 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 09-Jan-2000  jdc branches: 1.1.2;
file inch.c was initially added on branch curses-v3.
 1.1.2.1 09-Jan-2000  jdc New files for SUS v2 curses:
Move macros from curses.h
Add prototype for wchar_t
 1.6.18.1 21-Jan-2007  blymn Wide curses merge
 1.7.10.1 18-May-2008  yamt sync with head.
 1.10.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.11.14.1 10-Jun-2019  christos Sync with HEAD
 1.11.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.14.12.1 02-Aug-2025  perseant Sync with HEAD
 1.12 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.11 15-Aug-2021  rillig branches: 1.11.4;
libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed. Removing the extra semicolon fixes the lint
warnings about empty declarations. These empty declarations are a GCC
extension.
 1.10 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.9 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.8 24-Feb-2019  roy Fix warn macro usage.

Thanks to rofl0r.
 1.7 06-Jan-2017  roy branches: 1.7.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.6 21-Apr-2012  blymn branches: 1.6.14;
Fix build break if curses is built without wide char support
 1.5 21-Apr-2012  blymn Remove trailing whitespace
 1.4 07-Aug-2011  blymn branches: 1.4.2;
Merge the attributes into the returned characters.
 1.3 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.1 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.4.2.1 23-May-2012  yamt sync with head.
 1.6.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.14.1 10-Jun-2019  christos Sync with HEAD
 1.11.4.1 02-Aug-2025  perseant Sync with HEAD
 1.36 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.35 12-Mar-2020  roy curses: use perror rather than err in initscr

libhack lacks err and perror is more portable.
 1.34 11-Mar-2020  roy curses: application should exit if initscr(3) fails

POSIX defines this behaviour here:
https://pubs.opengroup.org/onlinepubs/7908799/xcurses/initscr.html

Partial fix for PR lib/23910
 1.33 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.32 11-Jan-2017  roy branches: 1.32.6; 1.32.12; 1.32.14;
Remove setup already done in newterm and even set_term.
 1.31 10-Jan-2017  roy Implement POSIX curses function ripoffline(3).
 1.30 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.29 22-Jan-2007  jdc branches: 1.29.58;
Pull down the following from the wcurses branch:
ctrace.c: revision 1.16.2.2
initscr.c: revision 1.27.18.2
Orginal commit message:

Do the debug initialisation only in ctrace.c. Otherwise, it might not
get done, for example, if we start curses with setterm() and not initscr().
 1.28 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.27 16-Mar-2004  jdc branches: 1.27.18;
We no longer need <signal.h>.
 1.26 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.25 30-Jul-2003  dsl Remove __winlistp, add *screen to WINDOW and initialise in newwin().
Make delwin() remove window from list of windows on its screen.
Free win->lspace and win->lines for subwins (they only share text space).
Free things in the correct (and same) order if malloc() fails in __makenew().
Adjust delscreen() for delwin() removing itself from winlist.
Fixes potential massive corruptions if delwin() called on a main window.
NB: not responsible for the sysinst core dumps :-(
 1.24 27-Jan-2003  jdc ARemove (no longer used) __nca.
 1.23 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.22 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.21 05-Jan-2001  christos de-lint:
- bad arithmetic shift
- const castaways.
 1.20 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.19 15-Jun-2000  jdc Move setting of __endwin so that we also change it from the stop handler.
 1.18 01-May-2000  blymn branches: 1.18.2;
* Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.17 27-Apr-2000  jdc Add virtual screen for wnoutrefresh()/doupdate().
 1.16 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.15 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.14 14-Apr-2000  jdc Add a list of windows (used when a colour pair changes).
 1.13 12-Apr-2000  jdc Initialise colour variable (__nca).
Include private header.
 1.12 11-Apr-2000  blymn Made data structures opaque
 1.11 28-Jun-1999  simonb branches: 1.11.6;
Get rid of the evil trailing spaces and tabs.
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 12-Sep-1997  phil Make endwin() save state so a subsequent call to wrefresh restores curses
and makes endwin()/wrefresh() act like a SIGTSTP.
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file initscr.c was added on branch netbsd-1-0 on 1994-08-17 21:52:24 +0000
 1.11.6.1 05-Mar-2000  jdc Add alternate character set support.
 1.18.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.27.18.2 22-Jan-2007  jdc Do the debug initialisation only in ctrace.c. Otherwise, it might not
get done, for example, if we start curses with setterm() and not initscr().
 1.27.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.29.58.2 20-Mar-2017  pgoyette Sync with HEAD
 1.29.58.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.32.14.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.14.1 10-Jun-2019  christos Sync with HEAD
 1.32.12.1 20-Oct-2018  pgoyette Sync with head
 1.32.6.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.21 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.20 19-Oct-2022  blymn branches: 1.20.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.19 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.18 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.17 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.16 22-Jun-2021  blymn Fix the debug output to stop spamming out the aline for row 0, we
may not be working on that row so the output is pointless.
 1.15 06-Jul-2020  uwe mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.14 09-Jun-2019  blymn branches: 1.14.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.13 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.12 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.11 31-Jan-2017  roy branches: 1.11.4; 1.11.10; 1.11.12;
Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.10 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.9 06-Jan-2017  roy branches: 1.9.2;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.8 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.7 22-Oct-2016  christos remove bogus malloc casts
 1.6 16-Oct-2013  roy branches: 1.6.8;
Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.5 23-Feb-2010  drochner branches: 1.5.6; 1.5.12;
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.4 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.3 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.5.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.8.3 20-Mar-2017  pgoyette Sync with HEAD
 1.6.8.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.9.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.12.1 10-Jun-2019  christos Sync with HEAD
 1.11.10.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.11.4.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #1567):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.14.2.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #986):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.20.4.1 02-Aug-2025  perseant Sync with HEAD
 1.25 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.24 19-Oct-2022  blymn branches: 1.24.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.23 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.22 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.21 16-Jan-2022  rillig libcurses: remove unreachable statements

Found by lint.

No binary change.
 1.20 16-Nov-2021  kre Move 'i' into DEBUG only code (now there be three).
Hopefully unbreaks !DEBUG builds.
 1.19 16-Nov-2021  blymn Fix handling of the tab special character.
 1.18 15-Nov-2021  blymn Fix for PR lib/55433

Correct the behaviour for ins_wstr:
* Properly check the string will fit by processing any special
characters present when preforming the check.
* Simplify the routine by removing code that duplicates the code in
_cursesi_addwchar and just call _cursesi_addwchar.
 1.17 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.16 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.15 06-Jul-2020  uwe mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.14 09-Jun-2019  blymn branches: 1.14.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.13 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.12 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.11 31-Jan-2017  roy branches: 1.11.4; 1.11.10; 1.11.12;
Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.10 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.9 02-Jan-2017  roy branches: 1.9.2;
Implement POSIX Curses functions immedok(3) and syncok(3).
 1.8 22-Oct-2016  christos remove bogus malloc casts
 1.7 16-Oct-2013  roy branches: 1.7.8;
Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.6 16-Dec-2010  wiz branches: 1.6.6; 1.6.12;
Observe the following spelling:
- wide character (noun)
- wide-character (adjective)

Inspired by jmc@OpenBSD.
 1.5 23-Feb-2010  drochner misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.4 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.3 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.8.3 20-Mar-2017  pgoyette Sync with HEAD
 1.7.8.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.8.1 04-Nov-2016  pgoyette Sync with HEAD
 1.9.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.11.12.1 10-Jun-2019  christos Sync with HEAD
 1.11.10.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.11.4.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #1567):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.14.2.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #986):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.24.4.1 02-Aug-2025  perseant Sync with HEAD
 1.29 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.28 19-Oct-2022  blymn branches: 1.28.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.27 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.26 06-Jul-2020  uwe mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.25 09-Jun-2019  blymn branches: 1.25.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.24 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.23 06-Jan-2017  roy branches: 1.23.6; 1.23.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.22 22-Jul-2009  roy branches: 1.22.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.21 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.20 05-Feb-2006  jdc branches: 1.20.6;
Use the background attributes for the background when inserting characters.
 1.19 26-Jan-2006  jdc Use the window background colour, not the default colour.
Should fix PR install/32617
 1.18 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.15 20-May-2000  mycroft GC __FORCEPAINT.
 1.14 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.13 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.12 11-Apr-2000  blymn Made data structures opaque
 1.11 13-Apr-1999  mrg branches: 1.11.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.10 19-Aug-1998  thorpej Add some braces to make egcs happy.
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file insch.c was added on branch netbsd-1-0 on 1994-08-17 21:52:25 +0000
 1.11.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.20.6.4 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.20.6.3 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.20.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.20.6.1 21-Jan-2007  blymn Wide curses merge
 1.22.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.23.14.1 10-Jun-2019  christos Sync with HEAD
 1.23.6.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #1567):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.25.2.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #986):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.28.4.1 02-Aug-2025  perseant Sync with HEAD
 1.24 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.23 19-Oct-2022  blymn branches: 1.23.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.22 12-Apr-2022  blymn Fix compile breakage when wide char support is disabled.
 1.21 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.20 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.19 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.18 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.17 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.16 22-Jul-2009  roy branches: 1.16.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.15 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.14 28-May-2007  blymn branches: 1.14.10;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.13 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.12 05-Feb-2006  jdc branches: 1.12.6;
Handle both background character and background attribute.
 1.11 15-Jan-2006  jdc Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.10 29-Jul-2003  dsl Copy correct size of 1 line when doing insert/delete line on a subwin.
 1.9 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.8 20-Apr-2001  jdc Implement scrolling regions :
has_ic()
has_il()
setscrreg()
wsetscrreg()
 1.7 20-May-2000  mycroft GC __FORCEPAINT.
 1.6 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.5 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.4 16-Apr-2000  mycroft Make subwindows scroll correctly.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 05-Mar-2000  jdc branches: 1.1.2;
file insdelln.c was initially added on branch curses-v3.
 1.1.2.2 16-Mar-2000  jdc Handle subwins correctly.
 1.1.2.1 05-Mar-2000  jdc winsdelln() implementation - insert or delete lines.
 1.12.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.12.6.1 21-Jan-2007  blymn Wide curses merge
 1.14.10.1 18-May-2008  yamt sync with head.
 1.16.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.23.4.1 02-Aug-2025  perseant Sync with HEAD
 1.14 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.13 07-Aug-2003  agc branches: 1.13.80;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file insertln.c was added on branch netbsd-1-0 on 1994-08-17 21:52:27 +0000
 1.10.6.2 05-Mar-2000  jdc Now uses insdelln().
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.13.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.11 19-Oct-2022  blymn branches: 1.11.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.10 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.9 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.8 06-Jul-2020  uwe mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.7 09-Jun-2019  blymn branches: 1.7.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.6 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.5 06-Jan-2017  roy branches: 1.5.6; 1.5.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.4 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.3 22-Jul-2009  roy branches: 1.3.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.5.14.1 10-Jun-2019  christos Sync with HEAD
 1.5.6.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #1567):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.7.2.1 07-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #986):

lib/libcurses/insch.c: revision 1.26
lib/libcurses/ins_wch.c: revision 1.15
lib/libcurses/ins_wstr.c: revision 1.15
lib/libcurses/insstr.c: revision 1.8

mvwins*(WINDOW *win, ...) functions - call wins* on win, not stdscr.
From Naman Jain in PR lib/55460.
 1.11.4.1 02-Aug-2025  perseant Sync with HEAD
 1.9 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.8 15-Aug-2021  rillig branches: 1.8.4;
libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed. Removing the extra semicolon fixes the lint
warnings about empty declarations. These empty declarations are a GCC
extension.
 1.7 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.6 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.5 24-Feb-2019  roy Fix warn macro usage.

Thanks to rofl0r.
 1.4 07-Aug-2011  blymn branches: 1.4.42;
Fix a bug that prevented instr and friends returning OK.
 1.3 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.1 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.4.42.1 10-Jun-2019  christos Sync with HEAD
 1.8.4.1 02-Aug-2025  perseant Sync with HEAD
 1.11 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.10 25-Jan-2022  blymn branches: 1.10.4;
Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.9 15-Aug-2021  rillig libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed. Removing the extra semicolon fixes the lint
warnings about empty declarations. These empty declarations are a GCC
extension.
 1.8 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.7 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.6 24-Feb-2019  roy Fix warn macro usage.

Thanks to rofl0r.
 1.5 22-Nov-2018  uwe Drop HAVE_WCHAR ifdefs from code that is not even compiled with !HAVE_WCHAR.

We still try to mainain the ability to build our curses with
!HAVE_WCHAR, but it doesn't make sense to provide stubs for new wide
API functions that just error out when !HAVE_WCHAR. Any code that
only uses old API (and can work with !HAVE_WCHAR curses) doesn't use
those new functions. The code that uses new API obviosly cannot work
when all the new API is stubbed out.

So the plan is to drop the stubs. This commit does that for files
that are not even compiled with !HAVE_WCHAR (not only those stubs are
useless, they were not even there to begin with).

Same object code is generated for the normal HAVE_WCHAR case. Nothing
is even recompiled for !HAVE_WCHAR.

Ok by blymn@ jdc@ roy@
 1.4 06-Jan-2017  roy branches: 1.4.12; 1.4.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.3 22-Jul-2009  roy branches: 1.3.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.4.14.1 10-Jun-2019  christos Sync with HEAD
 1.4.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.10.4.1 02-Aug-2025  perseant Sync with HEAD
 1.5 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.4 21-Apr-2012  roy Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.3 03-Feb-2010  roy branches: 1.3.6;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.2 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.3.6.1 23-May-2012  yamt sync with head.
 1.8 11-Jun-2019  blymn Fix typo for unknown key keyname return.
 1.7 06-Jan-2017  roy branches: 1.7.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.6 28-Apr-2008  martin branches: 1.6.44;
Remove clause 3 and 4 from TNF licenses
 1.5 25-Oct-2007  jdc branches: 1.5.6;
Return "-1" for unknown keys and only return NULL for errors.

Make the key name string a static buffer. The specification allows this,
so the previous behaviour would leak a small amount of memory, as the
application wouldn't free the returned string.

Fixes one part of PR pkg/37062.
 1.4 04-Aug-2007  jdc branches: 1.4.2; 1.4.4;
Add KEY_RESIZE.
Fix use after free().
 1.3 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.2 19-Mar-2006  christos branches: 1.2.6;
Coverity 1552: Don't leak memory.
 1.1 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.2.6.1 21-Jan-2007  blymn Wide curses merge
 1.4.4.2 04-Aug-2007  jdc Add KEY_RESIZE.
Fix use after free().
 1.4.4.1 04-Aug-2007  jdc file keyname.c was added on branch matt-mips64 on 2007-08-04 08:36:50 +0000
 1.4.2.1 06-Nov-2007  matt sync with HEAD
 1.5.6.1 18-May-2008  yamt sync with head.
 1.6.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.16 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.15 06-Sep-2021  rin branches: 1.15.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.14 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.13 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.12 03-Feb-2010  roy branches: 1.12.28;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.11 01-Apr-2009  cube Make keypad return an int instead of nothing, as the SUS and even
curses_input(3) [!] say it should.

OK'd jdc@. ABI lawyers say this doesn't need major bump.
 1.10 21-Jan-2007  jdc branches: 1.10.18; 1.10.20; 1.10.24;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.9 17-Feb-2003  dsl branches: 1.9.18;
Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.8 13-Jun-2001  wiz withough -> without
 1.7 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.6 25-May-2000  jdc Send 'ks' sequence from first call to keypad(win, TRUE) only and not from
wgetch(). Don't send 'ke' sequence from keypad(win, FALSE) or wgetch().
This makes us compatible with Solaris.
Suggested by ITOH Yasufumi.
 1.5 17-May-2000  jdc Send, if necessary, 'ks' or 'ke' sequences from keypad() and wgetch().
Fixes PR 10116.
 1.4 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 13-Apr-1999  mrg branches: 1.1.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.1.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.9.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.10.24.1 21-Apr-2010  matt sync to netbsd-5
 1.10.20.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.10.18.1 10-Dec-2009  snj Pull up following revision(s) (requested by drochner in ticket #1190):
lib/libcurses/keypad.c: revision 1.11
lib/libcurses/curses.h: revision 1.94
Make keypad return an int instead of nothing, as the SUS and even
curses_input(3) [!] say it should.
OK'd jdc@. ABI lawyers say this doesn't need major bump.
 1.12.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.15.4.1 02-Aug-2025  perseant Sync with HEAD
 1.8 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.7 06-Jan-2017  roy branches: 1.7.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.6 31-Dec-2016  roy Implement ncurses extensions is_leaveok and is_keypad.

The former allows the ncurses (and pdcurses) macros getsyx and setsyx
to be implemented, which is needed by a surprising number of applications.

The latter is needed for Python curses support so it doesn't have to dive
into ncurses window structure.
 1.5 28-Apr-2008  martin branches: 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 24-Apr-2000  blymn branches: 1.4.38;
* Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 09-Jan-2000  jdc branches: 1.1.2;
file leaveok.c was initially added on branch curses-v3.
 1.1.2.1 09-Jan-2000  jdc New files for SUS v2 curses:
Move macros from curses.h
Add prototype for wchar_t
 1.4.38.1 18-May-2008  yamt sync with head.
 1.5.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.26.1 02-Aug-2025  perseant Sync with HEAD
 1.19 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.18 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.17 06-Sep-2021  rin branches: 1.17.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.16 01-Jul-2020  uwe hline, vline - don't lose attributes when using default character.

Make default (wide) and non-wide behavior match. If the character
argument has (only) attributes set, use them with the default line
character.

In the wide case don't do the fallback in hline - it just calls
hline_set that needs to do it anyway. Fix the latter to check the
wcwidth of the right character and avoid division by zero.
 1.15 01-Jul-2020  uwe Oops. Fix y/x typo in the previous whline() fix for !HAVE_WCHAR.
 1.14 30-Jun-2020  uwe Fix indentation in the copyright.
Make it match its siblings in other files.
 1.13 30-Jun-2020  uwe whline - save/restore the y coordinate too.
Reaching the right side of the screen can cause a line wrap.
Forgot to apply the fix to the !HAVE_WCHAR case.
PR lib/55434
 1.12 30-Jun-2020  uwe whline_set - save/restore the y coordinate too.
Reaching the right side of the screen can cause a line wrap.
PR lib/55434
 1.11 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.10 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.9 06-Jan-2017  roy branches: 1.9.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.8 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.7 02-Jan-2017  roy Whitespace
 1.6 23-Feb-2010  drochner branches: 1.6.28;
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.5 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.4 02-Jan-2002  blymn branches: 1.4.20;
Remove extraneous tabs from blank lines.
 1.3 13-Jun-2001  wiz withough -> without
 1.2 05-Feb-2001  jdc Display default (HLINE/VLINE) characters when character 0 is passed in.
This is not in the SUSv2 specification but is what System V curses does
(and it's consistent with box() and border()).
 1.1 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.4.20.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.4.20.1 21-Jan-2007  blymn Wide curses merge
 1.6.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.14.1 10-Jun-2019  christos Sync with HEAD
 1.17.4.1 02-Aug-2025  perseant Sync with HEAD
 1.17 04-Oct-2011  roy Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.16 20-Jan-2004  wiz Grammer fix. From Douwe Kiela.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.13 20-Apr-2000  blymn * Fix longname behaviour so it returns the last alias for the terminal
name which, by convention, is the verbose terminal description.
* Fix compile errors when DEBUG defined.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 13-Apr-2000  simonb Include "curses_private.h" to get function declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg branches: 1.9.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file longname.c was added on branch netbsd-1-0 on 1994-08-17 21:52:28 +0000
 1.9.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.11 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.10 06-Sep-2021  rin branches: 1.10.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.9 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.8 07-Aug-2011  blymn branches: 1.8.24;
flush the output after writing the meta sequence.
 1.7 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.6 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.5 02-Dec-2001  blymn branches: 1.5.20;
* Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.4 13-Jun-2001  wiz withough -> without
 1.3 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.2 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.1 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.5.20.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.8.24.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.10.4.1 02-Aug-2025  perseant Sync with HEAD
 1.2 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.1 23-Mar-2020  roy branches: 1.1.2; 1.1.10;
curses: Add stubs for mouse functions

No mouse support actually included.
But that doesn't matter because most terms don't actually support a mouse.

We should look into hooking these into wsmouse(4) and xterm mouse
in the future.

Compatable with nCurses mouse API version 2.
 1.1.10.1 02-Aug-2025  perseant Sync with HEAD
 1.1.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.2.1 23-Mar-2020  martin file mouse.c was added on branch phil-wifi on 2020-04-08 14:07:14 +0000
 1.26 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.25 04-Nov-2022  blymn branches: 1.25.4;

PR bin/57072

This fixes observed behviour in the PR. Allow the cursor to be
moved one past the EOL, if postitioned here then set ISPASTEOL.
also protect out of range access if win->cury is past maxy.
 1.24 27-Apr-2022  blymn Fix for PR 56243
clear the past EOL flags when moving the cursor - they are no longer
valid as move cannot put the cursor past the EOL.
 1.23 19-Oct-2021  blymn Add a bit more debug.
 1.22 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.21 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.20 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.19 26-Sep-2018  kamil According to POSIX moving the cursor in curses(3) touches the window

Mark the old and new lines as dirty, so they will be refreshed upon next
call to getch(3)-like routine.

This also matches the ncurses behavior.

Reviewed by <roy>
 1.18 06-Jan-2017  roy branches: 1.18.6; 1.18.12; 1.18.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.17 23-Feb-2010  drochner branches: 1.17.28;
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.16 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.15 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.14 10-Aug-2003  dsl branches: 1.14.18;
Revert most of rev 1.27 of addbytes.c and associated changes.
Posix requires that adding '\n' does clrtoeol() and 'x = 0'.
(Making "\r\n" erase the text that has just been displayed.)
Remove __NONL test from addbytes, __NONL is a property of the output device.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 31-Jul-2003  dsl Do something more sensible for waddbytes(..., "\r\n", ...);
I'm not sure about the clrtoeol() at all though - maybe it should
be done as part of scroll()?
Leave 'x' alone when __NONL set.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file move.c was added on branch netbsd-1-0 on 1994-08-17 21:52:29 +0000
 1.14.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.17.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.14.1 10-Jun-2019  christos Sync with HEAD
 1.18.12.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.18.6.1 27-Sep-2018  martin Pull up following revision(s) (requested by kamil in ticket #1040):

lib/libcurses/move.c: revision 1.19

According to POSIX moving the cursor in curses(3) touches the window

Mark the old and new lines as dirty, so they will be refreshed upon next
call to getch(3)-like routine.

This also matches the ncurses behavior.
Reviewed by <roy>
 1.25.4.1 02-Aug-2025  perseant Sync with HEAD
 1.3 07-Aug-1993  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.3 07-Aug-1993  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.25 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.24 12-Apr-2022  blymn branches: 1.24.4;
Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.23 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.22 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.21 11-Jan-2017  roy Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.20 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.19 20-Feb-2014  blymn branches: 1.19.8;
Correct the implementation of mvderwin, it now works as specified by
SUSv2.
 1.18 18-Oct-2013  christos fix unused warnings
 1.17 28-Sep-2012  blymn Correct behaviour of mvderwin(). It should remap a given area of the parent
window not move a derived window as it was before.
 1.16 15-Sep-2011  blymn branches: 1.16.2; 1.16.8;
- Make mvderwin work as per the SUSv2 specification and other curses
implementations.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 08-Apr-2003  jdc Make sure that windows are not off the left or top edges of the screen.
Noticed while looking at PR 21041.
 1.13 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.12 08-Oct-2001  blymn Add mvderwin function.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file mvwin.c was added on branch netbsd-1-0 on 1994-08-17 21:52:31 +0000
 1.16.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.16.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.2.1 30-Oct-2012  yamt sync with head
 1.19.8.2 20-Mar-2017  pgoyette Sync with HEAD
 1.19.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.4.1 02-Aug-2025  perseant Sync with HEAD
 1.68 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.67 03-May-2022  blymn branches: 1.67.4;

* Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.66 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.65 26-Mar-2022  uwe __makenew: use calloc to get zeroed memory for window contents.

PR lib/56767.
 1.64 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.63 19-Oct-2021  blymn Add a bit more debug.
 1.62 07-Sep-2021  rin PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.
 1.61 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.60 01-Jun-2021  mcf Fix initial line hash calculation for subwindows

lp->hash is not initialized at this point. Since the hash is
calculated in chunks using __hash_more(), it needs to be initialized
to 0 first (just as in doupdate()).

Detected with valgrind while running python's test suite when
debugging an unrelated issue.

ok uwe@
 1.59 15-May-2021  uwe __newwin - fix BGWCOL initialization.

From Michael Forney in PR lib/56174
 1.58 14-Jul-2020  uwe branches: 1.58.2;
newwin - fix crash with negative ncols.

When support for negative nrows/ncols was added, one s/ncols/maxx/ was
missed so we ended up passing negative (i.e. huge unsigned) length
when hashing the line contents.

Reported by Naman Jain in PR lib/55484
 1.57 09-Jun-2019  blymn branches: 1.57.2;
Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.56 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.55 01-Apr-2019  roy printw: rework vw_printw so it uses open_memstream rather than funopen2

This makes it more portable as open_memstream is POSIX and fixes a
potential issue with wide characters not fully being printed
due to any buffer overflow.
 1.54 10-Oct-2018  roy curses: test terminal capabilities for drawing in the bottom right corner

If auto margins are present, we need to turn them off or enter
an insert mode to "push" the character we want into the corner.
If pushing a wide character of greater than one cell, we need something
more than ich1, othewise the bottom right corner will remain blank.

Follow on fix for PR# 30978.

OK jdc@
 1.53 05-Oct-2018  roy curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.
 1.52 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.51 18-Sep-2017  roy branches: 1.51.2; 1.51.4;
Allow a subwindow to contain another subwindow.

This reverts r1.37 and allows wip/rtv to work better.
 1.50 06-Jan-2017  roy branches: 1.50.6;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.49 05-Jan-2017  roy Implement ncurses is_pad(3).
Correct documentation about is_keypad(3).
 1.48 23-Oct-2016  christos It is expensive to open and close files for every printf, keep it around.
 1.47 22-Jul-2009  roy branches: 1.47.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.46 14-Apr-2008  jdc Make __subwin() static.
 1.45 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.44 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.43 15-Jan-2006  jdc branches: 1.43.6;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.42 28-Mar-2004  jdc Changes to support *echochar().
Should fix PR lib/24927.
 1.41 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.40 01-Aug-2003  dsl Remove unused extern for __winlistp.
 1.39 30-Jul-2003  dsl Remove __winlistp, add *screen to WINDOW and initialise in newwin().
Make delwin() remove window from list of windows on its screen.
Free win->lspace and win->lines for subwins (they only share text space).
Free things in the correct (and same) order if malloc() fails in __makenew().
Adjust delscreen() for delwin() removing itself from winlist.
Fixes potential massive corruptions if delwin() called on a main window.
NB: not responsible for the sysinst core dumps :-(
 1.38 05-Jul-2003  jdc New sub-windows should not be marked as pads.
(Also noticed by David Laight.)
 1.37 26-Jun-2003  dsl Error attempts at nested subwindows, the data structures don't support them.
I can't quite decide whether the X/Open Curses Issue 4, version 2 needs them.
 1.36 09-Jun-2003  jdc Mark all lines on new pads as dirty. This ensures that we draw blank
(untouched) lines when the pad is refreshed.
 1.35 08-Apr-2003  jdc Make sure that windows are not off the left or top edges of the screen.
Noticed while looking at PR 21041.
 1.34 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.33 23-Dec-2002  jdc Add newpad() and subpad().
Modify __makenew(), __newwin() and __subwin() to handle pads.
 1.32 05-Dec-2002  jdc Mark lines on new windows unchanged.
Add window to __set_subwin() debug.
 1.31 25-Nov-2002  jdc Set default colour on windows created after a call to start_color().
(Also noticed by Pooka).
 1.30 22-Oct-2002  blymn Fix lint nits mainly with the len parameter type in hash_more.
 1.29 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.28 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.27 11-Dec-2001  blymn * Remove termcap globals from public interface
* Clean up commented out code
 1.26 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.25 17-May-2001  jdc Set scrolling region top correctly.
Fixes scrolling bug in sub-windows.
 1.24 20-Apr-2001  jdc Implement scrolling regions :
has_ic()
has_il()
setscrreg()
wsetscrreg()
 1.23 05-Jan-2001  christos remove redundant declarations.
 1.22 20-Apr-2000  blymn * Added new function dupwin.
* Fixed bug in copywin overwrite code.
 1.21 18-Apr-2000  jdc Set background character and attributes for added characters.
 1.20 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.19 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.18 16-Apr-2000  mycroft Make subwindows scroll correctly.
 1.17 15-Apr-2000  jdc Initialise window delay for all new windows (including sub-windows).
 1.16 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.15 14-Apr-2000  jdc Add a list of windows (used when a colour pair changes).
 1.14 12-Apr-2000  jdc Add background character/attributes.
 1.13 11-Apr-2000  blymn Made data structures opaque
 1.12 23-Jun-1999  christos branches: 1.12.6;
Silence casts
 1.11 22-Apr-1999  mycroft Initialization of the backing store pointers in __set_subwin() was just
totally wrong. It needs to offset by the origin of the parent window.
 1.10 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file newwin.c was added on branch netbsd-1-0 on 1994-08-17 21:52:34 +0000
 1.12.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.43.6.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.43.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.43.6.1 21-Jan-2007  blymn Wide curses merge
 1.47.28.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.47.28.1 04-Nov-2016  pgoyette Sync with HEAD
 1.50.6.4 14-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #1574):

lib/libcurses/newwin.c: revision 1.58

newwin - fix crash with negative ncols.

When support for negative nrows/ncols was added, one s/ncols/maxx/ was
missed so we ended up passing negative (i.e. huge unsigned) length
when hashing the line contents.

Reported by Naman Jain in PR lib/55484
 1.50.6.3 09-Oct-2018  martin Back out the following revision(s) (requested by roy in ticket #1049):

lib/libcurses/refresh.c: revision 1.89
lib/libcurses/newwin.c: revision 1.53

curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.


As discussed in the PR, this change introduces a regression.
 1.50.6.2 09-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1049):

lib/libcurses/refresh.c: revision 1.89
lib/libcurses/newwin.c: revision 1.53

curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.
 1.50.6.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.51.4.1 10-Jun-2019  christos Sync with HEAD
 1.51.2.1 20-Oct-2018  pgoyette Sync with head
 1.57.2.1 14-Jul-2020  martin Pull up following revision(s) (requested by uwe in ticket #1004):

lib/libcurses/newwin.c: revision 1.58

newwin - fix crash with negative ncols.

When support for negative nrows/ncols was added, one s/ncols/maxx/ was
missed so we ended up passing negative (i.e. huge unsigned) length
when hashing the line contents.

Reported by Naman Jain in PR lib/55484
 1.58.2.1 31-May-2021  cjep sync with head
 1.67.4.1 02-Aug-2025  perseant Sync with HEAD
 1.8 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.7 06-Jan-2017  roy branches: 1.7.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.6 04-Dec-2003  jdc branches: 1.6.80;
Make nodelay() return an int.
Now conforms to the Single Unix Specification.
Fixes PR lib/23531 by usa at garbagecollect dot jp.
 1.5 13-Jun-2001  wiz withough -> without
 1.4 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 13-Apr-1999  mrg branches: 1.1.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.1.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.6.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.26.1 02-Aug-2025  perseant Sync with HEAD
 1.8 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.7 06-Jan-2017  roy branches: 1.7.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.6 28-Feb-2014  blymn branches: 1.6.8;
Fix reversed logic in the notimeout call.
Fix obsolete email addresses in copyright.
 1.5 13-Jun-2001  wiz branches: 1.5.58; 1.5.64;
withough -> without
 1.4 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 13-Apr-1999  mrg branches: 1.1.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.1.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.5.64.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.58.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.7.26.1 02-Aug-2025  perseant Sync with HEAD
 1.18 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.17 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.16 01-Aug-2004  dsl branches: 1.16.12;
overwrite() wasn't copying enough lines or columns.
copywin() couldn't seem to decide whether it should work in window or
screen coordinates - and managed to do neither.
Change copywin() to use window relative coords (as ncurses and solaris do),
and change overwrite() and overlay() to use the modified interface.
It is now possible to use overwrite() to save part of curscr while a
temporary window is drawn.
Fixes PR/26506
 1.15 07-Aug-2003  agc branches: 1.15.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.13 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file overlay.c was added on branch netbsd-1-0 on 1994-08-17 21:52:36 +0000
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.15.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.16.12.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.19 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.18 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.17 01-Aug-2004  dsl branches: 1.17.12;
overwrite() wasn't copying enough lines or columns.
copywin() couldn't seem to decide whether it should work in window or
screen coordinates - and managed to do neither.
Change copywin() to use window relative coords (as ncurses and solaris do),
and change overwrite() and overlay() to use the modified interface.
It is now possible to use overwrite() to save part of curscr while a
temporary window is drawn.
Fixes PR/26506
 1.16 07-Aug-2003  agc branches: 1.16.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.14 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.13 18-Apr-2000  blymn More multiple changes:
* Added function derwin.
* Added function copywin.
* Modified both overlay and overwrite to use copywin.
* Updated man page with new functions and fixed minor format glitch.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file overwrite.c was added on branch netbsd-1-0 on 1994-08-17 21:52:37 +0000
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.16.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.17.12.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.11 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.10 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.9 22-Jul-2009  roy branches: 1.9.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 21-Jan-2007  jdc branches: 1.7.10;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.6 02-Dec-2001  blymn branches: 1.6.20;
* Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.5 07-Jan-2001  augustss Make this compile again.
(I thought the idea was to test things before commiting;
if it doesn't even compile it can't possibly have been tested.)
 1.4 07-Jan-2001  jdc Free(3) delstr after use.
Pointed out by Mike Grupenhoff in email.
 1.3 22-Dec-2000  jdc Revert the change to the `pc' capability from the previous change. Pointed
out in email by Thomas Dickey.
 1.2 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.1 11-May-2000  jdc New functions delay_output() and napms().
 1.6.20.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.7.10.1 18-May-2008  yamt sync with head.
 1.9.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.31 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.30 21-Dec-2022  blymn branches: 1.30.2;
Add more debug so a call to waddbytes can be traced to the caller.
 1.29 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.28 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.27 01-Apr-2019  roy printw: rework vw_printw so it uses open_memstream rather than funopen2

This makes it more portable as open_memstream is POSIX and fixes a
potential issue with wide characters not fully being printed
due to any buffer overflow.
 1.26 28-Mar-2019  uwe winwrite - using addch() on individual bytes of e.g. UTF-8 encoding
doesn't work that well. addstr() the whole buffer instead. This is
still not enirely correct b/c printf can run out of stdio buffer
mid-character for very long output, but deal with it later.
 1.25 21-Mar-2019  uwe winwrite - deobfuscate a bit.
 1.24 06-Jan-2017  roy branches: 1.24.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.23 23-Oct-2016  christos It is expensive to open and close files for every printf, keep it around.
 1.22 17-Jul-2011  joerg branches: 1.22.24;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.21 07-Jul-2009  joerg Add vw_printw and vw_scanw as mandated by SUSv2's xcurses. Follow
ncurses and just make the historic vwprintw and vwscanw functions
aliases, ignoring that they should take a varargs.h va_list argument.
 1.20 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.19 07-Aug-2003  agc branches: 1.19.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.17 24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.16 30-Dec-2000  martin va_list -> _BSD_VA_LIST_ to be consistent with prototype
(doesn't compile on sparc64 otherwise)
 1.15 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.14 14-Apr-2000  simonb Don't wrap declarations of mvwprintw & mvwscanw.
 1.13 13-Apr-2000  jdc Restore const after the Open Group decided it was OK.
Thanks due to Brett Lymn.
 1.12 11-Apr-2000  blymn Made data structures opaque
 1.11 13-Apr-1999  mrg branches: 1.11.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 22-Jul-1997  mikel RCSid police, fix warnings
 1.8 17-Aug-1994  cgd branches: 1.8.2;
clean up import
 1.7 24-Jan-1994  cgd changes from branch
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd branches: 1.5.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 24-Jan-1994  cgd minor fixups
 1.8.2.2 17-Aug-1994  cgd clean up import
 1.8.2.1 17-Aug-1994  cgd file printw.c was added on branch netbsd-1-0 on 1994-08-17 21:52:39 +0000
 1.11.6.2 13-Jan-2000  jdc Correctly handle characters with 8th bit set in __winwrite().
Add a DEBUG entry.
 1.11.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.19.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.22.24.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.24.1 04-Nov-2016  pgoyette Sync with HEAD
 1.24.14.1 10-Jun-2019  christos Sync with HEAD
 1.30.2.1 02-Aug-2025  perseant Sync with HEAD
 1.24 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.23 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.22 06-Jan-2017  roy branches: 1.22.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.21 03-Feb-2010  roy branches: 1.21.28;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.20 19-Sep-2007  jdc Add debugging for the WCHAR cases.
 1.19 28-May-2007  blymn branches: 1.19.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.18 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.17 07-Aug-2003  agc branches: 1.17.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.15 31-Dec-2001  blymn fix __startwin() so it outputs the init strings to the correct device.
 1.14 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.13 20-Apr-2000  blymn * Fix longname behaviour so it returns the last alias for the terminal
name which, by convention, is the verbose terminal description.
* Fix compile errors when DEBUG defined.
 1.12 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 07-Dec-1999  simonb branches: 1.10.2;
In a debugging check, use %s for unctrl (it returns a char *).
 1.9 04-Oct-1999  lukem update post change to return value of tputs() third argument
 1.8 13-Apr-1999  mrg branches: 1.8.2;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file putchar.c was added on branch netbsd-1-0 on 1994-08-17 21:52:40 +0000
 1.8.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.2.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.17.18.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.17.18.1 21-Jan-2007  blymn Wide curses merge
 1.19.4.1 06-Nov-2007  matt sync with HEAD
 1.21.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.14.1 10-Jun-2019  christos Sync with HEAD
 1.129 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.128 24-Jun-2023  msaitoh branches: 1.128.2;
Fix typo in comment.
 1.127 28-Apr-2023  blymn Don't set the clear_to_eol variable in doupdate to NULL, this was a
leftover from previous code that makes no sense and makes worms(6)
crash randomly. Thanks to kre@ for reporting this.
 1.126 05-Dec-2022  blymn branches: 1.126.2;
Revert previous change, it is not correct.
 1.125 30-Nov-2022  blymn When performing a scroll, check the last line of the region is the same
on virtscr and curscr because the indexes past are supposed to be
one *past* the last matching line (they may actually match if the line is
at the bottom of the screen). Iff they don't match reduce the scroll
region size by one so we don't scroll non-matching lines, also check
if the region is then 0 after the decrement and just return if it was.
 1.124 19-Oct-2022  blymn Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.123 03-May-2022  blymn * Don't redraw the background if the new background character is the
same as the old one. This prevents excessive redraws in some
applications.

* Fix bug introduced when wbkgrndset was fixed, we cannot blindly
replace any instance of the old background character with the new one
because some of those characters were put there by the application
leading to display corruption. So flag characters as background when
they are erased and only update the flagged characters when setting
the background.
 1.122 19-Apr-2022  blymn fix for PR 55496

* Fix bkgrndset so that it actually sets the background character in
in line with the SUSv2 specification.

* Add an internal function to copy a complex character

* Make the previously static celleq function into a libcurses private
function so that it can be called in other files.
 1.121 13-Apr-2022  pgoyette Fix build (enabled only for MKDEBUG?)
 1.120 12-Apr-2022  blymn Fix compile breakage when wide char support is disabled.
 1.119 12-Apr-2022  blymn Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.118 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.117 17-Dec-2021  uwe curses: spell "foreground" correctly in comments
 1.116 07-Sep-2021  rin PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.
 1.115 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.114 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.113 08-May-2021  mrg avoid accessing stack garbage.

on arm64eb resuming vi(1) would often crash. in makech(), the 'csp'
variable is either set to current window data, or a local stack
variable's address '&blank'. the window data has many lines of info
stored, and 'csp++' is used per line here. unfortunately, a case
existed where 'csp++' operated on csp initialised from '&blank' which
eventually crashes when, on my display with 160 columns and 'csp + 155'
exceeds the mapped stack and crashes.

match the '!_cursesi_screen->curwin' conditional that initialises csp,
and avoid csp++ here. assert() that csp != &blank in both places that
modify csp.

thanks to jdc@ and mlelstv@.

XXX: possibly also should avoid the putch() here as well.
 1.112 24-Feb-2020  rin 0x%p --> %p for non-external codes.
 1.111 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.110 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.109 12-May-2019  blymn Add more debug to _wnoutrefresh
 1.108 24-Apr-2019  blymn Add/improve debug output for some routines.
 1.107 29-Mar-2019  roy Minor adjustment to prior to match putch
 1.106 29-Mar-2019  roy Use WCOL rather than wcwidth(3) as we should already know the width
during refresh.
Ensure the character width is not negative when advancing during refresh
(unlikely) and we actually have something to insert in the lower right
corner depending on terminal caps.

Fixes PR lib/54085
 1.105 06-Jan-2019  uwe _wnoutrefresh - extend current position checks.

Also verify that dwin->cury >= begy (ditto for x), i.e. for pads make
sure that the current position is after the beginning of the displayed
portion. While here refactor the checks for better readability.

We should probably combine the y and x checks b/c if one of them is
not in the range, the current position as a whole is not in the range
and it doesn't make sense to pick and set just the y or just the x
part of it.
 1.104 06-Jan-2019  uwe _wnoutrefresh - fix current position checks for pads

maxy is an absolute value and should not be adjusted for begy when we
check also absolute cury. Note that this change does not affect
calculations for normal windows as for them we always pass zero for
begy. Ditto for x.
 1.103 06-Jan-2019  uwe prefresh - fix current position calculations

The code was copy-pasted from wrefresh(), but for pads we need to
adjust for (pbegy, pbegx).

PR lib/53801
 1.102 30-Nov-2018  roy curses: Fix inverted logic when drawing LR corner with auto margins

Thanks to M. Levinson.
 1.101 18-Nov-2018  uwe Reindent a few lineeq() calls now that we can w/out exceeding 80
columns limit. Whitespace change only.
 1.100 18-Nov-2018  uwe Further tweak previous. Change the check order to be more logical.
No functional change intentded. While here fix indentation.
 1.99 18-Nov-2018  uwe Merge one more #ifdef with mostly identical code in both branches.
The same object code is generated modulo gratuitously different order
of checks.
 1.98 18-Nov-2018  uwe Merge another #ifdefs that now has identical code in both branches
modulo swapped arguments to celleq() call. Same object code is
generated otherwise for both HAVE_WCHAR and !HAVE_WCHAR
 1.97 18-Nov-2018  uwe Merge few #ifdefs that now have identical code in both branches.
Same object code is generated for both HAVE_WCHAR and !HAVE_WCHAR.
 1.96 18-Nov-2018  uwe Define celleq() and lineeq() for !HAVE_WCHAR too and use them instead
of explicit memcmp() calls. Same object code is generated for both
HAVE_WCHAR and !HAVE_WCHAR, but we can now try to merge some of the
#ifdefs
 1.95 18-Nov-2018  uwe Rename cellcmp() and linecmp() to celleq() and lineeq() respectively
and make them static.
 1.94 18-Nov-2018  uwe quickch - fix inverted checks.

I have to admit I have no idea what's going on here, but HAVE_WCHAR
code here inverted the sense of linecmp and cellcmp checks w.r.t the
!HAVE_WCHAR variant just above it. Cf. also all other similar #ifdefs
in this file.

Found through source code inspection, not really tested.
 1.93 18-Nov-2018  uwe cellcmp - use logical && not bitwise &
 1.92 29-Oct-2018  uwe Fix operator precedence for !HAVE_WCHAR
 1.91 21-Oct-2018  roy curses: ensure attributes are correctly set for each character

Another fix for PR# 30978.
 1.90 10-Oct-2018  roy curses: test terminal capabilities for drawing in the bottom right corner

If auto margins are present, we need to turn them off or enter
an insert mode to "push" the character we want into the corner.
If pushing a wide character of greater than one cell, we need something
more than ich1, othewise the bottom right corner will remain blank.

Follow on fix for PR# 30978.

OK jdc@
 1.89 05-Oct-2018  roy curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.
 1.88 20-Mar-2017  christos branches: 1.88.4; 1.88.10; 1.88.12;
Make this compile again: use ce instead of clr_eol which gcc thinks might
be NULL.
 1.87 11-Jan-2017  roy branches: 1.87.2;
Kill stray refs to __virtscr and _cursesi_screen missed in prior commit.
 1.86 11-Jan-2017  roy ripoffline requires wnoutrefresh to work before _cursesi_screen has been
set.
 1.85 10-Jan-2017  roy When doupdate is called, check for typeahead input after N lines changed
instead of aborting really early.

This allows some screen update when holding the page down key for example.
 1.84 10-Jan-2017  roy Test for __ISPASTEOL when moving the cursor and it hasn't moved.
Unset __ISPASTEOL when moving the cursor during refresh.
 1.83 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.82 06-Jan-2017  roy u_int -> unsigned int, u_int32_t -> uint32_t.
 1.81 31-Dec-2016  roy Implement POSIX Curses typeahead function.
 1.80 10-Jan-2016  jdc branches: 1.80.2;
Clear the "forced" flag after updating a line, otherwise we'll always do
complete line redraws.
 1.79 20-Feb-2014  blymn Correct the implementation of mvderwin, it now works as specified by
SUSv2.
 1.78 06-Dec-2013  blymn Make the touch family of calls actually force an update of the
terminal bypassing optimisations. Previously if curses thought curscr
was in sync with virtscr (curses concept of what is on the screen) then
nothing would be output. This change forces an update out to the terminal
regardless.
 1.77 05-May-2013  jdc Add extra debugging when copying window contents.
 1.76 21-Apr-2012  blymn branches: 1.76.2;
Fix build break if curses is built without wide char support
 1.75 03-Oct-2011  roy branches: 1.75.2;
Use tiparm instead of vtparm.
 1.74 16-Jun-2011  jdc Correctly test for __ISDIRTY.
Problem noticed by (and test case provided by) blymn@.
 1.73 08-Feb-2010  roy branches: 1.73.4;
Fix an off-by-one error.
Thanks to Matthias Drochner.
 1.72 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.71 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.70 13-Jun-2008  yamt remove unnecessary casts.
 1.69 06-Oct-2007  martin branches: 1.69.6; 1.69.8;
Make it build without HAVE_WCHAR
 1.68 19-Sep-2007  jdc We don't need separate #ifdef's for __ALTCHARSET and WA_ALTCHARSET, as they
are defined to be the same in curses.h.
 1.67 29-May-2007  veego branches: 1.67.4;
Fix compile errors on i386 by changing %ld to %zu.
 1.66 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.65 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.64 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.63 15-Jan-2006  jdc branches: 1.63.6;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.62 23-Oct-2005  dsl Don't read entry after end of array.
Discovered by Neil Ludban running curses under 'ElecticFence'
 1.61 18-Feb-2005  dsl Change first arg of __hash_more to const void * to remove need for double casts
 1.60 07-Apr-2004  christos check fflush() return code (from Julian Coleman)
 1.59 28-Mar-2004  jdc branches: 1.59.4;
Changes to support *echochar().
Should fix PR lib/24927.
 1.58 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.57 05-Jul-2003  jdc Rework the way window/wub-window refresh is done.

For each line that is marked dirty on each sub-window, we now mark the
relevant line on the parent as dirty and unmark it on the sub-window.
This avoids copying the same data multiple times and also leaves the
cursor in the correct position for the window refreshed.
 1.56 28-Jun-2003  jdc Make the refresh complete in the presence of multiple sub-windows.
Match function names in the debug output.
 1.55 26-Jun-2003  dsl Stop refresh(subwin) doing refresh on the other subwin's created before it.
(If nothing else the cursor would get left in the wrong place).
Fix some if (!flags & MASK) checks.
 1.54 29-Mar-2003  jdc Now refresh() refreshes subwindows too.
Fixes PR lib/20544 by rtr.
 1.53 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.52 27-Jan-2003  jdc Check for conflict between colour and other attributes. The previous
checks when adding attributes could be inadequate if background colours
were later added to a window.
 1.51 12-Jan-2003  jdc Back out part of rev 1.50. We can't call werase() here.
Fixes PR lib/19739 by Matthias Scheler.
Problem also noted by Martin Husemann.
 1.50 23-Dec-2002  jdc Add pnoutrefresh() and prefresh().
Modify _cursesi_wnoutrefresh() to handle pads.
 1.49 05-Dec-2002  jdc When copying a line from a window, only copy the changed part instead of
the whole line.
This fixes a bug when displaying displaying overlapping windows.
 1.48 22-Oct-2002  blymn Fix lint nits mainly with the len parameter type in hash_more.
 1.47 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.46 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.45 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.44 31-Dec-2001  blymn fix __startwin() so it outputs the init strings to the correct device.
 1.43 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.42 20-Sep-2001  blymn Add code to allow resizing of windows and the underlying terminal.
 1.41 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.40 02-Aug-2000  itojun on repaint, we must look at attributes present on curscr.
check __ISPASTEOL on curscr->lines, not on win->lines. PR 10732.
 1.39 01-Aug-2000  itojun use __cputchar(), not putchar().
otherwise, __CTRACE() will not be useful for debugging curses internals.
 1.38 03-Jul-2000  matt More include cleanup. Remvoe (p) from #undef in libipsec.
 1.37 15-Jun-2000  jdc branches: 1.37.2;
Move setting of __endwin so that we also change it from the stop handler.
 1.36 12-Jun-2000  jdc Copy all background attributes (not just colour) from win to __virtscr.
 1.35 20-May-2000  mycroft branches: 1.35.2;
GC __FORCEPAINT.
 1.34 19-May-2000  mycroft Fix a silly bug that caused blanks to always be redrawn on dirty lines in
curscr. This usually manifested itself as a very slow redraw after suspend.
 1.33 19-May-2000  mycroft More microoptimization, and explicitly skip lines that are not dirty.
 1.32 19-May-2000  mycroft Two optimizations in quickch():
* Don't bother comparing lines that are not dirty when looking for the top
and bottom regions.
* In the loop that searches for the largest equal region, do the totally
half-assed hack of splitting the inner loop into two parts -- comparing
only the hash values the first time, and doing memcmp()s the second time.
This makes many of my test cases >100x as fast.
XXX This code needs a lot more work.
 1.31 19-May-2000  mycroft We already initialize UP and BC when we fire up Curses, so pass a null pointer
to t_goto() to avoid doing it again... and again... and...
 1.30 18-May-2000  mycroft Clear any cached __LEAVEOK flag in __virtscr when refreshing another window.
 1.29 07-May-2000  jdc Don't try and refresh those parts of windows that are outside our terminal.
 1.28 29-Apr-2000  mycroft As the comment suggests, move the __unsetattr() to the end of doupdate(), just
before the fflush(). This avoids needlessly resetting modes.
 1.27 29-Apr-2000  mycroft Speed up refresh in the presence of attributes by precalculating a mask for
each `end' command to turn off other attributes in the case of conflicts.
 1.26 28-Apr-2000  jdc We can't assume colour won't be turned off if the escape sequences for
turning off attributes aren't the same as the one for colour, so decide
that we've turned off colour when we turn off any attributes.
 1.25 28-Apr-2000  jdc Remove test code inadvertently left in.
 1.24 27-Apr-2000  jdc Don't change the cursor position if __LEAVEOK.
 1.23 27-Apr-2000  jdc Implement wnoutrefresh() and doupdate(). wrefresh() now calls these functions
and the previous wrefresh() code is split between them. Background character
and attribute handling is now done in wnoutrefresh(), thus simplifying the code
in doupdate(), makech() and quickch().
Refine xterm workround and test for it earlier - this cuts down the number of
lines we test when looking for a scrolled region.
Rename unsetattr() to __unsetattr(), so it can be used by __stopwin().
 1.22 21-Apr-2000  jdc Work round xterm bug which displays the wrong background colour when the
screen has just been scrolled.
Only use CL if all lines have the same background colour.
Fix debug output in quickch().
 1.21 19-Apr-2000  blymn Converted all termcap library calls to the "new" interface, this fixes
a problem with curses crashing when the CM capability was larger than
64 bytes and eliminates some possible buffer overflow problems.
 1.20 18-Apr-2000  jdc Add support for background characters and attributes.
Add extra colour/attributes debugging.
 1.19 16-Apr-2000  jdc Really don't move with altcharset set.
Leave other attributes if MS is defined.
Move attribute unsetting into a new function.
 1.18 15-Apr-2000  jdc Don't move with altcharset or colour set (if you try this on an xterm, you
won't actually move, but will think you have).
 1.17 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.16 12-Apr-2000  jdc Add color manipulation.
Note that window background attributes are not handled yet.
 1.15 11-Apr-2000  blymn Made data structures opaque
 1.14 17-Sep-1999  simonb branches: 1.14.6;
When dumping the attributes for a line, put a space between each attribute
so you can tell where each one starts and stops, and prefix these lines
with "attr: ".
 1.13 28-Jun-1999  simonb Remove the test for NOQCH, and print the line flags in the CTRACE in
the main loop wrefresh().
 1.12 23-Jun-1999  christos - protect NULL attributes from de-referencing
- Silence pointer casts
 1.11 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 12-Sep-1997  phil Make endwin() save state so a subsequent call to wrefresh restores curses
and makes endwin()/wrefresh() act like a SIGTSTP.
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 07-Aug-1993  mycroft New version from uunet.
 1.3 01-Aug-1993  mycroft Add RCS identifiers.
 1.2 09-Jul-1993  alm added Andrew Chernov's patch set:
Standard curses library use eight bit for standout mode, so
8-bit characters displays like highlighted 7-bit characters.

This patch produce library which is fully compatible with all curses
programs and add 8-bit chars to all input/display functions.
---
I don't think, that any programs wish to use internal curses
attribute _STANDOUT directly, in expressions like:
addch( ch | _STANDOUT );
Normal interface use standout() and standend() functions instead.
Many programs use 'char' type (with sign extention) for input characters
and sign extention becomes _STANDOUT mode in this case.
So, I refuse this future and allow 8-bit characters for programs,
which is designed for 7-bit only ('char' type using instead of
'unsigned char').
---
This small patch fix unpleasant standard curses bug:
curses can't expand TAB at all (but tries).
A man who wrote this curses misplace SYNC_IN and SYNCH_OUT,
this patch exchange macro calls.

This patch useful for standard 7-bit curses too, for this
you must delete '_' symbol before waddbytes and apply patch.
---
Oh, NO! This curses are really buggy!

This small patch fix following problem:
[ assumed scrollok(stdscr, TRUE) ]
when addch(ch) at lower right corner of screen, curses are realy
gone mad instead if simple scrolling... Curses code assumed that
this will be done correctly, but implement it with two bugs.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file refresh.c was added on branch netbsd-1-0 on 1994-08-17 21:52:41 +0000
 1.14.6.3 16-Mar-2000  jdc Fix debug crash when using subwins.
 1.14.6.2 05-Mar-2000  jdc Add alternate character set support.
 1.14.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.35.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.37.2.2 13-Aug-2000  itojun pullup 1.39 -> 1.40 (approved by releng-1-5)
on repaint, we must look at attributes present on curscr.
check __ISPASTEOL on curscr->lines, not on win->lines. PR 10732.
 1.37.2.1 03-Aug-2000  itojun pullup (approved by releng-1-5)

> use __cputchar(), not putchar().
> otherwise, __CTRACE() will not be useful for debugging curses internals.

1.18 -> 1.19 basesrc/lib/libcurses/cr_put.c
1.38 -> 1.39 basesrc/lib/libcurses/refresh.c
1.12 -> 1.13 basesrc/lib/libcurses/scroll.c
 1.59.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.63.6.10 18-Mar-2007  jdc Mark subsequent cells of multi-column characters with __WCWIDTH and
their attributes and only display them once.
 1.63.6.9 28-Feb-2007  blymn Output the non-spacing characters to the screen.
 1.63.6.8 05-Feb-2007  blymn Don't overwrite character width when copying characters between screens.
 1.63.6.7 04-Feb-2007  blymn Ansify static function prototypes
 1.63.6.6 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.63.6.5 23-Jan-2007  jdc Mask off the attribute bits when checking which attributes we need to set.
 1.63.6.4 22-Jan-2007  jdc Only produce debug information for the current line.
 1.63.6.3 22-Jan-2007  blymn * Make WCHAR libcurses the default build
* Sprinkle about some SET_WCOL() calls where they were missing
 1.63.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.63.6.1 21-Jan-2007  blymn Wide curses merge
 1.67.4.1 06-Nov-2007  matt sync with HEAD
 1.69.8.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.69.6.1 17-Jun-2008  yamt sync with head.
 1.73.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.75.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.75.2.1 23-May-2012  yamt sync with head.
 1.76.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.76.2.1 23-Jun-2013  tls resync from head
 1.80.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.80.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.80.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.87.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.88.12.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.88.12.1 10-Jun-2019  christos Sync with HEAD
 1.88.10.4 18-Jan-2019  pgoyette Synch with HEAD
 1.88.10.3 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.88.10.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.88.10.1 20-Oct-2018  pgoyette Sync with head
 1.88.4.2 09-Oct-2018  martin Back out the following revision(s) (requested by roy in ticket #1049):

lib/libcurses/refresh.c: revision 1.89
lib/libcurses/newwin.c: revision 1.53

curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.


As discussed in the PR, this change introduces a regression.
 1.88.4.1 09-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1049):

lib/libcurses/refresh.c: revision 1.89
lib/libcurses/newwin.c: revision 1.53

curses: allow drawing the lowest right hand cell of the terminal

This is a historical behaviour that needs fixing
If any terminal does scroll when drawing in the lowest right hand cell
of the terminal then an entry should be made in the terminfo database
(currently there is no standard code) to state that and define
__SCROLLWIN as before.

Fixes PR# 30978.
 1.126.2.1 20-Jul-2024  martin Pull up following revision(s) (requested by rin in ticket #756):

lib/libcurses/refresh.c: revision 1.127

Don't set the clear_to_eol variable in doupdate to NULL, this was a
leftover from previous code that makes no sense and makes worms(6)
crash randomly. Thanks to kre@ for reporting this.
 1.128.2.1 02-Aug-2025  perseant Sync with HEAD
 1.37 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.36 19-Oct-2022  blymn branches: 1.36.4;
Fixes for lib/56926 amongst other things:
- plod now correctly accounts for wide characters when plodding
- use erase line when in color mode if the terminal has the capability
- ensure that the CA_CONTINUATION flag is applied consistently to the
subsequent characters in a wide character.
- fix a bunch of refresh bugs that caused inconsistent placement of
wide characters.
 1.35 26-Apr-2022  blymn Fix for PR 55517.
Actually us x values to recalculate subwin columns.
 1.34 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.33 07-Sep-2021  rin PR lib/56388

For __newwin() and __resizewin(), the line hash was calculated as if
HAVE_WCHAR is disabled.

Fix this bug by refactoring __hash_line() function, which calculates
the line hash by an appropriate method.
 1.32 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.31 29-May-2021  nia wresize: don't bound pads to the size of the screen

allows avoiding a workaround in aiomixer,

ok blymn uwe
 1.30 02-Nov-2018  blymn branches: 1.30.6;
Remove obsolete clauses from copyright block. Original copyright was
mine so should be ok to do.
 1.29 03-Oct-2018  roy curses: resize ripped off windows

The application must still redraw them though.
 1.28 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.27 28-Sep-2018  roy curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@
 1.26 24-Jan-2017  roy branches: 1.26.4; 1.26.10; 1.26.12;
Implement POSIX Curses Soft Label Key functions.
 1.25 11-Jan-2017  roy branches: 1.25.2;
Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.24 10-Jan-2017  roy Fix resizing terms.
 1.23 10-Jan-2017  roy Implement POSIX curses function ripoffline(3).
 1.22 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.21 05-Jan-2017  roy Implement is_term_resized and resize_term(3) ncurses extensions.
resizeterm(3) is now a wrapper for resize_term(3).
 1.20 22-Jul-2009  roy branches: 1.20.28;
Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.19 29-Apr-2008  jdc Revert the scrolling region change from revision 1.18, as this breaks (at
least) mutt:

Only change the scrolling region if the window now has fewer rows.
 1.18 14-Apr-2008  jdc branches: 1.18.2;
Remove unused code.
Only change the scrolling region if the window now has fewer rows.
 1.17 08-Nov-2007  jdc Make sure we don't shrink windows or sub-windows so that they end up
with zero length or height.
 1.16 25-Oct-2007  jdc Only resize curscr, __virtscr and stdscr when the screen is resized.

Note the behaviour of sub-windows when the parent window is resized.

Fixes PR pkg/37129.
 1.15 27-Aug-2007  jdc Fix resizing bug where the values of LINES and/or COLS changed while we
were resizing windows, leading to inconsistencies between the sizes of
stdscr and curscr.

Should fix the curses part of PR lib/36702.
 1.14 28-May-2007  blymn branches: 1.14.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.13 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.12 15-Jan-2006  jdc branches: 1.12.4; 1.12.6; 1.12.8;
Background characters and attributes don't need to be kept per character
cell, as they are merged when characters are added. Remove the per cell
storage and clarify the manual page. Pointed out by ruibiao@.
 1.11 29-Apr-2004  christos PR/25397: David A. Holland: bug in second loop of resizeterm
(win used uninitialized), hidden by wrong gcc appeasal.
 1.10 16-Mar-2004  jdc branches: 1.10.2;
gcc -Wuninitialized
 1.9 30-Jul-2003  dsl Use _cursesi_screen->winlistp (depracating __winlist)
 1.8 26-Jun-2003  dsl Stop refresh(subwin) doing refresh on the other subwin's created before it.
(If nothing else the cursor would get left in the wrong place).
Fix some if (!flags & MASK) checks.
 1.7 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.6 10-Feb-2003  dsl resize subwindows when a window is resized, otherwise the subwin has
pointers into the ether.
(approved by christos)
 1.5 23-Dec-2002  jdc Only reset flags if the "window" is not a pad.
 1.4 22-Oct-2002  blymn Fix lint nits mainly with the len parameter type in hash_more.
 1.3 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.2 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.1 20-Sep-2001  blymn Add code to allow resizing of windows and the underlying terminal.
 1.10.2.1 11-May-2004  tron Pull up revision 1.11 (requested by kleink in ticket #297):
PR/25397: David A. Holland: bug in second loop of resizeterm
(win used uninitialized), hidden by wrong gcc appeasal.
 1.12.8.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.12.6.3 07-Feb-2007  blymn Destroy non-spacing storage before resizing happens.
 1.12.6.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.12.6.1 21-Jan-2007  blymn Wide curses merge
 1.12.4.2 01-Sep-2007  pavel Addendum to ticket #842:
Apply patch from jdc to correct compilation with -DDEBUG. closes PR lib/36868.
 1.12.4.1 28-Aug-2007  liamjfoy Pull up following revision(s) (requested by jdc in ticket #842):
lib/libcurses/tstp.c: revision 1.36
lib/libcurses/resize.c: revision 1.15
Fix resizing bug where the values of LINES and/or COLS changed while we
were resizing windows, leading to inconsistencies between the sizes of
stdscr and curscr.
Should fix the curses part of PR lib/36702.
 1.14.4.2 09-Jan-2008  matt sync with HEAD
 1.14.4.1 06-Nov-2007  matt sync with HEAD
 1.18.2.1 18-May-2008  yamt sync with head.
 1.20.28.2 20-Mar-2017  pgoyette Sync with HEAD
 1.20.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.25.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.26.12.1 10-Jun-2019  christos Sync with HEAD
 1.26.10.3 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.26.10.2 20-Oct-2018  pgoyette Sync with head
 1.26.10.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.26.4.2 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.26.4.1 03-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1043):

lib/libcurses/resize.c: revision 1.27
lib/libcurses/get_wch.c: revision 1.19
lib/libcurses/getch.c: revision 1.70

curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

OK kamil@
 1.30.6.1 31-May-2021  cjep sync with head
 1.36.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 01-Jan-2022  msaitoh s/implemenation/implementation/ in comment.
 1.6 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.5 03-Oct-2018  roy curses: resize ripped off windows

The application must still redraw them though.
 1.4 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.3 24-Jan-2017  roy branches: 1.3.2; 1.3.6; 1.3.12; 1.3.14;
Implement POSIX Curses Soft Label Key functions.
 1.2 12-Jan-2017  roy branches: 1.2.2;
Use the screen argument, not _cursesi_screen.
 1.1 11-Jan-2017  roy Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.2.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.3.14.1 10-Jun-2019  christos Sync with HEAD
 1.3.12.1 20-Oct-2018  pgoyette Sync with head
 1.3.6.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.3.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.3.2.1 24-Jan-2017  pgoyette file ripoffline.c was added on branch pgoyette-localcount on 2017-03-20 06:56:59 +0000
 1.24 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.23 30-Jun-2019  blymn branches: 1.23.12;
Fix return for mvscanw to return ERR/OK instead of the number of
elements scanned, now matches SUSv2 specification

Bump lib major due to return change.
 1.22 06-Jan-2017  roy branches: 1.22.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.21 17-Jul-2011  joerg branches: 1.21.24;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.20 07-Jul-2009  joerg Add vw_printw and vw_scanw as mandated by SUSv2's xcurses. Follow
ncurses and just make the historic vwprintw and vwscanw functions
aliases, ignoring that they should take a varargs.h va_list argument.
 1.19 29-May-2007  blymn Fix some compiler warnings.
Remove shadowed variable declarations when DEBUG is defined.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.16 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.15 30-Dec-2000  martin va_list -> _BSD_VA_LIST_ to be consistent with prototype
(doesn't compile on sparc64 otherwise)
 1.14 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.13 14-Apr-2000  simonb Don't wrap declarations of mvwprintw & mvwscanw.
 1.12 13-Apr-2000  jdc Restore const after the Open Group decided it was OK.
Thanks due to Brett Lymn.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 24-Jan-1994  cgd changes from branch
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd branches: 1.4.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 24-Jan-1994  cgd minor fixups
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file scanw.c was added on branch netbsd-1-0 on 1994-08-17 21:52:43 +0000
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.21.24.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.22.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.23.12.1 02-Aug-2025  perseant Sync with HEAD
 1.40 11-Jul-2024  blymn PR lib/58282

This is a partial fix for the issues raised. This change will
reduce the output by preventing the foreground and background
colours being set on each cell. The current colour pair applied
is tracked and requests to set the colour to the same pair is now
a no-op.
 1.39 27-May-2024  uwe branches: 1.39.2;
curses: init old_mode to 1 (normal visible cursor)

PR bin/58090: Ctrl-Z, fg makes blinking cursor in vi
ok blymn@
 1.38 17-May-2024  uwe curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@
 1.37 08-Apr-2022  andvar branches: 1.37.2;
fix various typos, mainly in comments, but also log messages, docs, game text.
 1.36 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.35 16-Nov-2018  blymn Fix for PR lib/52063
Many thanks to Onno van der Linden (o.vd.linden@quicknet.nl) for providing
the bulk of the patch that fixes the issue.
 1.34 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.33 20-Mar-2017  roy branches: 1.33.4; 1.33.10; 1.33.12;
Put back filter(3) I mistakenly removed in r1.29
 1.32 17-Feb-2017  roy Disable typeahead being set to infd by default as this seems to cause
refresh issues in nvi.
 1.31 31-Jan-2017  roy Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.30 24-Jan-2017  roy Implement POSIX Curses Soft Label Key functions.
 1.29 11-Jan-2017  roy branches: 1.29.2;
Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.28 10-Jan-2017  roy Implement POSIX curses function ripoffline(3).
 1.27 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.26 31-Dec-2016  roy Implement POSIX Curses typeahead function.
 1.25 30-Dec-2016  roy Add the POSIX filter() function to libcurses.
 1.24 26-Nov-2015  christos branches: 1.24.2;
fix memory leaks (from Rin Okuyama)
 1.23 10-Jun-2010  dholland After consultation with jdc@, apply the patch from PR 42412 even though
the crash went away -- it's not clear that it went away for any reason
besides by accident.

The change is: use calloc instead of malloc for allocating SCREENs.
 1.22 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.21 08-Dec-2007  jdc Keep pushed-back characters locally. Fixes problems where KEY_* symbols
are pushed back. Should fix the arrow keys part of PR pkg/37173.

While we are here, make getch() and get_wch() check for resize immediately,
instead of reading a key, checking for resize and then having to push-back
the just read key.
 1.20 28-May-2007  blymn branches: 1.20.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.19 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.18 23-Aug-2006  jdc branches: 1.18.4;
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.17 23-Mar-2004  jdc branches: 1.17.6; 1.17.12;
We should check against NULL here.
From Brett Lymn.
 1.16 22-Mar-2004  jdc Add KEY_RESIZE support and a SIGWINCH handler.
Fixes PR bin/20032.
This requires a change to KEY_MAX, which affects libform and libmenu, so we
need to change libcurses major number.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 30-Jul-2003  dsl Remove __winlistp, add *screen to WINDOW and initialise in newwin().
Make delwin() remove window from list of windows on its screen.
Free win->lspace and win->lines for subwins (they only share text space).
Free things in the correct (and same) order if malloc() fails in __makenew().
Adjust delscreen() for delwin() removing itself from winlist.
Fixes potential massive corruptions if delwin() called on a main window.
NB: not responsible for the sysinst core dumps :-(
 1.13 05-Apr-2003  jdc Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.

Fixes PR 20834 by Stephen Borrill.
 1.12 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.11 02-Feb-2003  jdc I was slightly too agressive removing clearok() in revision 1.8.
Add back a clearok(stdscr) for terminals where the startup sequence
doesn't clear the screen.
 1.10 27-Jan-2003  jdc ARemove (no longer used) __nca.
 1.9 09-Jan-2003  blymn Added halfdelay() function.
 1.8 23-Dec-2002  jdc Handle function argument changes to __newwin().
Don't call clearok() for new windows in newterm() - it caused a screen erase
on the first refresh() of the window.
 1.7 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.6 26-Jun-2002  itojun handle non-tty cases more gracefully.
 1.5 02-Jan-2002  blymn branches: 1.5.2;
Remove extraneous tabs from blank lines.
 1.4 31-Dec-2001  blymn * Fixed uninitialiased variable problem in newterm
* Implemented better fix for screen not clearing for refresh()
when newterm used to start curses.
 1.3 30-Dec-2001  blymn Make newterm set the default screen if the old default screen was
ended, stops new vi crashing. Thanks to Aymeric Vincent for the fix.
 1.2 27-Dec-2001  blymn Fix newterm so it syncs curscr to stdscr when term is created. Thanks
to Onno van der Linden for finding this bug.
 1.1 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.5.2.1 16-Jun-2003  grant Apply patch (requested by jdc in ticket #1244):

Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.
 1.17.12.1 25-Aug-2006  ghen Pull up following revision(s) (requested by jdc in ticket #54):
lib/libcurses/color.c: revision 1.31
lib/libcurses/screen.c: revision 1.18
lib/libcurses/delwin.c: revision 1.14
Make sure we update the correct window when changing colour pairs.
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.17.6.1 25-Aug-2006  ghen Pull up following revision(s) (requested by jdc in ticket #1475):
lib/libcurses/color.c: revision 1.31
lib/libcurses/screen.c: revision 1.18
lib/libcurses/delwin.c: revision 1.14
Make sure we update the correct window when changing colour pairs.
When deleting windows and screens, also set to NULL the standard names
that refer to the window or screen just deleted.
Add some more debugging information.
 1.18.4.3 25-Jan-2007  blymn * rearrange code to ensure that SET_WCOL() is called after attributes
are copied/set.

* fix some instances where attributes were being checked without
masking with WA_ATTRIBUTES

* Replace another instance of non-spacing character copying with function
call.
 1.18.4.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.18.4.1 21-Jan-2007  blymn Wide curses merge
 1.20.4.1 09-Jan-2008  matt sync with HEAD
 1.24.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.24.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.24.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.29.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.33.12.1 10-Jun-2019  christos Sync with HEAD
 1.33.10.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.33.10.1 20-Oct-2018  pgoyette Sync with head
 1.33.4.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.37.2.1 24-Jul-2024  martin Pull up following revision(s) (requested by uwe in ticket #768):

tests/lib/libcurses/tests/curs_set: revision 1.2
lib/libcurses/screen.c: revision 1.39

curses: init old_mode to 1 (normal visible cursor)
PR bin/58090: Ctrl-Z, fg makes blinking cursor in vi
ok blymn@

adjust initial cursor state to reflect reality
Missed in PR bin/58090

Fixes PR lib/58313
 1.39.2.1 02-Aug-2025  perseant Sync with HEAD
 1.29 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.28 05-Dec-2024  blymn Fixes PR lib/58823

Implement the ncurses extension wgetscrreg which returns the
scrolling region of the given window. Also implement getscrreg to
get the scrolling region of stdscr which appears to be missing from
ncurses but does follow the convention of having a non w prefixed
function that applies to stdscr.

Due to the addtion of a new function a minor library version bump has
been done.
 1.27 06-Sep-2021  rin branches: 1.27.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.26 09-Jun-2019  blymn Rework previous fix for getch cursor position when cursor is moved
without refresh. If the window is not dirty but the window cursor
position does not match curscr then move the cursor. This fixes
the issues seen in PR lib/54263.
 1.25 20-May-2019  blymn Back out incorrect fix for PR 53617 and fix it in a different way.
Keep track of the cursor location, if getch is called without a refresh
and without pending updates (dirty windows) then move the cursor to the
correct location directly. Doing this prevents unnecessary refreshes.
 1.24 10-Feb-2017  blymn branches: 1.24.12;
Remove checks for cursor being in scrolling region, ncurses doesn't
do checking, rather just scrolls the scrolling region so we shall
follow suit. SUSv2 says what is happens when scrl is called with the
cursor outside the scrolling is undefined so we should match ncurses.
This fixes PR#51819 without forcing tin to use terminfo directly.
 1.23 06-Jan-2017  roy branches: 1.23.2;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.22 03-Feb-2010  roy branches: 1.22.28;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.21 28-Jul-2009  christos fix debugging build. Hi Roy!
 1.20 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.19 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.18 07-Aug-2003  agc branches: 1.18.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.16 17-May-2001  jdc Set scrolling region top correctly.
Fixes scrolling bug in sub-windows.
 1.15 20-Apr-2001  jdc Implement scrolling regions :
has_ic()
has_il()
setscrreg()
wsetscrreg()
 1.14 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.13 01-Aug-2000  itojun use __cputchar(), not putchar().
otherwise, __CTRACE() will not be useful for debugging curses internals.
 1.12 15-Apr-2000  blymn branches: 1.12.4;
Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 13-Apr-1999  mrg branches: 1.10.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 17-Aug-1994  cgd branches: 1.7.2;
clean up import
 1.6 24-Jan-1994  cgd changes from branch
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd branches: 1.4.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.2.1 24-Jan-1994  cgd minor fixups
 1.7.2.2 17-Aug-1994  cgd clean up import
 1.7.2.1 17-Aug-1994  cgd file scroll.c was added on branch netbsd-1-0 on 1994-08-17 21:52:44 +0000
 1.10.6.1 05-Mar-2000  jdc Add wscrl().
 1.12.4.1 03-Aug-2000  itojun pullup (approved by releng-1-5)

> use __cputchar(), not putchar().
> otherwise, __CTRACE() will not be useful for debugging curses internals.

1.18 -> 1.19 basesrc/lib/libcurses/cr_put.c
1.38 -> 1.39 basesrc/lib/libcurses/refresh.c
1.12 -> 1.13 basesrc/lib/libcurses/scroll.c
 1.18.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.22.28.2 20-Mar-2017  pgoyette Sync with HEAD
 1.22.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.23.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.24.12.1 10-Jun-2019  christos Sync with HEAD
 1.27.4.1 02-Aug-2025  perseant Sync with HEAD
 1.7 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.6 06-Jan-2017  roy branches: 1.6.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.5 28-Apr-2008  martin branches: 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 24-Apr-2000  blymn branches: 1.4.38;
* Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.3 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 09-Jan-2000  jdc branches: 1.1.2;
file scrollok.c was initially added on branch curses-v3.
 1.1.2.1 09-Jan-2000  jdc New files for SUS v2 curses:
Move macros from curses.h
Add prototype for wchar_t
 1.4.38.1 18-May-2008  yamt sync with head.
 1.5.44.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.26.1 02-Aug-2025  perseant Sync with HEAD
 1.72 17-May-2024  uwe curses: constify newterm() and setterm() arguments

newterm() argument is const in the spec, so this fixes our
conformance.

setterm() is not in the spec, but it's natural and in ncurses its
argument is const too, so follow suit.

Doesn't change the ABI, so no bump required.

ok blymn@
 1.71 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.70 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.69 10-Jun-2021  mcf Add missing newline to debug trace message

ok blymn@
 1.68 26-Oct-2018  uwe Ignore terminfo padding specifications when checking whether
exit_attribute_mode contains exit_alt_charset_mode.

Fixes PR lib/53653.
 1.67 02-Oct-2018  roy curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.
LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635
 1.66 23-Mar-2017  roy branches: 1.66.4; 1.66.10; 1.66.12;
POSIX says that use_env(3) must precede setupterm(3).
The former lives in curses.h, but the latter lives in term.h.

This is solved by moving the function to libterminfo.
Because the environment can affect the terminal capabilities for
lines and columns, it follows that the tty size should affect it to.
So move that code to libterminfo and adjust in libcurses.
 1.65 20-Mar-2017  christos Make this compile again (gcc does not like strcmp(maybe-NULL, maybe-NULL);
simplify the life of the {compiler,human eyes}.
 1.64 31-Jan-2017  roy Move ESCDELAY to curses.c so all globals are close to each other.
Remove _reentrant and use ESCDELAY and TABSIZE as we're not really
reentrant.
 1.63 30-Jan-2017  roy Check _cursesi_term is set in a few places and sprinkle some static.
 1.62 30-Jan-2017  roy If either set_escdelay(3) or set_tabsize(3) are called, set _reentrant
to ensure we use the saved value for the sceen.

This effectively makes ESCDELAY and TABSIZE read-only when either
of these functions are called.
 1.61 11-Jan-2017  roy branches: 1.61.2;
Move the ripoffline logic out of screen.c and into ripoffline.c.
Store ripped off lines in the SCREEN structure so we can repaint then
when the terminal is resized.
Fix mvwin(3) so it can move windows in the ripped off area.
 1.60 10-Jan-2017  roy Implement POSIX curses function ripoffline(3).
 1.59 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.58 05-Jan-2017  roy Whitespace
 1.57 05-Jan-2017  roy Add the set_escdelay(3) and set_tabsize(3) ncurses extensions.
 1.56 31-Dec-2016  roy Implement POSIX curses use_env function.
 1.55 30-Dec-2016  roy Add the POSIX filter() function to libcurses.
 1.54 09-Jan-2016  jdc branches: 1.54.2;
Remove extra new line in debugging output.
 1.53 24-Nov-2015  christos PR/50092: don't leak screen on multiple setterms.
 1.52 16-Oct-2013  roy Add TABSIZE, which is derived from terminfo init_tabs.
Use this when processing \t.
If TABSIZE is set in the environment, this takes precedence.
 1.51 25-Sep-2013  dsainty Fix a NULL dereference if the exit_alt_charset_mode capability is not defined.

The previous version of this file changed a terminal initialisation test on
the exit_attribute_mode capability, checking for the exit_alt_charset_mode
capability as a substring, rather than performing a search for the hard-coded
^O character.

That works better on terminals where ^O is not the correct value for
exit_alt_charset_mode. But it works worse on terminals that don't have a
definition specified for exit_alt_charset_mode.

For example:

% TERMCAP='xterm:me=\E[m:' TERM=xterm vi
segmentation fault (core dumped) TERMCAP='xterm:me=\E[m:' TERM=xterm vi

The crash can be avoided (without fixing the bug) by defining
exit_alt_charset_mode:

% TERMCAP='xterm|:me=\E[m:ae=:' TERM=xterm vi
ex/vi: Error: xterm: No such process

We now test exit_alt_charset_mode for NULL before continuing with the fatal
test, restoring the original no-crash behaviour.

XXX does_ctrl_o() is now just a naive reimplementation of strstr(), so should
probably just use strstr() instead.
 1.50 05-May-2013  jdc Extend does_ctrl_o() to compare exit attribute and ext ACS sequences.
 1.49 21-Apr-2012  roy branches: 1.49.2;
Add capfile(5) to describe the termcap format.
Adjust various man pages and other documentation to point to capfile(5)
instead of termcap(5).
Remove getcap(3) as curses hasn't been building it for a long time.
Punt wrterm.c as tset no longer uses it.
 1.48 04-Oct-2011  roy branches: 1.48.2; 1.48.4;
Move longname(3) from curses to terminfo, pre-cursor to fix PR/43386.
 1.47 11-Feb-2010  roy Don't assume the terminal has a description.
 1.46 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.45 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.44 22-Feb-2009  christos Get the ESCDELAY from the environment.
 1.43 06-Oct-2007  martin branches: 1.43.14;
Make it build without HAVE_WCHAR
 1.42 19-Sep-2007  jdc We don't need separate #ifdef's for __ALTCHARSET and WA_ALTCHARSET, as they
are defined to be the same in curses.h.
 1.41 28-May-2007  blymn branches: 1.41.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.40 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.39 24-Jul-2004  blymn branches: 1.39.12;
Remove _cursesi_genbuf, it was not being set and caused a SIGSEGV
in getcap(). Fixed getcap() to use screen->cursesi_genbuf.
Thanks to Peter Bex for spotting this. This closes pr lib/26404.
 1.38 21-Oct-2003  fvdl branches: 1.38.2;
Don't compare a char to NULL.
 1.37 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.36 02-Feb-2003  jdc Redo the conflict calculation (again).
Assume that "me" clears all attributes apart from acs.
Problem noticed when working on window(1).
 1.35 27-Jan-2003  jdc Change the way we calculate conflicts when turning off attributes.
We now check the termcap entries for "\E[m" or "\E[0m" or a longer
"\E[ ... m" sequence containing a "0".
 1.34 05-Dec-2002  jdc Set LINES and COLS here so that __swflags() sets flags on the initial windows.
Remove no longer useful debug output.
 1.33 11-Sep-2002  jdc Add a hack for xterm-like terminals where "\E[m" will turn off
other attributes.
 1.32 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.31 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.30 11-Dec-2001  blymn * Remove termcap globals from public interface
* Clean up commented out code
 1.29 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.28 22-Dec-2000  jdc Revert the change to the `pc' capability from the previous change. Pointed
out in email by Thomas Dickey.
 1.27 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.26 12-Jun-2000  jdc Restore changes 1.23->1.24 that were accidently overwritten.
 1.25 12-Jun-2000  jdc Make sure tspace is large enough to hold all capabilities.
 1.24 03-Jun-2000  blymn Fix broken getcap call - it was always returning NULL. Thanks Itojun
for spotting this one!
 1.23 19-May-2000  mycroft branches: 1.23.2;
We already initialize UP and BC when we fire up Curses, so pass a null pointer
to t_goto() to avoid doing it again... and again... and...
 1.22 29-Apr-2000  mycroft Fix pasto.
 1.21 29-Apr-2000  mycroft Speed up refresh in the presence of attributes by precalculating a mask for
each `end' command to turn off other attributes in the case of conflicts.
 1.20 27-Apr-2000  jdc Background colour erase is 'ut' not 'be'.
 1.19 22-Apr-2000  blymn * Fixed need for duplicate namp string in setterm.c
* Added meta function (turns meta bit on and off on terminal if supported)
* Added curs_set to control cursor visibility if supported.
 1.18 19-Apr-2000  blymn Converted all termcap library calls to the "new" interface, this fixes
a problem with curses crashing when the CM capability was larger than
64 bytes and eliminates some possible buffer overflow problems.
 1.17 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.16 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.15 12-Apr-2000  jdc Add colour capabilities.
Increase size of attribute buffers.
Include private header.
 1.14 11-Apr-2000  blymn Made data structures opaque
 1.13 07-Dec-1999  simonb branches: 1.13.2;
Another unctrl() %s fix.
 1.12 28-Jun-1999  simonb branches: 1.12.4;
Get rid of the evil trailing spaces and tabs.
 1.11 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 30-Jan-1998  perry merge with lite-2
 1.8 22-Jul-1997  mikel RCSid police, fix warnings
 1.7 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 24-Jan-1994  cgd changes from branch
 1.4 04-Dec-1993  cgd update from branch
 1.3 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.2 09-Nov-1993  cgd branches: 1.2.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1 07-Aug-1993  mycroft branches: 1.1.1;
New files.
 1.1.1.2 30-Jan-1998  perry import lite-2
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.2.2.2 24-Jan-1994  cgd minor fixups
 1.2.2.1 04-Dec-1993  cgd update from latest
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file setterm.c was added on branch netbsd-1-0 on 1994-08-17 21:52:45 +0000
 1.12.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.13.2.2 05-Mar-2000  jdc Add alternate character set support.
 1.13.2.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.23.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.38.2.1 26-Jul-2004  tron Pull up revision 1.39 (requested by blymn in ticket #716):
Remove _cursesi_genbuf, it was not being set and caused a SIGSEGV
in getcap(). Fixed getcap() to use screen->cursesi_genbuf.
Thanks to Peter Bex for spotting this. This closes pr lib/26404.
 1.39.12.3 21-Jan-2007  jdc Change debug code slightly, so that it doesn't confuse __CTRACE().
 1.39.12.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.39.12.1 21-Jan-2007  blymn Wide curses merge
 1.41.4.1 06-Nov-2007  matt sync with HEAD
 1.43.14.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.48.4.2 26-Sep-2013  riz Pull up following revision(s) (requested by dsainty in ticket #960):
lib/libcurses/setterm.c: revision 1.51
Fix a NULL dereference if the exit_alt_charset_mode capability is not
defined.
The previous version of this file changed a terminal initialisation test on
the exit_attribute_mode capability, checking for the exit_alt_charset_mode
capability as a substring, rather than performing a search for the
hard-coded
^O character.
That works better on terminals where ^O is not the correct value for
exit_alt_charset_mode. But it works worse on terminals that don't have a
definition specified for exit_alt_charset_mode.
For example:
% TERMCAP='xterm:me=\E[m:' TERM=xterm vi
segmentation fault (core dumped) TERMCAP='xterm:me=\E[m:' TERM=xterm vi
The crash can be avoided (without fixing the bug) by defining
exit_alt_charset_mode:
% TERMCAP='xterm|:me=\E[m:ae=:' TERM=xterm vi
ex/vi: Error: xterm: No such process
We now test exit_alt_charset_mode for NULL before continuing with the fatal
test, restoring the original no-crash behaviour.
XXX does_ctrl_o() is now just a naive reimplementation of strstr(), so
should
probably just use strstr() instead.
 1.48.4.1 11-May-2013  riz branches: 1.48.4.1.2;
Pull up following revision(s) (requested by jdc in ticket #885):
lib/libcurses/setterm.c: revision 1.50
Extend does_ctrl_o() to compare exit attribute and ext ACS sequences.
 1.48.4.1.2.1 26-Sep-2013  riz Pull up following revision(s) (requested by dsainty in ticket #960):
lib/libcurses/setterm.c: revision 1.51
Fix a NULL dereference if the exit_alt_charset_mode capability is not
defined.
The previous version of this file changed a terminal initialisation test on
the exit_attribute_mode capability, checking for the exit_alt_charset_mode
capability as a substring, rather than performing a search for the
hard-coded
^O character.
That works better on terminals where ^O is not the correct value for
exit_alt_charset_mode. But it works worse on terminals that don't have a
definition specified for exit_alt_charset_mode.
For example:
% TERMCAP='xterm:me=\E[m:' TERM=xterm vi
segmentation fault (core dumped) TERMCAP='xterm:me=\E[m:' TERM=xterm vi
The crash can be avoided (without fixing the bug) by defining
exit_alt_charset_mode:
% TERMCAP='xterm|:me=\E[m:ae=:' TERM=xterm vi
ex/vi: Error: xterm: No such process
We now test exit_alt_charset_mode for NULL before continuing with the fatal
test, restoring the original no-crash behaviour.
XXX does_ctrl_o() is now just a naive reimplementation of strstr(), so
should
probably just use strstr() instead.
 1.48.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.48.2.1 23-May-2012  yamt sync with head.
 1.49.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.49.2.1 23-Jun-2013  tls resync from head
 1.54.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.54.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.54.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.61.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.66.12.1 10-Jun-2019  christos Sync with HEAD
 1.66.10.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.66.10.1 20-Oct-2018  pgoyette Sync with head
 1.66.4.1 04-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1047):

lib/libcurses/curses_private.h: revision 1.64
lib/libcurses/curses_private.h: revision 1.65
lib/libcurses/initscr.c: revision 1.33
lib/libcurses/curses_screen.3: revision 1.24
lib/libcurses/curses_screen.3: revision 1.25
lib/libcurses/newwin.c: revision 1.52
lib/libcurses/fileio.c: revision 1.6
lib/libcurses/ripoffline.c: revision 1.4
lib/libcurses/resize.c: revision 1.28
lib/libcurses/ripoffline.c: revision 1.5
lib/libcurses/resize.c: revision 1.29
lib/libcurses/screen.c: revision 1.34
lib/libcurses/setterm.c: revision 1.67

curses: fix ripoffline

When creating stdscr, ensure it's placed and sized in accordance with
lines ripped off.

LINES is no longer adjusted for lines ripped off.
POSIX makes no mention that it should be adjusted.
Bottom lines are now placed correctly.
Lines ripped off are now displayed after calling initscr.

ok kamil@

Fixes PR #53635

-

curses: resize ripped off windows
The application must still redraw them though.

-

Fix typos in curses_screen.3
Fn -> Ft in the resize_term(3) prototype
funcion -> function
 1.48 05-Dec-2024  blymn Fixes PR lib/58823

Implement the ncurses extension wgetscrreg which returns the
scrolling region of the given window. Also implement getscrreg to
get the scrolling region of stdscr which appears to be missing from
ncurses but does follow the convention of having a non w prefixed
function that applies to stdscr.

Due to the addtion of a new function a minor library version bump has
been done.
 1.47 12-Apr-2022  blymn branches: 1.47.4;
Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.46 06-Sep-2021  rin Always autogen fileio.h.

Bump CURSES_LIB_MAJOR.CURSES_LIB_MINOR to 9.0 belatedly.
 1.45 13-Mar-2020  roy terminfo: promote numeric parameters from short to int

POSIX mandates implementations must support upto a short but may exceed it.
When NetBSD terminfo was implemented, no terminfo description used over
a short, but because ncurses has supported ints for some time, some now do.

Infact, such a terminfo description was imported where colour pairs for
screen-256color went up to 65536 which exposed a bug in the existing
implementation where it set to zero. Because the number might mean
something more than a range, we need to be able to store it accurately.

This requires a version bump because whilst the API hasn't changed thanks
to C int promotion, the ABI has. Also the underlying database structure
has changed as well - we now store the numeric paramter inside a uint32_t
field rather than a uint16_t one.
Whilst this change can still read the old style database, the old one
cannot read the new one and thus we now maintain the database as
terminfo2.cdb, leaving the old library and database alone so old programs
still work fine.

libcurses, libfrom, libmenu and libpanel have also been bumped to
accomoate this change.
 1.44 30-Jun-2019  blymn Fix return for mvscanw to return ERR/OK instead of the number of
elements scanned, now matches SUSv2 specification

Bump lib major due to return change.
 1.43 16-Nov-2018  blymn Fix for PR lib/52063
Many thanks to Onno van der Linden (o.vd.linden@quicknet.nl) for providing
the bulk of the patch that fixes the issue.
 1.42 02-Jan-2017  roy branches: 1.42.12; 1.42.14;
Bump libcurses to 7.1 for prior additions.
 1.41 22-Nov-2015  kamil branches: 1.41.2;
Note to update major of libpanel(3) for new major of curses(3)
 1.40 11-Jan-2009  christos bump shared libraries.
 1.39 14-Apr-2008  jdc Increment minor for getwin()/putwin() addition.
Document fileio.h regeneration.
 1.38 21-Mar-2008  jdc Increment libcurses minor version (termattrs() and term_attrs() added).
 1.37 28-May-2007  blymn branches: 1.37.4;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.36 28-Mar-2004  jdc branches: 1.36.18;
Increment libcurses minor to 1 (addition of *echochar()).
 1.35 22-Mar-2004  jdc Increment major number (to 6) because of the change to KEY_MAX,
 1.34 04-Dec-2003  jdc Increment libcurses minor to 11 for nodelay() void -> int change.
 1.33 05-Oct-2003  jdc Increment libcurses minor to 10 for addition of redrawwin() and wredrawln().
 1.32 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.31 21-May-2003  jdc Increment libcurses minor for addition of addchstr() functions.
 1.30 30-Mar-2003  jdc Increment libcurses minor (addition of attr_set() group of functions).
 1.29 27-Jan-2003  jdc Increment the minor version (from 5 to 6) for the addition of
can_change_color() and no_color_video().
Add a note of things to change when the major version is incremented.
 1.28 09-Jan-2003  blymn Added halfdelay() function.
 1.27 23-Dec-2002  jdc Bump minor to 4 (pads support).
 1.26 22-Oct-2002  blymn Added the ncurses extensions define_key and keyok.
 1.25 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.24 19-Jul-2002  blymn * Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
 1.23 02-Dec-2001  christos lib/14813: Jason R. Thorpe: worm(6) no longer builds w/ new libcurses
Make baudrate a function, gc old variables, implement ospeed in terms of
baudrate, bump major number to 5, since we don't have __baset anymore.
 1.22 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.21 15-Oct-2001  blymn Added function - bumped minor version of lib.
 1.20 20-Apr-2001  jdc Bump libcurses minor (now 4.2).
 1.19 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.18 31-Dec-2000  jdc Libcurses-4.0
Removal of termcap capabilities requires major bump. Pointed out by Itojun.
Capabilities are still available if `_CURSES_TERMCAP_COMPAT' is defined.
 1.17 22-Dec-2000  jdc Libcurses minor bump.
 1.16 11-May-2000  jdc libcurses minor++.
 1.15 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.14 27-Apr-2000  jdc Bump libcurses minor (new functions - wnoutrefresh() and doupdate()).
 1.13 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.12 25-Apr-2000  blymn Bump minor version.
 1.11 11-Apr-2000  blymn Made data structures opaque
 1.10 27-Jun-1999  simonb branches: 1.10.6;
Little nit - major first, then minor.
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 25-Feb-1999  abs Add a note to update src/distrib/sets/lists/base/shl.*, and add a missing
RCS Id.
 1.7 18-Feb-1998  jtc Ncurses (like SysV/XOpen based curses implementations) includes
the termcap API. This changes bsd-curses to do the same, so we
can update program Makefiles and the like *before* ncurses 4.2
is integrated.
 1.6 05-Jan-1998  perry RCSID Police.
 1.5 17-Aug-1994  cgd branches: 1.5.2;
clean up import
 1.4 03-Apr-1994  cgd major number bump, for stdio and safety...
 1.3 04-Dec-1993  cgd minor rev
 1.2 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1 08-Nov-1993  cgd add shlib_version file, with version 0.0
 1.5.2.2 17-Aug-1994  cgd clean up import
 1.5.2.1 17-Aug-1994  cgd file shlib_version was added on branch netbsd-1-0 on 1994-08-17 21:52:46 +0000
 1.10.6.2 05-Mar-2000  jdc minor++ because of new functions.
 1.10.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.36.18.1 28-May-2007  blymn Bump shlib version.
 1.37.4.1 23-Mar-2008  matt sync with HEAD
 1.41.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.42.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.42.14.1 10-Jun-2019  christos Sync with HEAD
 1.42.12.1 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.47.4.1 02-Aug-2025  perseant Sync with HEAD
 1.21 20-Dec-2022  blymn Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.
 1.20 12-Apr-2022  blymn branches: 1.20.2;
Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.19 25-Jan-2022  blymn Correct (hopefully) the handling of wide characters.

* Remove the WCOL family of macros, these were "stealing" the upper bits
of a character attribute to store the column width of a character. No
warning was given about this in curses.h which meant it was easy to
accidentally reuse the bits in use by the WCOL macros (we already did).
Add couple of 16bit ints to the character structure iff HAVE_WCHAR is
true to hold the display width and wide char related flags (just
continuation at the moment)
* Convert all instances of WCOL macros to just reference the column width
in the char structure so it is not obfuscated.
* Fix cursor positioning so placing a cursor in the middle of a wide char
actually does just that.
* Fix plod so it understands that if the cursor is going to be positioned
in the middle of a wide char it cannot just reprint the char to get there.
* Fix plodput so it correctly counts the number of output characters for
wide characters.
* Fix slk routines to properly size the wctomb() buffer.
 1.18 06-Jan-2022  blymn Revert change for array definition, it was incorrect, thanks Uwe.
 1.17 06-Jan-2022  blymn Properly size and array to hold the larget return from wctomb.
 1.16 06-Sep-2021  rin Style fixes most for __CTRACE().
 1.15 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.14 15-Aug-2021  christos This is a mess; always define MB_LEN_MAX so both the regular and libhack
version of curses compiles. Really we should not be defining MB_LEN_MAX here,
and include <limits.h> in curses_private.h to get it.
 1.13 15-Aug-2021  christos need limits.h
 1.12 15-Aug-2021  christos Use MBL_LEN_MAX (constant) so that SSP works
 1.11 24-Jun-2021  martin Fix printf format for size_t
 1.10 24-Jun-2021  blymn Make sure we don't use wide char routines when DISABLE_WCHAR is in
effect.
 1.9 22-Jun-2021  blymn Fix how the slk are drawn by making sure we use ins_wchar in the
bottom left of the screen to avoid a scroll because this may cause
an ERR if scrollok is false.
 1.8 28-Jul-2019  uwe __slk_set_finalise - fix length vs. width confusion
 1.7 28-Jul-2019  uwe __slk_set - fix calculating "len" for HAVE_WCHAR
 1.6 27-Jul-2019  uwe Put slk_color() undef #ifdef HAVE_WCHAR too.
 1.5 27-Jul-2019  uwe Put wide character functions under #ifdef HAVE_WCHAR
 1.4 04-Oct-2018  roy curses: once __slk_init is called, reset slk_fmt

This allows soft label keys to be used on more than one terminal.
 1.3 04-Oct-2018  roy curses: declare SLK format as invalid until slk_init(3) called

If we don't, then when __slk_init with a valid format of 0 it sets
up labels to be drawn without a window.
 1.2 30-Jan-2017  roy branches: 1.2.2; 1.2.4; 1.2.8; 1.2.14; 1.2.16;
Just return ERR instead of asserting if someone calls the slk routines
to affect the ripped off window before the window is actually ripped off.
 1.1 24-Jan-2017  roy Implement POSIX Curses Soft Label Key functions.
 1.2.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.16.1 10-Jun-2019  christos Sync with HEAD
 1.2.14.1 20-Oct-2018  pgoyette Sync with head
 1.2.8.1 08-Oct-2018  martin Pull up following revision(s) (requested by roy in ticket #1048):

lib/libcurses/curses_private.h: revision 1.66
lib/libcurses/slk.c: revision 1.3
lib/libcurses/slk.c: revision 1.4

curses: declare SLK format as invalid until slk_init(3) called

If we don't, then when __slk_init with a valid format of 0 it sets
up labels to be drawn without a window.

-

curses: once __slk_init is called, reset slk_fmt

This allows soft label keys to be used on more than one terminal.
 1.2.4.2 21-Apr-2017  bouyer Sync with HEAD
 1.2.4.1 30-Jan-2017  bouyer file slk.c was added on branch bouyer-socketcan on 2017-04-21 16:53:10 +0000
 1.2.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.1 30-Jan-2017  pgoyette file slk.c was added on branch pgoyette-localcount on 2017-03-20 06:56:59 +0000
 1.20.2.1 21-Dec-2022  martin Pull up following revision(s) (requested by blymn in ticket #15):

lib/libcurses/slk.c: revision 1.21
lib/libcurses/addbytes.c: revision 1.68

Backout change to addnstr that broke other applications as n should be
the number of bytes to add - for multibyte characters n will be > 1.

Fix __slk_draw to pass in the actual length of the label instead of
the default label length because wide characters may make the
actual string length longer than the slk display length.
 1.20 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.19 10-Jan-2017  roy branches: 1.19.26;
Use the window's screen's terminal.
 1.18 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.17 29-Nov-2016  christos PR/51673: Carsten Kunze: curses: standend() does not turn off A_BOLD;
according the X/Open it needs to turn off all attributes.
 1.16 03-Feb-2010  roy branches: 1.16.28;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.15 20-Jan-2004  wiz Improve function descriptions. From Douwe Kiela.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 27-Jan-2003  jdc Remove check for attribute/colour conflict.
This is now handled in refresh.c as it's not possible to handle the
conflict with background colour here.
 1.12 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 12-Apr-2000  jdc Add check for conflict with colour.
 1.9 11-Apr-2000  blymn Made data structures opaque
 1.8 13-Apr-1999  mrg branches: 1.8.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file standout.c was added on branch netbsd-1-0 on 1994-08-17 21:52:47 +0000
 1.8.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.16.28.2 20-Mar-2017  pgoyette Sync with HEAD
 1.16.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.19.26.1 02-Aug-2025  perseant Sync with HEAD
 1.3 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.2 06-Jan-2017  roy branches: 1.2.2; 1.2.28;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.1 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.2.28.1 02-Aug-2025  perseant Sync with HEAD
 1.2.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.2.1 06-Jan-2017  pgoyette file syncok.c was added on branch pgoyette-localcount on 2017-01-07 08:56:04 +0000
 1.10 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.9 06-Jan-2017  roy branches: 1.9.26;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.8 04-Nov-2009  dsl branches: 1.8.28;
Round timeout values up.
More importantly convert 1..99 to 1, not 0.
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 25-Jul-2006  christos branches: 1.6.20;
PR/34011: Julian Coleman: Limit timeout to 25.5 seconds.
 1.5 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.4 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.3 12-Apr-2000  jdc Copyright assgned to TNF.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 13-Apr-1999  mrg branches: 1.1.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.1.6.1 05-Mar-2000  jdc Add !delay check.
 1.6.20.1 18-May-2008  yamt sync with head.
 1.8.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.26.1 02-Aug-2025  perseant Sync with HEAD
 1.19 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.18 06-Sep-2021  rin branches: 1.18.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.17 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.16 17-Oct-2015  uwe branches: 1.16.2;
Fix x/y edito.
 1.15 21-Jan-2007  jdc branches: 1.15.36; 1.15.54;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.14 07-Aug-2003  agc branches: 1.14.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.12 20-May-2000  mycroft GC __FORCEPAINT.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file toucholap.c was added on branch netbsd-1-0 on 1994-08-17 21:52:49 +0000
 1.14.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.15.54.1 07-Nov-2015  riz Pull up following revision(s) (requested by uwe in ticket #1007):
lib/libcurses/toucholap.c: revision 1.16
Fix x/y edito.
 1.15.36.1 15-Nov-2015  bouyer Pull up following revision(s) (requested by uwe in ticket #1337):
lib/libcurses/toucholap.c: revision 1.16
Fix x/y edito.
 1.16.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.4.1 02-Aug-2025  perseant Sync with HEAD
 1.35 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.34 12-Apr-2022  blymn branches: 1.34.4;
Make the default colour pair be pair 0 which appears to match other
curses implementations.
 1.33 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.32 03-Jul-2020  uwe wtouchln - verify/clip input parameters
From Naman Jain in PR lib/55454
 1.31 24-Apr-2019  blymn Add/improve debug output for some routines.
 1.30 06-Jan-2017  roy branches: 1.30.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.29 02-Jan-2017  roy Implement POSIX Curses functions immedok(3) and syncok(3).
 1.28 07-Jan-2016  jdc branches: 1.28.2;
Display force flag in debug print.
 1.27 06-Dec-2013  blymn Make the touch family of calls actually force an update of the
terminal bypassing optimisations. Previously if curses thought curscr
was in sync with virtscr (curses concept of what is on the screen) then
nothing would be output. This change forces an update out to the terminal
regardless.
 1.26 23-Feb-2010  drochner branches: 1.26.6; 1.26.12;
misc fixes and improvements:
-call setlocale(LC_CTYPE, "") before nl_langinfo(CODESET) if the
locale settings is (still) at "C" - otherwise the CODESET doesn't work
-fix the type of the WACS_* symbols -- this needs to be cchar_t*
-add safeguards where the return value of wcwidth() is used for
loop counters or indexing -- it can be -1
-use more common code in the widechar support case -- in particular
let the wchar functions do the work even if chtype ones were called
-implement wcursyncup/wsyncup/wsyncdown
-somewhat experimental: allow ACS_* variables to refer to WACS_*
table entries -- this way, programs using the old chtype using API
can use UTF8 line drawing on terminals which support UTF8 but not
ACS switching
-fix some logics bugs in UTF8 recognition and ALTCHARSET handling
 1.25 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.24 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.23 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.22 23-Aug-2006  jdc branches: 1.22.4;
Add some more debugging information.
 1.21 01-Jan-2006  jdc branches: 1.21.2;
Don't crash if asked to touch more lines than there are in a window.
 1.20 05-Oct-2003  jdc branches: 1.20.6;
Add redrawwin() and wredrawln().
Fixes PR lib/20038.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 17-Feb-2003  dsl Fix resize of windows with subwins.
Let window size be given as a -ver number => lines from bottom.
Fix trace calls of pointers
(approved by Brett Lumn)
 1.17 05-Dec-2002  jdc Add some (useful) debugging to wtouchln().
 1.16 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.15 20-May-2000  mycroft GC __FORCEPAINT.
 1.14 19-May-2000  mycroft Be more careful with the first/last pointers when untouching.
 1.13 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.12 15-Apr-2000  jdc Don't reset firstchp and lastchp even if this line was not dirty.
They could have been set previously by a parent window or sub-window.
 1.11 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.10 11-Apr-2000  blymn Made data structures opaque
 1.9 13-Apr-1999  mrg branches: 1.9.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file touchwin.c was added on branch netbsd-1-0 on 1994-08-17 21:52:50 +0000
 1.9.6.2 16-Jan-2000  jdc Remove bsd_touchwin().
 1.9.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.20.6.1 21-Jan-2006  snj Pull up following revision(s) (requested by jdc in ticket #1108):
lib/libcurses/touchwin.c: revision 1.21
Don't crash if asked to touch more lines than there are in a window.
 1.21.2.1 28-Aug-2006  tron Pull up following revision(s) (requested by jdc in ticket #75):
lib/libcurses/tty.c: revision 1.38
lib/libcurses/tstp.c: revision 1.33
lib/libcurses/touchwin.c: revision 1.22
Add some more debugging information.
 1.22.4.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.22.4.1 21-Jan-2007  blymn Wide curses merge
 1.26.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.30.14.1 10-Jun-2019  christos Sync with HEAD
 1.34.4.1 02-Aug-2025  perseant Sync with HEAD
 1.2 09-Nov-1993  mycroft Clean up deleted files.
 1.1 07-Aug-1993  mycroft New files.
 1.15 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.14 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.13 21-Jan-2007  jdc branches: 1.13.58;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.12 07-Aug-2003  agc branches: 1.12.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 26-Jun-2002  christos PR/17352: David Laight: Curses core-dumps on windows > 1024 wide.
 1.10 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.9 27-Apr-2000  jdc Fix `gcc -Wuninitialized`.
Use unctrl() for capability string when debugging.
 1.8 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.7 15-Apr-2000  jdc Changed function to use ANSI style.
 1.6 12-Apr-2000  jdc Include private header.
Make capability parser more generic (it is now also used by colour routines).
Note that the termcap file we use contains terminfo % escapes, which are
not always compatible with the termcap ones. We'll lose in those cases.
 1.5 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.4 22-Jul-1997  mikel RCSid police, fix warnings
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file tscroll.c was added on branch netbsd-1-0 on 1994-08-17 21:52:52 +0000
 1.12.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.13.58.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.45 06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.44 18-Oct-2018  roy curses: don't optimize stdout buffer for non BSD platforms

The way BSD setvbuf works is not portable and should not be relied on.
This is only important if curses is started, stopped and started in the
same session which is how portable applications handle terminal resizing.
 1.43 18-Sep-2018  rin PR lib/53615

Before invoking a previous signal handler, make sure it is not SIG_*.
Fix potential crash with SIGWINCH.

OK roy
 1.42 06-Jan-2017  roy branches: 1.42.6; 1.42.12; 1.42.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.41 24-Nov-2016  christos don't coredump if we call endwin when initscr fails.
 1.40 15-Oct-2013  christos branches: 1.40.8;
Instead of turning off the 8th bit on resume, turn it on, as it is on by
default. Problem reported by atatat@ when suspending vi and resuming loses
the ability to use the alt key.
 1.39 29-Aug-2011  christos branches: 1.39.2; 1.39.8;
Fix for systems that don't have TCSASOFT as intended originally. Simplify.
 1.38 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.37 22-Jul-2009  roy Prepare curses for the possibility of changing from termcap to terminfo.
term.h #defines lines, pad_char and no_color_video macros which conflict
with existing curses code. We change lines to alines and nlines depending
on use, pad_char to padchar and no_color_video becomes no_color_attributes
but with a strong alias from no_color_video.
 1.36 27-Aug-2007  jdc Fix resizing bug where the values of LINES and/or COLS changed while we
were resizing windows, leading to inconsistencies between the sizes of
stdscr and curscr.

Should fix the curses part of PR lib/36702.
 1.35 21-Jan-2007  jdc branches: 1.35.4;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.34 25-Aug-2006  jdc branches: 1.34.2; 1.34.4; 1.34.6;
Handle cases where the application installs a SIGWINCH handler after the
curses one is installed by:

1. not reinstalling the curses one after restarting
2. not sending KEY_RESIZE

Also, update the size of curscr, stdscr and __virtscr to match the new
screen size, so that their sizes are always updated.

Fixes the cases where applications call endwin() and then refresh() in
their SIGWINCH handler (i.e. the resizing problems in PR pkg/27777).
 1.33 23-Aug-2006  jdc Add some more debugging information.
 1.32 25-Mar-2004  jdc branches: 1.32.12;
Change TSTP handler back to using signal().
This fixes a problem where vi would not suspend.
Also, make sure that the signal handlers aren't set or removed multiple times.
Finally, add debug output when the signal handlers are set and removed.
 1.31 22-Mar-2004  jdc Add KEY_RESIZE support and a SIGWINCH handler.
Fixes PR bin/20032.
This requires a change to KEY_MAX, which affects libform and libmenu, so we
need to change libcurses major number.
 1.30 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.29 10-Jul-2003  dsl Stop def_prog_mode() saving incorrect termio settings.
Make set_prog_mode() set the correct settings.
I'm not certain how much restoration set_prog_mode() should do, but it
definitely doesn't want to do all of __restartwin().
Maybe __restartwin() should be calling set_prog_mode()?
 1.28 28-May-2003  dsl Don't restartwin() if it isn't stopped.
Ensures we don't save the modified tty flags (as well as doing all the
initialisation twice) if the application (eg systat) calls curses functions
in its own restart code.
 1.27 18-May-2003  dsl Don't do __stopwin() if it is already stopped.
Allows error messages from programs like sysinst() to be seen.
(There is an explicit stopwin() before the error message is output,
and a second in the atexit() called cleanup() routine)
 1.26 04-Aug-2002  jdc Reset cursor visibility after restarting the screen, as the cursor visibility
setting can be changed when the screen is restarted.
 1.25 02-Jan-2002  blymn Remove extraneous tabs from blank lines.
 1.24 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.23 14-Jan-2001  blymn There was a missing check for curscr != NULL, fixed.
 1.22 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.21 15-Jun-2000  jdc Move setting of __endwin so that we also change it from the stop handler.
 1.20 22-May-2000  jdc branches: 1.20.2;
Use __restartwin() in reset_prog_mode() and __stopwin() in
reset_shell_mode().
 1.19 17-May-2000  jdc Send, if necessary, 'ks' or 'ke' sequences from keypad() and wgetch().
Fixes PR 10116.
 1.18 27-Apr-2000  jdc Use __unsetattr() to unset attributes on 'curscr'.
 1.17 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.16 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.15 12-Apr-2000  jdc Replace __TERMATTR with __ATTRIBUTES (includes colour).
Add def_prog_mode() and reset_prog_mode().
 1.14 11-Apr-2000  blymn Made data structures opaque
 1.13 13-Apr-1999  mrg branches: 1.13.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.12 30-Jan-1998  perry merge with lite-2
 1.11 13-Nov-1997  phil Changes to make endwin() act like a SIGSTP in terms of nicely restarting
curses mode. Taken from e-mail about PR 3981. (Still some stuff left
in PR3981 to deal with.)
 1.10 12-Sep-1997  phil branches: 1.10.2;
Make endwin() save state so a subsequent call to wrefresh restores curses
and makes endwin()/wrefresh() act like a SIGTSTP.
 1.9 22-Jul-1997  mikel RCSid police, fix warnings
 1.8 17-Aug-1994  cgd branches: 1.8.2;
clean up import
 1.7 24-Jan-1994  cgd changes from branch
 1.6 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.5 09-Nov-1993  cgd branches: 1.5.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.4 10-Aug-1993  mycroft Actually use the signal number we're passed.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 24-Jan-1994  cgd minor fixups
 1.8.2.2 17-Aug-1994  cgd clean up import
 1.8.2.1 17-Aug-1994  cgd file tstp.c was added on branch netbsd-1-0 on 1994-08-17 21:52:53 +0000
 1.10.2.1 15-Nov-1997  mellon Pull rev 1.11 up from trunk (phil)
 1.13.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.20.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.32.12.2 28-Aug-2006  tron Pull up following revision(s) (requested by jdc in ticket #76):
lib/libcurses/tstp.c: revision 1.34
Handle cases where the application installs a SIGWINCH handler after the
curses one is installed by:
1. not reinstalling the curses one after restarting
2. not sending KEY_RESIZE
Also, update the size of curscr, stdscr and __virtscr to match the new
screen size, so that their sizes are always updated.
Fixes the cases where applications call endwin() and then refresh() in
their SIGWINCH handler (i.e. the resizing problems in PR pkg/27777).
 1.32.12.1 28-Aug-2006  tron Pull up following revision(s) (requested by jdc in ticket #75):
lib/libcurses/tty.c: revision 1.38
lib/libcurses/tstp.c: revision 1.33
lib/libcurses/touchwin.c: revision 1.22
Add some more debugging information.
 1.34.6.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.34.4.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.34.2.1 28-Aug-2007  liamjfoy Pull up following revision(s) (requested by jdc in ticket #842):
lib/libcurses/tstp.c: revision 1.36
lib/libcurses/resize.c: revision 1.15
Fix resizing bug where the values of LINES and/or COLS changed while we
were resizing windows, leading to inconsistencies between the sizes of
stdscr and curscr.
Should fix the curses part of PR lib/36702.
 1.35.4.1 06-Nov-2007  matt sync with HEAD
 1.39.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.39.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.40.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.42.14.1 10-Jun-2019  christos Sync with HEAD
 1.42.12.2 20-Oct-2018  pgoyette Sync with head
 1.42.12.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.42.6.1 27-Sep-2018  martin Pull up following revision(s) (requested by kamil in ticket #1039):

lib/libcurses/getch.c: revision 1.66
lib/libcurses/getch.c: revision 1.67
lib/libcurses/tstp.c: revision 1.43
lib/libcurses/get_wch.c: revision 1.15
lib/libcurses/get_wch.c: revision 1.16

PR lib/53615
getch() and get_wch() should return KEY_RESIZE when interrupted by SIGWIN=
CH.

OK roy

-

PR lib/53615
Before invoking a previous signal handler, make sure it is not SIG_*.
Fix potential crash with SIGWINCH.

OK roy

-

Correct detecting of terminal resize in curses(3) with keypad(,TRUE)
A previous change fixed only keypad(,FALSE) scenarios.

-

Handle catching terminal resize in INKEY_NORM and INKEY_ASSEMBLING (in the
middle of assembling a key code from passed codes) as both accept keys with
fgetc(3) and both can be in theory interrupted with a resize.

PR lib/53615
 1.51 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.50 09-Oct-2023  blymn branches: 1.50.2;
Correct the fd closed check so we actually check the outfd as per
the comment. Thanks for jdc@netbsd.org for catching this one.
 1.49 06-Sep-2021  rin branches: 1.49.2;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.48 16-Nov-2018  blymn Fix for PR lib/52063
Many thanks to Onno van der Linden (o.vd.linden@quicknet.nl) for providing
the bulk of the patch that fixes the issue.
 1.47 18-Oct-2018  roy curses: don't optimize stdout buffer for non BSD platforms

The way BSD setvbuf works is not portable and should not be relied on.
This is only important if curses is started, stopped and started in the
same session which is how portable applications handle terminal resizing.
 1.46 06-Jan-2017  roy branches: 1.46.12; 1.46.14;
KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.45 31-Dec-2016  roy Implement POSIX Curses typeahead function.
 1.44 12-Dec-2016  christos fix placement of lint comment
 1.43 29-Aug-2011  christos branches: 1.43.24;
Fix for systems that don't have TCSASOFT as intended originally. Simplify.
 1.42 03-Feb-2010  roy Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.41 01-Nov-2009  dsl Move calls to __restore_termios() into the failing path of the functions
that fail - instead of in most of the callers.
All rather pointless if tcsetattr() fails to set the mode we want we
are very unlikely to be able to restore any later on.
 1.40 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.39 21-Jan-2007  jdc Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.38 23-Aug-2006  jdc branches: 1.38.4;
Add some more debugging information.
 1.37 25-Jul-2006  christos branches: 1.37.2;
PR/34011: Julian Coleman: Limit timeout to 25.5 seconds.
 1.36 20-Jan-2004  wiz Add function descriptions. From Douwe Kiela.
 1.35 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.34 30-Jul-2003  dsl Adjust layut to put ?: clause on a single line
 1.33 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.32 05-Apr-2003  jdc Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.

Fixes PR 20834 by Stephen Borrill.
 1.31 09-Jan-2003  atatat Let's call it 'duration' instead of 'timeout' so that the compiler is happy.
 1.30 09-Jan-2003  blymn Added halfdelay() function.
 1.29 26-Jun-2002  itojun handle non-tty cases more gracefully.
 1.28 02-Jan-2002  blymn branches: 1.28.2;
Remove extraneous tabs from blank lines.
 1.27 31-Dec-2001  blymn fix __startwin() so it outputs the init strings to the correct device.
 1.26 02-Dec-2001  christos lib/14813: Jason R. Thorpe: worm(6) no longer builds w/ new libcurses
Make baudrate a function, gc old variables, implement ospeed in terms of
baudrate, bump major number to 5, since we don't have __baset anymore.
 1.25 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.24 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.23 16-Jun-2000  jdc Really fix the __endwin/stop handler problem.
 1.22 15-Jun-2000  jdc Move setting of __endwin so that we also change it from the stop handler.
 1.21 22-May-2000  jdc branches: 1.21.2;
Use __restartwin() in reset_prog_mode() and __stopwin() in
reset_shell_mode().
 1.20 17-May-2000  jdc Send, if necessary, 'ks' or 'ke' sequences from keypad() and wgetch().
Fixes PR 10116.
 1.19 01-May-2000  blymn * Made erasechar and killchar into functions
* Modified __init_getch to use termcap handle that has been allocated
(_cursesi_genbuf) instead of refetching it.
* Make wgetstr support erase - this is not a full blown SUSv2 version
but it is a start.
 1.18 27-Apr-2000  mycroft No, really, make sure ECHO is cleared in cbreak() mode too.
 1.17 27-Apr-2000  mycroft Don't fiddle with the tty echo state in echo() and noecho(); it should always
remain off.
 1.16 17-Apr-2000  blymn Multiple fixes:
* Added Bill's fixes for errors when compiling with WARNS=1
* Incorporated fixes to make usage of unctrl consistent in debug and
made improvements to ctrace - it now timestamps it's output better.
* Reduced the number of mallocs done by __init_getch by allocating key
structs in bunches instead of singly.
* Removed the shadowing of global declarations in newwin and subwin
functions
 1.15 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.14 12-Apr-2000  jdc Add intrflush().
Add def_shell_mode() and reset_shell_mode().
Include private header.
 1.13 11-Apr-2000  blymn Made data structures opaque
 1.12 28-Jun-1999  simonb branches: 1.12.6;
Get rid of the evil trailing spaces and tabs.
 1.11 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.10 30-Jan-1998  perry merge with lite-2
 1.9 13-Nov-1997  phil Changes to make endwin() act like a SIGSTP in terms of nicely restarting
curses mode. Taken from e-mail about PR 3981. (Still some stuff left
in PR3981 to deal with.)
 1.8 12-Sep-1997  phil branches: 1.8.2;
Make endwin() save state so a subsequent call to wrefresh restores curses
and makes endwin()/wrefresh() act like a SIGTSTP.
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 14-Aug-1994  mycroft Fix return value from endwin().
 1.4 24-Jan-1994  cgd branches: 1.4.2;
changes from branch
 1.3 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.2 09-Nov-1993  cgd branches: 1.2.2;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.1 07-Aug-1993  mycroft branches: 1.1.1;
New files.
 1.1.1.2 30-Jan-1998  perry import lite-2
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.2.2.1 24-Jan-1994  cgd minor fixups
 1.4.2.1 14-Aug-1994  mycroft update from trunk
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file tty.c was added on branch netbsd-1-0 on 1994-08-17 21:52:55 +0000
 1.8.2.1 15-Nov-1997  mellon Pull rev 1.9 up from trunk (phil)
 1.12.6.2 05-Mar-2000  jdc Use fpurge() in flushinp().
 1.12.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.21.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.28.2.1 16-Jun-2003  grant Apply patch (requested by jdc in ticket #1244):

Keep the cr->nl translation state in a separate variable, so that we can
do the translation ourselves (if the tty didn't do it for us).
Add debugging to track functions that change tty state.
 1.37.2.1 28-Aug-2006  tron Pull up following revision(s) (requested by jdc in ticket #75):
lib/libcurses/tty.c: revision 1.38
lib/libcurses/tstp.c: revision 1.33
lib/libcurses/touchwin.c: revision 1.22
Add some more debugging information.
 1.38.4.2 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.38.4.1 21-Jan-2007  blymn Wide curses merge
 1.43.24.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.46.14.1 10-Jun-2019  christos Sync with HEAD
 1.46.12.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.46.12.1 20-Oct-2018  pgoyette Sync with head
 1.49.2.1 10-Oct-2023  martin Pull up following revision(s) (requested by kim in ticket #402):

tests/lib/libcurses/check_files/waddstr2.chk: revision 1.2
tests/lib/libcurses/check_files/addstr3.chk: revision 1.5
lib/libcurses/addbytes.c: revision 1.69
lib/libcurses/tty.c: revision 1.50

Fix for install/56467

Set x to 0 before calling scroll based on a proposed fix by RVP (thanks!)
Update check files affected by a fix to addbyte.c in libcurses.

Correct the fd closed check so we actually check the outfd as per
the comment. Thanks for jdc%netbsd.org@localhost for catching this one.
 1.50.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.10 14-Feb-2004  christos branches: 1.10.18;
Fix the non working unctrl mess:
1. delete the incorrect duplicate macro from unctrl.h
2. move unctrl macros from curses.h to unctrl.h and make curses.h include
unctrl.h in curses.h instead of duplicating their definition.
3. constify unctrl arrays; make length unsigned.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.7 22-Jul-1997  mikel RCSid police, fix warnings
 1.6 17-Aug-1994  cgd branches: 1.6.2;
clean up import
 1.5 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.4 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs.
 1.3 07-Aug-1993  mycroft New version from uunet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.2 17-Aug-1994  cgd clean up import
 1.6.2.1 17-Aug-1994  cgd file unctrl.c was added on branch netbsd-1-0 on 1994-08-17 21:52:57 +0000
 1.10.18.1 21-Jan-2007  blymn Wide curses merge
 1.5 28-May-2015  wiz Fix quoting in macro.
Needed by dialog-1.2-20150513.
 1.4 28-May-2007  blymn branches: 1.4.36; 1.4.54;
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.3 14-Feb-2004  christos branches: 1.3.18;
Fix the non working unctrl mess:
1. delete the incorrect duplicate macro from unctrl.h
2. move unctrl macros from curses.h to unctrl.h and make curses.h include
unctrl.h in curses.h instead of duplicating their definition.
3. constify unctrl arrays; make length unsigned.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.1 23-May-1997  jtc Moved unctrl.h from games/mille.
Install it, as it's part of the curses interface.
 1.3.18.1 21-Jan-2007  blymn Wide curses merge
 1.4.54.1 01-Jun-2015  snj Pull up following revision(s) (requested by wiz in ticket #811):
lib/libcurses/unctrl.h: revision 1.5
Fix quoting in macro.
Needed by dialog-1.2-20150513.
 1.4.36.1 19-Jun-2015  snj Pull up following revision(s) (requested by wiz in ticket #1302):
lib/libcurses/unctrl.h: revision 1.5
Fix quoting in macro.
Needed by dialog-1.2-20150513.
 1.14 23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.13 06-Sep-2021  rin branches: 1.13.4;
Expand __CTRACE() to __nothing #ifndef DEBUG.

Remove most of #ifdef DEBUG around __CTRACE() calls.

No binary changes, except for line numbers for assert().
 1.12 06-Jan-2017  roy KNF.
Normalise coding style.
White space police.
Sprinkle some extra braces to make the flow more clear.

No functional changes.
 1.11 03-Feb-2010  roy branches: 1.11.28;
Userland now builds and uses terminfo instead of termcap.

OK: core@, jdc@
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 21-Jan-2007  jdc branches: 1.9.10;
Add debug "areas" that allow selective debugging by setting the
"CURSES_TRACE_MASK" environment variable. Postive vales include
debug areas, negative values exclude them.
 1.8 20-Jan-2004  wiz branches: 1.8.18;
Use standard comment format. Fix typo. From Douwe Kiela.
 1.7 27-Jan-2003  jdc Remove check for attribute/colour conflict.
This is now handled in refresh.c as it's not possible to handle the
conflict with background colour here.
 1.6 19-Dec-2000  jdc Rename variables refering to termcap capabilities from NN to __tc_nn. Case
adjusted to match termcap capability. A few other variable names renamed too
(ones related to or derived from termcap variables).
 1.5 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.4 15-Apr-2000  blymn Added functions to replace what were previously macros in curses.h
(this is a requirement of SUSv2) - the old macro behaviour can be
restored by defining _CURSES_USE_MACROS.
Changed function prototypes to use ANSI style.
All externally visible functions now have ANSI style declarations.
 1.3 12-Apr-2000  jdc Copyright assgned to TNF.
Add check for conflict with colour.
Shrink one line comments.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 13-Apr-1999  mrg branches: 1.1.6;
Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.1.6.1 09-Jan-2000  jdc Changes to make libcurses SUS v2 compatible.
 1.8.18.1 21-Jan-2007  jdc Apply the changes that add debug "areas" on HEAD to the wcurses branch.
Add correspending changes to the debug code that is only present on the branch.
 1.9.10.1 18-May-2008  yamt sync with head.
 1.11.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.13.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 06-Sep-2021  rin Fix old-style definition: curses_version() --> curses_version(void)
 1.3 03-Sep-2019  roy branches: 1.3.4;
curses: believe in unicorns

Hopefully this ends the bikeshed.
If you don't believe in unicorns, please #if 0 it out to preserve
the humour.
 1.2 03-Sep-2019  roy curses: Add __NetBSD_Curses_Version__

Similar to __NetBSD_Version__ from sys/param.h but has no
correlation to it or the ELF symver libcurses is built as.

If we say that v1 was everything prior to this, it makes sense to
start this from v2.
 1.1 02-Sep-2019  roy curses(3): add curses_version()

Returns NetBSD-Curses %s
Where %s is the NetBSD version taken from sys/param.h

Discussed on tech-net@, only for ncurses compat.
 1.3.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.4.1 03-Sep-2019  martin file version.c was added on branch phil-wifi on 2020-04-13 08:03:12 +0000
 1.3 20-Apr-2000  kleink * Move <wchar.h> from libcurses to include (for the missing functionality
is to be provided by libc).
* Define wint_t and size_t in <wchar.h> as well.
 1.2 11-Apr-2000  blymn Made data structures opaque
 1.1 09-Jan-2000  jdc branches: 1.1.2;
file wchar.h was initially added on branch curses-v3.
 1.1.2.1 09-Jan-2000  jdc New files for SUS v2 curses:
Move macros from curses.h
Add prototype for wchar_t
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
Wide curses merge
 1.1.2.2 31-Jan-2007  blymn Fix up build errors.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.5 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.4 07-Aug-2003  agc branches: 1.4.18;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.3 02-Jul-1999  simonb More trailing white space.
 1.2 09-Jan-1998  perry RCS Id Police.
 1.1 17-Aug-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 17-Aug-1994  cgd branches: 1.1.1.1.2;
new libcurses, from new nvi
 1.1.1.1.2.2 17-Aug-1994  cgd new libcurses, from new nvi
 1.1.1.1.2.1 17-Aug-1994  cgd file ex1.c was added on branch netbsd-1-0 on 1994-08-17 21:14:03 +0000
 1.4.18.2 31-Jan-2007  blymn Fix up build errors.
 1.4.18.1 21-Jan-2007  blymn Wide curses merge
 1.2 28-May-2007  blymn Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
 1.1 21-Jan-2007  blymn branches: 1.1.2;
This file originates from the ncurses distribution, thanks to the ncurses people for letting us use it
 1.1.2.2 27-Feb-2007  blymn Fix crash if number of lines in file were less than screen size.
 1.1.2.1 21-Jan-2007  blymn Merge wide curses.
 1.15 03-Dec-2021  andvar fix various typos in comments, log messages and documentation.
 1.14 15-Jul-2014  christos Use TOOL_VFONTEDPR
 1.13 15-Jul-2014  christos stopgap for non-netbsd build.
 1.12 05-Jul-2014  dholland Reorg docs, part 1:
Move all the reference manuals to subdirs of /usr/share/doc/reference.
We have subdirs ref1-ref9, corresponding to man page sections 1-9.

Everything that's the reference manual for a program (sections 1, 6,
8), C interface (sections 2, 3), driver or file system (section 4),
format or configuration (section 5), or kernel internal interface
(section 9) belongs in here.

Section 7 is a little less clear: some things that might go in section
7 if they were a man page aren't really reference manuals. So I'm only
putting things in reference section 7 that are (to me) clearly
reference material, rather than e.g. tutorials, guides, FAQs, etc.
This obviously leaves some room for debate, especially without first
editing the docs with this distinction in mind, but if people hate
what I've done things can always be moved again.

Note also that while roff macro man pages traditionally go in section
7, I have put all the roff documentation (macros, tools, etc.) in one
place in reference/ref1/roff. This will make it easier to find and
also easier to edit it into some kind of coherent form.
 1.11 05-Jul-2014  dholland Rework /usr/share/doc.

Update the <bsd.doc.mk> infrastructure, and update the docs to match
the new infrastructure.

- Build and install text, ps, pdf, and/or html, not roff sources.

- Don't wire the chapter numbers into the build system, or use them in
the installed pathnames. This didn't matter much when the docs were a
museum, but now that we're theoretically going to start maintaining
them again, we're going to add and remove documents periodically and
having the chapter numbers baked in creates a lot of thrashing for no
purpose.

- Specify the document name explicitly, rather than implicitly in a
path. Use this name (instead of other random strings) as the name
of the installed files.

- Specify the document section, which is the subdirectory of
/usr/share/doc to install into.

- Allow multiple subdocuments. (That is, multiple documents in one
output directory.)

- Enumerate the .png files groff emits along with html so they can be
installed.

- Remove assorted hand-rolled rules for running roff and roff widgetry
and add enough variable settings to make these unnecessary. This
includes support for
- explicit use of soelim
- refer
- tbl
- pic
- eqn

- Forcibly apply at least minimal amounts of sanity to certain
autogenerated roff files.

- Don't exclude USD.doc, SMM.doc, and PSD.doc directories from the
build, as they now actually do stuff.

Note: currently we can't generate pdf. This turns out to be a
nontrivial problem with no immediate solution forthcoming. So for now,
as a workaround, install compressed .ps as the printable form.
 1.10 10-Jul-2003  lukem branches: 1.10.62; 1.10.74;
Rename a large chunk of the make(1) variables which refer to a
program/tool from "FOO" to "TOOL_FOO". The new variables are:
TOOL_ASN1_COMPILE TOOL_CAP_MKDB TOOL_CAT TOOL_CKSUM TOOL_COMPILE_ET
TOOL_CONFIG TOOL_CRUNCHGEN TOOL_CTAGS TOOL_DB TOOL_EQN TOOL_FGEN
TOOL_GENCAT TOOL_GROFF TOOL_HEXDUMP TOOL_INDXBIB TOOL_INSTALLBOOT
TOOL_INSTALL_INFO TOOL_M4 TOOL_MAKEFS TOOL_MAKEINFO TOOL_MAKEWHATIS
TOOL_MDSETIMAGE TOOL_MENUC TOOL_MKCSMAPPER TOOL_MKESDB
TOOL_MKLOCALE TOOL_MKMAGIC TOOL_MKTEMP TOOL_MSGC TOOL_MTREE
TOOL_PAX TOOL_PIC TOOL_PREPMKBOOTIMAGE TOOL_PWD_MKDB TOOL_REFER
TOOL_ROFF_ASCII TOOL_ROFF_DVI TOOL_ROFF_HTML TOOL_ROFF_PS
TOOL_ROFF_RAW TOOL_RPCGEN TOOL_SOELIM TOOL_SUNLABEL TOOL_TBL
TOOL_UUDECODE TOOL_VGRIND TOOL_ZIC

For each, provide default in <bsd.sys.mk> of the form:
TOOL_FOO?= foo
and for the ${USETOOLS}=="yes" case in <bsd.own.mk>, provide override:
TOOL_FOO= ${TOOLDIR}/bin/${_TOOL_PREFIX}foo

Document all of these in bsd.README.

This cleans up a chunk of potential (and actual) namespace collision
within our build infrastructure, as well as improves consistency in
the share/mk documentation and provision of appropriate defaults for
each of these variables.
 1.9 13-Aug-2002  pooka add ${MACROS} to roff call to make output paper readable
 1.8 26-Jan-1999  tron Patch by Greg A. Woods to prevent creation of files in source directory
while building documentation. Fixes PR lib/6812.
 1.7 09-Jan-1998  perry RCS Id Police.
 1.6 21-Dec-1997  christos use ${SOELIM} instead of soelim
 1.5 21-Dec-1997  christos Make this use object directories.
 1.4 17-Aug-1994  cgd branches: 1.4.2;
clean up import
 1.3 01-Jul-1994  cgd install the right things
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.4.2.2 17-Aug-1994  cgd clean up import
 1.4.2.1 17-Aug-1994  cgd file Makefile was added on branch netbsd-1-0 on 1994-08-17 21:53:04 +0000
 1.10.74.1 10-Aug-2014  tls Rebase.
 1.10.62.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file Master was added on branch netbsd-1-0 on 1994-08-17 21:53:06 +0000
 1.8 13-Feb-2023  andvar s/chracter/character/ in documentation.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.5 02-Jul-1999  simonb More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file appen.A was added on branch netbsd-1-0 on 1994-08-17 21:53:06 +0000
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file appen.B was added on branch netbsd-1-0 on 1994-08-17 21:53:08 +0000
 1.8 13-Feb-2023  andvar s/chracter/character/ in documentation.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.5 02-Jul-1999  simonb More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file appen.C was added on branch netbsd-1-0 on 1994-08-17 21:53:09 +0000
 1.3 17-Aug-1994  mycroft Clean up deleted files.
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file c_macros was added on branch netbsd-1-0 on 1994-08-17 21:53:10 +0000
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file doc.I was added on branch netbsd-1-0 on 1994-08-17 21:53:11 +0000
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file doc.II was added on branch netbsd-1-0 on 1994-08-17 21:53:12 +0000
 1.6 07-Sep-2024  andvar spelling and grammar fixes, mainly in comments.
 1.5 07-Aug-2003  agc branches: 1.5.110;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file doc.III was added on branch netbsd-1-0 on 1994-08-17 21:53:13 +0000
 1.5.110.1 02-Aug-2025  perseant Sync with HEAD
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file doc.IV was added on branch netbsd-1-0 on 1994-08-17 21:53:14 +0000
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 02-Jul-1999  simonb More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file ex1.c was added on branch netbsd-1-0 on 1994-08-17 21:53:15 +0000
 1.8 06-Jul-2022  andvar fix various typos in comments.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 02-Jul-1999  simonb More trailing white space.
 1.5 09-Jan-1998  perry RCS Id Police.
 1.4 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file ex2.c was added on branch netbsd-1-0 on 1994-08-17 21:53:16 +0000
 1.36 14-Apr-2008  jdc Document termattrs(), term_attrs(), putwin() and getwin()
 1.35 28-Mar-2004  jdc Changes to support *echochar().
Should fix PR lib/24927.
 1.34 05-Oct-2003  jdc Add redrawwin() and wredrawln().
Fixes PR lib/20038.
 1.33 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.32 20-Jun-2003  jdc Add noqiflush() and qiflush()
Fixes PR lib/20037.
 1.31 20-Jun-2003  jdc Add keyname().
Fixes PR lib/20033.
Allow SMALL to be defined, to reduce the size of the library.
 1.30 21-May-2003  jdc Add addchstr() family of functions.
Based on mail from Douwe Kiela.
Fixes PR lib/21285 by Thomas Klausner.
 1.29 21-May-2003  jdc Add mvw* functions.
 1.28 21-May-2003  jdc Sort addbytes().
 1.27 30-Mar-2003  jdc Add attr_set() group of functions.
Fixes PR lib/20034 by Thomas Klausner.
 1.26 27-Jan-2003  jdc Rename can_change_colors() to can_change_color().
Add no_color_video().
 1.25 09-Jan-2003  blymn Added halfdelay() function.
 1.24 23-Dec-2002  jdc Add descriptions for newpad(), subpad(), prefresh() and pnoutrefresh().
 1.23 23-Oct-2002  blymn Added documentation for define_key and keyok
Fixed borkage with getpary.
 1.22 04-Aug-2002  jdc Set the curses default colours to white on black when using colour.
See the Single UNIX Specification, Version 2 :

http://www.opengroup.org/onlinepubs/007908799/xcurses/can_change_color.html

Also, add the functions :

use_default_colors();
assume_default_colors(fore, back);

(from ncurses) that allow the terminal default colours or user-specified
default colours to be used.
 1.21 19-Jul-2002  blymn Add idcok to documentation.
 1.20 02-Dec-2001  blymn * Major change to add support for the newterm/set_term functions.
* Added fix to getch.c suggested by Gabriel Rosenkoetter (thanks :-)
 1.19 14-Oct-2001  blymn Added 2 new functions and a macro:
- getparx
- getpary
- getparyx (macro)
Also minor tweak to the man page to correct grammar on a couple of items.
 1.18 08-Oct-2001  blymn Add mvderwin function.
 1.17 20-Sep-2001  blymn Add code to allow resizing of windows and the underlying terminal.
 1.16 21-Apr-2001  jdc Document getnstr().
 1.15 01-Jan-2001  simonb Add the instr and inchstr families of functions.
 1.14 27-Sep-2000  wrstuden Last revision had some problems. One .De was missing, and a number of
.De's were really .Ds's. Problems were causing output not to be rendered-
number of output pages more than doubled after these fixes, and made much more
sense.
 1.13 11-May-2000  jdc branches: 1.13.4;
Documemt getattrs(), delay_output() and napms().
Document functions (get*).
 1.12 27-Apr-2000  jdc Add wnoutrefresh() and doupdate().
 1.11 26-Apr-2000  blymn * Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.
 1.10 24-Apr-2000  blymn * Added rcs id line to files missing it.
* Added code to __restartwin to restore meta and cursor visibility states
* Added code to __stopwin to disable meta.
* Added the *line group of functions for drawing character lines.
 1.9 23-Apr-2000  blymn * Fixed bug in copywin which was copying more than it should.
* Changed call to wrefresh in wgetch to be before input read.
* Changed default old cursor mode to be high vis in curs_set
* Added documentation for various new functions to fns.doc.
 1.8 12-Apr-2000  jdc Add colour capabilities and functions.
Add background manipulation functions.
Add def/reset_prog/shell_mode().
 1.7 11-Apr-2000  blymn Made data structures opaque
 1.6 02-Jul-1999  simonb branches: 1.6.6;
More trailing white space.
 1.5 13-Apr-1999  mrg Upgrades the standard NetBSD curses library to provide some
of the SYSV curses facilities. The added features are the collapsing
of arrow and function keysequences (as defined by termcap for the
terminal) into symbolic code returns thus relieving the application of
recognising multi-character key sequences. Other features are the
capability to perform a timed wait for a key (good for when you are
not sure if there is a keypress ready or not) and the capability for
turning off the inter-key timeout when assembling multi-character
function keys.

this work was done by Julian Coleman <J.D.Coleman@newcastle.ac.uk>
and blymn@baea.com.au (Brett Lymn). i'm just integrating it. thanks
HEAPS guys!
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file fns.doc was added on branch netbsd-1-0 on 1994-08-17 21:53:17 +0000
 1.6.6.1 05-Mar-2000  jdc Document new functions.
 1.13.4.1 29-Sep-2000  wrstuden Pull in revision 1.13 -> 1.14. Approved by thorpej.

Original log message:

> Last revision had some problems. One .De was missing, and a number of
> .De's were really .Ds's. Problems were causing output not to be rendered-
> number of output pages more than doubled after these fixes, and made much more
> sense.
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 02-Jul-1999  simonb More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.0 was added on branch netbsd-1-0 on 1994-08-17 21:53:20 +0000
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 02-Jul-1999  simonb More trailing white space.
 1.5 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.1 was added on branch netbsd-1-0 on 1994-08-17 21:53:21 +0000
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.6 12-Apr-2000  jdc Add COLORS and COLOR_PAIRS.
 1.5 26-Jan-1999  tron Patch by Greg A. Woods to prevent creation of files in source directory
while building documentation. Fixes PR lib/6812.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.2 was added on branch netbsd-1-0 on 1994-08-17 21:53:22 +0000
 1.9 02-Nov-2003  wiz Typo; from Jared Yanovich via jmc@openbsd.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.6 02-Jul-1999  simonb More trailing white space.
 1.5 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.3 was added on branch netbsd-1-0 on 1994-08-17 21:53:23 +0000
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.4 was added on branch netbsd-1-0 on 1994-08-17 21:53:25 +0000
 1.10 20-Feb-2023  gutteridge intro.5: fix typo and grammar and simplify a phrase
 1.9 13-Feb-2023  andvar s/chracter/character/ in documentation.
 1.8 02-Nov-2003  wiz Typo; from Jared Yanovich via jmc@openbsd.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.5 02-Jul-1999  simonb More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.5 was added on branch netbsd-1-0 on 1994-08-17 21:53:27 +0000
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 21-May-2003  jdc Mention _CURSES_USE_MACROS.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file intro.6 was added on branch netbsd-1-0 on 1994-08-17 21:53:28 +0000
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 02-Jul-1999  simonb More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file life.c was added on branch netbsd-1-0 on 1994-08-17 21:53:29 +0000
 1.8 27-Apr-2004  uwe Add trailing space that got lost from the string definition.
Pointed out in PR lib/25340 by Juho Juopperi.
 1.7 07-Aug-2003  agc branches: 1.7.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 24-Jul-2000  hubertf ".di Df" -> ".di\n.Df", to fix creation of paper.ps
Noted in PR 10661 by Patrick Welche <prlw1@cam.ac.uk>
 1.5 02-Jul-1999  simonb branches: 1.5.10;
More trailing white space.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file macros was added on branch netbsd-1-0 on 1994-08-17 21:53:30 +0000
 1.5.10.1 24-Jul-2000  hubertf Pullup rev. 1.6 to 1.5 branch, OK'd by thorpej.

> ".di Df" -> ".di\n.Df", to fix creation of paper.ps
> Noted in PR 10661 by Patrick Welche <prlw1@cam.ac.uk>
 1.7.2.1 28-Apr-2004  jmc Pullup rev 1.8 (requested by uwe in ticket #204)

Add trailing space that got lost from the string definition. PR#25340
 1.2 09-Nov-1993  mycroft Clean up deleted files.
 1.1 09-Nov-1993  cgd update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.7 04-May-2023  uwe Fix spelling of Kurt Shoens surname.
PR misc/57389
 1.6 23-May-2005  christos Make these work with today's curses and termcap reality.
 1.5 07-Aug-2003  agc branches: 1.5.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file twinkle1.c was added on branch netbsd-1-0 on 1994-08-17 21:53:31 +0000
 1.5.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.6 23-May-2005  christos Make these work with today's curses and termcap reality.
 1.5 07-Aug-2003  agc branches: 1.5.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file twinkle2.c was added on branch netbsd-1-0 on 1994-08-17 21:53:34 +0000
 1.5.4.1 24-Jul-2005  snj Apply patch (requested by riz in ticket #5516):
Sync libcurses with HEAD of 2005-07-22.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 09-Jan-1998  perry RCS Id Police.
 1.3 17-Aug-1994  cgd branches: 1.3.2;
clean up import
 1.2 09-Nov-1993  cgd repeat after me: "I hate rcs ids"
 1.1 09-Nov-1993  cgd branches: 1.1.1;
update to new version from berkeley. doesn't compile yet, nor
does it have rcsid's. this is for diffs. new doc layout thang.
 1.1.1.1 17-Aug-1994  cgd new libcurses, from new nvi
 1.3.2.2 17-Aug-1994  cgd clean up import
 1.3.2.1 17-Aug-1994  cgd file win_st.c was added on branch netbsd-1-0 on 1994-08-17 21:53:35 +0000

RSS XML Feed