summaryrefslogtreecommitdiffstats
path: root/lib/libcurses/base
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2000-03-26 16:45:00 +0000
committermillert <millert@openbsd.org>2000-03-26 16:45:00 +0000
commitf3e2efddedcd14d4f5420fb6d8bdeffe9370bfe0 (patch)
tree3e27a9e1ea5b33fdfe6435a18bafe8eccaa574a1 /lib/libcurses/base
parentRemove idiotic, braindead casts T* -> void* (diff)
downloadwireguard-openbsd-f3e2efddedcd14d4f5420fb6d8bdeffe9370bfe0.tar.xz
wireguard-openbsd-f3e2efddedcd14d4f5420fb6d8bdeffe9370bfe0.zip
Update to ncurses-5.0-20000325
Diffstat (limited to 'lib/libcurses/base')
-rw-r--r--lib/libcurses/base/lib_color.c86
-rw-r--r--lib/libcurses/base/lib_dft_fgbg.c7
-rw-r--r--lib/libcurses/base/lib_mouse.c6
-rw-r--r--lib/libcurses/base/lib_set_term.c6
4 files changed, 60 insertions, 45 deletions
diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c
index e917647497b..7d246bd05ee 100644
--- a/lib/libcurses/base/lib_color.c
+++ b/lib/libcurses/base/lib_color.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_color.c,v 1.6 2000/03/10 01:35:02 millert Exp $ */
+/* $OpenBSD: lib_color.c,v 1.7 2000/03/26 16:45:03 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -43,7 +43,7 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: lib_color.c,v 1.45 2000/02/27 00:20:31 tom Exp $")
+MODULE_ID("$From: lib_color.c,v 1.49 2000/03/26 03:12:12 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
@@ -88,16 +88,20 @@ static const color_t hls_palette[] =
/* *INDENT-ON* */
#ifdef NCURSES_EXT_FUNCS
+/*
+ * These are called from _nc_do_color(), which in turn is called from
+ * vidattr - so we have to assume that SP may be null.
+ */
static int
default_fg(void)
{
- return (SP->_default_fg != C_MASK) ? SP->_default_fg : COLOR_WHITE;
+ return (SP != 0) ? SP->_default_fg : COLOR_WHITE;
}
static int
default_bg(void)
{
- return (SP->_default_bg != C_MASK) ? SP->_default_bg : COLOR_BLACK;
+ return SP != 0 ? SP->_default_bg : COLOR_BLACK;
}
#else
#define default_fg() COLOR_WHITE
@@ -261,7 +265,7 @@ init_pair(short pair, short f, short b)
T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
- if ((pair < 1) || (pair >= COLOR_PAIRS))
+ if ((pair < 0) || (pair >= COLOR_PAIRS))
returnCode(ERR);
#ifdef NCURSES_EXT_FUNCS
if (SP->_default_color) {
@@ -275,9 +279,12 @@ init_pair(short pair, short f, short b)
returnCode(ERR);
} else
#endif
+ {
if ((f < 0) || (f >= COLORS)
- || (b < 0) || (b >= COLORS))
- returnCode(ERR);
+ || (b < 0) || (b >= COLORS)
+ || (pair < 1))
+ returnCode(ERR);
+ }
/*
* When a pair's content is changed, replace its colors (if pair was
@@ -307,6 +314,8 @@ init_pair(short pair, short f, short b)
}
}
SP->_color_pairs[pair] = result;
+ if ((int)(SP->_current_attr & A_COLOR) == COLOR_PAIR(pair))
+ SP->_current_attr |= A_COLOR; /* force attribute update */
if (initialize_pair) {
const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
@@ -410,49 +419,52 @@ pair_content(short pair, short *f, short *b)
}
void
-_nc_do_color(int pair, bool reverse, int (*outc) (int))
+_nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
{
- short fg, bg;
+ short fg = C_MASK, bg = C_MASK;
+ short old_fg, old_bg;
- if (pair == 0) {
- if (
-#ifdef NCURSES_EXT_FUNCS
- !SP->_default_color ||
-#endif
- !set_original_colors()) {
- fg = default_fg();
- bg = default_bg();
- } else {
- fg = C_MASK;
- bg = C_MASK;
- }
- } else {
+ if (pair != 0) {
if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
tputs(tparm(set_color_pair, pair), 1, outc);
return;
- } else {
+ } else if (SP != 0) {
pair_content(pair, &fg, &bg);
-#ifdef NCURSES_EXT_FUNCS
- if (SP->_default_color) {
- if (fg == C_MASK)
- fg = SP->_default_fg;
- if (bg == C_MASK)
- bg = SP->_default_bg;
- }
-#endif
}
}
- if (fg == C_MASK || bg == C_MASK) {
- if (set_original_colors() != TRUE) {
- if (fg == C_MASK)
- fg = default_fg();
- if (bg == C_MASK)
- bg = default_bg();
+ if (old_pair >= 0 && SP != 0) {
+ pair_content(old_pair, &old_fg, &old_bg);
+ if ((fg == C_MASK && old_fg != C_MASK)
+ || (bg == C_MASK && old_bg != C_MASK)) {
+#ifdef NCURSES_EXT_FUNCS
+ /*
+ * A minor optimization - but extension. If "AX" is specified in
+ * the terminal description, treat it as screen's indicator of ECMA
+ * SGR 39 and SGR 49, and assume the two sequences are independent.
+ */
+ if (SP->_has_sgr_39_49 && old_bg == C_MASK && old_fg != C_MASK) {
+ tputs("\033[39m", 1, outc);
+ } else if (SP->_has_sgr_39_49 && old_fg == C_MASK && old_bg != C_MASK) {
+ tputs("\033[49m", 1, outc);
+ } else
+#endif
+ set_original_colors();
}
+ } else {
+ set_original_colors();
+ if (old_pair < 0)
+ return;
}
+#ifdef NCURSES_EXT_FUNCS
+ if (fg == C_MASK)
+ fg = default_fg();
+ if (bg == C_MASK)
+ bg = default_bg();
+#endif
+
if (reverse) {
short xx = fg;
fg = bg;
diff --git a/lib/libcurses/base/lib_dft_fgbg.c b/lib/libcurses/base/lib_dft_fgbg.c
index df007242458..b695b6d7f1e 100644
--- a/lib/libcurses/base/lib_dft_fgbg.c
+++ b/lib/libcurses/base/lib_dft_fgbg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_dft_fgbg.c,v 1.3 2000/03/10 01:35:02 millert Exp $ */
+/* $OpenBSD: lib_dft_fgbg.c,v 1.4 2000/03/26 16:45:03 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -35,7 +35,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_dft_fgbg.c,v 1.8 2000/02/19 23:57:40 tom Exp $")
+MODULE_ID("$From: lib_dft_fgbg.c,v 1.10 2000/03/26 03:08:53 Alexander.V.Lukyanov Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -64,9 +64,10 @@ assume_default_colors(int fg, int bg)
returnCode(ERR);
SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK);
+ SP->_has_sgr_39_49 = tigetflag("AX");
SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
if (SP->_color_pairs != 0)
- SP->_color_pairs[0] = PAIR_OF(fg, bg);
+ init_pair(0, fg, bg);
returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c
index 2bac96dd2e6..44bf768e833 100644
--- a/lib/libcurses/base/lib_mouse.c
+++ b/lib/libcurses/base/lib_mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_mouse.c,v 1.8 2000/03/10 01:35:02 millert Exp $ */
+/* $OpenBSD: lib_mouse.c,v 1.9 2000/03/26 16:45:03 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -86,7 +86,7 @@
#endif
#endif
-MODULE_ID("$From: lib_mouse.c,v 1.50 2000/02/13 00:59:39 tom Exp $")
+MODULE_ID("$From: lib_mouse.c,v 1.51 2000/03/18 22:11:42 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
@@ -228,7 +228,7 @@ static int initialized;
static void
initialize_mousetype(void)
{
- static char *xterm_kmous = "\033[M";
+ static const char *xterm_kmous = "\033[M";
/* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c
index 55f4b205a34..014e43a85f3 100644
--- a/lib/libcurses/base/lib_set_term.c
+++ b/lib/libcurses/base/lib_set_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_set_term.c,v 1.7 2000/03/10 01:35:02 millert Exp $ */
+/* $OpenBSD: lib_set_term.c,v 1.8 2000/03/26 16:45:03 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -45,7 +45,7 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_set_term.c,v 1.50 2000/02/13 00:59:39 tom Exp $")
+MODULE_ID("$From: lib_set_term.c,v 1.51 2000/03/26 01:03:36 tom Exp $")
SCREEN *
set_term(SCREEN * screenp)
@@ -190,6 +190,8 @@ _nc_setupscreen(short slines, short const scolumns, FILE * output)
SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
#endif
#ifdef NCURSES_EXT_FUNCS
+ SP->_default_color = FALSE;
+ SP->_has_sgr_39_49 = FALSE;
SP->_default_fg = COLOR_WHITE;
SP->_default_bg = COLOR_BLACK;
#endif