aboutsummaryrefslogtreecommitdiff
path: root/ncurses/base
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2021-02-25 17:22:00 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2021-02-25 17:22:00 +0000
commitbf0ab54638a5ef969749f6ceae30e864f9556ea8 (patch)
tree11690c2184e55d37bcd3c7fd13f3d0d9d20dbcb0 /ncurses/base
parent72c3fc31f590566e93496732d6fa769cd353e270 (diff)
downloadsrc-bf0ab54638a5ef969749f6ceae30e864f9556ea8.tar.gz
src-bf0ab54638a5ef969749f6ceae30e864f9556ea8.zip
Vendor import ncurses 6.2-20210220vendor/ncurses/6.2-20210220vendor/ncurses
Diffstat (limited to 'ncurses/base')
-rwxr-xr-xncurses/base/MKlib_gen.sh17
-rw-r--r--ncurses/base/lib_addch.c18
-rw-r--r--ncurses/base/lib_addstr.c10
-rw-r--r--ncurses/base/lib_bkgd.c74
-rw-r--r--ncurses/base/lib_color.c45
-rw-r--r--ncurses/base/lib_driver.c4
-rw-r--r--ncurses/base/lib_getch.c74
-rw-r--r--ncurses/base/lib_getstr.c3
-rw-r--r--ncurses/base/lib_initscr.c9
-rw-r--r--ncurses/base/lib_mouse.c62
-rw-r--r--ncurses/base/lib_newterm.c13
-rw-r--r--ncurses/base/lib_screen.c8
-rw-r--r--ncurses/base/lib_set_term.c29
-rw-r--r--ncurses/base/new_pair.c27
-rw-r--r--ncurses/base/wresize.c12
15 files changed, 297 insertions, 108 deletions
diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
index c8e4efe0c8d1..3829eff8eecb 100755
--- a/ncurses/base/MKlib_gen.sh
+++ b/ncurses/base/MKlib_gen.sh
@@ -2,7 +2,7 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.64 2020/02/15 14:58:02 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.68 2020/08/23 00:02:29 tom Exp $)
#
##############################################################################
# Copyright 2018,2020 Thomas E. Dickey #
@@ -73,12 +73,12 @@ USE="$3"
# appears in gcc 5.0 and (with modification) in 5.1, making it necessary to
# determine if we are using gcc, and if so, what version because the proposed
# solution uses a nonstandard option.
-PRG=`echo "$1" | $AWK '{ sub(/^[ ]*/,""); sub(/[ ].*$/, ""); print; }' || exit 0`
+PRG=`echo "$1" | "$AWK" '{ sub(/^[ ]*/,""); sub(/[ ].*$/, ""); print; }' || exit 0`
FSF=`("$PRG" --version 2>/dev/null || exit 0) | fgrep "Free Software Foundation" | head -n 1`
ALL=`"$PRG" -dumpversion 2>/dev/null || exit 0`
-ONE=`echo "$ALL" | sed -e 's/\..*$//'`
+ONE=`echo "$ALL" | sed -e 's/[^0-9].*$//'`
if test -n "$FSF" && test -n "$ALL" && test -n "$ONE" ; then
- if test $ONE -ge 5 ; then
+ if test "$ONE" -ge 5 ; then
echo ".. adding -P option to work around $PRG $ALL" >&2
preprocessor="$preprocessor -P"
fi
@@ -96,7 +96,6 @@ trap "rm -f $ED1 $ED2 $ED3 $ED4 $AW1 $AW2 $TMP" 0 1 2 3 15
ALL=$USE
if test "$USE" = implemented ; then
- CALL="call_"
cat >$ED1 <<EOF1
/^extern.*implemented/{
h
@@ -119,7 +118,6 @@ if test "$USE" = implemented ; then
}
EOF1
else
- CALL=""
cat >$ED1 <<EOF1
/^extern.*${ALL}/{
h
@@ -178,7 +176,7 @@ EOF3
if test "$USE" = generated ; then
cat >$ED4 <<EOF
- s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) (\2) (\3)/
+ s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) \2 (\3)/
/attr_[sg]et.* z)/s,z),z GCC_UNUSED),
EOF
else
@@ -433,6 +431,7 @@ BEGIN {
print "#include <ncurses_cfg.h>"
print ""
print "#undef NCURSES_NOMACROS /* _this_ file uses macros */"
+ print "#define NCURSES_NOMACROS 1"
print ""
print "#include <curses.priv.h>"
print ""
@@ -495,7 +494,7 @@ EOF
sed -n -f $ED1 \
| sed -e 's/NCURSES_EXPORT(\(.*\)) \(.*\) (\(.*\))/\1 \2(\3)/' \
| sed -f $ED2 \
-| $AWK -f $AW1 using=$USE \
+| "$AWK" -f $AW1 using="$USE" \
| sed \
-e 's/ [ ]*$//g' \
-e 's/^\([a-zA-Z_][a-zA-Z_]*[ *]*\)/\1 gen_/' \
@@ -507,7 +506,7 @@ $preprocessor $TMP 2>/dev/null \
-e 's/ / /g' \
-e 's/^ //' \
-e 's/_Bool/NCURSES_BOOL/g' \
-| $AWK -f $AW2 \
+| "$AWK" -f $AW2 \
| sed -f $ED3 \
| sed \
-e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \
diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c
index 604b13be8cec..378c2881faac 100644
--- a/ncurses/base/lib_addch.c
+++ b/ncurses/base/lib_addch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2020,2021 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.134 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.137 2021/02/20 22:24:34 tom Exp $")
static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
@@ -208,6 +208,20 @@ _nc_build_wch(WINDOW *win, ARG_CH_T ch)
WINDOW_EXT(win, addch_x) = x;
WINDOW_EXT(win, addch_y) = y;
+ /*
+ * If the background character is a wide-character, that may interfere with
+ * processing multibyte characters in this function.
+ */
+ if (!is8bits(CharOf(CHDEREF(ch)))) {
+ if (WINDOW_EXT(win, addch_used) != 0) {
+ /* discard the incomplete multibyte character */
+ WINDOW_EXT(win, addch_used) = 0;
+ TR(TRACE_VIRTPUT,
+ ("Alert discarded incomplete multibyte"));
+ }
+ return 1;
+ }
+
init_mb(state);
buffer[WINDOW_EXT(win, addch_used)] = (char) CharOf(CHDEREF(ch));
WINDOW_EXT(win, addch_used) += 1;
diff --git a/ncurses/base/lib_addstr.c b/ncurses/base/lib_addstr.c
index 19ebfcd5b337..a1e8829dd7f5 100644
--- a/ncurses/base/lib_addstr.c
+++ b/ncurses/base/lib_addstr.c
@@ -45,7 +45,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_addstr.c,v 1.56 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.57 2020/12/05 20:06:19 tom Exp $")
NCURSES_EXPORT(int)
waddnstr(WINDOW *win, const char *astr, int n)
@@ -60,10 +60,10 @@ waddnstr(WINDOW *win, const char *astr, int n)
("... current %s", _traceattr(WINDOW_ATTRS(win))));
code = OK;
if (n < 0)
- n = (int) strlen(astr);
+ n = INT_MAX;
TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
- while ((n-- > 0) && (*str != '\0')) {
+ while ((*str != '\0') && (n-- > 0)) {
NCURSES_CH_T ch;
TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str)));
SetChar(ch, UChar(*str++), A_NORMAL);
@@ -232,10 +232,10 @@ waddnwstr(WINDOW *win, const wchar_t *str, int n)
("... current %s", _traceattr(WINDOW_ATTRS(win))));
code = OK;
if (n < 0)
- n = (int) wcslen(str);
+ n = INT_MAX;
TR(TRACE_VIRTPUT, ("str is not null, length = %d", n));
- while ((n-- > 0) && (*str != L('\0'))) {
+ while ((*str != L('\0')) && (n-- > 0)) {
NCURSES_CH_T ch;
TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str));
SetChar(ch, *str++, A_NORMAL);
diff --git a/ncurses/base/lib_bkgd.c b/ncurses/base/lib_bkgd.c
index 2030030f91a5..23effc7cd141 100644
--- a/ncurses/base/lib_bkgd.c
+++ b/ncurses/base/lib_bkgd.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
* Copyright 1998-2014,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,9 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_bkgd.c,v 1.54 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.62 2021/02/13 20:06:54 tom Exp $")
+
+static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
/*
* Set the window's background information.
@@ -49,7 +51,7 @@ static NCURSES_INLINE void
#endif
wbkgrndset(WINDOW *win, const ARG_CH_T ch)
{
- T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracech_t(ch)));
+ T((T_CALLED("wbkgrndset(%p,%s)"), (void *) win, _tracech_t(ch)));
if (win) {
attr_t off = AttrOf(win->_nc_bkgd);
@@ -103,26 +105,36 @@ NCURSES_EXPORT(void)
wbkgdset(WINDOW *win, chtype ch)
{
NCURSES_CH_T wch;
+ T((T_CALLED("wbkgdset(%p,%s)"), (void *) win, _tracechtype(ch)));
SetChar2(wch, ch);
wbkgrndset(win, CHREF(wch));
+ returnVoid;
}
/*
* Set the window's background information and apply it to each cell.
*/
-#if USE_WIDEC_SUPPORT
-NCURSES_EXPORT(int)
-#else
static NCURSES_INLINE int
-#undef wbkgrnd
-#endif
-wbkgrnd(WINDOW *win, const ARG_CH_T ch)
+_nc_background(WINDOW *win, const ARG_CH_T ch, bool narrow)
{
#undef SP_PARM
#define SP_PARM SP /* to use Charable() */
int code = ERR;
- T((T_CALLED("wbkgd(%p,%s)"), (void *) win, _tracech_t(ch)));
+#if USE_WIDEC_SUPPORT
+ T((T_CALLED("%s(%p,%s)"),
+ narrow ? "wbkgd" : "wbkgrnd",
+ (void *) win,
+ _tracecchar_t(ch)));
+#define TraceChar(c) _tracecchar_t2(1, &(c))
+#else
+ T((T_CALLED("%s(%p,%s)"),
+ "wbkgd",
+ (void *) win,
+ _tracech_t(ch)));
+ (void) narrow;
+#define TraceChar(c) _tracechar(CharOf(c))
+#endif
if (SP == 0) {
;
@@ -143,6 +155,14 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
SetPair(new_bkgd, 0);
}
+ /* avoid setting background-character to a null */
+ if (CharOf(new_bkgd) == 0) {
+ NCURSES_CH_T tmp_bkgd = blank;
+ SetAttr(tmp_bkgd, AttrOf(new_bkgd));
+ SetPair(tmp_bkgd, GetPair(new_bkgd));
+ new_bkgd = tmp_bkgd;
+ }
+
memset(&old_bkgd, 0, sizeof(old_bkgd));
(void) wgetbkgrnd(win, &old_bkgd);
@@ -160,7 +180,7 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
old_pair = 0;
}
T(("... old background char %s, attr %s, pair %d",
- _tracechar(CharOf(old_char)), _traceattr(old_attr), old_pair));
+ TraceChar(old_char), _traceattr(old_attr), old_pair));
new_char = new_bkgd;
RemAttr(new_char, ~A_CHARTEXT);
@@ -168,14 +188,18 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
new_pair = GetPair(new_bkgd);
/* SVr4 limits background character to printable 7-bits */
- if (!Charable(new_bkgd)) {
+ if (
+#if USE_WIDEC_SUPPORT
+ narrow &&
+#endif
+ !Charable(new_bkgd)) {
new_char = old_char;
}
if (!(new_attr & A_COLOR)) {
new_pair = 0;
}
T(("... new background char %s, attr %s, pair %d",
- _tracechar(CharOf(new_char)), _traceattr(new_attr), new_pair));
+ TraceChar(new_char), _traceattr(new_attr), new_pair));
(void) wbkgrndset(win, CHREF(new_bkgd));
@@ -196,7 +220,19 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
attr_t tmp_attr = AttrOf(*cp);
if (CharEq(*cp, old_bkgd)) {
- SetChar2(*cp, CharOf(new_char));
+#if USE_WIDEC_SUPPORT
+ if (!narrow) {
+ if (Charable(new_bkgd)) {
+ SetChar2(*cp, CharOf(new_char));
+ } else {
+ SetChar(*cp, L' ', AttrOf(new_char));
+ }
+ memcpy(cp->chars,
+ new_char.chars,
+ CCHARW_MAX * sizeof(cp->chars[0]));
+ } else
+#endif
+ SetChar2(*cp, CharOf(new_char));
}
if (tmp_pair != 0) {
if (tmp_pair == old_pair) {
@@ -220,10 +256,18 @@ wbkgrnd(WINDOW *win, const ARG_CH_T ch)
returnCode(code);
}
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int)
+wbkgrnd(WINDOW *win, const ARG_CH_T ch)
+{
+ return _nc_background(win, ch, FALSE);
+}
+#endif
+
NCURSES_EXPORT(int)
wbkgd(WINDOW *win, chtype ch)
{
NCURSES_CH_T wch;
SetChar2(wch, ch);
- return wbkgrnd(win, CHREF(wch));
+ return _nc_background(win, CHREF(wch), TRUE);
}
diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c
index 376ad4f6047d..907e9743fcda 100644
--- a/ncurses/base/lib_color.c
+++ b/ncurses/base/lib_color.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -49,7 +49,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_color.c,v 1.143 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.146 2021/02/14 00:17:09 tom Exp $")
#ifdef USE_TERM_DRIVER
#define CanChange InfoOf(SP_PARM).canchange
@@ -140,7 +140,6 @@ NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette = hls_palette;
#endif
/* *INDENT-ON* */
-
#if NCURSES_EXT_FUNCS
/*
* These are called from _nc_do_color(), which in turn is called from
@@ -190,12 +189,12 @@ set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc)
if (set_a_background) {
TPUTS_TRACE("set_a_background");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_a_background, bg),
+ TIPARM_1(set_a_background, bg),
1, outc);
} else {
TPUTS_TRACE("set_background");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_background, toggled_colors(bg)),
+ TIPARM_1(set_background, toggled_colors(bg)),
1, outc);
}
#endif
@@ -210,12 +209,12 @@ set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc)
if (set_a_foreground) {
TPUTS_TRACE("set_a_foreground");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_a_foreground, fg),
+ TIPARM_1(set_a_foreground, fg),
1, outc);
} else {
TPUTS_TRACE("set_foreground");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_foreground, toggled_colors(fg)),
+ TIPARM_1(set_foreground, toggled_colors(fg)),
1, outc);
}
#endif
@@ -253,14 +252,15 @@ init_direct_colors(NCURSES_SP_DCL0)
{
static NCURSES_CONST char name[] = "RGB";
- int n;
- const char *s;
- int width;
rgb_bits_t *result = &(SP_PARM->_direct_color);
result->value = 0;
if (COLORS >= 8) {
+ int n;
+ const char *s;
+ int width;
+
/* find the number of bits needed for the maximum color value */
for (width = 0; (1 << width) - 1 < (COLORS - 1); ++width) {
;
@@ -361,7 +361,6 @@ NCURSES_EXPORT(int)
NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
{
int result = ERR;
- int maxpairs = 0, maxcolors = 0;
T((T_CALLED("start_color(%p)"), (void *) SP_PARM));
@@ -370,8 +369,8 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
} else if (SP_PARM->_coloron) {
result = OK;
} else {
- maxpairs = MaxPairs;
- maxcolors = MaxColors;
+ int maxpairs = MaxPairs;
+ int maxcolors = MaxColors;
if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
set_foreground_color(NCURSES_SP_ARGx
default_fg(NCURSES_SP_ARG),
@@ -672,14 +671,14 @@ _nc_init_pair(SCREEN *sp, int pair, int f, int b)
(int) tp[b].red, (int) tp[b].green, (int) tp[b].blue));
NCURSES_PUTP2("initialize_pair",
- TPARM_7(initialize_pair,
- pair,
- (int) tp[f].red,
- (int) tp[f].green,
- (int) tp[f].blue,
- (int) tp[b].red,
- (int) tp[b].green,
- (int) tp[b].blue));
+ TIPARM_7(initialize_pair,
+ pair,
+ (int) tp[f].red,
+ (int) tp[f].green,
+ (int) tp[f].blue,
+ (int) tp[b].red,
+ (int) tp[b].green,
+ (int) tp[b].blue));
}
#endif
@@ -746,7 +745,7 @@ _nc_init_color(SCREEN *sp, int color, int r, int g, int b)
CallDriver_4(sp, td_initcolor, color, r, g, b);
#else
NCURSES_PUTP2("initialize_color",
- TPARM_4(initialize_color, color, r, g, b));
+ TIPARM_4(initialize_color, color, r, g, b));
#endif
sp->_color_defs = max(color + 1, sp->_color_defs);
@@ -1004,7 +1003,7 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
- TPARM_1(set_color_pair, pair),
+ TIPARM_1(set_color_pair, pair),
1, outc);
return;
} else if (SP_PARM != 0) {
diff --git a/ncurses/base/lib_driver.c b/ncurses/base/lib_driver.c
index 546760710cb7..c53802f3732a 100644
--- a/ncurses/base/lib_driver.c
+++ b/ncurses/base/lib_driver.c
@@ -34,8 +34,9 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_driver.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_driver.c,v 1.9 2020/08/29 19:53:35 tom Exp $")
+#ifndef EXP_WIN32_DRIVER
typedef struct DriverEntry {
const char *name;
TERM_DRIVER *driver;
@@ -77,6 +78,7 @@ _nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret)
}
returnCode(code);
}
+#endif /* !EXP_WIN32_DRIVER */
NCURSES_EXPORT(int)
NCURSES_SP_NAME(has_key) (SCREEN *sp, int keycode)
diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c
index bf2115dd0641..38537591afc0 100644
--- a/ncurses/base/lib_getch.c
+++ b/ncurses/base/lib_getch.c
@@ -41,9 +41,10 @@
**
*/
+#define NEED_KEY_EVENT
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.139 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.141 2020/09/05 22:50:47 tom Exp $")
#include <fifo_defs.h>
@@ -134,7 +135,7 @@ _nc_use_meta(WINDOW *win)
}
#ifdef USE_TERM_DRIVER
-# ifdef _WIN32
+# if defined(_NC_WINDOWS) && !defined(EXP_WIN32_DRIVER)
static HANDLE
_nc_get_handle(int fd)
{
@@ -155,7 +156,14 @@ check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
#ifdef USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp);
rc = TCBOf(sp)->drv->td_testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
-# ifdef _WIN32
+# if defined(EXP_WIN32_DRIVER)
+ /* if we emulate terminfo on console, we have to use the console routine */
+ if (IsTermInfoOnConsole(sp)) {
+ rc = _nc_console_testmouse(sp,
+ _nc_console_handle(sp->_ifd),
+ delay EVENTLIST_2nd(evl));
+ } else
+# elif defined(_NC_WINDOWS)
/* if we emulate terminfo on console, we have to use the console routine */
if (IsTermInfoOnConsole(sp)) {
HANDLE fd = _nc_get_handle(sp->_ifd);
@@ -163,29 +171,36 @@ check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
} else
# endif
rc = TCB->drv->td_testmouse(TCB, delay EVENTLIST_2nd(evl));
-#else
-#if USE_SYSMOUSE
+#else /* !USE_TERM_DRIVER */
+# if USE_SYSMOUSE
if ((sp->_mouse_type == M_SYSMOUSE)
&& (sp->_sysmouse_head < sp->_sysmouse_tail)) {
rc = TW_MOUSE;
} else
-#endif
+# endif
{
+# if defined(EXP_WIN32_DRIVER)
+ rc = _nc_console_testmouse(sp,
+ _nc_console_handle(sp->_ifd),
+ delay
+ EVENTLIST_2nd(evl));
+# else
rc = _nc_timed_wait(sp,
TWAIT_MASK,
delay,
(int *) 0
EVENTLIST_2nd(evl));
-#if USE_SYSMOUSE
+# endif
+# if USE_SYSMOUSE
if ((sp->_mouse_type == M_SYSMOUSE)
&& (sp->_sysmouse_head < sp->_sysmouse_tail)
&& (rc == 0)
&& (errno == EINTR)) {
rc |= TW_MOUSE;
}
-#endif
+# endif
}
-#endif
+#endif /* USE_TERM_DRIVER */
return rc;
}
@@ -290,31 +305,54 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
} else
#endif
{ /* Can block... */
-#ifdef USE_TERM_DRIVER
+#if defined(USE_TERM_DRIVER)
int buf;
-#ifdef _WIN32
+# if defined(EXP_WIN32_DRIVER)
+ if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak) {
+# if USE_PTHREADS_EINTR
+ if ((pthread_self) && (pthread_kill) && (pthread_equal))
+ _nc_globals.read_thread = pthread_self();
+# endif
+ n = _nc_console_read(sp,
+ _nc_console_handle(sp->_ifd),
+ &buf);
+# if USE_PTHREADS_EINTR
+ _nc_globals.read_thread = 0;
+# endif
+ } else
+# elif defined(_NC_WINDOWS)
if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && sp->_cbreak)
n = _nc_mingw_console_read(sp,
_nc_get_handle(sp->_ifd),
&buf);
else
-#endif
+# endif /* EXP_WIN32_DRIVER */
n = CallDriver_1(sp, td_read, &buf);
ch = buf;
-#else
+#else /* !USE_TERM_DRIVER */
+#if defined(EXP_WIN32_DRIVER)
+ int buf;
+#endif
unsigned char c2 = 0;
-# if USE_PTHREADS_EINTR
-# if USE_WEAK_SYMBOLS
+#if USE_PTHREADS_EINTR
+#if USE_WEAK_SYMBOLS
if ((pthread_self) && (pthread_kill) && (pthread_equal))
-# endif
+#endif
_nc_globals.read_thread = pthread_self();
-# endif
+#endif
+#if defined(EXP_WIN32_DRIVER)
+ n = _nc_console_read(sp,
+ _nc_console_handle(sp->_ifd),
+ &buf);
+ c2 = buf;
+#else
n = (int) read(sp->_ifd, &c2, (size_t) 1);
+#endif
#if USE_PTHREADS_EINTR
_nc_globals.read_thread = 0;
#endif
ch = c2;
-#endif
+#endif /* USE_TERM_DRIVER */
}
if ((n == -1) || (n == 0)) {
diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c
index d0b09a3b927e..7871fb357a62 100644
--- a/ncurses/base/lib_getstr.c
+++ b/ncurses/base/lib_getstr.c
@@ -39,9 +39,10 @@
**
*/
+#define NEED_KEY_EVENT
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getstr.c,v 1.34 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.35 2020/07/18 20:02:24 tom Exp $")
/*
* This wipes out the last character, no matter whether it was a tab, control
diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c
index 2ace0924a0ea..6b9149135501 100644
--- a/ncurses/base/lib_initscr.c
+++ b/ncurses/base/lib_initscr.c
@@ -46,7 +46,7 @@
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$Id: lib_initscr.c,v 1.45 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.48 2020/09/07 14:26:48 tom Exp $")
NCURSES_EXPORT(WINDOW *)
initscr(void)
@@ -66,10 +66,9 @@ initscr(void)
_nc_globals.init_screen = TRUE;
- if ((env = getenv("TERM")) == 0
- || *env == '\0') {
- env = "unknown";
- }
+ env = getenv("TERM");
+ (void) VALID_TERM_ENV(env, "unknown");
+
if ((name = strdup(env)) == NULL) {
fprintf(stderr, "Error opening allocating $TERM.\n");
ExitProgram(EXIT_FAILURE);
diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c
index 2530dec5a6e4..6caef327a3c0 100644
--- a/ncurses/base/lib_mouse.c
+++ b/ncurses/base/lib_mouse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -85,7 +85,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.184 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.192 2021/02/14 00:17:09 tom Exp $")
#include <tic.h>
@@ -142,19 +142,29 @@ make an error
#define MASK_RESERVED_EVENT(x) (mmask_t) NCURSES_MOUSE_MASK(x, 040)
#if NCURSES_MOUSE_VERSION == 1
+
#define BUTTON_CLICKED (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED)
#define BUTTON_PRESSED (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED)
#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED | BUTTON4_RELEASED)
#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED)
#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED)
+
#define MAX_BUTTONS 4
+
#else
+
#define BUTTON_CLICKED (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED | BUTTON4_CLICKED | BUTTON5_CLICKED)
#define BUTTON_PRESSED (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED | BUTTON4_PRESSED | BUTTON5_PRESSED)
#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED | BUTTON4_RELEASED | BUTTON5_RELEASED)
#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED | BUTTON5_DOUBLE_CLICKED)
#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED | BUTTON5_TRIPLE_CLICKED)
+
+#if NCURSES_MOUSE_VERSION == 2
#define MAX_BUTTONS 5
+#else
+#define MAX_BUTTONS 11
+#endif
+
#endif
#define INVALID_EVENT -1
@@ -426,7 +436,7 @@ enable_xterm_mouse(SCREEN *sp, int enable)
#if USE_EMX_MOUSE
sp->_emxmouse_activated = enable;
#else
- NCURSES_PUTP2("xterm-mouse", TPARM_1(sp->_mouse_xtermcap, enable));
+ NCURSES_PUTP2("xterm-mouse", TIPARM_1(sp->_mouse_xtermcap, enable));
#endif
sp->_mouse_active = enable;
}
@@ -477,8 +487,6 @@ unload_gpm_library(SCREEN *sp)
T(("unload GPM library"));
sp->_mouse_gpm_loaded = FALSE;
sp->_mouse_fd = -1;
- dlclose(sp->_dlopen_gpm);
- sp->_dlopen_gpm = 0;
}
}
@@ -486,7 +494,14 @@ static void
load_gpm_library(SCREEN *sp)
{
sp->_mouse_gpm_found = FALSE;
- if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+
+ /*
+ * If we already had a successful dlopen, reuse it.
+ */
+ if (sp->_dlopen_gpm != 0) {
+ sp->_mouse_gpm_found = TRUE;
+ sp->_mouse_gpm_loaded = TRUE;
+ } else if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
@@ -500,13 +515,15 @@ load_gpm_library(SCREEN *sp)
#endif
T(("GPM initialization failed: %s", dlerror()));
unload_gpm_library(sp);
+ dlclose(sp->_dlopen_gpm);
+ sp->_dlopen_gpm = 0;
} else {
sp->_mouse_gpm_found = TRUE;
sp->_mouse_gpm_loaded = TRUE;
}
}
}
-#endif
+#endif /* HAVE_LIBDL */
static bool
enable_gpm_mouse(SCREEN *sp, bool enable)
@@ -928,7 +945,7 @@ handle_wheel(SCREEN *sp, MEVENT * eventp, int button, int wheel)
break;
case 1:
if (wheel) {
-#if NCURSES_MOUSE_VERSION == 2
+#if NCURSES_MOUSE_VERSION >= 2
eventp->bstate = MASK_PRESS(5);
/* See comment above for button 4 */
#else
@@ -953,10 +970,24 @@ static bool
decode_X10_bstate(SCREEN *sp, MEVENT * eventp, unsigned intro)
{
bool result;
+ int button = 0;
+ int wheel = (intro & 96) == 96;
eventp->bstate = 0;
- if (!handle_wheel(sp, eventp, (int) intro, (intro & 96) == 96)) {
+ if (intro >= 96) {
+ if (intro >= 160) {
+ button = (int) (intro - 152); /* buttons 8-11 */
+ } else {
+ button = (int) (intro - 92); /* buttons 4-7 */
+ }
+ } else {
+ button = (intro & 3);
+ }
+
+ if (button > MAX_BUTTONS) {
+ eventp->bstate = REPORT_MOUSE_POSITION;
+ } else if (!handle_wheel(sp, eventp, (int) intro, wheel)) {
/*
* Release events aren't reported for individual buttons, just for
@@ -1261,10 +1292,21 @@ decode_xterm_SGR1006(SCREEN *sp, MEVENT * eventp)
if (read_SGR(sp, &data)) {
int b = data.params[0];
int b3 = 1 + (b & 3);
+ int wheel = ((b & 64) == 64);
+
+ if (b >= 132) {
+ b3 = MAX_BUTTONS + 1;
+ } else if (b >= 128) {
+ b3 = (b - 120); /* buttons 8-11 */
+ } else if (b >= 64) {
+ b3 = (b - 60); /* buttons 6-7 */
+ }
eventp->id = NORMAL_EVENT;
if (data.final == 'M') {
- (void) handle_wheel(sp, eventp, b, (b & 64) == 64);
+ (void) handle_wheel(sp, eventp, b, wheel);
+ } else if (b3 > MAX_BUTTONS) {
+ eventp->bstate = REPORT_MOUSE_POSITION;
} else {
mmask_t pressed = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_PRESSED);
mmask_t release = (mmask_t) NCURSES_MOUSE_MASK(b3, NCURSES_BUTTON_RELEASED);
diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c
index ac897906e9fb..bba97ba1fae8 100644
--- a/ncurses/base/lib_newterm.c
+++ b/ncurses/base/lib_newterm.c
@@ -49,7 +49,7 @@
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.102 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.103 2020/09/05 21:34:04 tom Exp $")
#ifdef USE_TERM_DRIVER
#define NumLabels InfoOf(SP_PARM).numlabels
@@ -88,6 +88,12 @@ _nc_initscr(NCURSES_SP_DCL0)
buf.c_oflag &= (unsigned) ~(ONLCR);
#elif HAVE_SGTTY_H
buf.sg_flags &= ~(ECHO | CRMOD);
+#elif defined(EXP_WIN32_DRIVER)
+ buf.dwFlagIn = CONMODE_IN_DEFAULT;
+ buf.dwFlagOut = CONMODE_OUT_DEFAULT | VT_FLAG_OUT;
+ if (WINCONSOLE.isTermInfoConsole) {
+ buf.dwFlagIn |= VT_FLAG_IN;
+ }
#else
memset(&buf, 0, sizeof(buf));
#endif
@@ -195,6 +201,11 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
current = CURRENT_SCREEN;
its_term = (current ? current->_term : 0);
+#if defined(EXP_WIN32_DRIVER)
+ _setmode(fileno(_ifp), _O_BINARY);
+ _setmode(fileno(_ofp), _O_BINARY);
+#endif
+
INIT_TERM_DRIVER();
/* this loads the capability entry, then sets LINES and COLS */
if (
diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c
index 164356dc41de..6afba6611c61 100644
--- a/ncurses/base/lib_screen.c
+++ b/ncurses/base/lib_screen.c
@@ -42,7 +42,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_screen.c,v 1.97 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.100 2020/05/25 22:48:41 tom Exp $")
#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
@@ -58,7 +58,7 @@ MODULE_ID("$Id: lib_screen.c,v 1.97 2020/02/02 23:34:34 tom Exp $")
#define ARG_SLIMIT(name) /* nothing */
#endif
-#define CUR_SLIMIT _nc_SLIMIT(limit - (target - base))
+#define CUR_SLIMIT _nc_SLIMIT(limit - (size_t) (target - base))
#define TOP_SLIMIT _nc_SLIMIT(sizeof(buffer))
/*
@@ -67,7 +67,7 @@ MODULE_ID("$Id: lib_screen.c,v 1.97 2020/02/02 23:34:34 tom Exp $")
* format. It happens to be unused in the file 5.22 database (2015/03/07).
*/
static const char my_magic[] =
-{'\210', '\210', '\210', '\210'};
+{'\210', '\210', '\210', '\210', 0};
#if NCURSES_EXT_PUTWIN
typedef enum {
@@ -441,7 +441,7 @@ read_win(WINDOW *win, FILE *fp)
}
static int
-read_row(char *source, NCURSES_CH_T * prior, NCURSES_CH_T * target, int length)
+read_row(char *source, NCURSES_CH_T *prior, NCURSES_CH_T *target, int length)
{
while (*source != '\0' && length > 0) {
#if NCURSES_WIDECHAR
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index c5f26bc7a656..8573fbe7d522 100644
--- a/ncurses/base/lib_set_term.c
+++ b/ncurses/base/lib_set_term.c
@@ -44,10 +44,17 @@
#include <curses.priv.h>
#include <tic.h>
+#if USE_GPM_SUPPORT
+#ifdef HAVE_LIBDL
+/* use dynamic loader to avoid linkage dependency */
+#include <dlfcn.h>
+#endif
+#endif
+
#undef CUR
#define CUR SP_TERMTYPE
-MODULE_ID("$Id: lib_set_term.c,v 1.169 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.175 2020/10/10 19:09:03 juergen Exp $")
#ifdef USE_TERM_DRIVER
#define MaxColors InfoOf(sp).maxcolors
@@ -197,6 +204,14 @@ delscreen(SCREEN *sp)
if (_nc_find_prescr() == sp) {
_nc_forget_prescr();
}
+#if USE_GPM_SUPPORT
+#ifdef HAVE_LIBDL
+ if (sp->_dlopen_gpm != 0) {
+ dlclose(sp->_dlopen_gpm);
+ sp->_dlopen_gpm = 0;
+ }
+#endif
+#endif /* USE_GPM_SUPPORT */
free(sp);
/*
@@ -340,8 +355,9 @@ NCURSES_SP_NAME(_nc_setupscreen) (
sp->_next_screen = _nc_screen_chain;
_nc_screen_chain = sp;
- if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
+ if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0) {
returnCode(ERR);
+ }
#endif
/*
@@ -391,6 +407,11 @@ NCURSES_SP_NAME(_nc_setupscreen) (
fflush(output);
setmode(output, O_BINARY);
#endif
+#if defined(EXP_WIN32_DRIVER)
+ T(("setting output mode to binary"));
+ fflush(output);
+ _setmode(fileno(output), _O_BINARY);
+#endif
NCURSES_SP_NAME(_nc_set_buffer) (NCURSES_SP_ARGx output, TRUE);
sp->_lines = (NCURSES_SIZE_T) slines;
sp->_lines_avail = (NCURSES_SIZE_T) slines;
@@ -399,6 +420,10 @@ NCURSES_SP_NAME(_nc_setupscreen) (
fflush(output);
sp->_ofd = output ? fileno(output) : -1;
sp->_ofp = output;
+#if defined(EXP_WIN32_DRIVER)
+ if (output)
+ _setmode(fileno(output), _O_BINARY);
+#endif
sp->out_limit = (size_t) ((2 + slines) * (6 + scolumns));
if ((sp->out_buffer = malloc(sp->out_limit)) == 0)
sp->out_limit = 0;
diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c
index 547ab2818066..c04f4acbb95d 100644
--- a/ncurses/base/new_pair.c
+++ b/ncurses/base/new_pair.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2021 Thomas E. Dickey *
* Copyright 2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -61,7 +61,7 @@
#endif
-MODULE_ID("$Id: new_pair.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: new_pair.c,v 1.21 2021/02/14 00:17:09 tom Exp $")
#if NCURSES_EXT_COLORS
@@ -144,17 +144,16 @@ static int
_nc_find_color_pair(SCREEN *sp, int fg, int bg)
{
colorpair_t find;
- int result;
- void *pp;
+ int result = -1;
find.fg = fg;
find.bg = bg;
- if (sp != 0 &&
- (pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
- colorpair_t *temp = *(colorpair_t **) pp;
- result = (int) (temp - sp->_color_pairs);
- } else {
- result = -1;
+ if (sp != 0) {
+ void *pp;
+ if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
+ colorpair_t *temp = *(colorpair_t **) pp;
+ result = (int) (temp - sp->_color_pairs);
+ }
}
return result;
}
@@ -197,7 +196,10 @@ NCURSES_EXPORT(void)
_nc_reset_color_pair(SCREEN *sp, int pair, colorpair_t * next)
{
colorpair_t *last;
+
if (ValidPair(sp, pair)) {
+ bool used;
+
ReservePairs(sp, pair);
last = &(sp->_color_pairs[pair]);
delink_color_pair(sp, pair);
@@ -205,6 +207,11 @@ _nc_reset_color_pair(SCREEN *sp, int pair, colorpair_t * next)
(last->fg != next->fg || last->bg != next->bg)) {
/* remove the old entry from fast index */
tdelete(last, &sp->_ordered_pairs, compare_data);
+ used = FALSE;
+ } else {
+ used = (last->mode != cpFREE);
+ }
+ if (!used) {
/* create a new entry in fast index */
*last = *next;
tsearch(last, &sp->_ordered_pairs, compare_data);
diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c
index 93276ef5c42b..30718b8878fd 100644
--- a/ncurses/base/wresize.c
+++ b/ncurses/base/wresize.c
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.39 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.41 2020/04/18 21:01:00 tom Exp $")
static int
cleanup_lines(struct ldat *data, int length)
@@ -176,7 +176,15 @@ wresize(WINDOW *win, int ToLines, int ToCols)
if (s == 0)
returnCode(cleanup_lines(new_lines, row));
for (col = 0; col <= ToCols; ++col) {
- s[col] = (col <= size_x
+ bool valid = (col <= size_x);
+ if_WIDEC({
+ if (col == ToCols
+ && col < size_x
+ && isWidecBase(win->_line[row].text[col])) {
+ valid = FALSE;
+ }
+ });
+ s[col] = (valid
? win->_line[row].text[col]
: win->_nc_bkgd);
}