summaryrefslogtreecommitdiffstats
path: root/lib/libcurses/base
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2000-03-10 01:35:01 +0000
committermillert <millert@openbsd.org>2000-03-10 01:35:01 +0000
commit4b107ee47ccf17c9f1ad6db8a59eb142776341c8 (patch)
tree20e23a45f7f7880a685cfd1261008320e43805bb /lib/libcurses/base
parentincreased buffer size. (diff)
downloadwireguard-openbsd-4b107ee47ccf17c9f1ad6db8a59eb142776341c8.tar.xz
wireguard-openbsd-4b107ee47ccf17c9f1ad6db8a59eb142776341c8.zip
Update to ncurses-5.0-20000304
Diffstat (limited to 'lib/libcurses/base')
-rw-r--r--lib/libcurses/base/lib_color.c70
-rw-r--r--lib/libcurses/base/lib_dft_fgbg.c33
-rw-r--r--lib/libcurses/base/lib_getch.c554
-rw-r--r--lib/libcurses/base/lib_mouse.c6
-rw-r--r--lib/libcurses/base/lib_newterm.c6
-rw-r--r--lib/libcurses/base/lib_nl.c6
-rw-r--r--lib/libcurses/base/lib_pad.c5
-rw-r--r--lib/libcurses/base/lib_set_term.c6
-rw-r--r--lib/libcurses/base/wresize.c219
9 files changed, 461 insertions, 444 deletions
diff --git a/lib/libcurses/base/lib_color.c b/lib/libcurses/base/lib_color.c
index f60847d43cd..e917647497b 100644
--- a/lib/libcurses/base/lib_color.c
+++ b/lib/libcurses/base/lib_color.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_color.c,v 1.5 2000/01/02 22:06:51 millert Exp $ */
+/* $OpenBSD: lib_color.c,v 1.6 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 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 *
@@ -43,11 +43,11 @@
#include <term.h>
#include <tic.h>
-MODULE_ID("$From: lib_color.c,v 1.42 2000/01/01 16:42:37 tom Exp $")
+MODULE_ID("$From: lib_color.c,v 1.45 2000/02/27 00:20:31 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 = 0;
@@ -91,13 +91,13 @@ static const color_t hls_palette[] =
static int
default_fg(void)
{
- return (SP->_default_fg >= 0) ? SP->_default_fg : COLOR_WHITE;
+ return (SP->_default_fg != C_MASK) ? SP->_default_fg : COLOR_WHITE;
}
static int
default_bg(void)
{
- return (SP->_default_bg >= 0) ? SP->_default_bg : COLOR_BLACK;
+ return (SP->_default_bg != C_MASK) ? SP->_default_bg : COLOR_BLACK;
}
#else
#define default_fg() COLOR_WHITE
@@ -420,37 +420,51 @@ _nc_do_color(int pair, bool reverse, int (*outc) (int))
!SP->_default_color ||
#endif
!set_original_colors()) {
- set_foreground_color(default_fg(), outc);
- set_background_color(default_bg(), outc);
+ fg = default_fg();
+ bg = default_bg();
+ } else {
+ fg = C_MASK;
+ bg = C_MASK;
}
} else {
if (set_color_pair) {
TPUTS_TRACE("set_color_pair");
tputs(tparm(set_color_pair, pair), 1, outc);
+ return;
} else {
pair_content(pair, &fg, &bg);
- if (reverse) {
- short xx = fg;
- fg = bg;
- bg = xx;
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_default_color) {
+ if (fg == C_MASK)
+ fg = SP->_default_fg;
+ if (bg == C_MASK)
+ bg = SP->_default_bg;
}
+#endif
+ }
+ }
- T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
-
- if (fg == C_MASK || bg == C_MASK) {
- if (set_original_colors() != TRUE) {
- if (fg == C_MASK)
- set_foreground_color(default_fg(), outc);
- if (bg == C_MASK)
- set_background_color(default_bg(), outc);
- }
- }
- if (fg != C_MASK) {
- set_foreground_color(fg, outc);
- }
- if (bg != C_MASK) {
- set_background_color(bg, outc);
- }
+ if (fg == C_MASK || bg == C_MASK) {
+ if (set_original_colors() != TRUE) {
+ if (fg == C_MASK)
+ fg = default_fg();
+ if (bg == C_MASK)
+ bg = default_bg();
}
}
+
+ if (reverse) {
+ short xx = fg;
+ fg = bg;
+ bg = xx;
+ }
+
+ 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/lib/libcurses/base/lib_dft_fgbg.c b/lib/libcurses/base/lib_dft_fgbg.c
index 80da38979a6..df007242458 100644
--- a/lib/libcurses/base/lib_dft_fgbg.c
+++ b/lib/libcurses/base/lib_dft_fgbg.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_dft_fgbg.c,v 1.2 1999/11/28 17:49:53 millert Exp $ */
+/* $OpenBSD: lib_dft_fgbg.c,v 1.3 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * 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 *
@@ -31,10 +31,11 @@
/****************************************************************************
* Author: Thomas E. Dickey <dickey@clark.net> 1997,1999 *
****************************************************************************/
+
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_dft_fgbg.c,v 1.7 1999/11/14 01:22:11 tom Exp $")
+MODULE_ID("$From: lib_dft_fgbg.c,v 1.8 2000/02/19 23:57:40 tom Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -43,8 +44,8 @@ MODULE_ID("$From: lib_dft_fgbg.c,v 1.7 1999/11/14 01:22:11 tom Exp $")
int
use_default_colors(void)
{
- T((T_CALLED("use_default_colors()")));
- returnCode(assume_default_colors(C_MASK, C_MASK));
+ T((T_CALLED("use_default_colors()")));
+ returnCode(assume_default_colors(C_MASK, C_MASK));
}
/*
@@ -54,18 +55,18 @@ use_default_colors(void)
int
assume_default_colors(int fg, int bg)
{
- T((T_CALLED("assume_default_colors(%d,%d)"), fg, 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 = (fg != COLOR_WHITE) || (bg != COLOR_BLACK);
- SP->_default_fg = fg;
- SP->_default_bg = bg;
- if (SP->_color_pairs != 0)
- SP->_color_pairs[0] = PAIR_OF(fg, bg);
- returnCode(OK);
+ SP->_default_color = (fg != COLOR_WHITE) || (bg != COLOR_BLACK);
+ SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
+ SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
+ if (SP->_color_pairs != 0)
+ SP->_color_pairs[0] = PAIR_OF(fg, bg);
+ returnCode(OK);
}
diff --git a/lib/libcurses/base/lib_getch.c b/lib/libcurses/base/lib_getch.c
index 9c1b5f314a6..3057117c347 100644
--- a/lib/libcurses/base/lib_getch.c
+++ b/lib/libcurses/base/lib_getch.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_getch.c,v 1.3 2000/01/23 04:57:41 millert Exp $ */
+/* $OpenBSD: lib_getch.c,v 1.4 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 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 *
@@ -42,151 +42,154 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_getch.c,v 1.44 2000/01/17 19:58:18 tom Exp $")
+MODULE_ID("$From: lib_getch.c,v 1.46 2000/02/20 01:21:33 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->_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;
- }
+ 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 *);
@@ -198,147 +201,137 @@ 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);
+ }
+
+ /*
+ * 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);
}
-
/*
** int
** kgetch()
@@ -357,68 +350,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/lib/libcurses/base/lib_mouse.c b/lib/libcurses/base/lib_mouse.c
index 29cec56f17e..2bac96dd2e6 100644
--- a/lib/libcurses/base/lib_mouse.c
+++ b/lib/libcurses/base/lib_mouse.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_mouse.c,v 1.7 2000/01/09 05:06:02 millert Exp $ */
+/* $OpenBSD: lib_mouse.c,v 1.8 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 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 *
@@ -86,7 +86,7 @@
#endif
#endif
-MODULE_ID("$From: lib_mouse.c,v 1.48 2000/01/08 17:34:43 tom Exp $");
+MODULE_ID("$From: lib_mouse.c,v 1.50 2000/02/13 00:59:39 tom Exp $")
#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
diff --git a/lib/libcurses/base/lib_newterm.c b/lib/libcurses/base/lib_newterm.c
index 3360ebcd704..73899d4ecc8 100644
--- a/lib/libcurses/base/lib_newterm.c
+++ b/lib/libcurses/base/lib_newterm.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_newterm.c,v 1.6 2000/01/02 22:06:51 millert Exp $ */
+/* $OpenBSD: lib_newterm.c,v 1.7 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 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 *
@@ -49,7 +49,7 @@
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_newterm.c,v 1.43 2000/01/01 16:56:20 tom Exp $")
+MODULE_ID("$From: lib_newterm.c,v 1.44 2000/02/13 00:59:39 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
diff --git a/lib/libcurses/base/lib_nl.c b/lib/libcurses/base/lib_nl.c
index 5e69c25e300..9e089cb9216 100644
--- a/lib/libcurses/base/lib_nl.c
+++ b/lib/libcurses/base/lib_nl.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_nl.c,v 1.3 2000/01/09 05:06:02 millert Exp $ */
+/* $OpenBSD: lib_nl.c,v 1.4 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 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 *
@@ -44,7 +44,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_nl.c,v 1.5 2000/01/08 17:33:30 tom Exp $")
+MODULE_ID("$From: lib_nl.c,v 1.6 2000/02/13 00:59:39 tom Exp $")
#ifdef __EMX__
#include <io.h>
diff --git a/lib/libcurses/base/lib_pad.c b/lib/libcurses/base/lib_pad.c
index c031c018853..4f2ed3e58be 100644
--- a/lib/libcurses/base/lib_pad.c
+++ b/lib/libcurses/base/lib_pad.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_pad.c,v 1.1 1999/01/18 19:09:55 millert Exp $ */
+/* $OpenBSD: lib_pad.c,v 1.2 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: lib_pad.c,v 1.27 1998/06/28 00:10:16 tom Exp $")
+MODULE_ID("$From: lib_pad.c,v 1.28 2000/03/05 00:21:55 David.Mosberger Exp $")
WINDOW *newpad(int l, int c)
{
@@ -243,6 +243,7 @@ bool wide;
newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
newscr->_curx = win->_curx - pmincol + win->_begx;
}
+ newscr->_leaveok = win->_leaveok;
win->_flags &= ~_HASMOVED;
/*
diff --git a/lib/libcurses/base/lib_set_term.c b/lib/libcurses/base/lib_set_term.c
index 67d84e53e0d..55f4b205a34 100644
--- a/lib/libcurses/base/lib_set_term.c
+++ b/lib/libcurses/base/lib_set_term.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_set_term.c,v 1.6 2000/01/02 22:06:51 millert Exp $ */
+/* $OpenBSD: lib_set_term.c,v 1.7 2000/03/10 01:35:02 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998-2000 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 *
@@ -45,7 +45,7 @@
#include <term.h> /* cur_term */
#include <tic.h>
-MODULE_ID("$From: lib_set_term.c,v 1.49 2000/01/01 16:44:29 tom Exp $")
+MODULE_ID("$From: lib_set_term.c,v 1.50 2000/02/13 00:59:39 tom Exp $")
SCREEN *
set_term(SCREEN * screenp)
diff --git a/lib/libcurses/base/wresize.c b/lib/libcurses/base/wresize.c
index b70f5678231..9eacdbf6a0d 100644
--- a/lib/libcurses/base/wresize.c
+++ b/lib/libcurses/base/wresize.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: wresize.c,v 1.2 1999/03/02 06:23:28 millert Exp $ */
+/* $OpenBSD: wresize.c,v 1.3 2000/03/10 01:35:03 millert Exp $ */
/****************************************************************************
- * 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,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$From: wresize.c,v 1.12 1999/02/27 18:57:31 tom Exp $")
+MODULE_ID("$From: 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
@@ -49,120 +49,133 @@ MODULE_ID("$From: 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);
}