Home | History | Annotate | Download | only in libcurses
History log of /src/lib/libcurses/get_wch.c
RevisionDateAuthorComments
 1.28  23-Dec-2024  blymn Sprinkle about some cycle wasting checks for the win pointer being
null. Unfortunately, ncurses does this and there is some sloppy code
out there that relies on the check resulting in segfaults in
NetBSD curses which then, of course, gets blamed for the error.
 1.27  24-Aug-2024  christos Check for returning ERR to avoid negative array index later (CID-1617248)
 1.26  06-Sep-2021  rin branches: 1.26.2; 1.26.4;
Style fixes most for __CTRACE().
 1.25  06-Sep-2021  rin Expand __CTRACE() to __nothing #ifndef DEBUG.

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

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

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

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

And in the documentation for get*():

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

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

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

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

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

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

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

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

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

Fixes #53636

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Extraneous whitespace removal.

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

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

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

Rename global variable "state" to "_cursesi_state".

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

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

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

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

Rename global variable "state" to "_cursesi_state".

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

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

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

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

curses: resizeterm(3) should always send KEY_RESIZE

Fixes #53636

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

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

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

OK roy

-

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

OK roy

-

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

-

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

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

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

Pads are not to be automatically refreshed on input.

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

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

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

lib/libcurses/get_wch.c: revision 1.27

Check for returning ERR to avoid negative array index later (CID-1617248)

RSS XML Feed