aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/base
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/base')
-rw-r--r--contrib/ncurses/ncurses/base/MKunctrl.awk4
-rw-r--r--contrib/ncurses/ncurses/base/lib_addch.c353
-rw-r--r--contrib/ncurses/ncurses/base/lib_addstr.c88
-rw-r--r--contrib/ncurses/ncurses/base/lib_box.c137
-rw-r--r--contrib/ncurses/ncurses/base/lib_clrbot.c47
-rw-r--r--contrib/ncurses/ncurses/base/lib_clreol.c78
-rw-r--r--contrib/ncurses/ncurses/base/lib_color.c589
-rw-r--r--contrib/ncurses/ncurses/base/lib_dft_fgbg.c43
-rw-r--r--contrib/ncurses/ncurses/base/lib_freeall.c123
-rw-r--r--contrib/ncurses/ncurses/base/lib_getch.c565
-rw-r--r--contrib/ncurses/ncurses/base/lib_hline.c49
-rw-r--r--contrib/ncurses/ncurses/base/lib_insstr.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_mouse.c484
-rw-r--r--contrib/ncurses/ncurses/base/lib_move.c32
-rw-r--r--contrib/ncurses/ncurses/base/lib_newterm.c227
-rw-r--r--contrib/ncurses/ncurses/base/lib_newwin.c395
-rw-r--r--contrib/ncurses/ncurses/base/lib_nl.c32
-rw-r--r--contrib/ncurses/ncurses/base/lib_pad.c408
-rw-r--r--contrib/ncurses/ncurses/base/lib_refresh.c236
-rw-r--r--contrib/ncurses/ncurses/base/lib_scroll.c124
-rw-r--r--contrib/ncurses/ncurses/base/lib_scrreg.c34
-rw-r--r--contrib/ncurses/ncurses/base/lib_set_term.c472
-rw-r--r--contrib/ncurses/ncurses/base/lib_slk.c6
-rw-r--r--contrib/ncurses/ncurses/base/lib_vline.c55
-rw-r--r--contrib/ncurses/ncurses/base/version.c7
-rw-r--r--contrib/ncurses/ncurses/base/wresize.c217
26 files changed, 2552 insertions, 2309 deletions
diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk
index 0f4419242a99..3d5b25637d75 100644
--- a/contrib/ncurses/ncurses/base/MKunctrl.awk
+++ b/contrib/ncurses/ncurses/base/MKunctrl.awk
@@ -1,4 +1,4 @@
-# $Id: MKunctrl.awk,v 1.6 1998/06/06 18:18:07 tom Exp $
+# $Id: MKunctrl.awk,v 1.7 2000/04/01 19:49:26 tom Exp $
##############################################################################
# Copyright (c) 1998 Free Software Foundation, Inc. #
# #
@@ -50,6 +50,8 @@ END {
printf "\"^\\%03o\"", ch + 64
} else if (ch == 127) {
printf "\"^?\""
+ } else if (ch >= 128 && ch < 160) {
+ printf "\"~\\%03o\"", ch - 64
} else {
printf "\"\\%03o\"", ch
gap = gap " "
diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c
index 101d75ef29a9..69c17c34709b 100644
--- a/contrib/ncurses/ncurses/base/lib_addch.c
+++ b/contrib/ncurses/ncurses/base/lib_addch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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,7 +41,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.44 2000/05/20 21:13:11 tom Exp $")
/*
* Ugly microtweaking alert. Everything from here to end of module is
@@ -56,40 +56,40 @@ MODULE_ID("$Id: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $")
/* Return bit mask for clearing color pair number if given ch has color */
#define COLOR_MASK(ch) (~(chtype)((ch)&A_COLOR?A_COLOR:0))
-static inline chtype render_char(WINDOW *win, chtype ch)
+static inline chtype
+render_char(WINDOW *win, chtype ch)
/* compute a rendition of the given char correct for the current context */
{
- chtype a = win->_attrs;
-
- if (ch == ' ')
- {
- /* color in attrs has precedence over bkgd */
- ch = a | (win->_bkgd & COLOR_MASK(a));
- }
- else
- {
- /* color in attrs has precedence over bkgd */
- a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a);
- /* color in ch has precedence */
- ch |= (a & COLOR_MASK(ch));
- }
-
- TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd,
- win->_attrs, ch));
-
- return(ch);
+ chtype a = win->_attrs;
+
+ if (ch == ' ') {
+ /* color in attrs has precedence over bkgd */
+ ch = a | (win->_bkgd & COLOR_MASK(a));
+ } else {
+ /* color in attrs has precedence over bkgd */
+ a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a);
+ /* color in ch has precedence */
+ ch |= (a & COLOR_MASK(ch));
+ }
+
+ TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd,
+ win->_attrs, ch));
+
+ return (ch);
}
-chtype _nc_background(WINDOW *win)
+chtype
+_nc_background(WINDOW *win)
/* make render_char() visible while still allowing us to inline it below */
{
- return (win->_bkgd);
+ return (win->_bkgd);
}
-chtype _nc_render(WINDOW *win, chtype ch)
+chtype
+_nc_render(WINDOW *win, chtype ch)
/* make render_char() visible while still allowing us to inline it below */
{
- return render_char(win, ch);
+ return render_char(win, ch);
}
/* check if position is legal; if not, return error */
@@ -105,149 +105,152 @@ chtype _nc_render(WINDOW *win, chtype ch)
return(ERR); \
}
#else
-#define CHECK_POSITION(win, x, y) /* nothing */
+#define CHECK_POSITION(win, x, y) /* nothing */
#endif
-static inline
-int waddch_literal(WINDOW *win, chtype ch)
+static inline int
+waddch_literal(WINDOW *win, chtype ch)
{
- int x;
- struct ldat *line;
+ int x;
+ struct ldat *line;
+
+ x = win->_curx;
+
+ CHECK_POSITION(win, x, win->_cury);
+
+ /*
+ * If we're trying to add a character at the lower-right corner more
+ * than once, fail. (Moving the cursor will clear the flag).
+ */
+#if 0 /* Solaris 2.6 allows updating the corner more than once */
+ if (win->_flags & _WRAPPED) {
+ if (x >= win->_maxx)
+ return (ERR);
+ win->_flags &= ~_WRAPPED;
+ }
+#endif
+
+ ch = render_char(win, ch);
+ TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
- x = win->_curx;
+ line = win->_line + win->_cury;
- CHECK_POSITION(win, x, win->_cury);
+ CHANGED_CELL(line, x);
+ line->text[x++] = ch;
+
+ TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch)));
+ if (x > win->_maxx) {
/*
- * If we're trying to add a character at the lower-right corner more
- * than once, fail. (Moving the cursor will clear the flag).
+ * The _WRAPPED flag is useful only for telling an application that
+ * we've just wrapped the cursor. We don't do anything with this flag
+ * except set it when wrapping, and clear it whenever we move the
+ * cursor. If we try to wrap at the lower-right corner of a window, we
+ * cannot move the cursor (since that wouldn't be legal). So we return
+ * an error (which is what SVr4 does). Unlike SVr4, we can
+ * successfully add a character to the lower-right corner (Solaris 2.6
+ * does this also, however).
*/
- if (win->_flags & _WRAPPED) {
- if (x >= win->_maxx)
- return (ERR);
- win->_flags &= ~_WRAPPED;
- }
-
- ch = render_char(win, ch);
- TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
-
- line = win->_line+win->_cury;
-
- CHANGED_CELL(line,x);
-
- line->text[x++] = ch;
-
- TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch)));
- if (x > win->_maxx) {
- /*
- * The _WRAPPED flag is useful only for telling an application
- * that we've just wrapped the cursor. We don't do anything
- * with this flag except set it when wrapping, and clear it
- * whenever we move the cursor. If we try to wrap at the
- * lower-right corner of a window, we cannot move the cursor
- * (since that wouldn't be legal). So we return an error
- * (which is what SVr4 does). Unlike SVr4, we can successfully
- * add a character to the lower-right corner.
- */
- win->_flags |= _WRAPPED;
- if (++win->_cury > win->_regbottom) {
- win->_cury = win->_regbottom;
- win->_curx = win->_maxx;
- if (!win->_scroll)
- return (ERR);
- scroll(win);
- }
- win->_curx = 0;
- return (OK);
+ win->_flags |= _WRAPPED;
+ if (++win->_cury > win->_regbottom) {
+ win->_cury = win->_regbottom;
+ win->_curx = win->_maxx;
+ if (!win->_scroll)
+ return (ERR);
+ scroll(win);
}
- win->_curx = x;
- return OK;
+ win->_curx = 0;
+ return (OK);
+ }
+ win->_curx = x;
+ return OK;
}
-static inline
-int waddch_nosync(WINDOW *win, const chtype ch)
+static inline int
+waddch_nosync(WINDOW *win, const chtype ch)
/* the workhorse function -- add a character to the given window */
{
- int x, y;
- int t = 0;
- const char *s = 0;
-
- if ((ch & A_ALTCHARSET)
- || ((t = TextOf(ch)) > 127)
- || ((s = unctrl(t))[1] == 0))
- return waddch_literal(win, ch);
-
- x = win->_curx;
- y = win->_cury;
-
- switch (t) {
- case '\t':
- x += (TABSIZE-(x%TABSIZE));
-
- /*
- * Space-fill the tab on the bottom line so that we'll get the
- * "correct" cursor position.
- */
- if ((! win->_scroll && (y == win->_regbottom))
- || (x <= win->_maxx)) {
- chtype blank = (' ' | AttrOf(ch));
- while (win->_curx < x) {
- if (waddch_literal(win, blank) == ERR)
- return(ERR);
- }
- break;
- } else {
- wclrtoeol(win);
- win->_flags |= _WRAPPED;
- if (++y > win->_regbottom) {
- x = win->_maxx;
- y--;
- if (win->_scroll) {
- scroll(win);
- x = 0;
- }
- } else {
- x = 0;
- }
- }
- break;
- case '\n':
- wclrtoeol(win);
- if (++y > win->_regbottom) {
- y--;
- if (win->_scroll)
- scroll(win);
- else
- return (ERR);
+ int x, y;
+ int t = 0;
+ const char *s = 0;
+
+ if ((ch & A_ALTCHARSET)
+ || ((t = TextOf(ch)) > 127)
+ || ((s = unctrl(t))[1] == 0))
+ return waddch_literal(win, ch);
+
+ x = win->_curx;
+ y = win->_cury;
+
+ switch (t) {
+ case '\t':
+ x += (TABSIZE - (x % TABSIZE));
+
+ /*
+ * Space-fill the tab on the bottom line so that we'll get the
+ * "correct" cursor position.
+ */
+ if ((!win->_scroll && (y == win->_regbottom))
+ || (x <= win->_maxx)) {
+ chtype blank = (' ' | AttrOf(ch));
+ while (win->_curx < x) {
+ if (waddch_literal(win, blank) == ERR)
+ return (ERR);
+ }
+ break;
+ } else {
+ wclrtoeol(win);
+ win->_flags |= _WRAPPED;
+ if (++y > win->_regbottom) {
+ x = win->_maxx;
+ y--;
+ if (win->_scroll) {
+ scroll(win);
+ x = 0;
}
- /* FALLTHRU */
- case '\r':
+ } else {
x = 0;
- win->_flags &= ~_WRAPPED;
- break;
- case '\b':
- if (x == 0)
- return (OK);
- x--;
- win->_flags &= ~_WRAPPED;
- break;
- default:
- while (*s)
- if (waddch_literal(win, (*s++)|AttrOf(ch)) == ERR)
- return ERR;
- return(OK);
+ }
}
-
- win->_curx = x;
- win->_cury = y;
-
- return(OK);
+ break;
+ case '\n':
+ wclrtoeol(win);
+ if (++y > win->_regbottom) {
+ y--;
+ if (win->_scroll)
+ scroll(win);
+ else
+ return (ERR);
+ }
+ /* FALLTHRU */
+ case '\r':
+ x = 0;
+ win->_flags &= ~_WRAPPED;
+ break;
+ case '\b':
+ if (x == 0)
+ return (OK);
+ x--;
+ win->_flags &= ~_WRAPPED;
+ break;
+ default:
+ while (*s)
+ if (waddch_literal(win, (*s++) | AttrOf(ch)) == ERR)
+ return ERR;
+ return (OK);
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return (OK);
}
-int _nc_waddch_nosync(WINDOW *win, const chtype c)
+int
+_nc_waddch_nosync(WINDOW *win, const chtype c)
/* export copy of waddch_nosync() so the string-put functions can use it */
{
- return(waddch_nosync(win, c));
+ return (waddch_nosync(win, c));
}
/*
@@ -258,36 +261,38 @@ int _nc_waddch_nosync(WINDOW *win, const chtype c)
/* These are actual entry points */
-int waddch(WINDOW *win, const chtype ch)
+int
+waddch(WINDOW *win, const chtype ch)
{
- int code = ERR;
+ int code = ERR;
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch)));
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win,
+ _tracechtype(ch)));
- if (win && (waddch_nosync(win, ch) != ERR))
- {
- _nc_synchook(win);
- code = OK;
- }
+ if (win && (waddch_nosync(win, ch) != ERR)) {
+ _nc_synchook(win);
+ code = OK;
+ }
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code));
- return(code);
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
}
-int wechochar(WINDOW *win, const chtype ch)
+int
+wechochar(WINDOW *win, const chtype ch)
{
- int code = ERR;
-
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch)));
-
- if (win && (waddch_nosync(win, ch) != ERR))
- {
- bool save_immed = win->_immed;
- win->_immed = TRUE;
- _nc_synchook(win);
- win->_immed = save_immed;
- code = OK;
- }
- TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code));
- return(code);
+ int code = ERR;
+
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win,
+ _tracechtype(ch)));
+
+ if (win && (waddch_nosync(win, ch) != ERR)) {
+ bool save_immed = win->_immed;
+ win->_immed = TRUE;
+ _nc_synchook(win);
+ win->_immed = save_immed;
+ code = OK;
+ }
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
+ return (code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c
index 9ac55e42aba7..0a72165910f3 100644
--- a/contrib/ncurses/ncurses/base/lib_addstr.c
+++ b/contrib/ncurses/ncurses/base/lib_addstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -40,64 +40,64 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_addstr.c,v 1.16 1998/06/28 00:38:29 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.17 2000/04/29 21:15:55 tom Exp $")
int
waddnstr(WINDOW *win, const char *const astr, int n)
{
-unsigned const char *str = (unsigned const char *)astr;
-int code = ERR;
+ unsigned const char *str = (unsigned const char *) astr;
+ int code = ERR;
- 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, ("str is not null"));
- code = OK;
- if (n < 0)
- n = (int)strlen(astr);
-
- while((n-- > 0) && (*str != '\0')) {
+ 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, ("str is not null"));
+ code = OK;
+ if (n < 0)
+ n = (int) strlen(astr);
+
+ while ((n-- > 0) && (*str != '\0')) {
TR(TRACE_VIRTPUT, ("*str = %#x", *str));
- if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
- code = ERR;
- break;
+ if (_nc_waddch_nosync(win, (chtype) * str++) == ERR) {
+ code = ERR;
+ break;
}
- }
- _nc_synchook(win);
}
- TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
- returnCode(code);
+ _nc_synchook(win);
+ }
+ TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
+ returnCode(code);
}
int
-waddchnstr(WINDOW *win, const chtype *const astr, int n)
+waddchnstr(WINDOW *win, const chtype * const astr, int n)
{
-short y = win->_cury;
-short x = win->_curx;
-int code = OK;
-struct ldat *line;
+ NCURSES_SIZE_T y = win->_cury;
+ NCURSES_SIZE_T x = win->_curx;
+ int code = OK;
+ struct ldat *line;
- T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
+ T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
- if (!win)
- returnCode(ERR);
+ if (!win)
+ returnCode(ERR);
- if (n < 0) {
- const chtype *str;
- n = 0;
- for (str=(const chtype *)astr; *str!=0; str++)
- n++;
- }
- if (n > win->_maxx - x + 1)
- n = win->_maxx - x + 1;
- if (n == 0)
- returnCode(code);
+ if (n < 0) {
+ const chtype *str;
+ n = 0;
+ for (str = (const chtype *) astr; *str != 0; str++)
+ n++;
+ }
+ if (n > win->_maxx - x + 1)
+ n = win->_maxx - x + 1;
+ if (n == 0)
+ returnCode(code);
- line = &(win->_line[y]);
- memcpy(line->text+x, astr, n*sizeof(*astr));
- CHANGED_RANGE(line, x, x+n-1);
+ line = &(win->_line[y]);
+ memcpy(line->text + x, astr, n * sizeof(*astr));
+ CHANGED_RANGE(line, x, x + n - 1);
- _nc_synchook(win);
- returnCode(code);
+ _nc_synchook(win);
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_box.c b/contrib/ncurses/ncurses/base/lib_box.c
index bcd96416f954..8a682585b560 100644
--- a/contrib/ncurses/ncurses/base/lib_box.c
+++ b/contrib/ncurses/ncurses/base/lib_box.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_box.c
**
@@ -42,69 +40,80 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_box.c,v 1.10 1998/02/11 12:13:56 tom Exp $")
+MODULE_ID("$Id: lib_box.c,v 1.11 2000/04/29 21:12:37 tom Exp $")
-int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
- chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
+int
+wborder(WINDOW *win,
+ chtype ls, chtype rs, chtype ts, chtype bs,
+ chtype tl, chtype tr, chtype bl, chtype br)
{
-short i;
-short endx, endy;
+ NCURSES_SIZE_T i;
+ NCURSES_SIZE_T endx, endy;
T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
- win,
- _tracechtype2(1,ls),
- _tracechtype2(2,rs),
- _tracechtype2(3,ts),
- _tracechtype2(4,bs),
- _tracechtype2(5,tl),
- _tracechtype2(6,tr),
- _tracechtype2(7,bl),
- _tracechtype2(8,br)));
-
- if (!win)
- returnCode(ERR);
-
- if (ls == 0) ls = ACS_VLINE;
- if (rs == 0) rs = ACS_VLINE;
- if (ts == 0) ts = ACS_HLINE;
- if (bs == 0) bs = ACS_HLINE;
- if (tl == 0) tl = ACS_ULCORNER;
- if (tr == 0) tr = ACS_URCORNER;
- if (bl == 0) bl = ACS_LLCORNER;
- if (br == 0) br = ACS_LRCORNER;
-
- ls = _nc_render(win, ls);
- rs = _nc_render(win, rs);
- ts = _nc_render(win, ts);
- bs = _nc_render(win, bs);
- tl = _nc_render(win, tl);
- tr = _nc_render(win, tr);
- bl = _nc_render(win, bl);
- br = _nc_render(win, br);
-
- T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br));
-
- endx = win->_maxx;
- endy = win->_maxy;
-
- for (i = 0; i <= endx; i++) {
- win->_line[0].text[i] = ts;
- win->_line[endy].text[i] = bs;
- }
- win->_line[endy].firstchar = win->_line[0].firstchar = 0;
- win->_line[endy].lastchar = win->_line[0].lastchar = endx;
-
- for (i = 0; i <= endy; i++) {
- win->_line[i].text[0] = ls;
- win->_line[i].text[endx] = rs;
- win->_line[i].firstchar = 0;
- win->_line[i].lastchar = endx;
- }
- win->_line[0].text[0] = tl;
- win->_line[0].text[endx] = tr;
- win->_line[endy].text[0] = bl;
- win->_line[endy].text[endx] = br;
-
- _nc_synchook(win);
- returnCode(OK);
+ win,
+ _tracechtype2(1, ls),
+ _tracechtype2(2, rs),
+ _tracechtype2(3, ts),
+ _tracechtype2(4, bs),
+ _tracechtype2(5, tl),
+ _tracechtype2(6, tr),
+ _tracechtype2(7, bl),
+ _tracechtype2(8, br)));
+
+ if (!win)
+ returnCode(ERR);
+
+ if (ls == 0)
+ ls = ACS_VLINE;
+ if (rs == 0)
+ rs = ACS_VLINE;
+ if (ts == 0)
+ ts = ACS_HLINE;
+ if (bs == 0)
+ bs = ACS_HLINE;
+ if (tl == 0)
+ tl = ACS_ULCORNER;
+ if (tr == 0)
+ tr = ACS_URCORNER;
+ if (bl == 0)
+ bl = ACS_LLCORNER;
+ if (br == 0)
+ br = ACS_LRCORNER;
+
+ ls = _nc_render(win, ls);
+ rs = _nc_render(win, rs);
+ ts = _nc_render(win, ts);
+ bs = _nc_render(win, bs);
+ tl = _nc_render(win, tl);
+ tr = _nc_render(win, tr);
+ bl = _nc_render(win, bl);
+ br = _nc_render(win, br);
+
+ T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx",
+ ls, rs, ts, bs, tl, tr, bl, br));
+
+ endx = win->_maxx;
+ endy = win->_maxy;
+
+ for (i = 0; i <= endx; i++) {
+ win->_line[0].text[i] = ts;
+ win->_line[endy].text[i] = bs;
+ }
+ win->_line[endy].firstchar = win->_line[0].firstchar = 0;
+ win->_line[endy].lastchar = win->_line[0].lastchar = endx;
+
+ for (i = 0; i <= endy; i++) {
+ win->_line[i].text[0] = ls;
+ win->_line[i].text[endx] = rs;
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = endx;
+ }
+ win->_line[0].text[0] = tl;
+ win->_line[0].text[endx] = tr;
+ win->_line[endy].text[0] = bl;
+ win->_line[endy].text[endx] = br;
+
+ _nc_synchook(win);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_clrbot.c b/contrib/ncurses/ncurses/base/lib_clrbot.c
index cec34161acef..d1e243f37ffd 100644
--- a/contrib/ncurses/ncurses/base/lib_clrbot.c
+++ b/contrib/ncurses/ncurses/base/lib_clrbot.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -40,36 +40,37 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_clrbot.c,v 1.14 1998/06/28 00:36:26 tom Exp $")
+MODULE_ID("$Id: lib_clrbot.c,v 1.15 2000/04/29 21:15:26 tom Exp $")
-int wclrtobot(WINDOW *win)
+int
+wclrtobot(WINDOW *win)
{
-int code = ERR;
+ int code = ERR;
- T((T_CALLED("wclrtobot(%p)"), win));
+ T((T_CALLED("wclrtobot(%p)"), win));
- if (win) {
- short y;
- short startx = win->_curx;
- chtype blank = _nc_background(win);
+ if (win) {
+ NCURSES_SIZE_T y;
+ NCURSES_SIZE_T startx = win->_curx;
+ chtype blank = _nc_background(win);
- T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx));
+ T(("clearing from y = %d to y = %d with maxx = %d",
+ win->_cury, win->_maxy, win->_maxx));
- for (y = win->_cury; y <= win->_maxy; y++) {
- struct ldat *line = &(win->_line[y]);
- chtype *ptr = &(line->text[startx]);
- chtype *end = &(line->text[win->_maxx]);
+ for (y = win->_cury; y <= win->_maxy; y++) {
+ struct ldat *line = &(win->_line[y]);
+ chtype *ptr = &(line->text[startx]);
+ chtype *end = &(line->text[win->_maxx]);
- CHANGED_TO_EOL(line, startx, win->_maxx);
+ CHANGED_TO_EOL(line, startx, win->_maxx);
- while (ptr <= end)
- *ptr++ = blank;
+ while (ptr <= end)
+ *ptr++ = blank;
- startx = 0;
- }
- _nc_synchook(win);
- code = OK;
+ startx = 0;
}
- returnCode(code);
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
-
diff --git a/contrib/ncurses/ncurses/base/lib_clreol.c b/contrib/ncurses/ncurses/base/lib_clreol.c
index 0c7522278e38..a5d067cbfd5f 100644
--- a/contrib/ncurses/ncurses/base/lib_clreol.c
+++ b/contrib/ncurses/ncurses/base/lib_clreol.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
** lib_clreol.c
**
@@ -41,51 +40,52 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_clreol.c,v 1.15 1998/06/28 00:32:20 tom Exp $")
+MODULE_ID("$Id: lib_clreol.c,v 1.16 2000/04/29 21:14:54 tom Exp $")
-int wclrtoeol(WINDOW *win)
+int
+wclrtoeol(WINDOW *win)
{
-int code = ERR;
+ int code = ERR;
- T((T_CALLED("wclrtoeol(%p)"), win));
+ T((T_CALLED("wclrtoeol(%p)"), win));
- if (win) {
- chtype blank;
- chtype *ptr, *end;
- struct ldat *line;
- short y = win->_cury;
- short x = win->_curx;
+ if (win) {
+ chtype blank;
+ chtype *ptr, *end;
+ struct ldat *line;
+ NCURSES_SIZE_T y = win->_cury;
+ NCURSES_SIZE_T x = win->_curx;
- /*
- * If we have just wrapped the cursor, the clear applies to the
- * new line, unless we are at the lower right corner.
- */
- if (win->_flags & _WRAPPED
- && y < win->_maxy) {
- win->_flags &= ~_WRAPPED;
- }
+ /*
+ * If we have just wrapped the cursor, the clear applies to the
+ * new line, unless we are at the lower right corner.
+ */
+ if (win->_flags & _WRAPPED
+ && y < win->_maxy) {
+ win->_flags &= ~_WRAPPED;
+ }
- /*
- * There's no point in clearing if we're not on a legal
- * position, either.
- */
- if (win->_flags & _WRAPPED
- || y > win->_maxy
- || x > win->_maxx)
- returnCode(ERR);
+ /*
+ * There's no point in clearing if we're not on a legal
+ * position, either.
+ */
+ if (win->_flags & _WRAPPED
+ || y > win->_maxy
+ || x > win->_maxx)
+ returnCode(ERR);
- blank = _nc_background(win);
- line = &win->_line[y];
- CHANGED_TO_EOL(line, x, win->_maxx);
+ blank = _nc_background(win);
+ line = &win->_line[y];
+ CHANGED_TO_EOL(line, x, win->_maxx);
- ptr = &(line->text[x]);
- end = &(line->text[win->_maxx]);
+ ptr = &(line->text[x]);
+ end = &(line->text[win->_maxx]);
- while (ptr <= end)
- *ptr++ = blank;
+ while (ptr <= end)
+ *ptr++ = blank;
- _nc_synchook(win);
- code = OK;
- }
- returnCode(code);
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
index 297a14c36d6e..71bee42487cd 100644
--- a/contrib/ncurses/ncurses/base/lib_color.c
+++ b/contrib/ncurses/ncurses/base/lib_color.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -34,22 +34,22 @@
/* lib_color.c
*
* Handles color emulation of SYS V curses
- *
*/
#include <curses.priv.h>
#include <term.h>
+#include <tic.h>
-MODULE_ID("$Id: lib_color.c,v 1.36 1999/10/03 00:20:37 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.51 2000/05/20 20:09:22 tom Exp $")
/*
* These should be screen structure members. They need to be globals for
- * hystorical reasons. So we assign them in start_color() and also in
+ * historical reasons. So we assign them in start_color() and also in
* set_term()'s screen-switching logic.
*/
-int COLOR_PAIRS;
-int COLORS;
+int COLOR_PAIRS = 0;
+int COLORS = 0;
/*
* Given a RGB range of 0..1000, we'll normally set the individual values
@@ -57,141 +57,179 @@ int COLORS;
*/
#define RGB_ON 680
#define RGB_OFF 0
-
+/* *INDENT-OFF* */
static const color_t cga_palette[] =
{
- /* R G B */
- {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
- {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
- {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
- {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
- {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
- {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
- {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
- {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
+ /* R G B */
+ {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
+ {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
+ {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
+ {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
+ {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
+ {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
+ {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
+ {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
};
+
static const color_t hls_palette[] =
{
- /* H L S */
- {0, 0, 0}, /* COLOR_BLACK */
- {120, 50, 100}, /* COLOR_RED */
- {240, 50, 100}, /* COLOR_GREEN */
- {180, 50, 100}, /* COLOR_YELLOW */
- {330, 50, 100}, /* COLOR_BLUE */
- {60, 50, 100}, /* COLOR_MAGENTA */
- {300, 50, 100}, /* COLOR_CYAN */
- {0, 50, 100}, /* COLOR_WHITE */
+ /* H L S */
+ { 0, 0, 0}, /* COLOR_BLACK */
+ { 120, 50, 100}, /* COLOR_RED */
+ { 240, 50, 100}, /* COLOR_GREEN */
+ { 180, 50, 100}, /* COLOR_YELLOW */
+ { 330, 50, 100}, /* COLOR_BLUE */
+ { 60, 50, 100}, /* COLOR_MAGENTA */
+ { 300, 50, 100}, /* COLOR_CYAN */
+ { 0, 50, 100}, /* COLOR_WHITE */
};
+/* *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 != 0) ? SP->_default_fg : COLOR_WHITE;
+}
+
+static int
+default_bg(void)
+{
+ return SP != 0 ? SP->_default_bg : COLOR_BLACK;
+}
+#else
+#define default_fg() COLOR_WHITE
+#define default_bg() COLOR_BLACK
+#endif
/*
* SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly
* to maintain compatibility with a pre-ANSI scheme. The same scheme is
* also used in the FreeBSD syscons.
*/
-static int toggled_colors(int c)
+static int
+toggled_colors(int c)
{
if (c < 16) {
static const int table[] =
- { 0, 4, 2, 6, 1, 5, 3, 7,
- 8, 12, 10, 14, 9, 13, 11, 15};
+ {0, 4, 2, 6, 1, 5, 3, 7,
+ 8, 12, 10, 14, 9, 13, 11, 15};
c = table[c];
}
return c;
}
-static void set_background_color(int bg, int (*outc)(int))
+static void
+set_background_color(int bg, int (*outc) (int))
{
- if (set_a_background)
- {
- TPUTS_TRACE("set_a_background");
- tputs(tparm(set_a_background, bg), 1, outc);
- }
- else
- {
- TPUTS_TRACE("set_background");
- tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
- }
+ if (set_a_background) {
+ TPUTS_TRACE("set_a_background");
+ tputs(tparm(set_a_background, bg), 1, outc);
+ } else {
+ TPUTS_TRACE("set_background");
+ tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
+ }
}
-static void set_foreground_color(int fg, int (*outc)(int))
+static void
+set_foreground_color(int fg, int (*outc) (int))
{
- if (set_a_foreground)
- {
- TPUTS_TRACE("set_a_foreground");
- tputs(tparm(set_a_foreground, fg), 1, outc);
- }
- else
- {
- TPUTS_TRACE("set_foreground");
- tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
- }
+ if (set_a_foreground) {
+ TPUTS_TRACE("set_a_foreground");
+ tputs(tparm(set_a_foreground, fg), 1, outc);
+ } else {
+ TPUTS_TRACE("set_foreground");
+ tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
+ }
}
-static bool set_original_colors(void)
+static bool
+set_original_colors(void)
{
- if (orig_pair != 0) {
- TPUTS_TRACE("orig_pair");
- putp(orig_pair);
- return TRUE;
- }
- else if (orig_colors != NULL)
- {
- TPUTS_TRACE("orig_colors");
- putp(orig_colors);
- return TRUE;
- }
- return FALSE;
+ if (orig_pair != 0) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ return TRUE;
+ } else if (orig_colors != NULL) {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ return TRUE;
+ }
+ return FALSE;
}
-int start_color(void)
+int
+start_color(void)
{
- T((T_CALLED("start_color()")));
+ int n;
+ const color_t *tp;
+
+ T((T_CALLED("start_color()")));
- if (set_original_colors() != TRUE)
- {
- set_foreground_color(COLOR_WHITE, _nc_outch);
- set_background_color(COLOR_BLACK, _nc_outch);
+ if (set_original_colors() != TRUE) {
+ set_foreground_color(default_fg(), _nc_outch);
+ set_background_color(default_bg(), _nc_outch);
+ }
+
+ if (VALID_NUMERIC(max_pairs))
+ COLOR_PAIRS = SP->_pair_count = max_pairs;
+ else
+ returnCode(ERR);
+ if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
+ returnCode(ERR);
+ SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
+ if (VALID_NUMERIC(max_colors))
+ COLORS = SP->_color_count = max_colors;
+ else
+ returnCode(ERR);
+ SP->_coloron = 1;
+
+ if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
+ returnCode(ERR);
+ tp = (hue_lightness_saturation) ? hls_palette : cga_palette;
+ for (n = 0; n < COLORS; n++) {
+ if (n < 8) {
+ SP->_color_table[n] = tp[n];
+ } else {
+ SP->_color_table[n] = tp[n % 8];
+ if (hue_lightness_saturation) {
+ SP->_color_table[n].green = 100;
+ } else {
+ if (SP->_color_table[n].red)
+ SP->_color_table[n].red = 1000;
+ if (SP->_color_table[n].green)
+ SP->_color_table[n].green = 1000;
+ if (SP->_color_table[n].blue)
+ SP->_color_table[n].blue = 1000;
+ }
}
+ }
- if (max_pairs != -1)
- COLOR_PAIRS = SP->_pair_count = max_pairs;
- else
- returnCode(ERR);
- if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
- returnCode(ERR);
- SP->_color_pairs[0] = PAIR_OF(COLOR_WHITE, COLOR_BLACK);
- if (max_colors != -1)
- COLORS = SP->_color_count = max_colors;
- else
- returnCode(ERR);
- SP->_coloron = 1;
-
- if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
- returnCode(ERR);
- if (hue_lightness_saturation)
- memcpy(SP->_color_table, hls_palette, sizeof(color_t) * COLORS);
- else
- memcpy(SP->_color_table, cga_palette, sizeof(color_t) * COLORS);
-
- T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
-
- returnCode(OK);
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+
+ returnCode(OK);
}
/* This function was originally written by Daniel Weaver <danw@znyx.com> */
-static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
+static void
+rgb2hls(short r, short g, short b, short *h, short *l, short *s)
/* convert RGB to HLS system */
{
short min, max, t;
- if ((min = g < r ? g : r) > b) min = b;
- if ((max = g > r ? g : r) < b) max = b;
+ if ((min = g < r ? g : r) > b)
+ min = b;
+ if ((max = g > r ? g : r) < b)
+ max = b;
/* calculate lightness */
*l = (min + max) / 20;
- if (min == max) /* black, white and all shades of gray */
- {
+ if (min == max) { /* black, white and all shades of gray */
*h = 0;
*s = 0;
return;
@@ -200,16 +238,16 @@ static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
/* calculate saturation */
if (*l < 50)
*s = ((max - min) * 100) / (max + min);
- else *s = ((max - min) * 100) / (2000 - max - min);
+ else
+ *s = ((max - min) * 100) / (2000 - max - min);
/* calculate hue */
if (r == max)
t = 120 + ((g - b) * 60) / (max - min);
+ else if (g == max)
+ t = 240 + ((b - r) * 60) / (max - min);
else
- if (g == max)
- t = 240 + ((b - r) * 60) / (max - min);
- else
- t = 360 + ((r - g) * 60) / (max - min);
+ t = 360 + ((r - g) * 60) / (max - min);
*h = t % 360;
}
@@ -218,212 +256,227 @@ static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
* Extension (1997/1/18) - Allow negative f/b values to set default color
* values.
*/
-int init_pair(short pair, short f, short b)
+int
+init_pair(short pair, short f, short b)
{
- unsigned result;
-
- T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
-
- if ((pair < 1) || (pair >= COLOR_PAIRS))
- returnCode(ERR);
- if (SP->_default_color)
- {
- if (f < 0)
- f = C_MASK;
- if (b < 0)
- b = C_MASK;
- if (f >= COLORS && f != C_MASK)
- returnCode(ERR);
- if (b >= COLORS && b != C_MASK)
- returnCode(ERR);
- }
- else
+ unsigned result;
+
+ T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
+
+ if ((pair < 0) || (pair >= COLOR_PAIRS))
+ returnCode(ERR);
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_default_color) {
+ if (f < 0)
+ f = C_MASK;
+ if (b < 0)
+ b = C_MASK;
+ if (f >= COLORS && f != C_MASK)
+ returnCode(ERR);
+ if (b >= COLORS && b != C_MASK)
+ returnCode(ERR);
+ } else
+#endif
+ {
if ((f < 0) || (f >= COLORS)
- || (b < 0) || (b >= COLORS))
- returnCode(ERR);
-
- /*
- * When a pair's content is changed, replace its colors (if pair was
- * initialized before a screen update is performed replacing original
- * pair colors with the new ones).
- */
- result = PAIR_OF(f,b);
- if (SP->_color_pairs[pair] != 0
- && SP->_color_pairs[pair] != result) {
- int y, x;
- attr_t z = COLOR_PAIR(pair);
-
- for (y = 0; y <= curscr->_maxy; y++) {
- struct ldat *ptr = &(curscr->_line[y]);
- bool changed = FALSE;
- for (x = 0; x <= curscr->_maxx; x++) {
- if ((ptr->text[x] & A_COLOR) == z) {
- /* Set the old cell to zero to ensure it will be
- updated on the next doupdate() */
- ptr->text[x] = 0;
- CHANGED_CELL(ptr,x);
- changed = TRUE;
- }
+ || (b < 0) || (b >= COLORS)
+ || (pair < 1))
+ returnCode(ERR);
+ }
+
+ /*
+ * When a pair's content is changed, replace its colors (if pair was
+ * initialized before a screen update is performed replacing original
+ * pair colors with the new ones).
+ */
+ result = PAIR_OF(f, b);
+ if (SP->_color_pairs[pair] != 0
+ && SP->_color_pairs[pair] != result) {
+ int y, x;
+ attr_t z = COLOR_PAIR(pair);
+
+ for (y = 0; y <= curscr->_maxy; y++) {
+ struct ldat *ptr = &(curscr->_line[y]);
+ bool changed = FALSE;
+ for (x = 0; x <= curscr->_maxx; x++) {
+ if ((ptr->text[x] & A_COLOR) == z) {
+ /* Set the old cell to zero to ensure it will be
+ updated on the next doupdate() */
+ ptr->text[x] = 0;
+ CHANGED_CELL(ptr, x);
+ changed = TRUE;
}
- if (changed)
- _nc_make_oldhash(y);
}
+ if (changed)
+ _nc_make_oldhash(y);
}
- SP->_color_pairs[pair] = result;
-
- if (initialize_pair)
- {
- const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
-
- T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
-
- if (initialize_pair)
- {
- TPUTS_TRACE("initialize_pair");
- putp(tparm(initialize_pair,
- pair,
- tp[f].red, tp[f].green, tp[f].blue,
- tp[b].red, tp[b].green, tp[b].blue));
- }
+ }
+ 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;
+
+ T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+
+ if (initialize_pair) {
+ TPUTS_TRACE("initialize_pair");
+ putp(tparm(initialize_pair,
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
}
+ }
- returnCode(OK);
+ returnCode(OK);
}
-int init_color(short color, short r, short g, short b)
+int
+init_color(short color, short r, short g, short b)
{
- T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
-
- if (initialize_color == NULL)
- returnCode(ERR);
-
- if (color < 0 || color >= COLORS)
- returnCode(ERR);
- if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
- returnCode(ERR);
-
- if (hue_lightness_saturation)
- rgb2hls(r, g, b,
- &SP->_color_table[color].red,
- &SP->_color_table[color].green,
- &SP->_color_table[color].blue);
- else
- {
- SP->_color_table[color].red = r;
- SP->_color_table[color].green = g;
- SP->_color_table[color].blue = b;
- }
+ T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
- if (initialize_color)
- {
- TPUTS_TRACE("initialize_color");
- putp(tparm(initialize_color, color, r, g, b));
- }
- returnCode(OK);
+ if (initialize_color == NULL)
+ returnCode(ERR);
+
+ if (color < 0 || color >= COLORS)
+ returnCode(ERR);
+ if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
+ returnCode(ERR);
+
+ if (hue_lightness_saturation)
+ rgb2hls(r, g, b,
+ &SP->_color_table[color].red,
+ &SP->_color_table[color].green,
+ &SP->_color_table[color].blue);
+ else {
+ SP->_color_table[color].red = r;
+ SP->_color_table[color].green = g;
+ SP->_color_table[color].blue = b;
+ }
+
+ if (initialize_color) {
+ TPUTS_TRACE("initialize_color");
+ putp(tparm(initialize_color, color, r, g, b));
+ }
+ returnCode(OK);
}
-bool can_change_color(void)
+bool
+can_change_color(void)
{
- T((T_CALLED("can_change_color()")));
- returnCode ((can_change != 0) ? TRUE : FALSE);
+ T((T_CALLED("can_change_color()")));
+ returnCode((can_change != 0) ? TRUE : FALSE);
}
-bool has_colors(void)
+bool
+has_colors(void)
{
- T((T_CALLED("has_colors()")));
- returnCode (((max_colors != -1) && (max_pairs != -1)
- && (((set_foreground != NULL)
- && (set_background != NULL))
- || ((set_a_foreground != NULL)
- && (set_a_background != NULL))
- || set_color_pair)) ? TRUE : FALSE);
+ T((T_CALLED("has_colors()")));
+ returnCode((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs)
+ && (((set_foreground != NULL)
+ && (set_background != NULL))
+ || ((set_a_foreground != NULL)
+ && (set_a_background != NULL))
+ || set_color_pair)) ? TRUE : FALSE);
}
-int color_content(short color, short *r, short *g, short *b)
+int
+color_content(short color, short *r, short *g, short *b)
{
T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
if (color < 0 || color >= COLORS)
returnCode(ERR);
- if (r) *r = SP->_color_table[color].red;
- if (g) *g = SP->_color_table[color].green;
- if (b) *b = SP->_color_table[color].blue;
+ if (r)
+ *r = SP->_color_table[color].red;
+ if (g)
+ *g = SP->_color_table[color].green;
+ if (b)
+ *b = SP->_color_table[color].blue;
returnCode(OK);
}
-int pair_content(short pair, short *f, short *b)
+int
+pair_content(short pair, short *f, short *b)
{
- T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
+ T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
- if ((pair < 0) || (pair >= COLOR_PAIRS))
- returnCode(ERR);
- if (f) *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
- if (b) *b = (SP->_color_pairs[pair] & C_MASK);
+ if ((pair < 0) || (pair >= COLOR_PAIRS))
+ returnCode(ERR);
+ if (f)
+ *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+ if (b)
+ *b = (SP->_color_pairs[pair] & C_MASK);
- returnCode(OK);
+ returnCode(OK);
}
-void _nc_do_color(int pair, bool reverse, int (*outc)(int))
+void
+_nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
{
- short fg, bg;
+ NCURSES_COLOR_T fg = C_MASK, bg = C_MASK;
+ NCURSES_COLOR_T old_fg, old_bg;
- if (pair == 0)
- {
- if (orig_pair)
- {
- TPUTS_TRACE("orig_pair");
- tputs(orig_pair, 1, outc);
- }
- else if (set_color_pair)
- {
+ if (pair < 0 || pair >= COLOR_PAIRS) {
+ return;
+ } else if (pair != 0) {
+ if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
tputs(tparm(set_color_pair, pair), 1, outc);
- }
- else
- {
- set_foreground_color(COLOR_WHITE, outc);
- set_background_color(COLOR_BLACK, outc);
+ return;
+ } else if (SP != 0) {
+ pair_content(pair, &fg, &bg);
}
}
- else
- {
- if (set_color_pair)
- {
- TPUTS_TRACE("set_color_pair");
- tputs(tparm(set_color_pair, pair), 1, outc);
+
+ 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
- {
- pair_content(pair, &fg, &bg);
- if (reverse) {
- short xx = fg;
- fg = bg;
- bg = xx;
- }
+ } else {
+ set_original_colors();
+ if (old_pair < 0)
+ return;
+ }
- T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+#ifdef NCURSES_EXT_FUNCS
+ if (fg == C_MASK)
+ fg = default_fg();
+ if (bg == C_MASK)
+ bg = default_bg();
+#endif
+
+ if (reverse) {
+ NCURSES_COLOR_T xx = fg;
+ fg = bg;
+ bg = xx;
+ }
- if (fg == C_MASK || bg == C_MASK)
- {
- if (set_original_colors() != TRUE)
- {
- if (fg == C_MASK)
- set_foreground_color(COLOR_WHITE, outc);
- if (bg == C_MASK)
- set_background_color(COLOR_BLACK, outc);
- }
- }
- if (fg != C_MASK)
- {
- set_foreground_color(fg, outc);
- }
- if (bg != C_MASK)
- {
- set_background_color(bg, outc);
- }
- }
+ T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+
+ if (fg != C_MASK) {
+ set_foreground_color(fg, outc);
+ }
+ if (bg != C_MASK) {
+ set_background_color(bg, outc);
}
}
diff --git a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
index a2dfbd218f74..19d75477b140 100644
--- a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
+++ b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -27,34 +27,45 @@
****************************************************************************/
/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997,1999 *
****************************************************************************/
+
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.3 1998/02/11 12:13:54 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.11 2000/05/07 01:26:06 tom Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
- * it is black on white. This is an extension to XSI curses.
- *
- * Invoke this function after 'start_color()'.
+ * it is white on black. This is an extension to XSI curses.
*/
int
use_default_colors(void)
{
- T((T_CALLED("use_default_colors()")));
+ T((T_CALLED("use_default_colors()")));
+ returnCode(assume_default_colors(C_MASK, C_MASK));
+}
- if (!SP->_coloron)
- returnCode(ERR);
+/*
+ * Modify the behavior of color-pair 0 so that the library assumes that it
+ * is something specific, possibly not white on black.
+ */
+int
+assume_default_colors(int fg, int bg)
+{
+ T((T_CALLED("assume_default_colors(%d,%d)"), fg, bg));
- if (!orig_pair && !orig_colors)
- returnCode(ERR);
+ if (!orig_pair && !orig_colors)
+ returnCode(ERR);
- if (initialize_pair) /* don't know how to handle this */
- returnCode(ERR);
+ if (initialize_pair) /* don't know how to handle this */
+ returnCode(ERR);
- SP->_default_color = TRUE;
- SP->_color_pairs[0] = PAIR_OF(C_MASK, C_MASK);
- returnCode(OK);
+ SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK);
+ SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
+ 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)
+ init_pair(0, fg, bg);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c
index 324e7a282741..28f0e5f9f425 100644
--- a/contrib/ncurses/ncurses/base/lib_freeall.c
+++ b/contrib/ncurses/ncurses/base/lib_freeall.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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 *
@@ -39,94 +39,101 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.15 1999/10/22 21:40:10 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.16 1999/11/28 01:34:11 tom Exp $")
-static void free_slk(SLK *p)
+static void
+free_slk(SLK *p)
{
- if (p != 0) {
- FreeIfNeeded(p->ent);
- FreeIfNeeded(p->buffer);
- free(p);
- }
+ if (p != 0) {
+ FreeIfNeeded(p->ent);
+ FreeIfNeeded(p->buffer);
+ free(p);
+ }
}
-static void free_tries(struct tries *p)
+static void
+free_tries(struct tries *p)
{
- struct tries *q;
-
- while (p != 0) {
- q = p->sibling;
- if (p->child != 0)
- free_tries(p->child);
- free(p);
- p = q;
- }
+ struct tries *q;
+
+ while (p != 0) {
+ q = p->sibling;
+ if (p->child != 0)
+ free_tries(p->child);
+ free(p);
+ p = q;
+ }
}
/*
* Free all ncurses data. This is used for testing only (there's no practical
* use for it as an extension).
*/
-void _nc_freeall(void)
+void
+_nc_freeall(void)
{
- WINDOWLIST *p, *q;
+ WINDOWLIST *p, *q;
#if NO_LEAKS
- _nc_free_tparm();
+ _nc_free_tparm();
#endif
+ if (SP != 0) {
while (_nc_windows != 0) {
- /* Delete only windows that're not a parent */
- for (p = _nc_windows; p != 0; p = p->next) {
- bool found = FALSE;
-
- for (q = _nc_windows; q != 0; q = q->next) {
- if ((p != q)
- && (q->win->_flags & _SUBWIN)
- && (p->win == q->win->_parent)) {
- found = TRUE;
- break;
- }
- }
-
- if (!found) {
- delwin(p->win);
- break;
- }
+ /* Delete only windows that're not a parent */
+ for (p = _nc_windows; p != 0; p = p->next) {
+ bool found = FALSE;
+
+ for (q = _nc_windows; q != 0; q = q->next) {
+ if ((p != q)
+ && (q->win->_flags & _SUBWIN)
+ && (p->win == q->win->_parent)) {
+ found = TRUE;
+ break;
+ }
}
+
+ if (!found) {
+ delwin(p->win);
+ break;
+ }
+ }
}
- if (SP != 0) {
- free_tries (SP->_keytry);
- free_tries (SP->_key_ok);
- free_slk(SP->_slk);
- FreeIfNeeded(SP->_color_pairs);
- FreeIfNeeded(SP->_color_table);
+ free_tries(SP->_keytry);
+ free_tries(SP->_key_ok);
+ free_slk(SP->_slk);
+ FreeIfNeeded(SP->_color_pairs);
+ FreeIfNeeded(SP->_color_table);
#if !BROKEN_LINKER
- FreeAndNull(SP);
+ FreeAndNull(SP);
#endif
- }
-
- if (cur_term != 0) {
- _nc_free_termtype(&(cur_term->type));
- free(cur_term);
- }
+ }
+ if (cur_term != 0) {
+ _nc_free_termtype(&(cur_term->type));
+ free(cur_term);
+ }
#ifdef TRACE
- (void) _nc_trace_buf(-1, 0);
+ (void) _nc_trace_buf(-1, 0);
#endif
#if HAVE_LIBDBMALLOC
- malloc_dump(malloc_errfd);
+ malloc_dump(malloc_errfd);
#elif HAVE_LIBDMALLOC
#elif HAVE_PURIFY
- purify_all_inuse();
+ purify_all_inuse();
#endif
}
-void _nc_free_and_exit(int code)
+void
+_nc_free_and_exit(int code)
{
- _nc_freeall();
- exit(code);
+ _nc_freeall();
+ exit(code);
}
+
#else
-void _nc_freeall(void) { }
+void
+_nc_freeall(void)
+{
+}
#endif
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
index b740885b8166..7ab4b5085c75 100644
--- a/contrib/ncurses/ncurses/base/lib_getch.c
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -40,143 +40,154 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.43 1999/03/08 02:35:10 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.47 2000/05/28 01:12:51 tom Exp $")
#include <fifo_defs.h>
-int ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
+int ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
#ifdef USE_EMX_MOUSE
# include <sys/select.h>
static int
kbd_mouse_read(unsigned char *p)
{
-fd_set fdset;
-int nums = SP->_ifd+1;
-
- for (;;) {
- FD_ZERO(&fdset);
- FD_SET(SP->_checkfd, &fdset);
- if (SP->_mouse_fd >= 0) {
- FD_SET(SP->_mouse_fd, &fdset);
- if (SP->_mouse_fd > SP->_checkfd)
- nums = SP->_mouse_fd+1;
- }
- if (select(nums, &fdset, NULL, NULL, NULL) >= 0) {
- int n;
-
- if (FD_ISSET(SP->_mouse_fd, &fdset)) /* Prefer mouse */
- n = read(SP->_mouse_fd, p, 1);
- else
- n = read(SP->_ifd, p, 1);
- return n;
- }
- if (errno != EINTR)
- return -1;
+ fd_set fdset;
+ int nums = SP->_ifd + 1;
+
+ for (;;) {
+ FD_ZERO(&fdset);
+ FD_SET(SP->_ifd, &fdset);
+ if (SP->_checkfd >= 0) {
+ FD_SET(SP->_checkfd, &fdset);
+ if (SP->_checkfd >= nums)
+ nums = SP->_checkfd + 1;
}
+ if (SP->_mouse_fd >= 0) {
+ FD_SET(SP->_mouse_fd, &fdset);
+ if (SP->_mouse_fd >= nums)
+ nums = SP->_mouse_fd + 1;
+ }
+ if (select(nums, &fdset, NULL, NULL, NULL) >= 0) {
+ int n;
+
+ if (SP->_mouse_fd >= 0
+ && FD_ISSET(SP->_mouse_fd, &fdset)) { /* Prefer mouse */
+ n = read(SP->_mouse_fd, p, 1);
+ } else {
+ n = read(SP->_ifd, p, 1);
+ }
+ return n;
+ }
+ if (errno != EINTR) {
+ return -1;
+ }
+ }
}
-#endif /* USE_EMX_MOUSE */
+#endif /* USE_EMX_MOUSE */
-static inline int fifo_peek(void)
+static inline int
+fifo_peek(void)
{
- int ch = SP->_fifo[peek];
- T(("peeking at %d", peek));
+ int ch = SP->_fifo[peek];
+ T(("peeking at %d", peek));
- p_inc();
- return ch;
+ p_inc();
+ return ch;
}
-
-static inline int fifo_pull(void)
+static inline int
+fifo_pull(void)
{
-int ch;
- ch = SP->_fifo[head];
- T(("pulling %d from %d", ch, head));
+ int ch;
+ ch = SP->_fifo[head];
+ T(("pulling %d from %d", ch, head));
- if (peek == head)
- {
- h_inc();
- peek = head;
- }
- else
- h_inc();
+ if (peek == head) {
+ h_inc();
+ peek = head;
+ } else
+ h_inc();
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+ if (_nc_tracing & TRACE_IEVENT)
+ _nc_fifo_dump();
#endif
- return ch;
+ return ch;
}
-static inline int fifo_push(void)
+static inline int
+fifo_push(void)
{
-int n;
-unsigned int ch;
+ int n;
+ unsigned int ch;
- if (tail == -1) return ERR;
+ if (tail == -1)
+ return ERR;
#ifdef HIDE_EINTR
-again:
- errno = 0;
+ again:
+ errno = 0;
#endif
#if USE_GPM_SUPPORT
- if ((SP->_mouse_fd >= 0)
- && (_nc_timed_wait(3, -1, (int *)0) & 2))
- {
- SP->_mouse_event(SP);
- ch = KEY_MOUSE;
- n = 1;
- } else
+ if ((SP->_mouse_fd >= 0)
+ && (_nc_timed_wait(3, -1, (int *) 0) & 2)) {
+ SP->_mouse_event(SP);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else
#endif
- {
- unsigned char c2=0;
+ {
+ unsigned char c2 = 0;
#ifdef USE_EMX_MOUSE
- n = kbd_mouse_read(&c2);
+ n = kbd_mouse_read(&c2);
#else
- n = read(SP->_ifd, &c2, 1);
+ n = read(SP->_ifd, &c2, 1);
#endif
- ch = c2 & 0xff;
- }
+ ch = c2 & 0xff;
+ }
#ifdef HIDE_EINTR
- /*
- * Under System V curses with non-restarting signals, getch() returns
- * with value ERR when a handled signal keeps it from completing.
- * If signals restart system calls, OTOH, the signal is invisible
- * except to its handler.
- *
- * We don't want this difference to show. This piece of code
- * tries to make it look like we always have restarting signals.
- */
- if (n <= 0 && errno == EINTR)
- goto again;
+ /*
+ * Under System V curses with non-restarting signals, getch() returns
+ * with value ERR when a handled signal keeps it from completing.
+ * If signals restart system calls, OTOH, the signal is invisible
+ * except to its handler.
+ *
+ * We don't want this difference to show. This piece of code
+ * tries to make it look like we always have restarting signals.
+ */
+ if (n <= 0 && errno == EINTR)
+ goto again;
#endif
- if ((n == -1) || (n == 0))
- {
- T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
- return ERR;
- }
- T(("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));
+ if ((n == -1) || (n == 0)) {
+ T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ return ERR;
+ }
+ T(("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));
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+ if (_nc_tracing & TRACE_IEVENT)
+ _nc_fifo_dump();
#endif
- return ch;
+ return ch;
}
-static inline void fifo_clear(void)
+static inline void
+fifo_clear(void)
{
-int i;
- for (i = 0; i < FIFO_SIZE; i++)
- SP->_fifo[i] = 0;
- head = -1; tail = peek = 0;
+ int i;
+ for (i = 0; i < FIFO_SIZE; i++)
+ SP->_fifo[i] = 0;
+ head = -1;
+ tail = peek = 0;
}
static int kgetch(WINDOW *);
@@ -188,147 +199,158 @@ static int kgetch(WINDOW *);
int
wgetch(WINDOW *win)
{
-int ch;
+ int ch;
- T((T_CALLED("wgetch(%p)"), win));
+ T((T_CALLED("wgetch(%p)"), win));
- if (!win)
- returnCode(ERR);
+ if (!win)
+ returnCode(ERR);
- if (cooked_key_in_fifo())
- {
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ if (cooked_key_in_fifo()) {
+ if (wgetch_should_refresh(win))
+ wrefresh(win);
- ch = fifo_pull();
- T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch));)
- returnCode(ch);
- }
+ ch = fifo_pull();
+ T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch)));
+ returnCode(ch);
+ }
- /*
- * Handle cooked mode. Grab a string from the screen,
- * stuff its contents in the FIFO queue, and pop off
- * the first character to return it.
- */
- if (head == -1 && !SP->_raw && !SP->_cbreak)
- {
- char buf[MAXCOLUMNS], *sp;
+ /*
+ * Handle cooked mode. Grab a string from the screen,
+ * stuff its contents in the FIFO queue, and pop off
+ * the first character to return it.
+ */
+ if (head == -1 && !SP->_raw && !SP->_cbreak) {
+ char buf[MAXCOLUMNS], *sp;
- T(("filling queue in cooked mode"));
+ T(("filling queue in cooked mode"));
- wgetnstr(win, buf, MAXCOLUMNS);
+ wgetnstr(win, buf, MAXCOLUMNS);
- /* ungetch in reverse order */
- ungetch('\n');
- for (sp = buf+strlen(buf); sp>buf; sp--)
- ungetch(sp[-1]);
+ /* ungetch in reverse order */
+ ungetch('\n');
+ for (sp = buf + strlen(buf); sp > buf; sp--)
+ ungetch(sp[-1]);
- returnCode(fifo_pull());
- }
+ returnCode(fifo_pull());
+ }
- if (wgetch_should_refresh(win))
- wrefresh(win);
+ if (wgetch_should_refresh(win))
+ wrefresh(win);
- if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1))
- {
- int delay;
+ if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1)) {
+ int delay;
- T(("timed delay in wgetch()"));
- if (SP->_cbreak > 1)
- delay = (SP->_cbreak - 1) * 100;
- else
- delay = win->_delay;
+ T(("timed delay in wgetch()"));
+ if (SP->_cbreak > 1)
+ delay = (SP->_cbreak - 1) * 100;
+ else
+ delay = win->_delay;
- T(("delay is %d milliseconds", delay));
+ T(("delay is %d milliseconds", delay));
- if (head == -1) /* fifo is empty */
- if (!_nc_timed_wait(3, delay, (int *)0))
- returnCode(ERR);
- /* else go on to read data available */
- }
+ if (head == -1) /* fifo is empty */
+ if (!_nc_timed_wait(3, delay, (int *) 0))
+ returnCode(ERR);
+ /* else go on to read data available */
+ }
- if (win->_use_keypad)
- {
- /*
- * This is tricky. We only want to get special-key
- * events one at a time. But we want to accumulate
- * mouse events until either (a) the mouse logic tells
- * us it's picked up a complete gesture, or (b)
- * there's a detectable time lapse after one.
- *
- * Note: if the mouse code starts failing to compose
- * press/release events into clicks, you should probably
- * increase the wait with mouseinterval().
- */
- int runcount = 0;
-
- do {
- ch = kgetch(win);
- if (ch == KEY_MOUSE)
- {
- ++runcount;
- if (SP->_mouse_inline(SP))
- break;
- }
- } while
- (ch == KEY_MOUSE
- && (_nc_timed_wait(3, SP->_maxclick, (int *)0)
- || !SP->_mouse_parse(runcount)));
- if (runcount > 0 && ch != KEY_MOUSE)
- {
- /* mouse event sequence ended by keystroke, push it */
- ungetch(ch);
- ch = KEY_MOUSE;
- }
- } else {
- if (head == -1)
- fifo_push();
- ch = fifo_pull();
+ if (win->_use_keypad) {
+ /*
+ * This is tricky. We only want to get special-key
+ * events one at a time. But we want to accumulate
+ * mouse events until either (a) the mouse logic tells
+ * us it's picked up a complete gesture, or (b)
+ * there's a detectable time lapse after one.
+ *
+ * Note: if the mouse code starts failing to compose
+ * press/release events into clicks, you should probably
+ * increase the wait with mouseinterval().
+ */
+ int runcount = 0;
+
+ do {
+ ch = kgetch(win);
+ if (ch == KEY_MOUSE) {
+ ++runcount;
+ if (SP->_mouse_inline(SP))
+ break;
+ }
+ } while
+ (ch == KEY_MOUSE
+ && (_nc_timed_wait(3, SP->_maxclick, (int *) 0)
+ || !SP->_mouse_parse(runcount)));
+ if (runcount > 0 && ch != KEY_MOUSE) {
+ /* mouse event sequence ended by keystroke, push it */
+ ungetch(ch);
+ ch = KEY_MOUSE;
}
+ } else {
+ if (head == -1)
+ fifo_push();
+ ch = fifo_pull();
+ }
- if (ch == ERR)
- {
+ if (ch == ERR) {
#if USE_SIZECHANGE
- if(SP->_sig_winch)
- {
- _nc_update_screensize();
- /* resizeterm can push KEY_RESIZE */
- if(cooked_key_in_fifo())
- {
- ch = fifo_pull();
- T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch));)
- returnCode(ch);
- }
+ if (SP->_sig_winch) {
+ _nc_update_screensize();
+ /* resizeterm can push KEY_RESIZE */
+ if (cooked_key_in_fifo()) {
+ ch = fifo_pull();
+ T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch)));
+ returnCode(ch);
}
-#endif
- T(("wgetch returning ERR"));
- returnCode(ERR);
}
-
- /*
- * Simulate ICRNL mode
- */
- if ((ch == '\r') && SP->_nl)
- ch = '\n';
-
- /* Strip 8th-bit if so desired. We do this only for characters that
- * are in the range 128-255, to provide compatibility with terminals
- * that display only 7-bit characters. Note that 'ch' may be a
- * function key at this point, so we mustn't strip _those_.
- */
- if ((ch < KEY_MIN) && (ch & 0x80))
- if (!SP->_use_meta)
- ch &= 0x7f;
-
- if (SP->_echo && ch < KEY_MIN && !(win->_flags & _ISPAD))
- wechochar(win, (chtype)ch);
-
- T(("wgetch returning : %#x = %s", ch, _trace_key(ch)));
-
- returnCode(ch);
+#endif
+ T(("wgetch returning ERR"));
+ returnCode(ERR);
+ }
+
+ /*
+ * If echo() is in effect, display the printable version of the
+ * key on the screen. Carriage return and backspace are treated
+ * specially by Solaris curses:
+ *
+ * If carriage return is defined as a function key in the
+ * terminfo, e.g., kent, then Solaris may return either ^J (or ^M
+ * if nonl() is set) or KEY_ENTER depending on the echo() mode.
+ * We echo before translating carriage return based on nonl(),
+ * since the visual result simply moves the cursor to column 0.
+ *
+ * Backspace is a different matter. Solaris curses does not
+ * translate it to KEY_BACKSPACE if kbs=^H. This does not depend
+ * on the stty modes, but appears to be a hardcoded special case.
+ * This is a difference from ncurses, which uses the terminfo entry.
+ * However, we provide the same visual result as Solaris, moving the
+ * cursor to the left.
+ */
+ if (SP->_echo && !(win->_flags & _ISPAD)) {
+ chtype backup = (ch == KEY_BACKSPACE) ? '\b' : ch;
+ if (backup < KEY_MIN)
+ wechochar(win, backup);
+ }
+
+ /*
+ * Simulate ICRNL mode
+ */
+ if ((ch == '\r') && SP->_nl)
+ ch = '\n';
+
+ /* Strip 8th-bit if so desired. We do this only for characters that
+ * are in the range 128-255, to provide compatibility with terminals
+ * that display only 7-bit characters. Note that 'ch' may be a
+ * function key at this point, so we mustn't strip _those_.
+ */
+ if ((ch < KEY_MIN) && (ch & 0x80))
+ if (!SP->_use_meta)
+ ch &= 0x7f;
+
+ T(("wgetch returning : %#x = %s", ch, _trace_key(ch)));
+
+ returnCode(ch);
}
-
/*
** int
** kgetch()
@@ -347,68 +369,63 @@ int ch;
static int
kgetch(WINDOW *win GCC_UNUSED)
{
-struct tries *ptr;
-int ch = 0;
-int timeleft = ESCDELAY;
-
- TR(TRACE_IEVENT, ("kgetch(%p) called", win));
-
- ptr = SP->_keytry;
-
- for(;;)
- {
- if (!raw_key_in_fifo())
- {
- if(fifo_push() == ERR)
- {
- peek = head; /* the keys stay uninterpreted */
- return ERR;
- }
- }
- ch = fifo_peek();
- if (ch >= KEY_MIN)
- {
- peek = head;
- /* assume the key is the last in fifo */
- t_dec(); /* remove the key */
- return ch;
- }
-
- TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char)ch)));
- while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
- ptr = ptr->sibling;
+ struct tries *ptr;
+ int ch = 0;
+ int timeleft = ESCDELAY;
+
+ TR(TRACE_IEVENT, ("kgetch(%p) called", win));
+
+ ptr = SP->_keytry;
+
+ for (;;) {
+ if (!raw_key_in_fifo()) {
+ if (fifo_push() == ERR) {
+ peek = head; /* the keys stay uninterpreted */
+ return ERR;
+ }
+ }
+ ch = fifo_peek();
+ if (ch >= KEY_MIN) {
+ peek = head;
+ /* assume the key is the last in fifo */
+ t_dec(); /* remove the key */
+ return ch;
+ }
+
+ TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char) ch)));
+ while ((ptr != NULL) && (ptr->ch != (unsigned char) ch))
+ ptr = ptr->sibling;
#ifdef TRACE
- if (ptr == NULL)
- {TR(TRACE_IEVENT, ("ptr is null"));}
- else
- TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
- ptr, ptr->ch, ptr->value));
+ if (ptr == NULL) {
+ TR(TRACE_IEVENT, ("ptr is null"));
+ } else
+ TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
+ ptr, ptr->ch, ptr->value));
#endif /* TRACE */
- if (ptr == NULL)
- break;
-
- if (ptr->value != 0) { /* sequence terminated */
- TR(TRACE_IEVENT, ("end of sequence"));
- if (peek == tail)
- fifo_clear();
- else
- head = peek;
- return(ptr->value);
- }
-
- ptr = ptr->child;
-
- if (!raw_key_in_fifo())
- {
- TR(TRACE_IEVENT, ("waiting for rest of sequence"));
- if (!_nc_timed_wait(3, timeleft, &timeleft)) {
- TR(TRACE_IEVENT, ("ran out of time"));
- break;
- }
- }
+ if (ptr == NULL)
+ break;
+
+ if (ptr->value != 0) { /* sequence terminated */
+ TR(TRACE_IEVENT, ("end of sequence"));
+ if (peek == tail)
+ fifo_clear();
+ else
+ head = peek;
+ return (ptr->value);
}
- ch = fifo_pull();
- peek = head;
- return ch;
+
+ ptr = ptr->child;
+
+ if (!raw_key_in_fifo()) {
+ TR(TRACE_IEVENT, ("waiting for rest of sequence"));
+ if (!_nc_timed_wait(3, timeleft, &timeleft)) {
+ TR(TRACE_IEVENT, ("ran out of time"));
+ break;
+ }
+ }
+ }
+ ch = fifo_pull();
+ peek = head;
+ return ch;
}
diff --git a/contrib/ncurses/ncurses/base/lib_hline.c b/contrib/ncurses/ncurses/base/lib_hline.c
index 3b0a602eeee9..71d6b140424c 100644
--- a/contrib/ncurses/ncurses/base/lib_hline.c
+++ b/contrib/ncurses/ncurses/base/lib_hline.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_hline.c
**
@@ -42,35 +40,36 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_hline.c,v 1.4 1998/06/28 00:11:01 tom Exp $")
+MODULE_ID("$Id: lib_hline.c,v 1.5 2000/04/29 21:14:30 tom Exp $")
-int whline(WINDOW *win, chtype ch, int n)
+int
+whline(WINDOW *win, chtype ch, int n)
{
-int code = ERR;
-short start;
-short end;
+ int code = ERR;
+ NCURSES_SIZE_T start;
+ NCURSES_SIZE_T end;
- T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n));
+ T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n));
- if (win) {
- struct ldat *line = &(win->_line[win->_cury]);
+ if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
- start = win->_curx;
- end = start + n - 1;
- if (end > win->_maxx)
- end = win->_maxx;
+ start = win->_curx;
+ end = start + n - 1;
+ if (end > win->_maxx)
+ end = win->_maxx;
- CHANGED_RANGE(line, start, end);
+ CHANGED_RANGE(line, start, end);
- if (ch == 0)
- ch = ACS_HLINE;
- ch = _nc_render(win, ch);
+ if (ch == 0)
+ ch = ACS_HLINE;
+ ch = _nc_render(win, ch);
- while ( end >= start) {
- line->text[end] = ch;
- end--;
- }
- code = OK;
+ while (end >= start) {
+ line->text[end] = ch;
+ end--;
}
- returnCode(code);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_insstr.c b/contrib/ncurses/ncurses/base/lib_insstr.c
index cba147318b8e..a2275f9457b6 100644
--- a/contrib/ncurses/ncurses/base/lib_insstr.c
+++ b/contrib/ncurses/ncurses/base/lib_insstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_insstr.c
**
@@ -43,39 +41,41 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insstr.c,v 1.13 1999/03/14 00:27:21 tom Exp $")
+MODULE_ID("$Id: lib_insstr.c,v 1.14 2000/04/29 21:16:41 tom Exp $")
-int winsnstr(WINDOW *win, const char *s, int n)
+int
+winsnstr(WINDOW *win, const char *s, int n)
{
-int code = ERR;
-short oy;
-short ox ;
-const unsigned char *str = (const unsigned char *)s;
-const unsigned char *cp;
+ int code = ERR;
+ NCURSES_SIZE_T oy;
+ NCURSES_SIZE_T ox;
+ const unsigned char *str = (const unsigned char *) s;
+ const unsigned char *cp;
- T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
+ T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
- if (win && str) {
- oy = win->_cury; ox = win->_curx;
- for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+ if (win && str) {
+ oy = win->_cury;
+ ox = win->_curx;
+ for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
- _nc_waddch_nosync(win, (chtype)(*cp));
+ _nc_waddch_nosync(win, (chtype) (*cp));
else if (is7bits(*cp) && iscntrl(*cp)) {
- winsch(win, ' ' + (chtype)(*cp));
- winsch(win, '^');
- win->_curx += 2;
+ winsch(win, ' ' + (chtype) (*cp));
+ winsch(win, '^');
+ win->_curx += 2;
} else {
- winsch(win, (chtype)(*cp));
- win->_curx++;
+ winsch(win, (chtype) (*cp));
+ win->_curx++;
}
if (win->_curx > win->_maxx)
- win->_curx = win->_maxx;
- }
-
- win->_curx = ox;
- win->_cury = oy;
- _nc_synchook(win);
- code = OK;
+ win->_curx = win->_maxx;
}
- returnCode(code);
+
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c
index d34d48342e4f..59db16d1aea6 100644
--- a/contrib/ncurses/ncurses/base/lib_mouse.c
+++ b/contrib/ncurses/ncurses/base/lib_mouse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -64,8 +64,7 @@
*/
#ifdef __EMX__
-# include "io.h"
-# include "fcntl.h"
+# include <io.h>
# define INCL_DOS
# define INCL_VIO
# define INCL_KBD
@@ -85,13 +84,13 @@
#endif
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.45 1999/10/22 21:39:02 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.52 2000/06/29 23:02:26 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
#define INVALID_EVENT -1
-static int mousetype;
+static int mousetype;
#define M_XTERM -1 /* use xterm's mouse tracking? */
#define M_NONE 0 /* no mouse device */
#define M_GPM 1 /* use GPM */
@@ -104,7 +103,7 @@ static Gpm_Connect gpm_connect;
#endif
#endif
-static mmask_t eventmask; /* current event mask */
+static mmask_t eventmask; /* current event mask */
static bool _nc_mouse_parse(int);
static void _nc_mouse_resume(SCREEN *);
@@ -116,22 +115,23 @@ static void _nc_mouse_wrap(SCREEN *);
* wgetch() may refer to the size and call _nc_mouse_parse() before circular
* list overflow.
*/
-static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
-static MEVENT *eventp = events; /* next free slot in event queue */
+static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
+static MEVENT *eventp = events; /* next free slot in event queue */
#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
#ifdef TRACE
-static void _trace_slot(const char *tag)
+static void
+_trace_slot(const char *tag)
{
- MEVENT *ep;
+ MEVENT *ep;
- _tracef(tag);
+ _tracef(tag);
- for (ep = events; ep < events + EV_MAX; ep++)
- _tracef("mouse event queue slot %ld = %s",
- (long) (ep - events),
- _tracemouse(ep));
+ for (ep = events; ep < events + EV_MAX; ep++)
+ _tracef("mouse event queue slot %ld = %s",
+ (long) (ep - events),
+ _tracemouse(ep));
}
#endif
@@ -143,8 +143,8 @@ static void _trace_slot(const char *tag)
static int mouse_wfd;
static int mouse_thread;
static int mouse_activated;
-static char mouse_buttons[] = { 0, 1, 3, 2};
-
+static char mouse_buttons[] =
+{0, 1, 3, 2};
# define M_FD(sp) sp->_mouse_fd
@@ -174,34 +174,34 @@ mouse_server(unsigned long ignored GCC_UNUSED)
unsigned long ignore;
/* open the handle for the mouse */
- if (MouOpen(NULL,&hmou) == 0) {
+ if (MouOpen(NULL, &hmou) == 0) {
- if (MouSetEventMask(&mask,hmou) == 0
- && MouDrawPtr(hmou) == 0) {
+ if (MouSetEventMask(&mask, hmou) == 0
+ && MouDrawPtr(hmou) == 0) {
for (;;) {
/* sit and wait on the event queue */
- if (MouReadEventQue(&mouev,&fWait,hmou))
- break;
+ if (MouReadEventQue(&mouev, &fWait, hmou))
+ break;
if (!mouse_activated)
goto finish;
/*
* OS/2 numbers a 3-button mouse inconsistently from other
* platforms:
- * 1 = left
- * 2 = right
- * 3 = middle.
+ * 1 = left
+ * 2 = right
+ * 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
- write_event(mouev.fs & MOUSE_BN1_DOWN,
- mouse_buttons[1], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN1_DOWN,
+ mouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
- write_event(mouev.fs & MOUSE_BN2_DOWN,
- mouse_buttons[3], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN2_DOWN,
+ mouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
- write_event(mouev.fs & MOUSE_BN3_DOWN,
- mouse_buttons[2], mouev.col, mouev.row);
+ write_event(mouev.fs & MOUSE_BN3_DOWN,
+ mouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
@@ -211,11 +211,11 @@ mouse_server(unsigned long ignored GCC_UNUSED)
DosWrite(2, errmess, strlen(errmess), &ignore);
MouClose(hmou);
}
- DosExit(EXIT_THREAD, 0L );
+ DosExit(EXIT_THREAD, 0L);
}
static void
server_state(const int state)
-{ /* It would be nice to implement pointer-off and stop looping... */
+{ /* It would be nice to implement pointer-off and stop looping... */
mouse_activated = state;
}
@@ -223,44 +223,30 @@ server_state(const int state)
static int initialized;
-static void _nc_mouse_init(void)
-/* initialize the mouse */
+static void
+initialize_mousetype(void)
{
- int i;
-
- if (initialized) {
- return;
- }
- initialized = TRUE;
-
- TR(MY_TRACE, ("_nc_mouse_init() called"));
-
- for (i = 0; i < EV_MAX; i++)
- events[i].id = INVALID_EVENT;
-
- /* we know how to recognize mouse events under xterm */
- if (key_mouse != 0
- && getenv("DISPLAY") != 0)
- mousetype = M_XTERM;
+ static const char *xterm_kmous = "\033[M";
+ /* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
- else if (!strncmp(cur_term->type.term_names, "linux", 5))
- {
- /* GPM: initialize connection to gpm server */
- gpm_connect.eventMask = GPM_DOWN|GPM_UP;
- gpm_connect.defaultMask = ~(gpm_connect.eventMask|GPM_HARD);
- gpm_connect.minMod = 0;
- gpm_connect.maxMod = ~((1<<KG_SHIFT)|(1<<KG_SHIFTL)|(1<<KG_SHIFTR));
- if (Gpm_Open (&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
- mousetype = M_GPM;
- SP->_mouse_fd = gpm_fd;
- }
+ /* GPM: initialize connection to gpm server */
+ gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
+ gpm_connect.minMod = 0;
+ gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
+ if (Gpm_Open(&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
+ mousetype = M_GPM;
+ SP->_mouse_fd = gpm_fd;
+ return;
}
#endif
/* OS/2 VIO */
#ifdef USE_EMX_MOUSE
- if (!mouse_thread && mousetype != M_XTERM && key_mouse) {
+ if (!mouse_thread
+ && strstr(cur_term->type.term_names, "xterm") == 0
+ && key_mouse) {
int handles[2];
if (pipe(handles) < 0) {
perror("mouse pipe error");
@@ -283,19 +269,53 @@ static void _nc_mouse_init(void)
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
- rc = DosCreateThread((unsigned long*)&mouse_thread, mouse_server, 0, 0, 8192);
- if (rc)
+ rc = DosCreateThread((unsigned long *) &mouse_thread,
+ mouse_server, 0, 0, 8192);
+ if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
- else
+ } else {
mousetype = M_XTERM;
+ return;
+ }
}
}
#endif
- T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ /* we know how to recognize mouse events under "xterm" */
+ if (key_mouse != 0) {
+ if (!strcmp(key_mouse, xterm_kmous)) {
+ mousetype = M_XTERM;
+ return;
+ }
+ } else if (strstr(cur_term->type.term_names, "xterm") != 0) {
+ (void) _nc_add_to_try(&(SP->_keytry), xterm_kmous, KEY_MOUSE);
+ mousetype = M_XTERM;
+ return;
+ }
+}
+
+static void
+_nc_mouse_init(void)
+/* initialize the mouse */
+{
+ int i;
+
+ if (!initialized) {
+ initialized = TRUE;
+
+ TR(MY_TRACE, ("_nc_mouse_init() called"));
+
+ for (i = 0; i < EV_MAX; i++)
+ events[i].id = INVALID_EVENT;
+
+ initialize_mousetype();
+
+ T(("_nc_mouse_init() set mousetype to %d", mousetype));
+ }
}
-static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
+static bool
+_nc_mouse_event(SCREEN * sp GCC_UNUSED)
/* query to see if there is a pending mouse event */
{
#if USE_GPM_SUPPORT
@@ -303,23 +323,27 @@ static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
Gpm_Event ev;
if (gpm_fd >= 0
- && _nc_timed_wait(2, 0, (int *)0)
- && Gpm_GetEvent(&ev) == 1)
- {
+ && (_nc_timed_wait(3, 0, (int *) 0) & 2) != 0
+ && Gpm_GetEvent(&ev) == 1) {
eventp->id = 0; /* there's only one mouse... */
eventp->bstate = 0;
- switch (ev.type & 0x0f)
- {
- case(GPM_DOWN):
- if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_PRESSED;
- if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_PRESSED;
- if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_PRESSED;
+ switch (ev.type & 0x0f) {
+ case (GPM_DOWN):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_PRESSED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_PRESSED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_PRESSED;
break;
- case(GPM_UP):
- if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_RELEASED;
- if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_RELEASED;
- if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_RELEASED;
+ case (GPM_UP):
+ if (ev.buttons & GPM_B_LEFT)
+ eventp->bstate |= BUTTON1_RELEASED;
+ if (ev.buttons & GPM_B_MIDDLE)
+ eventp->bstate |= BUTTON2_RELEASED;
+ if (ev.buttons & GPM_B_RIGHT)
+ eventp->bstate |= BUTTON3_RELEASED;
break;
default:
break;
@@ -336,20 +360,20 @@ static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
#endif
/* xterm: never have to query, mouse events are in the keyboard stream */
- return(FALSE); /* no event waiting */
+ return (FALSE); /* no event waiting */
}
-static bool _nc_mouse_inline(SCREEN *sp)
+static bool
+_nc_mouse_inline(SCREEN * sp)
/* mouse report received in the keyboard stream -- parse its info */
{
TR(MY_TRACE, ("_nc_mouse_inline() called"));
- if (mousetype == M_XTERM)
- {
- unsigned char kbuf[4];
- MEVENT *prev;
- size_t grabbed;
- int res;
+ if (mousetype == M_XTERM) {
+ unsigned char kbuf[4];
+ MEVENT *prev;
+ size_t grabbed;
+ int res;
/* This code requires that your xterm entry contain the kmous
* capability and that it be set to the \E[M documented in the
@@ -381,28 +405,27 @@ static bool _nc_mouse_inline(SCREEN *sp)
* single clist item. It always does under Linux but often
* fails to under Solaris.
*/
- for (grabbed = 0; grabbed < 3; grabbed += res)
- {
+ for (grabbed = 0; grabbed < 3; grabbed += res) {
- /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
+ /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
#ifdef USE_EMX_MOUSE
- res = read( M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
+ res = read(M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
#else
- res = read(sp->_ifd, kbuf + grabbed, 3-grabbed);
+ res = read(sp->_ifd, kbuf + grabbed, 3 - grabbed);
#endif
- if (res == -1)
- break;
+ if (res == -1)
+ break;
}
kbuf[3] = '\0';
- TR(TRACE_IEVENT, ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+ TR(TRACE_IEVENT,
+ ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
eventp->id = 0; /* there's only one mouse... */
/* processing code goes here */
eventp->bstate = 0;
- switch (kbuf[0] & 0x3)
- {
+ switch (kbuf[0] & 0x3) {
case 0x0:
eventp->bstate = BUTTON1_PRESSED;
#ifdef USE_EMX_MOUSE
@@ -434,8 +457,8 @@ static bool _nc_mouse_inline(SCREEN *sp)
*/
eventp->bstate =
(BUTTON1_RELEASED |
- BUTTON2_RELEASED |
- BUTTON3_RELEASED);
+ BUTTON2_RELEASED |
+ BUTTON3_RELEASED);
/*
* ...however, because there are no kinds of mouse events under
* xterm that can intervene between press and release, we can
@@ -444,11 +467,11 @@ static bool _nc_mouse_inline(SCREEN *sp)
*/
prev = PREV(eventp);
if (!(prev->bstate & BUTTON1_PRESSED))
- eventp->bstate &=~ BUTTON1_RELEASED;
+ eventp->bstate &= ~BUTTON1_RELEASED;
if (!(prev->bstate & BUTTON2_PRESSED))
- eventp->bstate &=~ BUTTON2_RELEASED;
+ eventp->bstate &= ~BUTTON2_RELEASED;
if (!(prev->bstate & BUTTON3_PRESSED))
- eventp->bstate &=~ BUTTON3_RELEASED;
+ eventp->bstate &= ~BUTTON3_RELEASED;
break;
}
@@ -464,21 +487,23 @@ static bool _nc_mouse_inline(SCREEN *sp)
eventp->x = (kbuf[1] - ' ') - 1;
eventp->y = (kbuf[2] - ' ') - 1;
- TR(MY_TRACE, ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
+ TR(MY_TRACE,
+ ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
_tracemouse(eventp),
(long) (eventp - events)));
/* bump the next-free pointer into the circular list */
eventp = NEXT(eventp);
-#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
- return(TRUE);
+#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
+ return (TRUE);
#endif
}
- return(FALSE);
+ return (FALSE);
}
-static void mouse_activate(bool on)
+static void
+mouse_activate(bool on)
{
if (!on && !initialized)
return;
@@ -508,11 +533,11 @@ static void mouse_activate(bool on)
/* Make runtime binding to cut down on object size of applications that
* do not use the mouse (e.g., 'clear').
*/
- SP->_mouse_event = _nc_mouse_event;
+ SP->_mouse_event = _nc_mouse_event;
SP->_mouse_inline = _nc_mouse_inline;
- SP->_mouse_parse = _nc_mouse_parse;
+ SP->_mouse_parse = _nc_mouse_parse;
SP->_mouse_resume = _nc_mouse_resume;
- SP->_mouse_wrap = _nc_mouse_wrap;
+ SP->_mouse_wrap = _nc_mouse_wrap;
} else {
@@ -540,12 +565,13 @@ static void mouse_activate(bool on)
*
**************************************************************************/
-static bool _nc_mouse_parse(int runcount)
+static bool
+_nc_mouse_parse(int runcount)
/* parse a run of atomic mouse events into a gesture */
{
- MEVENT *ep, *runp, *next, *prev = PREV(eventp);
- int n;
- bool merge;
+ MEVENT *ep, *runp, *next, *prev = PREV(eventp);
+ int n;
+ bool merge;
TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
@@ -570,14 +596,14 @@ static bool _nc_mouse_parse(int runcount)
* button basis, as long as the device-dependent mouse code puts stuff
* on the queue in MEVENT format.
*/
- if (runcount == 1)
- {
- TR(MY_TRACE, ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ if (runcount == 1) {
+ TR(MY_TRACE,
+ ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
+ _tracemouse(prev),
+ (long) (prev - events)));
return (prev->id >= 0)
- ? ((prev->bstate & eventmask) ? TRUE : FALSE)
- : FALSE;
+ ? ((prev->bstate & eventmask) ? TRUE : FALSE)
+ : FALSE;
}
/* find the start of the run */
@@ -587,12 +613,11 @@ static bool _nc_mouse_parse(int runcount)
}
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse press/release merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -600,36 +625,31 @@ static bool _nc_mouse_parse(int runcount)
/* first pass; merge press/release pairs */
do {
merge = FALSE;
- for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
- {
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next) {
if (ep->x == next->x && ep->y == next->y
- && (ep->bstate & (BUTTON1_PRESSED|BUTTON2_PRESSED|BUTTON3_PRESSED))
+ && (ep->bstate & (BUTTON1_PRESSED | BUTTON2_PRESSED | BUTTON3_PRESSED))
&& (!(ep->bstate & BUTTON1_PRESSED)
== !(next->bstate & BUTTON1_RELEASED))
&& (!(ep->bstate & BUTTON2_PRESSED)
== !(next->bstate & BUTTON2_RELEASED))
&& (!(ep->bstate & BUTTON3_PRESSED)
== !(next->bstate & BUTTON3_RELEASED))
- )
- {
+ ) {
if ((eventmask & BUTTON1_CLICKED)
- && (ep->bstate & BUTTON1_PRESSED))
- {
- ep->bstate &=~ BUTTON1_PRESSED;
+ && (ep->bstate & BUTTON1_PRESSED)) {
+ ep->bstate &= ~BUTTON1_PRESSED;
ep->bstate |= BUTTON1_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_CLICKED)
- && (ep->bstate & BUTTON2_PRESSED))
- {
- ep->bstate &=~ BUTTON2_PRESSED;
+ && (ep->bstate & BUTTON2_PRESSED)) {
+ ep->bstate &= ~BUTTON2_PRESSED;
ep->bstate |= BUTTON2_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_CLICKED)
- && (ep->bstate & BUTTON3_PRESSED))
- {
- ep->bstate &=~ BUTTON3_PRESSED;
+ && (ep->bstate & BUTTON3_PRESSED)) {
+ ep->bstate &= ~BUTTON3_PRESSED;
ep->bstate |= BUTTON3_CLICKED;
merge = TRUE;
}
@@ -641,12 +661,11 @@ static bool _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse click merge:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -668,12 +687,11 @@ static bool _nc_mouse_parse(int runcount)
* which would get us into portability trouble.
*/
do {
- MEVENT *follower;
+ MEVENT *follower;
merge = FALSE;
for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
- if (ep->id != INVALID_EVENT)
- {
+ if (ep->id != INVALID_EVENT) {
if (next->id != INVALID_EVENT)
continue;
follower = NEXT(next);
@@ -684,26 +702,22 @@ static bool _nc_mouse_parse(int runcount)
if ((ep->bstate &
(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
&& (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
- {
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED))
- {
- follower->bstate &=~ BUTTON1_CLICKED;
+ && (follower->bstate & BUTTON1_CLICKED)) {
+ follower->bstate &= ~BUTTON1_CLICKED;
follower->bstate |= BUTTON1_DOUBLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED))
- {
- follower->bstate &=~ BUTTON2_CLICKED;
+ && (follower->bstate & BUTTON2_CLICKED)) {
+ follower->bstate &= ~BUTTON2_CLICKED;
follower->bstate |= BUTTON2_DOUBLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_DOUBLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED))
- {
- follower->bstate &=~ BUTTON3_CLICKED;
+ && (follower->bstate & BUTTON3_CLICKED)) {
+ follower->bstate &= ~BUTTON3_CLICKED;
follower->bstate |= BUTTON3_DOUBLE_CLICKED;
merge = TRUE;
}
@@ -714,29 +728,25 @@ static bool _nc_mouse_parse(int runcount)
/* merge double-click events forward */
if ((ep->bstate &
(BUTTON1_DOUBLE_CLICKED
- | BUTTON2_DOUBLE_CLICKED
- | BUTTON3_DOUBLE_CLICKED))
+ | BUTTON2_DOUBLE_CLICKED
+ | BUTTON3_DOUBLE_CLICKED))
&& (follower->bstate &
- (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
- {
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))) {
if ((eventmask & BUTTON1_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON1_CLICKED))
- {
- follower->bstate &=~ BUTTON1_CLICKED;
+ && (follower->bstate & BUTTON1_CLICKED)) {
+ follower->bstate &= ~BUTTON1_CLICKED;
follower->bstate |= BUTTON1_TRIPLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON2_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON2_CLICKED))
- {
- follower->bstate &=~ BUTTON2_CLICKED;
+ && (follower->bstate & BUTTON2_CLICKED)) {
+ follower->bstate &= ~BUTTON2_CLICKED;
follower->bstate |= BUTTON2_TRIPLE_CLICKED;
merge = TRUE;
}
if ((eventmask & BUTTON3_TRIPLE_CLICKED)
- && (follower->bstate & BUTTON3_CLICKED))
- {
- follower->bstate &=~ BUTTON3_CLICKED;
+ && (follower->bstate & BUTTON3_CLICKED)) {
+ follower->bstate &= ~BUTTON3_CLICKED;
follower->bstate |= BUTTON3_TRIPLE_CLICKED;
merge = TRUE;
}
@@ -748,12 +758,11 @@ static bool _nc_mouse_parse(int runcount)
(merge);
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("before mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
#endif /* TRACE */
@@ -766,28 +775,28 @@ static bool _nc_mouse_parse(int runcount)
if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask)) {
eventp = prev;
}
-
#ifdef TRACE
- if (_nc_tracing & TRACE_IEVENT)
- {
+ if (_nc_tracing & TRACE_IEVENT) {
_trace_slot("after mouse event queue compaction:");
_tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
(long) (runp - events),
- (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ (long) ((eventp - events) + (EV_MAX - 1)) % EV_MAX,
runcount);
}
for (ep = runp; ep != eventp; ep = NEXT(ep))
if (ep->id != INVALID_EVENT)
- TR(MY_TRACE, ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
- _tracemouse(ep),
- (long) (ep - events)));
+ TR(MY_TRACE,
+ ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
+ _tracemouse(ep),
+ (long) (ep - events)));
#endif /* TRACE */
/* after all this, do we have a valid event? */
- return(PREV(eventp)->id != INVALID_EVENT);
+ return (PREV(eventp)->id != INVALID_EVENT);
}
-static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+static void
+_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
/* release mouse -- called by endwin() before shellout/exit */
{
TR(MY_TRACE, ("_nc_mouse_wrap() called"));
@@ -799,13 +808,14 @@ static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
break;
#if USE_GPM_SUPPORT
/* GPM: pass all mouse events to next client */
- case M_GPM:
- break;
+ case M_GPM:
+ break;
#endif
}
}
-static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+static void
+_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
/* re-connect to mouse -- called by doupdate() after shellout */
{
TR(MY_TRACE, ("_nc_mouse_resume() called"));
@@ -823,22 +833,22 @@ static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
*
**************************************************************************/
-int getmouse(MEVENT *aevent)
+int
+getmouse(MEVENT * aevent)
/* grab a copy of the current mouse event */
{
T((T_CALLED("getmouse(%p)"), aevent));
- if (aevent && (mousetype != M_NONE))
- {
+ if (aevent && (mousetype != M_NONE)) {
/* compute the current-event pointer */
- MEVENT *prev = PREV(eventp);
+ MEVENT *prev = PREV(eventp);
/* copy the event we find there */
*aevent = *prev;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _tracemouse(prev),
- (long) (prev - events)));
+ _tracemouse(prev),
+ (long) (prev - events)));
prev->id = INVALID_EVENT; /* so the queue slot becomes free */
returnCode(OK);
@@ -846,7 +856,8 @@ int getmouse(MEVENT *aevent)
returnCode(ERR);
}
-int ungetmouse(MEVENT *aevent)
+int
+ungetmouse(MEVENT * aevent)
/* enqueue a synthesized mouse event to be seen by the next wgetch() */
{
/* stick the given event in the next-free slot */
@@ -859,7 +870,8 @@ int ungetmouse(MEVENT *aevent)
return ungetch(KEY_MOUSE);
}
-mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
+mmask_t
+mousemask(mmask_t newmask, mmask_t * oldmask)
/* set the mouse event mask */
{
mmask_t result = 0;
@@ -873,16 +885,15 @@ mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
returnCode(0);
_nc_mouse_init();
- if ( mousetype != M_NONE )
- {
+ if (mousetype != M_NONE) {
eventmask = newmask &
(BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
- | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
- | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
- | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
- | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
- | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
- | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
+ | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
+ | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
+ | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
+ | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
+ | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
+ | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
mouse_activate(eventmask != 0);
@@ -892,21 +903,22 @@ mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
returnCode(result);
}
-bool wenclose(const WINDOW *win, int y, int x)
+bool
+wenclose(const WINDOW *win, int y, int x)
/* check to see if given window encloses given screen location */
{
- if (win)
- {
+ if (win) {
y -= win->_yoffset;
return ((win->_begy <= y &&
- win->_begx <= x &&
- (win->_begx + win->_maxx) >= x &&
- (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+ win->_begx <= x &&
+ (win->_begx + win->_maxx) >= x &&
+ (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
}
return FALSE;
}
-int mouseinterval(int maxclick)
+int
+mouseinterval(int maxclick)
/* set the maximum mouse interval within which to recognize a click */
{
int oldval;
@@ -919,46 +931,44 @@ int mouseinterval(int maxclick)
oldval = DEFAULT_MAXCLICK;
}
- return(oldval);
+ return (oldval);
}
/* This may be used by other routines to ask for the existence of mouse
support */
-int _nc_has_mouse(void) {
- return (mousetype==M_NONE ? 0:1);
+int
+_nc_has_mouse(void)
+{
+ return (mousetype == M_NONE ? 0 : 1);
}
-bool wmouse_trafo(const WINDOW* win, int* pY, int* pX, bool to_screen)
+bool
+wmouse_trafo(const WINDOW *win, int *pY, int *pX, bool to_screen)
{
- bool result = FALSE;
-
- if (win && pY && pX)
- {
- int y = *pY; int x = *pX;
-
- if (to_screen)
- {
- y += win->_begy + win->_yoffset;
- x += win->_begx;
- if (wenclose(win,y,x))
- result = TRUE;
- }
- else
- {
- if (wenclose(win,y,x))
- {
- y -= (win->_begy + win->_yoffset);
- x -= win->_begx;
- result = TRUE;
+ bool result = FALSE;
+
+ if (win && pY && pX) {
+ int y = *pY;
+ int x = *pX;
+
+ if (to_screen) {
+ y += win->_begy + win->_yoffset;
+ x += win->_begx;
+ if (wenclose(win, y, x))
+ result = TRUE;
+ } else {
+ if (wenclose(win, y, x)) {
+ y -= (win->_begy + win->_yoffset);
+ x -= win->_begx;
+ result = TRUE;
}
}
- if (result)
- {
- *pX = x;
- *pY = y;
+ if (result) {
+ *pX = x;
+ *pY = y;
}
}
- return(result);
+ return (result);
}
/* lib_mouse.c ends here */
diff --git a/contrib/ncurses/ncurses/base/lib_move.c b/contrib/ncurses/ncurses/base/lib_move.c
index 6f5bddff33ea..68415d6e620d 100644
--- a/contrib/ncurses/ncurses/base/lib_move.c
+++ b/contrib/ncurses/ncurses/base/lib_move.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -31,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
** lib_move.c
**
@@ -41,23 +40,22 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_move.c,v 1.8 1998/02/11 12:13:53 tom Exp $")
+MODULE_ID("$Id: lib_move.c,v 1.9 2000/04/29 21:11:19 tom Exp $")
int
wmove(WINDOW *win, int y, int x)
{
- T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
-
- if (win &&
- x >= 0 && x <= win->_maxx &&
- y >= 0 && y <= win->_maxy)
- {
- win->_curx = (short)x;
- win->_cury = (short)y;
-
- win->_flags &= ~_WRAPPED;
- win->_flags |= _HASMOVED;
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
+
+ if (win &&
+ x >= 0 && x <= win->_maxx &&
+ y >= 0 && y <= win->_maxy) {
+ win->_curx = (NCURSES_SIZE_T) x;
+ win->_cury = (NCURSES_SIZE_T) y;
+
+ win->_flags &= ~_WRAPPED;
+ win->_flags |= _HASMOVED;
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
index 9a4919bf5292..08e35cf50182 100644
--- a/contrib/ncurses/ncurses/base/lib_newterm.c
+++ b/contrib/ncurses/ncurses/base/lib_newterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_newterm.c
**
@@ -46,11 +44,12 @@
#define _POSIX_SOURCE
#endif
-#include <term.h> /* clear_screen, cup & friends, cur_term */
+#include <term.h> /* clear_screen, cup & friends, cur_term */
+#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.41 1999/07/24 20:07:48 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.46 2000/07/01 22:26:22 tom Exp $")
-#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
+#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
#endif
@@ -62,20 +61,21 @@ MODULE_ID("$Id: lib_newterm.c,v 1.41 1999/07/24 20:07:48 tom Exp $")
* The newterm function also initializes terminal settings, and since initscr
* is supposed to behave as if it calls newterm, we do it here.
*/
-static inline int _nc_initscr(void)
+static inline int
+_nc_initscr(void)
{
- /* for extended XPG4 conformance requires cbreak() at this point */
- /* (SVr4 curses does this anyway) */
- cbreak();
+ /* for extended XPG4 conformance requires cbreak() at this point */
+ /* (SVr4 curses does this anyway) */
+ cbreak();
#ifdef TERMIOS
- cur_term->Nttyb.c_lflag &= ~(ECHO|ECHONL);
- cur_term->Nttyb.c_iflag &= ~(ICRNL|INLCR|IGNCR);
- cur_term->Nttyb.c_oflag &= ~(ONLCR);
+ cur_term->Nttyb.c_lflag &= ~(ECHO | ECHONL);
+ cur_term->Nttyb.c_iflag &= ~(ICRNL | INLCR | IGNCR);
+ cur_term->Nttyb.c_oflag &= ~(ONLCR);
#else
- cur_term->Nttyb.sg_flags &= ~(ECHO|CRMOD);
+ cur_term->Nttyb.sg_flags &= ~(ECHO | CRMOD);
#endif
- return _nc_set_tty_mode(&cur_term->Nttyb);
+ return _nc_set_tty_mode(&cur_term->Nttyb);
}
/*
@@ -86,121 +86,138 @@ static inline int _nc_initscr(void)
*/
static int filter_mode = FALSE;
-void filter(void)
+void
+filter(void)
{
filter_mode = TRUE;
}
-SCREEN * newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
+SCREEN *
+newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
{
-int errret;
-int slk_format = _nc_slk_format;
-SCREEN* current;
+ int errret;
+ int slk_format = _nc_slk_format;
+ SCREEN *current;
#ifdef TRACE
-int t = _nc_getenv_num("NCURSES_TRACE");
+ int t = _nc_getenv_num("NCURSES_TRACE");
- if (t >= 0)
- trace(t);
+ if (t >= 0)
+ trace(t);
#endif
- T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
+ T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
- /* this loads the capability entry, then sets LINES and COLS */
- if (setupterm(name, fileno(ofp), &errret) == ERR)
- return 0;
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(name, fileno(ofp), &errret) == ERR)
+ return 0;
- /* implement filter mode */
- if (filter_mode) {
- LINES = 1;
+ /* implement filter mode */
+ if (filter_mode) {
+ LINES = 1;
- if (init_tabs != -1)
- TABSIZE = init_tabs;
- else
- TABSIZE = 8;
+ if (VALID_NUMERIC(init_tabs))
+ TABSIZE = init_tabs;
+ else
+ TABSIZE = 8;
- T(("TABSIZE = %d", TABSIZE));
+ T(("TABSIZE = %d", TABSIZE));
- clear_screen = 0;
- cursor_down = parm_down_cursor = 0;
- cursor_address = 0;
- cursor_up = parm_up_cursor = 0;
- row_address = 0;
+ clear_screen = 0;
+ cursor_down = parm_down_cursor = 0;
+ cursor_address = 0;
+ cursor_up = parm_up_cursor = 0;
+ row_address = 0;
- cursor_home = carriage_return;
- }
+ cursor_home = carriage_return;
+ }
- /* If we must simulate soft labels, grab off the line to be used.
- We assume that we must simulate, if it is none of the standard
- formats (4-4 or 3-2-3) for which there may be some hardware
- support. */
- if (num_labels <= 0 || !SLK_STDFMT(slk_format))
- if (slk_format)
- {
- if (ERR==_nc_ripoffline(-SLK_LINES(slk_format),
- _nc_slk_initialize))
- return 0;
- }
- /* this actually allocates the screen structure, and saves the
- * original terminal settings.
- */
- current = SP;
- _nc_set_screen(0);
- if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
- _nc_set_screen(current);
+ /* If we must simulate soft labels, grab off the line to be used.
+ We assume that we must simulate, if it is none of the standard
+ formats (4-4 or 3-2-3) for which there may be some hardware
+ support. */
+ if (num_labels <= 0 || !SLK_STDFMT(slk_format))
+ if (slk_format) {
+ if (ERR == _nc_ripoffline(-SLK_LINES(slk_format),
+ _nc_slk_initialize))
return 0;
}
-
- /* if the terminal type has real soft labels, set those up */
- if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
- _nc_slk_initialize(stdscr, COLS);
-
- SP->_ifd = fileno(ifp);
- SP->_checkfd = fileno(ifp);
- typeahead(fileno(ifp));
+ /* this actually allocates the screen structure, and saves the
+ * original terminal settings.
+ */
+ current = SP;
+ _nc_set_screen(0);
+ if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
+ _nc_set_screen(current);
+ return 0;
+ }
+
+ /* if the terminal type has real soft labels, set those up */
+ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
+ _nc_slk_initialize(stdscr, COLS);
+
+ SP->_ifd = fileno(ifp);
+ SP->_checkfd = fileno(ifp);
+ typeahead(fileno(ifp));
#ifdef TERMIOS
- SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
- !(cur_term->Ottyb.c_iflag & ISTRIP));
+ SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
+ !(cur_term->Ottyb.c_iflag & ISTRIP));
#else
- SP->_use_meta = FALSE;
+ SP->_use_meta = FALSE;
#endif
- SP->_endwin = FALSE;
-
- /* Check whether we can optimize scrolling under dumb terminals in case
- * we do not have any of these capabilities, scrolling optimization
- * will be useless.
- */
- SP->_scrolling = ((scroll_forward && scroll_reverse) ||
- ((parm_rindex || parm_insert_line || insert_line) &&
- (parm_index || parm_delete_line || delete_line)));
-
- baudrate(); /* sets a field in the SP structure */
-
- SP->_keytry = 0;
-
- /*
- * Check for mismatched graphic-rendition capabilities. Most SVr4
- * terminfo trees contain entries that have rmul or rmso equated to
- * sgr0 (Solaris curses copes with those entries). We do this only for
- * curses, since many termcap applications assume that smso/rmso and
- * smul/rmul are paired, and will not function properly if we remove
- * rmso or rmul. Curses applications shouldn't be looking at this
- * detail.
- */
+ SP->_endwin = FALSE;
+
+ /* Check whether we can optimize scrolling under dumb terminals in case
+ * we do not have any of these capabilities, scrolling optimization
+ * will be useless.
+ */
+ SP->_scrolling = ((scroll_forward && scroll_reverse) ||
+ ((parm_rindex || parm_insert_line || insert_line) &&
+ (parm_index || parm_delete_line || delete_line)));
+
+ baudrate(); /* sets a field in the SP structure */
+
+ SP->_keytry = 0;
+
+ /*
+ * Check for mismatched graphic-rendition capabilities. Most SVr4
+ * terminfo trees contain entries that have rmul or rmso equated to
+ * sgr0 (Solaris curses copes with those entries). We do this only for
+ * curses, since many termcap applications assume that smso/rmso and
+ * smul/rmul are paired, and will not function properly if we remove
+ * rmso or rmul. Curses applications shouldn't be looking at this
+ * detail.
+ */
#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
- SP->_use_rmso = SGR0_TEST(exit_standout_mode);
- SP->_use_rmul = SGR0_TEST(exit_underline_mode);
+ SP->_use_rmso = SGR0_TEST(exit_standout_mode);
+ SP->_use_rmul = SGR0_TEST(exit_underline_mode);
+
+#ifdef USE_WIDEC_SUPPORT
+ /*
+ * XFree86 xterm can be configured to support UTF-8 based on environment
+ * variable settings.
+ */
+ {
+ char *s;
+ if (((s = getenv("LC_ALL")) != 0
+ || (s = getenv("LC_CTYPE")) != 0
+ || (s = getenv("LANG")) != 0)
+ && strstr(s, "UTF-8") != 0) {
+ SP->_outch = _nc_utf8_outch;
+ }
+ }
+#endif
- /* compute movement costs so we can do better move optimization */
- _nc_mvcur_init();
+ /* compute movement costs so we can do better move optimization */
+ _nc_mvcur_init();
- /* initialize terminal to a sane state */
- _nc_screen_init();
+ /* initialize terminal to a sane state */
+ _nc_screen_init();
- /* Initialize the terminal line settings. */
- _nc_initscr();
+ /* Initialize the terminal line settings. */
+ _nc_initscr();
- _nc_signal_handler(TRUE);
+ _nc_signal_handler(TRUE);
- T((T_RETURN("%p"), SP));
- return(SP);
+ T((T_RETURN("%p"), SP));
+ return (SP);
}
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
index d7fc02b3216e..ececa58a314d 100644
--- a/contrib/ncurses/ncurses/base/lib_newwin.c
+++ b/contrib/ncurses/ncurses/base/lib_newwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_newwin.c
**
@@ -42,230 +40,247 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.21 1999/10/03 00:42:03 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.24 2000/04/29 18:49:51 tom Exp $")
-void _nc_freewin(WINDOW *win)
+void
+_nc_freewin(WINDOW *win)
{
-WINDOWLIST *p, *q;
-int i;
-
- if (win != 0) {
- for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
- if (p->win == win) {
- if (q == 0)
- _nc_windows = p->next;
- else
- q->next = p->next;
- free(p);
-
- if (! (win->_flags & _SUBWIN)) {
- for (i = 0; i <= win->_maxy && win->_line[i].text; i++)
- FreeIfNeeded(win->_line[i].text);
- }
- free(win->_line);
- free(win);
-
- if (win == curscr) curscr = 0;
- if (win == stdscr) stdscr = 0;
- if (win == newscr) newscr = 0;
-
- T(("...deleted win=%p", win));
- break;
- }
+ WINDOWLIST *p, *q;
+ int i;
+
+ if (win != 0) {
+ for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
+ if (p->win == win) {
+ if (q == 0)
+ _nc_windows = p->next;
+ else
+ q->next = p->next;
+ free(p);
+
+ if (!(win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy; i++)
+ FreeIfNeeded(win->_line[i].text);
}
+ free(win->_line);
+ free(win);
+
+ if (win == curscr)
+ curscr = 0;
+ if (win == stdscr)
+ stdscr = 0;
+ if (win == newscr)
+ newscr = 0;
+
+ T(("...deleted win=%p", win));
+ break;
+ }
}
+ }
}
-WINDOW * newwin(int num_lines, int num_columns, int begy, int begx)
+WINDOW *
+newwin(int num_lines, int num_columns, int begy, int begx)
{
-WINDOW *win;
-chtype *ptr;
-int i;
+ WINDOW *win;
+ chtype *ptr;
+ int i;
- T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
+ T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
- if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0)
- returnWin(0);
+ if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0)
+ returnWin(0);
- if (num_lines == 0)
- num_lines = SP->_lines_avail - begy;
- if (num_columns == 0)
- num_columns = screen_columns - begx;
+ if (num_lines == 0)
+ num_lines = SP->_lines_avail - begy;
+ if (num_columns == 0)
+ num_columns = screen_columns - begx;
- if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
- returnWin(0);
+ if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
+ returnWin(0);
- if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
- returnWin(0);
+ if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
+ returnWin(0);
- for (i = 0; i < num_lines; i++) {
- if ((win->_line[i].text = typeCalloc(chtype, (unsigned)num_columns)) == 0) {
- _nc_freewin(win);
- returnWin(0);
- }
- for (ptr = win->_line[i].text; ptr < win->_line[i].text + num_columns; )
- *ptr++ = ' ';
+ for (i = 0; i < num_lines; i++) {
+ win->_line[i].text = typeCalloc(chtype, (unsigned) num_columns);
+ if (win->_line[i].text == 0) {
+ _nc_freewin(win);
+ returnWin(0);
}
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text +
+ num_columns;)
+ *ptr++ = ' ';
+ }
- T(("newwin: returned window is %p", win));
+ T(("newwin: returned window is %p", win));
- returnWin(win);
+ returnWin(win);
}
-WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
+WINDOW *
+derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
{
-WINDOW *win;
-int i;
-int flags = _SUBWIN;
+ WINDOW *win;
+ int i;
+ int flags = _SUBWIN;
- T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns, begy, begx));
+ T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns,
+ begy, begx));
- /*
- ** make sure window fits inside the original one
- */
- if ( begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
- returnWin(0);
- if ( begy + num_lines > orig->_maxy + 1
- || begx + num_columns > orig->_maxx + 1)
- returnWin(0);
+ /*
+ ** make sure window fits inside the original one
+ */
+ if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
+ returnWin(0);
+ if (begy + num_lines > orig->_maxy + 1
+ || begx + num_columns > orig->_maxx + 1)
+ returnWin(0);
- if (num_lines == 0)
- num_lines = orig->_maxy + 1 - begy;
+ if (num_lines == 0)
+ num_lines = orig->_maxy + 1 - begy;
- if (num_columns == 0)
- num_columns = orig->_maxx + 1 - begx;
+ if (num_columns == 0)
+ num_columns = orig->_maxx + 1 - begx;
- if (orig->_flags & _ISPAD)
- flags |= _ISPAD;
+ if (orig->_flags & _ISPAD)
+ flags |= _ISPAD;
- if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx, flags)) == 0)
- returnWin(0);
+ if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy,
+ orig->_begx + begx, flags)) == 0)
+ returnWin(0);
- win->_pary = begy;
- win->_parx = begx;
- win->_attrs = orig->_attrs;
- win->_bkgd = orig->_bkgd;
+ win->_pary = begy;
+ win->_parx = begx;
+ win->_attrs = orig->_attrs;
+ win->_bkgd = orig->_bkgd;
- for (i = 0; i < num_lines; i++)
- win->_line[i].text = &orig->_line[begy++].text[begx];
+ for (i = 0; i < num_lines; i++)
+ win->_line[i].text = &orig->_line[begy++].text[begx];
- win->_parent = orig;
+ win->_parent = orig;
- T(("derwin: returned window is %p", win));
+ T(("derwin: returned window is %p", win));
- returnWin(win);
+ returnWin(win);
}
-
-WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
+WINDOW *
+subwin(WINDOW *w, int l, int c, int y, int x)
{
- T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x));
- T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+ T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x));
+ T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+
+ returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
+}
- returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
+static bool
+dimension_limit(int value)
+{
+ NCURSES_SIZE_T test = value;
+ return (test == value && value > 0);
}
WINDOW *
_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
{
-int i;
-WINDOWLIST *wp;
-WINDOW *win;
-bool is_pad = (flags & _ISPAD);
-
- T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
-
- if (num_lines <= 0 || num_columns <= 0)
- return 0;
-
- if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
- return 0;
-
- if ((win = typeCalloc(WINDOW, 1)) == 0)
- return 0;
-
- if ((win->_line = typeCalloc(struct ldat, ((unsigned)num_lines))) == 0) {
- free(win);
- return 0;
- }
-
- win->_curx = 0;
- win->_cury = 0;
- win->_maxy = num_lines - 1;
- win->_maxx = num_columns - 1;
- win->_begy = begy;
- win->_begx = begx;
- win->_yoffset = SP->_topstolen;
-
- win->_flags = flags;
- win->_attrs = A_NORMAL;
- win->_bkgd = BLANK;
-
- win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns == screen_columns);
- win->_idlok = FALSE;
- win->_idcok = TRUE;
- win->_scroll = FALSE;
- win->_leaveok = FALSE;
- win->_use_keypad = FALSE;
- win->_delay = -1;
- win->_immed = FALSE;
- win->_sync = 0;
- win->_parx = -1;
- win->_pary = -1;
- win->_parent = 0;
-
- win->_regtop = 0;
- win->_regbottom = num_lines - 1;
-
- win->_pad._pad_y = -1;
- win->_pad._pad_x = -1;
- win->_pad._pad_top = -1;
- win->_pad._pad_bottom = -1;
- win->_pad._pad_left = -1;
- win->_pad._pad_right = -1;
-
- for (i = 0; i < num_lines; i++)
- {
- /*
- * This used to do
- *
- * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE;
- *
- * which marks the whole window unchanged. That's how
- * SVr1 curses did it, but SVr4 curses marks the whole new
- * window changed.
- *
- * With the old SVr1-like code, say you have stdscr full of
- * characters, then create a new window with newwin(),
- * then do a printw(win, "foo ");, the trailing spaces are
- * completely ignored by the following refreshes. So, you
- * get "foojunkjunk" on the screen instead of "foo " as
- * you actually intended.
- *
- * SVr4 doesn't do this. Instead the spaces are actually written.
- * So that's how we want ncurses to behave.
- */
- win->_line[i].firstchar = 0;
- win->_line[i].lastchar = num_columns-1;
-
- if_USE_SCROLL_HINTS(win->_line[i].oldindex = i);
- }
-
- if (!is_pad && (begx + num_columns == screen_columns)) {
- win->_flags |= _ENDLINE;
-
- if (begx == 0 && num_lines == screen_lines && begy == 0)
- win->_flags |= _FULLWIN;
-
- if (begy + num_lines == screen_lines)
- win->_flags |= _SCROLLWIN;
- }
-
- wp->next = _nc_windows;
- wp->win = win;
- _nc_windows = wp;
-
- T((T_CREATE("window %p"), win));
-
- return(win);
+ int i;
+ WINDOWLIST *wp;
+ WINDOW *win;
+ bool is_pad = (flags & _ISPAD);
+
+ T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+
+ if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
+ return 0;
+
+ if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
+ return 0;
+
+ if ((win = typeCalloc(WINDOW, 1)) == 0)
+ return 0;
+
+ if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
+ free(win);
+ return 0;
+ }
+
+ win->_curx = 0;
+ win->_cury = 0;
+ win->_maxy = num_lines - 1;
+ win->_maxx = num_columns - 1;
+ win->_begy = begy;
+ win->_begx = begx;
+ win->_yoffset = SP->_topstolen;
+
+ win->_flags = flags;
+ win->_attrs = A_NORMAL;
+ win->_bkgd = BLANK;
+
+ win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns
+ == screen_columns);
+ win->_idlok = FALSE;
+ win->_idcok = TRUE;
+ win->_scroll = FALSE;
+ win->_leaveok = FALSE;
+ win->_use_keypad = FALSE;
+ win->_delay = -1;
+ win->_immed = FALSE;
+ win->_sync = 0;
+ win->_parx = -1;
+ win->_pary = -1;
+ win->_parent = 0;
+
+ win->_regtop = 0;
+ win->_regbottom = num_lines - 1;
+
+ win->_pad._pad_y = -1;
+ win->_pad._pad_x = -1;
+ win->_pad._pad_top = -1;
+ win->_pad._pad_bottom = -1;
+ win->_pad._pad_left = -1;
+ win->_pad._pad_right = -1;
+
+ for (i = 0; i < num_lines; i++) {
+ /*
+ * This used to do
+ *
+ * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE;
+ *
+ * which marks the whole window unchanged. That's how
+ * SVr1 curses did it, but SVr4 curses marks the whole new
+ * window changed.
+ *
+ * With the old SVr1-like code, say you have stdscr full of
+ * characters, then create a new window with newwin(),
+ * then do a printw(win, "foo ");, the trailing spaces are
+ * completely ignored by the following refreshes. So, you
+ * get "foojunkjunk" on the screen instead of "foo " as
+ * you actually intended.
+ *
+ * SVr4 doesn't do this. Instead the spaces are actually written.
+ * So that's how we want ncurses to behave.
+ */
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = num_columns - 1;
+
+ if_USE_SCROLL_HINTS(win->_line[i].oldindex = i);
+ }
+
+ if (!is_pad && (begx + num_columns == screen_columns)) {
+ win->_flags |= _ENDLINE;
+
+ if (begx == 0 && num_lines == screen_lines && begy == 0)
+ win->_flags |= _FULLWIN;
+
+ if (begy + num_lines == screen_lines)
+ win->_flags |= _SCROLLWIN;
+ }
+
+ wp->next = _nc_windows;
+ wp->win = win;
+ _nc_windows = wp;
+
+ T((T_CREATE("window %p"), win));
+
+ return (win);
}
diff --git a/contrib/ncurses/ncurses/base/lib_nl.c b/contrib/ncurses/ncurses/base/lib_nl.c
index 75d4a638148d..bfaffdefda5a 100644
--- a/contrib/ncurses/ncurses/base/lib_nl.c
+++ b/contrib/ncurses/ncurses/base/lib_nl.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* nl.c
*
@@ -43,37 +42,38 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_nl.c,v 1.4 1999/10/22 22:31:51 tom Exp $")
+MODULE_ID("$Id: lib_nl.c,v 1.6 2000/02/13 00:59:39 tom Exp $")
#ifdef __EMX__
#include <io.h>
-#include <fcntl.h>
#endif
-int nl(void)
+int
+nl(void)
{
- T((T_CALLED("nl()")));
+ T((T_CALLED("nl()")));
- SP->_nl = TRUE;
+ SP->_nl = TRUE;
#ifdef __EMX__
- _nc_flush();
- _fsetmode(NC_OUTPUT, "t");
+ _nc_flush();
+ _fsetmode(NC_OUTPUT, "t");
#endif
- returnCode(OK);
+ returnCode(OK);
}
-int nonl(void)
+int
+nonl(void)
{
- T((T_CALLED("nonl()")));
+ T((T_CALLED("nonl()")));
- SP->_nl = FALSE;
+ SP->_nl = FALSE;
#ifdef __EMX__
- _nc_flush();
- _fsetmode(NC_OUTPUT, "b");
+ _nc_flush();
+ _fsetmode(NC_OUTPUT, "b");
#endif
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_pad.c b/contrib/ncurses/ncurses/base/lib_pad.c
index d4e341c05c75..af7dd3b50194 100644
--- a/contrib/ncurses/ncurses/base/lib_pad.c
+++ b/contrib/ncurses/ncurses/base/lib_pad.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -31,7 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* lib_pad.c
* newpad -- create a new pad
@@ -41,240 +40,253 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_pad.c,v 1.27 1998/06/28 00:10:16 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.29 2000/04/29 21:19:44 tom Exp $")
-WINDOW *newpad(int l, int c)
+WINDOW *
+newpad(int l, int c)
{
-WINDOW *win;
-chtype *ptr;
-int i;
+ WINDOW *win;
+ chtype *ptr;
+ int i;
- T((T_CALLED("newpad(%d, %d)"), l, c));
+ T((T_CALLED("newpad(%d, %d)"), l, c));
- if (l <= 0 || c <= 0)
- returnWin(0);
+ if (l <= 0 || c <= 0)
+ returnWin(0);
- if ((win = _nc_makenew(l,c,0,0,_ISPAD)) == NULL)
- returnWin(0);
+ if ((win = _nc_makenew(l, c, 0, 0, _ISPAD)) == NULL)
+ returnWin(0);
- for (i = 0; i < l; i++) {
- if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
- if ((win->_line[i].text = typeCalloc(chtype, ((size_t)c))) == 0) {
- _nc_freewin(win);
- returnWin(0);
- }
- for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; )
- *ptr++ = ' ';
+ for (i = 0; i < l; i++) {
+ if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
+ if ((win->_line[i].text = typeCalloc(chtype, ((size_t) c))) == 0) {
+ _nc_freewin(win);
+ returnWin(0);
}
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + c;)
+ *ptr++ = ' ';
+ }
- returnWin(win);
+ returnWin(win);
}
-WINDOW *subpad(WINDOW *orig, int l, int c, int begy, int begx)
+WINDOW *
+subpad(WINDOW *orig, int l, int c, int begy, int begx)
{
-WINDOW *win = (WINDOW *)0;
+ WINDOW *win = (WINDOW *) 0;
- T((T_CALLED("subpad(%d, %d)"), l, c));
+ T((T_CALLED("subpad(%d, %d)"), l, c));
- if (orig) {
- if (!(orig->_flags & _ISPAD) || ((win = derwin(orig, l, c, begy, begx)) == NULL))
+ if (orig) {
+ if (!(orig->_flags & _ISPAD)
+ || ((win = derwin(orig, l, c, begy, begx)) == NULL))
returnWin(0);
- }
- returnWin(win);
+ }
+ returnWin(win);
}
-int prefresh(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+int
+prefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
{
- T((T_CALLED("prefresh()")));
- if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) != ERR
- && doupdate() != ERR) {
- returnCode(OK);
- }
- returnCode(ERR);
+ T((T_CALLED("prefresh()")));
+ if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow,
+ smaxcol) != ERR
+ && doupdate() != ERR) {
+ returnCode(OK);
+ }
+ returnCode(ERR);
}
-int pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
- int sminrow, int smincol, int smaxrow, int smaxcol)
+int
+pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
{
-const int my_len = 2; /* parameterize the threshold for hardscroll */
-short i, j;
-short m, n;
-short pmaxrow;
-short pmaxcol;
-short displaced;
-bool wide;
-
- T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
- win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
-
- if (win == 0)
- returnCode(ERR);
-
- if (!(win->_flags & _ISPAD))
- returnCode(ERR);
+ const int my_len = 2; /* parameterize the threshold for hardscroll */
+ NCURSES_SIZE_T i, j;
+ NCURSES_SIZE_T m, n;
+ NCURSES_SIZE_T pmaxrow;
+ NCURSES_SIZE_T pmaxcol;
+ NCURSES_SIZE_T displaced;
+ bool wide;
+
+ T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
+ win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
+
+ if (win == 0)
+ returnCode(ERR);
- /* negative values are interpreted as zero */
- if (pminrow < 0) pminrow = 0;
- if (pmincol < 0) pmincol = 0;
- if (sminrow < 0) sminrow = 0;
- if (smincol < 0) smincol = 0;
+ if (!(win->_flags & _ISPAD))
+ returnCode(ERR);
+ /* negative values are interpreted as zero */
+ if (pminrow < 0)
+ pminrow = 0;
+ if (pmincol < 0)
+ pmincol = 0;
+ if (sminrow < 0)
+ sminrow = 0;
+ if (smincol < 0)
+ smincol = 0;
+
+ pmaxrow = pminrow + smaxrow - sminrow;
+ pmaxcol = pmincol + smaxcol - smincol;
+
+ T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
+ T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+
+ /*
+ * Trim the caller's screen size back to the actual limits.
+ */
+ if (pmaxrow > win->_maxy) {
+ smaxrow -= (pmaxrow - win->_maxy);
pmaxrow = pminrow + smaxrow - sminrow;
+ }
+ if (pmaxcol > win->_maxx) {
+ smaxcol -= (pmaxcol - win->_maxx);
pmaxcol = pmincol + smaxcol - smincol;
+ }
- T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
- T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+ if (smaxrow > screen_lines
+ || smaxcol > screen_columns
+ || sminrow > smaxrow
+ || smincol > smaxcol)
+ returnCode(ERR);
- /*
- * Trim the caller's screen size back to the actual limits.
- */
- if (pmaxrow > win->_maxy) {
- smaxrow -= (pmaxrow - win->_maxy);
- pmaxrow = pminrow + smaxrow - sminrow;
- }
- if (pmaxcol > win->_maxx) {
- smaxcol -= (pmaxcol - win->_maxx);
- pmaxcol = pmincol + smaxcol - smincol;
+ T(("pad being refreshed"));
+
+ if (win->_pad._pad_y >= 0) {
+ displaced = pminrow - win->_pad._pad_y
+ - (sminrow - win->_pad._pad_top);
+ T(("pad being shifted by %d line(s)", displaced));
+ } else
+ displaced = 0;
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the pad to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the pad "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len));
+
+ for (i = pminrow, m = sminrow + win->_yoffset;
+ i <= pmaxrow && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline, n);
+ }
}
- if (smaxrow > screen_lines
- || smaxcol > screen_columns
- || sminrow > smaxrow
- || smincol > smaxcol)
- returnCode(ERR);
-
- T(("pad being refreshed"));
-
- if (win->_pad._pad_y >= 0) {
- displaced = pminrow - win->_pad._pad_y
- -(sminrow - win->_pad._pad_top);
- T(("pad being shifted by %d line(s)", displaced));
- } else
- displaced = 0;
-
- /*
- * For pure efficiency, we'd want to transfer scrolling information
- * from the pad to newscr whenever the window is wide enough that
- * its update will dominate the cost of the update for the horizontal
- * band of newscr that it occupies. Unfortunately, this threshold
- * tends to be complex to estimate, and in any case scrolling the
- * whole band and rewriting the parts outside win's image would look
- * really ugly. So. What we do is consider the pad "wide" if it
- * either (a) occupies the whole width of newscr, or (b) occupies
- * all but at most one column on either vertical edge of the screen
- * (this caters to fussy people who put boxes around full-screen
- * windows). Note that changing this formula will not break any code,
- * merely change the costs of various update cases.
- */
- wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len));
-
- for (i = pminrow, m = sminrow + win->_yoffset;
- i <= pmaxrow && m <= newscr->_maxy;
- i++, m++) {
- register struct ldat *nline = &newscr->_line[m];
- register struct ldat *oline = &win->_line[i];
-
- for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
- if (oline->text[j] != nline->text[n]) {
- nline->text[n] = oline->text[j];
- CHANGED_CELL(nline,n);
- }
- }
-
#if USE_SCROLL_HINTS
- if (wide) {
- int nind = m + displaced;
- if (oline->oldindex < 0
- || nind < sminrow
- || nind > smaxrow) {
+ if (wide) {
+ int nind = m + displaced;
+ if (oline->oldindex < 0
+ || nind < sminrow
+ || nind > smaxrow) {
+ nind = _NEWINDEX;
+ } else if (displaced) {
+ register struct ldat *pline = &curscr->_line[nind];
+ for (j = 0; j <= my_len; j++) {
+ int k = newscr->_maxx - j;
+ if (pline->text[j] != nline->text[j]
+ || pline->text[k] != nline->text[k]) {
nind = _NEWINDEX;
- } else if (displaced) {
- register struct ldat *pline = &curscr->_line[nind];
- for (j = 0; j <= my_len; j++) {
- int k = newscr->_maxx - j;
- if (pline->text[j] != nline->text[j]
- || pline->text[k] != nline->text[k]) {
- nind = _NEWINDEX;
- break;
- }
- }
+ break;
}
-
- nline->oldindex = nind;
}
-#endif /* USE_SCROLL_HINTS */
- oline->firstchar = oline->lastchar = _NOCHANGE;
- if_USE_SCROLL_HINTS(oline->oldindex = i);
- }
+ }
- /*
- * Clean up debris from scrolling or resizing the pad, so we do not
- * accidentally pick up the index value during the next call to this
- * procedure. The only rows that should have an index value are those
- * that are displayed during this cycle.
- */
+ nline->oldindex = nind;
+ }
+#endif /* USE_SCROLL_HINTS */
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ if_USE_SCROLL_HINTS(oline->oldindex = i);
+ }
+
+ /*
+ * Clean up debris from scrolling or resizing the pad, so we do not
+ * accidentally pick up the index value during the next call to this
+ * procedure. The only rows that should have an index value are those
+ * that are displayed during this cycle.
+ */
#if USE_SCROLL_HINTS
- for (i = pminrow-1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
- win->_line[i].oldindex = _NEWINDEX;
- for (i = pmaxrow+1; (i <= win->_maxy) && (win->_line[i].oldindex >= 0); i++)
- win->_line[i].oldindex = _NEWINDEX;
+ for (i = pminrow - 1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
+ win->_line[i].oldindex = _NEWINDEX;
+ for (i = pmaxrow + 1; (i <= win->_maxy)
+ && (win->_line[i].oldindex >= 0); i++)
+ win->_line[i].oldindex = _NEWINDEX;
#endif
- win->_begx = smincol;
- win->_begy = sminrow;
+ win->_begx = smincol;
+ win->_begy = sminrow;
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ /*
+ * Use the pad's current position, if it will be visible.
+ * If not, don't do anything; it's not an error.
+ */
+ if (win->_leaveok == FALSE
+ && win->_cury >= pminrow
+ && win->_curx >= pmincol
+ && win->_cury <= pmaxrow
+ && win->_curx <= pmaxcol) {
+ newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
+ newscr->_curx = win->_curx - pmincol + win->_begx;
+ }
+ newscr->_leaveok = win->_leaveok;
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Update our cache of the line-numbers that we displayed from the pad.
+ * We will use this on subsequent calls to this function to derive
+ * values to stuff into 'oldindex[]' -- for scrolling optimization.
+ */
+ win->_pad._pad_y = pminrow;
+ win->_pad._pad_x = pmincol;
+ win->_pad._pad_top = sminrow;
+ win->_pad._pad_left = smincol;
+ win->_pad._pad_bottom = smaxrow;
+ win->_pad._pad_right = smaxcol;
+
+ returnCode(OK);
+}
- if (win->_clear) {
- win->_clear = FALSE;
- newscr->_clear = TRUE;
- }
+int
+pechochar(WINDOW *pad, const chtype ch)
+{
+ T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch)));
- /*
- * Use the pad's current position, if it will be visible.
- * If not, don't do anything; it's not an error.
- */
- if (win->_leaveok == FALSE
- && win->_cury >= pminrow
- && win->_curx >= pmincol
- && win->_cury <= pmaxrow
- && win->_curx <= pmaxcol) {
- newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
- newscr->_curx = win->_curx - pmincol + win->_begx;
- }
- win->_flags &= ~_HASMOVED;
-
- /*
- * Update our cache of the line-numbers that we displayed from the pad.
- * We will use this on subsequent calls to this function to derive
- * values to stuff into 'oldindex[]' -- for scrolling optimization.
- */
- win->_pad._pad_y = pminrow;
- win->_pad._pad_x = pmincol;
- win->_pad._pad_top = sminrow;
- win->_pad._pad_left = smincol;
- win->_pad._pad_bottom = smaxrow;
- win->_pad._pad_right = smaxcol;
+ if (pad == 0)
+ returnCode(ERR);
- returnCode(OK);
-}
+ if (!(pad->_flags & _ISPAD))
+ returnCode(wechochar(pad, ch));
-int pechochar(WINDOW *pad, const chtype ch)
-{
- T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch)));
-
- if (pad == 0)
- returnCode(ERR);
-
- if (!(pad->_flags & _ISPAD))
- returnCode(wechochar(pad,ch));
-
- waddch(pad, ch);
- prefresh(pad, pad->_pad._pad_y,
- pad->_pad._pad_x,
- pad->_pad._pad_top,
- pad->_pad._pad_left,
- pad->_pad._pad_bottom,
- pad->_pad._pad_right);
-
- returnCode(OK);
+ waddch(pad, ch);
+ prefresh(pad, pad->_pad._pad_y,
+ pad->_pad._pad_x,
+ pad->_pad._pad_top,
+ pad->_pad._pad_left,
+ pad->_pad._pad_bottom,
+ pad->_pad._pad_right);
+
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c
index 88e3b75a56a1..910664b0187a 100644
--- a/contrib/ncurses/ncurses/base/lib_refresh.c
+++ b/contrib/ncurses/ncurses/base/lib_refresh.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* lib_refresh.c
*
@@ -42,142 +40,144 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_refresh.c,v 1.24 1999/07/31 11:36:37 juergen Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.25 2000/04/29 21:17:08 tom Exp $")
-int wrefresh(WINDOW *win)
+int
+wrefresh(WINDOW *win)
{
-int code;
-
- T((T_CALLED("wrefresh(%p)"), win));
-
- if (win == curscr) {
- curscr->_clear = TRUE;
- code = doupdate();
- } else if ((code = wnoutrefresh(win)) == OK) {
- if (win->_clear)
- newscr->_clear = TRUE;
- code = doupdate();
- /*
- * Reset the clearok() flag in case it was set for the special
- * case in hardscroll.c (if we don't reset it here, we'll get 2
- * refreshes because the flag is copied from stdscr to newscr).
- * Resetting the flag shouldn't do any harm, anyway.
- */
- win->_clear = FALSE;
- }
- returnCode(code);
-}
-
-int wnoutrefresh(WINDOW *win)
-{
-short limit_x;
-short i, j;
-short begx;
-short begy;
-short m, n;
-bool wide;
-
- T((T_CALLED("wnoutrefresh(%p)"), win));
-#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
- _tracedump("...win", win);
-#endif /* TRACE */
-
- /*
- * This function will break badly if we try to refresh a pad.
- */
- if ((win == 0)
- || (win->_flags & _ISPAD))
- returnCode(ERR);
+ int code;
- /* put them here so "win == 0" won't break our code */
- begx = win->_begx;
- begy = win->_begy;
-
- newscr->_bkgd = win->_bkgd;
- newscr->_attrs = win->_attrs;
-
- /* merge in change information from all subwindows of this window */
- wsyncdown(win);
+ T((T_CALLED("wrefresh(%p)"), win));
+ if (win == curscr) {
+ curscr->_clear = TRUE;
+ code = doupdate();
+ } else if ((code = wnoutrefresh(win)) == OK) {
+ if (win->_clear)
+ newscr->_clear = TRUE;
+ code = doupdate();
/*
- * For pure efficiency, we'd want to transfer scrolling information
- * from the window to newscr whenever the window is wide enough that
- * its update will dominate the cost of the update for the horizontal
- * band of newscr that it occupies. Unfortunately, this threshold
- * tends to be complex to estimate, and in any case scrolling the
- * whole band and rewriting the parts outside win's image would look
- * really ugly. So. What we do is consider the window "wide" if it
- * either (a) occupies the whole width of newscr, or (b) occupies
- * all but at most one column on either vertical edge of the screen
- * (this caters to fussy people who put boxes around full-screen
- * windows). Note that changing this formula will not break any code,
- * merely change the costs of various update cases.
+ * Reset the clearok() flag in case it was set for the special
+ * case in hardscroll.c (if we don't reset it here, we'll get 2
+ * refreshes because the flag is copied from stdscr to newscr).
+ * Resetting the flag shouldn't do any harm, anyway.
*/
- wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
-
- win->_flags &= ~_HASMOVED;
+ win->_clear = FALSE;
+ }
+ returnCode(code);
+}
- /*
- * Microtweaking alert! This double loop is one of the genuine
- * hot spots in the code. Even gcc doesn't seem to do enough
- * common-subexpression chunking to make it really tense,
- * so we'll force the issue.
- */
+int
+wnoutrefresh(WINDOW *win)
+{
+ NCURSES_SIZE_T limit_x;
+ NCURSES_SIZE_T i, j;
+ NCURSES_SIZE_T begx;
+ NCURSES_SIZE_T begy;
+ NCURSES_SIZE_T m, n;
+ bool wide;
+
+ T((T_CALLED("wnoutrefresh(%p)"), win));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...win", win);
+#endif /* TRACE */
- /* limit(n) */
+ /*
+ * This function will break badly if we try to refresh a pad.
+ */
+ if ((win == 0)
+ || (win->_flags & _ISPAD))
+ returnCode(ERR);
+
+ /* put them here so "win == 0" won't break our code */
+ begx = win->_begx;
+ begy = win->_begy;
+
+ newscr->_bkgd = win->_bkgd;
+ newscr->_attrs = win->_attrs;
+
+ /* merge in change information from all subwindows of this window */
+ wsyncdown(win);
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the window to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the window "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
+
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Microtweaking alert! This double loop is one of the genuine
+ * hot spots in the code. Even gcc doesn't seem to do enough
+ * common-subexpression chunking to make it really tense,
+ * so we'll force the issue.
+ */
+
+ /* limit(n) */
+ limit_x = win->_maxx;
+ /* limit(j) */
+ if (limit_x > win->_maxx)
limit_x = win->_maxx;
- /* limit(j) */
- if (limit_x > win->_maxx)
- limit_x = win->_maxx;
-
- for (i = 0, m = begy + win->_yoffset;
- i <= win->_maxy && m <= newscr->_maxy;
- i++, m++) {
- register struct ldat *nline = &newscr->_line[m];
- register struct ldat *oline = &win->_line[i];
- if (oline->firstchar != _NOCHANGE) {
- int last = oline->lastchar;
+ for (i = 0, m = begy + win->_yoffset;
+ i <= win->_maxy && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
- if (last > limit_x)
- last = limit_x;
+ if (oline->firstchar != _NOCHANGE) {
+ int last = oline->lastchar;
- for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
- if (oline->text[j] != nline->text[n]) {
- nline->text[n] = oline->text[j];
- CHANGED_CELL(nline, n);
- }
- }
+ if (last > limit_x)
+ last = limit_x;
+ for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline, n);
}
+ }
+ }
#if USE_SCROLL_HINTS
- if (wide) {
- int oind = oline->oldindex;
+ if (wide) {
+ int oind = oline->oldindex;
- nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + win->_yoffset;
- }
+ nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind
+ + win->_yoffset;
+ }
#endif /* USE_SCROLL_HINTS */
- oline->firstchar = oline->lastchar = _NOCHANGE;
- if_USE_SCROLL_HINTS(oline->oldindex = i);
- }
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ if_USE_SCROLL_HINTS(oline->oldindex = i);
+ }
- if (win->_clear) {
- win->_clear = FALSE;
- newscr->_clear = TRUE;
- }
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ if (!win->_leaveok) {
+ newscr->_cury = win->_cury + win->_begy + win->_yoffset;
+ newscr->_curx = win->_curx + win->_begx;
+ }
+ newscr->_leaveok = win->_leaveok;
- if (! win->_leaveok) {
- newscr->_cury = win->_cury + win->_begy + win->_yoffset;
- newscr->_curx = win->_curx + win->_begx;
- }
- newscr->_leaveok = win->_leaveok;
-
#ifdef TRACE
- if (_nc_tracing & TRACE_UPDATE)
- _tracedump("newscr", newscr);
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("newscr", newscr);
#endif /* TRACE */
- returnCode(OK);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_scroll.c b/contrib/ncurses/ncurses/base/lib_scroll.c
index 197bb221a07c..c2e3831da255 100644
--- a/contrib/ncurses/ncurses/base/lib_scroll.c
+++ b/contrib/ncurses/ncurses/base/lib_scroll.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_scroll.c
**
@@ -44,75 +42,79 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_scroll.c,v 1.16 1998/02/11 12:13:55 tom Exp $")
+MODULE_ID("$Id: lib_scroll.c,v 1.17 2000/04/29 21:10:51 tom Exp $")
-void _nc_scroll_window(WINDOW *win, int const n, short const top, short const bottom, chtype blank)
+void
+_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
+ NCURSES_SIZE_T const bottom, chtype blank)
{
-int line, j;
-size_t to_copy = (size_t)(sizeof(chtype) * (win->_maxx + 1));
-
- TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top,bottom));
-
- /*
- * This used to do a line-text pointer-shuffle instead of text copies.
- * That (a) doesn't work when the window is derived and doesn't have
- * its own storage, (b) doesn't save you a lot on modern machines
- * anyway. Your typical memcpy implementations are coded in
- * assembler using a tight BLT loop; for the size of copies we're
- * talking here, the total execution time is dominated by the one-time
- * setup cost. So there is no point in trying to be excessively
- * clever -- esr.
- */
-
- /* shift n lines downwards */
- if (n < 0) {
- for (line = bottom; line >= top-n; line--) {
- memcpy(win->_line[line].text,
- win->_line[line+n].text,
- to_copy);
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex);
- }
- for (line = top; line < top-n; line++) {
- for (j = 0; j <= win->_maxx; j ++)
- win->_line[line].text[j] = blank;
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
- }
- }
-
- /* shift n lines upwards */
- if (n > 0) {
- for (line = top; line <= bottom-n; line++) {
- memcpy(win->_line[line].text,
- win->_line[line+n].text,
- to_copy);
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex);
- }
- for (line = bottom; line > bottom-n; line--) {
- for (j = 0; j <= win->_maxx; j ++)
- win->_line[line].text[j] = blank;
- if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
- }
+ int line, j;
+ size_t to_copy = (size_t) (sizeof(chtype) * (win->_maxx + 1));
+
+ TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top, bottom));
+
+ /*
+ * This used to do a line-text pointer-shuffle instead of text copies.
+ * That (a) doesn't work when the window is derived and doesn't have
+ * its own storage, (b) doesn't save you a lot on modern machines
+ * anyway. Your typical memcpy implementations are coded in
+ * assembler using a tight BLT loop; for the size of copies we're
+ * talking here, the total execution time is dominated by the one-time
+ * setup cost. So there is no point in trying to be excessively
+ * clever -- esr.
+ */
+
+ /* shift n lines downwards */
+ if (n < 0) {
+ for (line = bottom; line >= top - n; line--) {
+ memcpy(win->_line[line].text,
+ win->_line[line + n].text,
+ to_copy);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line
+ + n].oldindex);
+ }
+ for (line = top; line < top - n; line++) {
+ for (j = 0; j <= win->_maxx; j++)
+ win->_line[line].text[j] = blank;
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
+ }
+ }
+
+ /* shift n lines upwards */
+ if (n > 0) {
+ for (line = top; line <= bottom - n; line++) {
+ memcpy(win->_line[line].text,
+ win->_line[line + n].text,
+ to_copy);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line
+ + n].oldindex);
+ }
+ for (line = bottom; line > bottom - n; line--) {
+ for (j = 0; j <= win->_maxx; j++)
+ win->_line[line].text[j] = blank;
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
}
- touchline(win, top, bottom-top+1);
+ }
+ touchline(win, top, bottom - top + 1);
}
int
wscrl(WINDOW *win, int n)
{
- T((T_CALLED("wscrl(%p,%d)"), win, n));
+ T((T_CALLED("wscrl(%p,%d)"), win, n));
- if (!win || !win->_scroll)
- returnCode(ERR);
+ if (!win || !win->_scroll)
+ returnCode(ERR);
- if (n == 0)
- returnCode(OK);
+ if (n == 0)
+ returnCode(OK);
- if ((n > (win->_regbottom - win->_regtop)) ||
- (-n > (win->_regbottom - win->_regtop)))
- returnCode(ERR);
+ if ((n > (win->_regbottom - win->_regtop)) ||
+ (-n > (win->_regbottom - win->_regtop)))
+ returnCode(ERR);
- _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win));
+ _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win));
- _nc_synchook(win);
- returnCode(OK);
+ _nc_synchook(win);
+ returnCode(OK);
}
diff --git a/contrib/ncurses/ncurses/base/lib_scrreg.c b/contrib/ncurses/ncurses/base/lib_scrreg.c
index ddeab2498bfd..b47c047f4623 100644
--- a/contrib/ncurses/ncurses/base/lib_scrreg.c
+++ b/contrib/ncurses/ncurses/base/lib_scrreg.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * 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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_scrreg.c
**
@@ -42,21 +40,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_scrreg.c,v 1.7 1998/02/11 12:13:53 tom Exp $")
+MODULE_ID("$Id: lib_scrreg.c,v 1.8 2000/04/29 21:13:04 tom Exp $")
-int wsetscrreg(WINDOW *win, int top, int bottom)
+int
+wsetscrreg(WINDOW *win, int top, int bottom)
{
- T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom));
-
- if (win &&
- top >= 0 && top <= win->_maxy &&
- bottom >= 0 && bottom <= win->_maxy &&
- bottom > top)
- {
- win->_regtop = (short)top;
- win->_regbottom = (short)bottom;
-
- returnCode(OK);
- } else
- returnCode(ERR);
+ T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom));
+
+ if (win &&
+ top >= 0 && top <= win->_maxy &&
+ bottom >= 0 && bottom <= win->_maxy &&
+ bottom > top) {
+ win->_regtop = (NCURSES_SIZE_T) top;
+ win->_regbottom = (NCURSES_SIZE_T) bottom;
+
+ returnCode(OK);
+ } else
+ returnCode(ERR);
}
diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c
index 443236cf9cda..b4d547fcf514 100644
--- a/contrib/ncurses/ncurses/base/lib_set_term.c
+++ b/contrib/ncurses/ncurses/base/lib_set_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -40,276 +40,352 @@
#include <curses.priv.h>
-#include <term.h> /* cur_term */
+#include <term.h> /* cur_term */
+#include <tic.h>
-MODULE_ID("$Id: lib_set_term.c,v 1.46 1999/07/24 20:05:49 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.55 2000/07/02 00:22:18 tom Exp $")
-SCREEN * set_term(SCREEN *screenp)
+SCREEN *
+set_term(SCREEN * screenp)
{
-SCREEN *oldSP;
+ SCREEN *oldSP;
- T((T_CALLED("set_term(%p)"), screenp));
+ T((T_CALLED("set_term(%p)"), screenp));
- oldSP = SP;
- _nc_set_screen(screenp);
+ oldSP = SP;
+ _nc_set_screen(screenp);
- set_curterm(SP->_term);
- curscr = SP->_curscr;
- newscr = SP->_newscr;
- stdscr = SP->_stdscr;
- COLORS = SP->_color_count;
- COLOR_PAIRS = SP->_pair_count;
- memcpy(acs_map, SP->_acs_map, sizeof(chtype)*ACS_LEN);
+ set_curterm(SP->_term);
+ curscr = SP->_curscr;
+ newscr = SP->_newscr;
+ stdscr = SP->_stdscr;
+ COLORS = SP->_color_count;
+ COLOR_PAIRS = SP->_pair_count;
+ memcpy(acs_map, SP->_acs_map, sizeof(chtype) * ACS_LEN);
- T((T_RETURN("%p"), oldSP));
- return(oldSP);
+ T((T_RETURN("%p"), oldSP));
+ return (oldSP);
}
-static void _nc_free_keytry(struct tries *kt)
+static void
+_nc_free_keytry(struct tries *kt)
{
- if (kt != 0) {
- _nc_free_keytry(kt->child);
- _nc_free_keytry(kt->sibling);
- free(kt);
- }
+ if (kt != 0) {
+ _nc_free_keytry(kt->child);
+ _nc_free_keytry(kt->sibling);
+ free(kt);
+ }
}
/*
* Free the storage associated with the given SCREEN sp.
*/
-void delscreen(SCREEN *sp)
+void
+delscreen(SCREEN * sp)
{
- SCREEN **scan = &_nc_screen_chain;
+ SCREEN **scan = &_nc_screen_chain;
- T((T_CALLED("delscreen(%p)"), sp));
+ T((T_CALLED("delscreen(%p)"), sp));
- while(*scan)
- {
- if (*scan == sp)
- {
- *scan = sp->_next_screen;
- break;
- }
- scan = &(*scan)->_next_screen;
+ while (*scan) {
+ if (*scan == sp) {
+ *scan = sp->_next_screen;
+ break;
}
+ scan = &(*scan)->_next_screen;
+ }
+
+ _nc_freewin(sp->_curscr);
+ _nc_freewin(sp->_newscr);
+ _nc_freewin(sp->_stdscr);
+ _nc_free_keytry(sp->_keytry);
+ _nc_free_keytry(sp->_key_ok);
+
+ FreeIfNeeded(sp->_color_table);
+ FreeIfNeeded(sp->_color_pairs);
+
+ FreeIfNeeded(sp->oldhash);
+ FreeIfNeeded(sp->newhash);
+
+ del_curterm(sp->_term);
+
+ /*
+ * If the associated output stream has been closed, we can discard the
+ * set-buffer. Limit the error check to EBADF, since fflush may fail
+ * for other reasons than trying to operate upon a closed stream.
+ */
+ if (sp->_ofp != 0
+ && sp->_setbuf != 0
+ && fflush(sp->_ofp) != 0
+ && errno == EBADF) {
+ free(sp->_setbuf);
+ }
+
+ free(sp);
+
+ /*
+ * If this was the current screen, reset everything that the
+ * application might try to use (except cur_term, which may have
+ * multiple references in different screens).
+ */
+ if (sp == SP) {
+ curscr = 0;
+ newscr = 0;
+ stdscr = 0;
+ COLORS = 0;
+ COLOR_PAIRS = 0;
+ _nc_set_screen(0);
+ }
+ returnVoid;
+}
- _nc_freewin(sp->_curscr);
- _nc_freewin(sp->_newscr);
- _nc_freewin(sp->_stdscr);
- _nc_free_keytry(sp->_keytry);
- _nc_free_keytry(sp->_key_ok);
-
- FreeIfNeeded(sp->_color_table);
- FreeIfNeeded(sp->_color_pairs);
+static ripoff_t rippedoff[5];
+static ripoff_t *rsp = rippedoff;
+#define N_RIPS SIZEOF(rippedoff)
- FreeIfNeeded(sp->oldhash);
- FreeIfNeeded(sp->newhash);
+static bool
+no_mouse_event(SCREEN * sp GCC_UNUSED)
+{
+ return FALSE;
+}
- del_curterm(sp->_term);
+static bool
+no_mouse_inline(SCREEN * sp GCC_UNUSED)
+{
+ return FALSE;
+}
- free(sp);
+static bool
+no_mouse_parse(int code GCC_UNUSED)
+{
+ return TRUE;
+}
- /*
- * If this was the current screen, reset everything that the
- * application might try to use (except cur_term, which may have
- * multiple references in different screens).
- */
- if (sp == SP) {
- curscr = 0;
- newscr = 0;
- stdscr = 0;
- COLORS = 0;
- COLOR_PAIRS = 0;
- _nc_set_screen(0);
- }
- returnVoid;
+static void
+no_mouse_resume(SCREEN * sp GCC_UNUSED)
+{
}
-static ripoff_t rippedoff[5];
-static ripoff_t *rsp = rippedoff;
-#define N_RIPS SIZEOF(rippedoff)
+static void
+no_mouse_wrap(SCREEN * sp GCC_UNUSED)
+{
+}
-static bool no_mouse_event (SCREEN *sp GCC_UNUSED) { return FALSE; }
-static bool no_mouse_inline(SCREEN *sp GCC_UNUSED) { return FALSE; }
-static bool no_mouse_parse (int code GCC_UNUSED) { return TRUE; }
-static void no_mouse_resume(SCREEN *sp GCC_UNUSED) { }
-static void no_mouse_wrap (SCREEN *sp GCC_UNUSED) { }
+#if defined(NCURSES_EXT_FUNCS) && defined(USE_COLORFGBG)
+static char *
+extract_fgbg(char *src, int *result)
+{
+ char *dst = 0;
+ long value = strtol(src, &dst, 0);
+
+ if (dst == 0) {
+ dst = src;
+ } else if (value >= 0) {
+ *result = value % max_colors;
+ }
+ while (*dst != 0 && *dst != ';')
+ dst++;
+ if (*dst == ';')
+ dst++;
+ return dst;
+}
+#endif
-int _nc_setupscreen(short slines, short const scolumns, FILE *output)
+int
+_nc_setupscreen(short slines, short const scolumns, FILE * output)
/* OS-independent screen initializations */
{
-int bottom_stolen = 0;
-size_t i;
-
- assert(SP==0); /* has been reset in newterm() ! */
- if (!_nc_alloc_screen())
- return ERR;
-
- SP->_next_screen = _nc_screen_chain;
- _nc_screen_chain = SP;
-
- _nc_set_buffer(output, TRUE);
- SP->_term = cur_term;
- SP->_lines = slines;
- SP->_lines_avail = slines;
- SP->_columns = scolumns;
- SP->_cursrow = -1;
- SP->_curscol = -1;
- SP->_nl = TRUE;
- SP->_raw = FALSE;
- SP->_cbreak = 0;
- SP->_echo = TRUE;
- SP->_fifohead = -1;
- SP->_endwin = TRUE;
- SP->_ofp = output;
- SP->_cursor = -1; /* cannot know real cursor shape */
+ int bottom_stolen = 0;
+ size_t i;
+
+ assert(SP == 0); /* has been reset in newterm() ! */
+ if (!_nc_alloc_screen())
+ return ERR;
+
+ SP->_next_screen = _nc_screen_chain;
+ _nc_screen_chain = SP;
+
+ _nc_set_buffer(output, TRUE);
+ SP->_term = cur_term;
+ SP->_lines = slines;
+ SP->_lines_avail = slines;
+ SP->_columns = scolumns;
+ SP->_cursrow = -1;
+ SP->_curscol = -1;
+ SP->_nl = TRUE;
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
+ SP->_echo = TRUE;
+ SP->_fifohead = -1;
+ SP->_endwin = TRUE;
+ SP->_ofp = output;
+ SP->_cursor = -1; /* cannot know real cursor shape */
#ifdef NCURSES_NO_PADDING
- SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
+ SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
+ TR(TRACE_CHARPUT | TRACE_MOVE, ("padding will%s be used",
+ SP->_no_padding ? " not" : ""));
#endif
-
- SP->_maxclick = DEFAULT_MAXCLICK;
- SP->_mouse_event = no_mouse_event;
- SP->_mouse_inline = no_mouse_inline;
- SP->_mouse_parse = no_mouse_parse;
- SP->_mouse_resume = no_mouse_resume;
- SP->_mouse_wrap = no_mouse_wrap;
- SP->_mouse_fd = -1;
-
- /* initialize the panel hooks */
- SP->_panelHook.top_panel = (struct panel*)0;
- SP->_panelHook.bottom_panel = (struct panel*)0;
- SP->_panelHook.stdscr_pseudo_panel = (struct panel*)0;
-
+#ifdef NCURSES_EXT_FUNCS
+ SP->_default_color = FALSE;
+ SP->_has_sgr_39_49 = FALSE;
+ SP->_default_fg = COLOR_WHITE;
+ SP->_default_bg = COLOR_BLACK;
+#ifdef 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
+ * color to that value plus 8. We'll only use the non-bold color for now -
+ * decide later if it is worth having default attributes as well.
+ */
+ if (getenv("COLORFGBG") != 0) {
+ char *p = getenv("COLORFGBG");
+ p = extract_fgbg(p, &(SP->_default_fg));
+ p = extract_fgbg(p, &(SP->_default_bg));
+ }
+#endif
+#endif /* NCURSES_EXT_FUNCS */
+
+ SP->_maxclick = DEFAULT_MAXCLICK;
+ SP->_mouse_event = no_mouse_event;
+ SP->_mouse_inline = no_mouse_inline;
+ SP->_mouse_parse = no_mouse_parse;
+ SP->_mouse_resume = no_mouse_resume;
+ SP->_mouse_wrap = no_mouse_wrap;
+ SP->_mouse_fd = -1;
+
+ /* initialize the panel hooks */
+ SP->_panelHook.top_panel = (struct panel *) 0;
+ SP->_panelHook.bottom_panel = (struct panel *) 0;
+ SP->_panelHook.stdscr_pseudo_panel = (struct panel *) 0;
+
+ /*
+ * If we've no magic cookie support, we suppress attributes that xmc
+ * would affect, i.e., the attributes that affect the rendition of a
+ * space. Note that this impacts the alternate character set mapping
+ * as well.
+ */
+ if (magic_cookie_glitch > 0) {
+
+ SP->_xmc_triggers = termattrs() & (
+ A_ALTCHARSET |
+ A_BLINK |
+ A_BOLD |
+ A_REVERSE |
+ A_STANDOUT |
+ A_UNDERLINE
+ );
+ SP->_xmc_suppress = SP->_xmc_triggers & (chtype) ~ (A_BOLD);
+
+ T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
+#if USE_XMC_SUPPORT
/*
- * If we've no magic cookie support, we suppress attributes that xmc
- * would affect, i.e., the attributes that affect the rendition of a
- * space. Note that this impacts the alternate character set mapping
- * as well.
+ * To keep this simple, suppress all of the optimization hooks
+ * except for clear_screen and the cursor addressing.
*/
- if (magic_cookie_glitch > 0) {
-
- SP->_xmc_triggers = termattrs() & (
- A_ALTCHARSET |
- A_BLINK |
- A_BOLD |
- A_REVERSE |
- A_STANDOUT |
- A_UNDERLINE
- );
- SP->_xmc_suppress = SP->_xmc_triggers & (chtype)~(A_BOLD);
-
- T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
-#if USE_XMC_SUPPORT
- /*
- * To keep this simple, suppress all of the optimization hooks
- * except for clear_screen and the cursor addressing.
- */
- clr_eol = 0;
- clr_eos = 0;
- set_attributes = 0;
+ clr_eol = 0;
+ clr_eos = 0;
+ set_attributes = 0;
#else
- magic_cookie_glitch = -1;
- acs_chars = 0;
+ magic_cookie_glitch = ABSENT_NUMERIC;
+ acs_chars = 0;
#endif
- }
- _nc_init_acs();
- memcpy(SP->_acs_map, acs_map, sizeof(chtype)*ACS_LEN);
+ }
+ _nc_init_acs();
+ memcpy(SP->_acs_map, acs_map, sizeof(chtype) * ACS_LEN);
- _nc_idcok = TRUE;
- _nc_idlok = FALSE;
+ _nc_idcok = TRUE;
+ _nc_idlok = FALSE;
- _nc_windows = 0; /* no windows yet */
+ _nc_windows = 0; /* no windows yet */
- SP->oldhash = 0;
- SP->newhash = 0;
+ SP->oldhash = 0;
+ SP->newhash = 0;
- T(("creating newscr"));
- if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ T(("creating newscr"));
+ if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
+ return ERR;
- T(("creating curscr"));
- if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
- return ERR;
+ T(("creating curscr"));
+ if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
+ return ERR;
- SP->_newscr = newscr;
- SP->_curscr = curscr;
+ SP->_newscr = newscr;
+ SP->_curscr = curscr;
#if USE_SIZECHANGE
- SP->_resize = resizeterm;
+ SP->_resize = resizeterm;
#endif
- newscr->_clear = TRUE;
- curscr->_clear = FALSE;
-
- for (i=0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
- if (rsp->hook) {
- WINDOW *w;
- int count = (rsp->line < 0) ? -rsp->line : rsp->line;
-
- if (rsp->line < 0) {
- w = newwin(count,scolumns,SP->_lines_avail - count,0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- bottom_stolen += count;
- }
- else
+ newscr->_clear = TRUE;
+ curscr->_clear = FALSE;
+
+ for (i = 0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
+ if (rsp->hook) {
+ WINDOW *w;
+ int count = (rsp->line < 0) ? -rsp->line : rsp->line;
+
+ if (rsp->line < 0) {
+ w = newwin(count, scolumns, SP->_lines_avail - count, 0);
+ if (w) {
+ rsp->w = w;
+ rsp->hook(w, scolumns);
+ bottom_stolen += count;
+ } else
return ERR;
- } else {
- w = newwin(count,scolumns, 0, 0);
- if (w) {
- rsp->w = w;
- rsp->hook(w, scolumns);
- SP->_topstolen += count;
- }
- else
+ } else {
+ w = newwin(count, scolumns, 0, 0);
+ if (w) {
+ rsp->w = w;
+ rsp->hook(w, scolumns);
+ SP->_topstolen += count;
+ } else
return ERR;
- }
- SP->_lines_avail -= count;
- }
- rsp->line = 0;
+ }
+ SP->_lines_avail -= count;
}
- /* reset the stack */
- rsp = rippedoff;
+ rsp->line = 0;
+ }
+ /* reset the stack */
+ rsp = rippedoff;
- T(("creating stdscr"));
- assert ((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
- if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
- return ERR;
- SP->_stdscr = stdscr;
+ T(("creating stdscr"));
+ assert((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
+ if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
+ return ERR;
+ SP->_stdscr = stdscr;
- def_shell_mode();
- def_prog_mode();
+ def_shell_mode();
+ def_prog_mode();
- return OK;
+ return OK;
}
/* The internal implementation interprets line as the number of
lines to rip off from the top or bottom.
*/
int
-_nc_ripoffline(int line, int (*init)(WINDOW *,int))
+_nc_ripoffline(int line, int (*init) (WINDOW *, int))
{
if (line == 0)
- return(OK);
+ return (OK);
if (rsp >= rippedoff + N_RIPS)
- return(ERR);
+ return (ERR);
rsp->line = line;
rsp->hook = init;
- rsp->w = 0;
+ rsp->w = 0;
rsp++;
- return(OK);
+ return (OK);
}
int
-ripoffline(int line, int (*init)(WINDOW *, int))
+ripoffline(int line, int (*init) (WINDOW *, int))
{
T((T_CALLED("ripoffline(%d,%p)"), line, init));
if (line == 0)
returnCode(OK);
- returnCode(_nc_ripoffline ((line<0) ? -1 : 1, init));
+ returnCode(_nc_ripoffline((line < 0) ? -1 : 1, init));
}
diff --git a/contrib/ncurses/ncurses/base/lib_slk.c b/contrib/ncurses/ncurses/base/lib_slk.c
index 9b9b09a4d064..21eae687c67f 100644
--- a/contrib/ncurses/ncurses/base/lib_slk.c
+++ b/contrib/ncurses/ncurses/base/lib_slk.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999 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,13 +41,13 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
-MODULE_ID("$Id: lib_slk.c,v 1.16 1999/03/03 23:44:22 juergen Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.17 1999/10/30 23:00:16 tom Exp $")
/*
* We'd like to move these into the screen context structure, but cannot,
* because slk_init() is called before initscr()/newterm().
*/
-int _nc_slk_format; /* one more than format specified in slk_init() */
+int _nc_slk_format = 0; /* one more than format specified in slk_init() */
/*
* Paint the info line for the PC style SLK emulation.
diff --git a/contrib/ncurses/ncurses/base/lib_vline.c b/contrib/ncurses/ncurses/base/lib_vline.c
index 007ef55cd3ba..e48b864f497d 100644
--- a/contrib/ncurses/ncurses/base/lib_vline.c
+++ b/contrib/ncurses/ncurses/base/lib_vline.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -31,8 +31,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
** lib_vline.c
**
@@ -42,36 +40,37 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_vline.c,v 1.4 1998/06/28 00:10:12 tom Exp $")
+MODULE_ID("$Id: lib_vline.c,v 1.5 2000/04/29 21:14:11 tom Exp $")
-int wvline(WINDOW *win, chtype ch, int n)
+int
+wvline(WINDOW *win, chtype ch, int n)
{
-int code = ERR;
-short row, col;
-short end;
+ int code = ERR;
+ NCURSES_SIZE_T row, col;
+ NCURSES_SIZE_T end;
- T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n));
+ T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n));
- if (win) {
- row = win->_cury;
- col = win->_curx;
- end = row + n - 1;
- if (end > win->_maxy)
- end = win->_maxy;
+ if (win) {
+ row = win->_cury;
+ col = win->_curx;
+ end = row + n - 1;
+ if (end > win->_maxy)
+ end = win->_maxy;
- if (ch == 0)
- ch = ACS_VLINE;
- ch = _nc_render(win, ch);
+ if (ch == 0)
+ ch = ACS_VLINE;
+ ch = _nc_render(win, ch);
- while(end >= row) {
- struct ldat *line = &(win->_line[end]);
- line->text[col] = ch;
- CHANGED_CELL(line, col);
- end--;
- }
-
- _nc_synchook(win);
- code = OK;
+ while (end >= row) {
+ struct ldat *line = &(win->_line[end]);
+ line->text[col] = ch;
+ CHANGED_CELL(line, col);
+ end--;
}
- returnCode(code);
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
}
diff --git a/contrib/ncurses/ncurses/base/version.c b/contrib/ncurses/ncurses/base/version.c
index 74d46ae9efa4..a2fe4d86d650 100644
--- a/contrib/ncurses/ncurses/base/version.c
+++ b/contrib/ncurses/ncurses/base/version.c
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: version.c,v 1.1 1999/10/23 13:28:49 tom Exp $")
+MODULE_ID("$Id: version.c,v 1.2 1999/12/04 21:27:23 tom Exp $")
const char *
curses_version(void)
@@ -40,9 +40,8 @@ curses_version(void)
static char my_version[80];
T((T_CALLED("curses_version()")));
- sprintf(my_version, "ncurses %d.%d.%d",
- NCURSES_VERSION_MAJOR,
- NCURSES_VERSION_MINOR,
+ sprintf(my_version, "ncurses %s.%d",
+ NCURSES_VERSION,
NCURSES_VERSION_PATCH);
returnPtr(my_version);
}
diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c
index 1b91476cbfd3..8121ff154dd5 100644
--- a/contrib/ncurses/ncurses/base/wresize.c
+++ b/contrib/ncurses/ncurses/base/wresize.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,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 *
@@ -32,7 +32,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.12 1999/02/27 18:57:31 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.16 2000/03/05 00:14:35 tom Exp $")
/*
* Reallocate a curses WINDOW struct to either shrink or grow to the specified
@@ -47,120 +47,133 @@ MODULE_ID("$Id: wresize.c,v 1.12 1999/02/27 18:57:31 tom Exp $")
int
wresize(WINDOW *win, int ToLines, int ToCols)
{
- register int row;
- int size_x, size_y;
- struct ldat *pline;
- chtype blank;
+ register int row;
+ int size_x, size_y;
+ struct ldat *pline;
+ chtype blank;
#ifdef TRACE
- T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
- if (win) {
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
+ T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
+ if (win) {
+ TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
+ win->_begy, win->_begx,
+ win->_maxy, win->_maxx,
+ win->_regtop, win->_regbottom));
+ if (_nc_tracing & TRACE_UPDATE)
_tracedump("...before", win);
- }
+ }
#endif
- if (!win || --ToLines < 0 || --ToCols < 0)
- returnCode(ERR);
+ if (!win || --ToLines < 0 || --ToCols < 0)
+ returnCode(ERR);
- size_x = win->_maxx;
- size_y = win->_maxy;
+ size_x = win->_maxx;
+ size_y = win->_maxy;
- if (ToLines == size_y
- && ToCols == size_x)
- returnCode(OK);
-
- pline = (win->_flags & _SUBWIN) ? win->_parent->_line : 0;
+ if (ToLines == size_y
+ && ToCols == size_x)
+ returnCode(OK);
+ if ((win->_flags & _SUBWIN)) {
/*
- * If the number of lines has changed, adjust the size of the overall
- * vector:
+ * Check if the new limits will fit into the parent window's size. If
+ * not, do not resize. We could adjust the location of the subwindow,
+ * but the application may not like that.
*/
- if (ToLines != size_y) {
- if (! (win->_flags & _SUBWIN)) {
- for (row = ToLines+1; row <= size_y; row++)
- free((char *)(win->_line[row].text));
- }
-
- win->_line = ld_ALLOC(win->_line, ToLines+1);
- if (win->_line == 0)
- returnCode(ERR);
-
- for (row = size_y+1; row <= ToLines; row++) {
- win->_line[row].text = 0;
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
- if ((win->_flags & _SUBWIN)) {
- win->_line[row].text =
- &pline[win->_begy + row].text[win->_begx];
- }
- }
+ if (win->_pary + ToLines > win->_parent->_maxy
+ || win->_parx + ToCols > win->_parent->_maxx) {
+ returnCode(ERR);
}
-
- /*
- * Adjust the width of the columns:
- */
- blank = _nc_background(win);
- for (row = 0; row <= ToLines; row++) {
- chtype *s = win->_line[row].text;
- int begin = (s == 0) ? 0 : size_x + 1;
- int end = ToCols;
-
- if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
-
- if (ToCols != size_x || s == 0) {
- if (! (win->_flags & _SUBWIN)) {
- win->_line[row].text = s = c_ALLOC(s, ToCols+1);
- if (win->_line[row].text == 0)
- returnCode(ERR);
- } else if (s == 0) {
- win->_line[row].text = s =
- &pline[win->_begy + row].text[win->_begx];
- }
-
- if (end >= begin) { /* growing */
- if (win->_line[row].firstchar < begin)
- win->_line[row].firstchar = begin;
- win->_line[row].lastchar = ToCols;
- do {
- s[end] = blank;
- } while (--end >= begin);
- } else { /* shrinking */
- win->_line[row].firstchar = 0;
- win->_line[row].lastchar = ToCols;
- }
- }
+ pline = win->_parent->_line;
+ } else {
+ pline = 0;
+ }
+
+ /*
+ * If the number of lines has changed, adjust the size of the overall
+ * vector:
+ */
+ if (ToLines != size_y) {
+ if (!(win->_flags & _SUBWIN)) {
+ for (row = ToLines + 1; row <= size_y; row++)
+ free((char *) (win->_line[row].text));
}
- /*
- * Finally, adjust the parameters showing screen size and cursor
- * position:
- */
- win->_maxx = ToCols;
- win->_maxy = ToLines;
-
- if (win->_regtop > win->_maxy)
- win->_regtop = win->_maxy;
- if (win->_regbottom > win->_maxy
- || win->_regbottom == size_y)
- win->_regbottom = win->_maxy;
-
- if (win->_curx > win->_maxx)
- win->_curx = win->_maxx;
- if (win->_cury > win->_maxy)
- win->_cury = win->_maxy;
+ win->_line = ld_ALLOC(win->_line, ToLines + 1);
+ if (win->_line == 0)
+ returnCode(ERR);
+
+ for (row = size_y + 1; row <= ToLines; row++) {
+ win->_line[row].text = 0;
+ win->_line[row].firstchar = 0;
+ win->_line[row].lastchar = ToCols;
+ if ((win->_flags & _SUBWIN)) {
+ win->_line[row].text =
+ &pline[win->_pary + row].text[win->_parx];
+ }
+ }
+ }
+
+ /*
+ * Adjust the width of the columns:
+ */
+ blank = _nc_background(win);
+ for (row = 0; row <= ToLines; row++) {
+ chtype *s = win->_line[row].text;
+ int begin = (s == 0) ? 0 : size_x + 1;
+ int end = ToCols;
+
+ if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
+
+ if (ToCols != size_x || s == 0) {
+ if (!(win->_flags & _SUBWIN)) {
+ win->_line[row].text = s = c_ALLOC(s, ToCols + 1);
+ if (win->_line[row].text == 0)
+ returnCode(ERR);
+ } else if (s == 0) {
+ win->_line[row].text = s =
+ &pline[win->_pary + row].text[win->_parx];
+ }
+
+ if (end >= begin) { /* growing */
+ if (win->_line[row].firstchar < begin)
+ win->_line[row].firstchar = begin;
+ win->_line[row].lastchar = ToCols;
+ do {
+ s[end] = blank;
+ } while (--end >= begin);
+ } else { /* shrinking */
+ win->_line[row].firstchar = 0;
+ win->_line[row].lastchar = ToCols;
+ }
+ }
+ }
+
+ /*
+ * Finally, adjust the parameters showing screen size and cursor
+ * position:
+ */
+ win->_maxx = ToCols;
+ win->_maxy = ToLines;
+
+ if (win->_regtop > win->_maxy)
+ win->_regtop = win->_maxy;
+ if (win->_regbottom > win->_maxy
+ || win->_regbottom == size_y)
+ win->_regbottom = win->_maxy;
+
+ if (win->_curx > win->_maxx)
+ win->_curx = win->_maxx;
+ if (win->_cury > win->_maxy)
+ win->_cury = win->_maxy;
#ifdef TRACE
- TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
- win->_begy, win->_begx,
- win->_maxy, win->_maxx,
- win->_regtop, win->_regbottom));
- if (_nc_tracing & TRACE_UPDATE)
- _tracedump("...after:", win);
+ TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
+ win->_begy, win->_begx,
+ win->_maxy, win->_maxx,
+ win->_regtop, win->_regbottom));
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...after:", win);
#endif
- returnCode(OK);
+ returnCode(OK);
}