History log of /netbsd-current/lib/libcurses/getch.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 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().


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.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().


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.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().


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.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.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.74 14-May-2020 simonb

KNF nit.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.73 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.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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.73 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.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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.65 31-Jan-2017 roy

branches: 1.65.4; 1.65.10;
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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.65 31-Jan-2017 roy

branches: 1.65.4; 1.65.10;
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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.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


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930
# 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


Revision tags: pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320
# 1.65 31-Jan-2017 roy

branches: 1.65.4; 1.65.10;
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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 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.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.65 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.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.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107
# 1.62 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.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.


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 1.59 21-Apr-2012 roy

branches: 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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


Revision tags: pgoyette-localcount-20170107
# 1.62 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.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.


Revision tags: netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 1.59 21-Apr-2012 roy

branches: 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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.60 01-Jan-2017 roy

Implement ncurses extension has_key.


Revision tags: pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 tls-maxphys-base yamt-pagecache-base5
# 1.59 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.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 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.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 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@


Revision tags: matt-premerge-20091211
# 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.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.52 09-Feb-2009 jdc

Fix bug where a single ESC was not recognised when in keypad() mode.
Noticed by abs@.


Revision tags: netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base
# 1.51 14-Apr-2008 jdc

branches: 1.51.8; 1.51.10;
Add extra debugging information.


Revision tags: keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 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.


Revision tags: matt-mips64-base
# 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.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base wcurses-base abandoned-netbsd-4-base netbsd-4-base
# 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.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 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)


Revision tags: fvdl_fs64_base
# 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.


Revision tags: netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 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.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 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


Revision tags: curses-v3-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 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.


Revision tags: comdex-fall-1999-base
# 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!


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Feb-1998 perry

remove obsolete register declarations


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.8 22-Jul-1997 mikel

RCSid police, fix warnings


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE
# 1.7 17-Aug-1994 cgd

branches: 1.7.2;
clean up import


Revision tags: netbsd-1-0-base
# 1.6 09-Nov-1993 cgd

repeat after me: "I hate rcs ids"


Revision tags: CSRG-94-01-23 CSRG-last CSRG-93-11-06
# 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.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 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