summaryrefslogtreecommitdiff
path: root/lib/libcurses/base
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-10-08 22:47:13 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-10-08 22:47:13 +0000
commit457e19a5caf834be99ae13c3efc359a02a42fb20 (patch)
tree244a1ee1210da4e47f53ccd339625b8a9f03b00e /lib/libcurses/base
parenta6de1b801fa82570ef7457ae6e5188ebc7f5d93e (diff)
update to ncurses-5.1-20001007
Diffstat (limited to 'lib/libcurses/base')
-rw-r--r--lib/libcurses/base/MKlib_gen.sh11
-rw-r--r--lib/libcurses/base/lib_addstr.c6
-rw-r--r--lib/libcurses/base/lib_color.c14
-rw-r--r--lib/libcurses/base/lib_colorset.c28
-rw-r--r--lib/libcurses/base/lib_getch.c20
-rw-r--r--lib/libcurses/base/lib_mouse.c8
-rw-r--r--lib/libcurses/base/lib_newterm.c8
-rw-r--r--lib/libcurses/base/lib_restart.c67
-rw-r--r--lib/libcurses/base/lib_set_term.c40
-rw-r--r--lib/libcurses/base/lib_winch.c21
10 files changed, 130 insertions, 93 deletions
diff --git a/lib/libcurses/base/MKlib_gen.sh b/lib/libcurses/base/MKlib_gen.sh
index 283a614c72d..2efe9091a08 100644
--- a/lib/libcurses/base/MKlib_gen.sh
+++ b/lib/libcurses/base/MKlib_gen.sh
@@ -2,8 +2,8 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# $OpenBSD: MKlib_gen.sh,v 1.1 1999/01/18 19:09:32 millert Exp $
-# ($From: MKlib_gen.sh,v 1.11 1998/01/17 14:16:52 Juan.Jose.Garcia.Ripoll Exp $)
+# $OpenBSD: MKlib_gen.sh,v 1.2 2000/10/08 22:46:58 millert Exp $
+# ($From: MKlib_gen.sh,v 1.12 2000/07/29 16:30:11 tom Exp $)
#
# The XSI Curses standard requires all curses entry points to exist as
# functions, even though many definitions would normally be shadowed
@@ -114,6 +114,11 @@ BEGIN {
print "\n"
skip=1;
+ if ( $1 == "chtype" ) {
+ returnType = "Char";
+ } else {
+ returnType = "Code";
+ }
print "M_" $2
print $0;
print "{";
@@ -201,7 +206,7 @@ BEGIN {
if (match($0, "^void"))
call = ""
else if (dotrace)
- call = "returnCode( ";
+ call = sprintf("return%s( ", returnType);
else
call = "%%return ";
diff --git a/lib/libcurses/base/lib_addstr.c b/lib/libcurses/base/lib_addstr.c
index 32d5fbb116f..99d76a18aa8 100644
--- a/lib/libcurses/base/lib_addstr.c
+++ b/lib/libcurses/base/lib_addstr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_addstr.c,v 1.2 2000/06/19 03:53:38 millert Exp $ */
+/* $OpenBSD: lib_addstr.c,v 1.3 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_addstr.c,v 1.17 2000/04/29 21:15:55 tom Exp $")
+MODULE_ID("$From: lib_addstr.c,v 1.18 2000/07/29 16:42:41 tom Exp $")
int
waddnstr(WINDOW *win, const char *const astr, int n)
@@ -53,7 +53,7 @@ waddnstr(WINDOW *win, const char *const astr, int n)
T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
if (win && (str != 0)) {
- T(("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs)));
TR(TRACE_VIRTPUT, ("str is not null"));
code = OK;
if (n < 0)
diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c
index a1a195453c4..952698083d0 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.8 2000/06/19 03:53:40 millert Exp $ */
+/* $OpenBSD: lib_color.c,v 1.9 2000/10/08 22:46:58 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.51 2000/05/20 20:09:22 tom Exp $")
+MODULE_ID("$From: lib_color.c,v 1.53 2000/09/02 18:02:15 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
@@ -87,7 +87,7 @@ static const color_t hls_palette[] =
};
/* *INDENT-ON* */
-#ifdef NCURSES_EXT_FUNCS
+#if 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.
@@ -267,7 +267,7 @@ init_pair(short pair, short f, short b)
if ((pair < 0) || (pair >= COLOR_PAIRS))
returnCode(ERR);
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (SP->_default_color) {
if (f < 0)
f = C_MASK;
@@ -440,7 +440,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
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
+#if NCURSES_EXT_FUNCS
/*
* A minor optimization - but extension. If "AX" is specified in
* the terminal description, treat it as screen's indicator of ECMA
@@ -460,7 +460,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
return;
}
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
if (fg == C_MASK)
fg = default_fg();
if (bg == C_MASK)
@@ -473,7 +473,7 @@ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
bg = xx;
}
- T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+ TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
if (fg != C_MASK) {
set_foreground_color(fg, outc);
diff --git a/lib/libcurses/base/lib_colorset.c b/lib/libcurses/base/lib_colorset.c
index e3070f4ce30..0c03674baab 100644
--- a/lib/libcurses/base/lib_colorset.c
+++ b/lib/libcurses/base/lib_colorset.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_colorset.c,v 1.2 1999/05/17 03:03:58 millert Exp $ */
+/* $OpenBSD: lib_colorset.c,v 1.3 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,17 +42,19 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$From: lib_colorset.c,v 1.5 1999/05/16 17:13:43 juergen Exp $")
+MODULE_ID("$From: lib_colorset.c,v 1.6 2000/07/29 16:37:19 tom Exp $")
-int wcolor_set(WINDOW *win, short color_pair_number, void *opts)
+int
+wcolor_set(WINDOW *win, short color_pair_number, void *opts)
{
- T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
- if (win && !opts && (color_pair_number >= 0) && (color_pair_number < COLOR_PAIRS)) {
- T(("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
- toggle_attr_on(win->_attrs,COLOR_PAIR(color_pair_number));
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
+ if (win
+ && !opts
+ && (color_pair_number >= 0)
+ && (color_pair_number < COLOR_PAIRS)) {
+ TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
+ toggle_attr_on(win->_attrs, COLOR_PAIR(color_pair_number));
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
-
-
diff --git a/lib/libcurses/base/lib_getch.c b/lib/libcurses/base/lib_getch.c
index 4d45740a62a..0b37e2190c6 100644
--- a/lib/libcurses/base/lib_getch.c
+++ b/lib/libcurses/base/lib_getch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_getch.c,v 1.6 2000/07/10 03:06:13 millert Exp $ */
+/* $OpenBSD: lib_getch.c,v 1.7 2000/10/08 22:46:58 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_getch.c,v 1.48 2000/07/08 11:21:51 tom Exp $")
+MODULE_ID("$From: lib_getch.c,v 1.49 2000/07/29 15:45:24 tom Exp $")
#include <fifo_defs.h>
@@ -91,7 +91,7 @@ static inline int
fifo_peek(void)
{
int ch = SP->_fifo[peek];
- T(("peeking at %d", peek));
+ TR(TRACE_IEVENT, ("peeking at %d", peek));
p_inc();
return ch;
@@ -102,7 +102,7 @@ fifo_pull(void)
{
int ch;
ch = SP->_fifo[head];
- T(("pulling %d from %d", ch, head));
+ TR(TRACE_IEVENT, ("pulling %d from %d", ch, head));
if (peek == head) {
h_inc();
@@ -164,17 +164,17 @@ fifo_push(void)
#endif
if ((n == -1) || (n == 0)) {
- T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ TR(TRACE_IEVENT, ("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
ch = ERR;
}
- T(("read %d characters", n));
+ TR(TRACE_IEVENT, ("read %d characters", n));
SP->_fifo[tail] = ch;
SP->_fifohold = 0;
if (head == -1)
head = peek = tail;
t_inc();
- T(("pushed %#x at %d", ch, tail));
+ TR(TRACE_IEVENT, ("pushed %#x at %d", ch, tail));
#ifdef TRACE
if (_nc_tracing & TRACE_IEVENT)
_nc_fifo_dump();
@@ -225,7 +225,7 @@ wgetch(WINDOW *win)
if (head == -1 && !SP->_raw && !SP->_cbreak) {
char buf[MAXCOLUMNS], *sp;
- T(("filling queue in cooked mode"));
+ TR(TRACE_IEVENT, ("filling queue in cooked mode"));
wgetnstr(win, buf, MAXCOLUMNS);
@@ -243,13 +243,13 @@ wgetch(WINDOW *win)
if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
int delay;
- T(("timed delay in wgetch()"));
+ TR(TRACE_IEVENT, ("timed delay in wgetch()"));
if (SP->_cbreak > 1)
delay = (SP->_cbreak - 1) * 100;
else
delay = win->_delay;
- T(("delay is %d milliseconds", delay));
+ TR(TRACE_IEVENT, ("delay is %d milliseconds", delay));
if (head == -1) /* fifo is empty */
if (!_nc_timed_wait(3, delay, (int *) 0))
diff --git a/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c
index cd8e602ce3b..e915f4bf6b7 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.10 2000/07/10 03:06:14 millert Exp $ */
+/* $OpenBSD: lib_mouse.c,v 1.11 2000/10/08 22:46:59 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.52 2000/06/29 23:02:26 tom Exp $")
+MODULE_ID("$From: lib_mouse.c,v 1.54 2000/10/03 08:26:34 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
@@ -156,7 +156,7 @@ write_event(int down, int button, int x, int y)
char buf[6];
unsigned long ignore;
- strcpy(buf, key_mouse);
+ strncpy(buf, key_mouse, 3); /* should be "\033[M" */
buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
buf[4] = ' ' + x - LEFT_COL + 1;
buf[5] = ' ' + y - TOP_ROW + 1;
@@ -516,7 +516,7 @@ mouse_activate(bool on)
switch (mousetype) {
case M_XTERM:
-#ifdef NCURSES_EXT_FUNCS
+#if NCURSES_EXT_FUNCS
keyok(KEY_MOUSE, on);
#endif
TPUTS_TRACE("xterm mouse initialization");
diff --git a/lib/libcurses/base/lib_newterm.c b/lib/libcurses/base/lib_newterm.c
index 6e01e19a271..2dbe3e87230 100644
--- a/lib/libcurses/base/lib_newterm.c
+++ b/lib/libcurses/base/lib_newterm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_newterm.c,v 1.10 2000/07/24 04:06:10 millert Exp $ */
+/* $OpenBSD: lib_newterm.c,v 1.11 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -42,14 +42,14 @@
#include <curses.priv.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_newterm.c,v 1.47 2000/07/22 22:33:34 Bruno.Haible Exp $")
+MODULE_ID("$From: lib_newterm.c,v 1.48 2000/09/02 18:11:42 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@@ -193,7 +193,7 @@ newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
SP->_use_rmso = SGR0_TEST(exit_standout_mode);
SP->_use_rmul = SGR0_TEST(exit_underline_mode);
-#ifdef USE_WIDEC_SUPPORT
+#if USE_WIDEC_SUPPORT
/*
* XFree86 xterm can be configured to support UTF-8 based on environment
* variable settings.
diff --git a/lib/libcurses/base/lib_restart.c b/lib/libcurses/base/lib_restart.c
index 8f2ae3f91fc..c77edbeb067 100644
--- a/lib/libcurses/base/lib_restart.c
+++ b/lib/libcurses/base/lib_restart.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_restart.c,v 1.2 1999/08/15 11:40:55 millert Exp $ */
+/* $OpenBSD: lib_restart.c,v 1.3 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -43,50 +43,51 @@
#include <curses.priv.h>
-#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
#define _POSIX_SOURCE
#endif
-#include <term.h> /* lines, columns, cur_term */
+#include <term.h> /* lines, columns, cur_term */
-MODULE_ID("$From: lib_restart.c,v 1.2 1999/07/24 20:10:04 tom Exp $")
+MODULE_ID("$From: lib_restart.c,v 1.3 2000/09/02 18:09:44 tom Exp $")
-int restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
+int
+restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
{
-int saveecho = SP->_echo;
-int savecbreak = SP->_cbreak;
-int saveraw = SP->_raw;
-int savenl = SP->_nl;
+ int saveecho = SP->_echo;
+ int savecbreak = SP->_cbreak;
+ int saveraw = SP->_raw;
+ int savenl = SP->_nl;
- T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
+ T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
- setupterm(termp, filenum, errret);
+ setupterm(termp, filenum, errret);
- if (saveecho)
- echo();
- else
- noecho();
+ if (saveecho)
+ echo();
+ else
+ noecho();
- if (savecbreak) {
- cbreak();
- noraw();
- } else if (saveraw) {
- nocbreak();
- raw();
- } else {
- nocbreak();
- noraw();
- }
- if (savenl)
- nl();
- else
- nonl();
+ if (savecbreak) {
+ cbreak();
+ noraw();
+ } else if (saveraw) {
+ nocbreak();
+ raw();
+ } else {
+ nocbreak();
+ noraw();
+ }
+ if (savenl)
+ nl();
+ else
+ nonl();
- reset_prog_mode();
+ reset_prog_mode();
#if USE_SIZECHANGE
- _nc_update_screensize();
+ _nc_update_screensize();
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c
index 438d8fade6d..6952649ddfe 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.10 2000/07/10 03:06:15 millert Exp $ */
+/* $OpenBSD: lib_set_term.c,v 1.11 2000/10/08 22:46:59 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.55 2000/07/02 00:22:18 tom Exp $")
+MODULE_ID("$From: lib_set_term.c,v 1.58 2000/10/04 22:05:48 tom Exp $")
SCREEN *
set_term(SCREEN * screenp)
@@ -173,7 +173,7 @@ no_mouse_wrap(SCREEN * sp GCC_UNUSED)
{
}
-#if defined(NCURSES_EXT_FUNCS) && defined(USE_COLORFGBG)
+#if NCURSES_EXT_FUNCS && USE_COLORFGBG
static char *
extract_fgbg(char *src, int *result)
{
@@ -222,17 +222,45 @@ _nc_setupscreen(short slines, short const scolumns, FILE * output)
SP->_endwin = TRUE;
SP->_ofp = output;
SP->_cursor = -1; /* cannot know real cursor shape */
-#ifdef NCURSES_NO_PADDING
+
+#if NCURSES_NO_PADDING
SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
SP->_no_padding ? " not" : ""));
#endif
-#ifdef NCURSES_EXT_FUNCS
+
+#if NCURSES_EXT_FUNCS
SP->_default_color = FALSE;
SP->_has_sgr_39_49 = FALSE;
+
+ /*
+ * Set our assumption of the terminal's default foreground and background
+ * colors. The curs_color man-page states that we can assume that the
+ * background is black. The origin of this assumption appears to be
+ * terminals that displayed colored text, but no colored backgrounds, e.g.,
+ * the first colored terminals around 1980. More recent ones with better
+ * technology can display not only colored backgrounds, but all
+ * combinations. So a terminal might be something other than "white" on
+ * black (green/black looks monochrome too), but black on white or even
+ * on ivory.
+ *
+ * White-on-black is the simplest thing to use for monochrome. Almost
+ * all applications that use color paint both text and background, so
+ * the distinction is moot. But a few do not - which is why we leave this
+ * configurable (a better solution is to use assume_default_colors() for
+ * the rare applications that do require that sort of appearance, since
+ * is appears that more users expect to be able to make a white-on-black
+ * or black-on-white display under control of the application than not).
+ */
+#ifdef USE_ASSUMED_COLOR
SP->_default_fg = COLOR_WHITE;
SP->_default_bg = COLOR_BLACK;
-#ifdef USE_COLORFGBG
+#else
+ SP->_default_fg = C_MASK;
+ SP->_default_bg = C_MASK;
+#endif
+
+#if USE_COLORFGBG
/*
* If rxvt's $COLORFGBG variable is set, use it to specify the assumed
* default colors. Note that rxvt (mis)uses bold colors, equating a bold
diff --git a/lib/libcurses/base/lib_winch.c b/lib/libcurses/base/lib_winch.c
index 8148b890a06..1c468be590b 100644
--- a/lib/libcurses/base/lib_winch.c
+++ b/lib/libcurses/base/lib_winch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_winch.c,v 1.1 1999/01/18 19:10:06 millert Exp $ */
+/* $OpenBSD: lib_winch.c,v 1.2 2000/10/08 22:46:59 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,14 +41,15 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_winch.c,v 1.1 1998/11/14 22:06:09 tom Exp $")
+MODULE_ID("$From: lib_winch.c,v 1.2 2000/07/29 16:41:44 tom Exp $")
-chtype winch(WINDOW *win)
+chtype
+winch(WINDOW *win)
{
- T((T_CALLED("winch(%p)"), win));
- if (win != 0) {
- returnCode(win->_line[win->_cury].text[win->_curx]);
- } else {
- returnCode(0);
- }
+ T((T_CALLED("winch(%p)"), win));
+ if (win != 0) {
+ returnChar(win->_line[win->_cury].text[win->_curx]);
+ } else {
+ returnChar(0);
+ }
}