summaryrefslogtreecommitdiff
path: root/lib/libcurses/tty
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcurses/tty')
-rw-r--r--lib/libcurses/tty/hashmap.c6
-rw-r--r--lib/libcurses/tty/lib_mvcur.c14
-rw-r--r--lib/libcurses/tty/lib_tstp.c16
-rw-r--r--lib/libcurses/tty/lib_twait.c83
-rw-r--r--lib/libcurses/tty/lib_vidattr.c15
-rw-r--r--lib/libcurses/tty/tty_update.c233
6 files changed, 259 insertions, 108 deletions
diff --git a/lib/libcurses/tty/hashmap.c b/lib/libcurses/tty/hashmap.c
index 25ea2478a84..a2442f97c1a 100644
--- a/lib/libcurses/tty/hashmap.c
+++ b/lib/libcurses/tty/hashmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hashmap.c,v 1.4 1999/03/18 16:46:58 millert Exp $ */
+/* $OpenBSD: hashmap.c,v 1.5 1999/11/28 17:49:54 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -72,7 +72,7 @@ AUTHOR
#include <curses.priv.h>
#include <term.h> /* for back_color_erase */
-MODULE_ID("$From: hashmap.c,v 1.33 1999/03/18 02:09:45 Alexander.V.Lukyanov Exp $")
+MODULE_ID("$From: hashmap.c,v 1.34 1999/11/28 00:10:57 tom Exp $")
#ifdef HASHDEBUG
@@ -288,7 +288,9 @@ void _nc_hash_map(void)
if (!hashtab)
{
if (oldhash)
+ {
FreeAndNull(oldhash);
+ }
lines_alloc = 0;
return;
}
diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c
index 29e9f89d266..b3179275d1f 100644
--- a/lib/libcurses/tty/lib_mvcur.c
+++ b/lib/libcurses/tty/lib_mvcur.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_mvcur.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */
+/* $OpenBSD: lib_mvcur.c,v 1.4 1999/11/28 17:49:54 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -155,7 +155,7 @@
#include <term.h>
#include <ctype.h>
-MODULE_ID("$From: lib_mvcur.c,v 1.57 1999/06/26 22:16:04 tom Exp $")
+MODULE_ID("$From: lib_mvcur.c,v 1.60 1999/10/03 01:08:27 Alexander.V.Lukyanov Exp $")
#define STRLEN(s) (s != 0) ? strlen(s) : 0
@@ -248,10 +248,10 @@ int _nc_msec_cost(const char *const cap, int affcnt)
{
if (isdigit(*cp))
number = number * 10 + (*cp - '0');
- else if (*cp == '.')
- number += (*++cp - 10) / 10.0;
else if (*cp == '*')
number *= affcnt;
+ else if (*cp == '.' && (*++cp != '>') && isdigit(*cp))
+ number += (*cp - '0') / 10.0;
}
cum_cost += number * 10;
@@ -736,6 +736,7 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
{
char use[OPT_SIZE], *sp;
int tactic = 0, newcost, usecost = INFINITY;
+ int t5_cr_cost;
#if defined(MAIN) || defined(NCURSES_TEST)
struct timeval before, after;
@@ -819,13 +820,14 @@ onscreen_mvcur(int yold,int xold,int ynew,int xnew, bool ovw)
* tactic #5: use left margin for wrap to right-hand side,
* unless strange wrap behavior indicated by xenl might hose us.
*/
+ t5_cr_cost = (xold>0 ? SP->_cr_cost : 0);
if (auto_left_margin && !eat_newline_glitch
&& yold > 0 && cursor_left
&& ((newcost=relative_move(NULL, yold-1, screen_columns-1, ynew, xnew, ovw)) != INFINITY)
- && SP->_cr_cost + SP->_cub1_cost + newcost + newcost < usecost)
+ && t5_cr_cost + SP->_cub1_cost + newcost < usecost)
{
tactic = 5;
- usecost = SP->_cr_cost + SP->_cub1_cost + newcost;
+ usecost = t5_cr_cost + SP->_cub1_cost + newcost;
}
/*
diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c
index b3c181521ae..aab402f0223 100644
--- a/lib/libcurses/tty/lib_tstp.c
+++ b/lib/libcurses/tty/lib_tstp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_tstp.c,v 1.4 1999/08/15 11:40:56 millert Exp $ */
+/* $OpenBSD: lib_tstp.c,v 1.5 1999/11/28 17:49:54 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999 Free Software Foundation, Inc. *
@@ -50,7 +50,7 @@
#define _POSIX_SOURCE
#endif
-MODULE_ID("$From: lib_tstp.c,v 1.19 1999/07/24 22:47:20 tom Exp $")
+MODULE_ID("$From: lib_tstp.c,v 1.20 1999/10/22 23:11:09 tom Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -201,13 +201,16 @@ static void tstp(int dummy GCC_UNUSED)
static void cleanup(int sig)
{
+ static int nested;
+
/*
* Actually, doing any sort of I/O from within an signal handler is
* "unsafe". But we'll _try_ to clean up the screen and terminal
* settings on the way out.
*/
- if (sig == SIGINT
- || sig == SIGQUIT) {
+ if (!nested++
+ && (sig == SIGINT
+ || sig == SIGQUIT)) {
#if HAVE_SIGACTION || HAVE_SIGVEC
sigaction_t act;
sigemptyset(&act.sa_mask);
@@ -221,6 +224,11 @@ static void cleanup(int sig)
SCREEN *scan = _nc_screen_chain;
while(scan)
{
+ if (SP != 0
+ && SP->_ofp != 0
+ && isatty(fileno(SP->_ofp))) {
+ SP->_cleanup = TRUE;
+ }
set_term(scan);
endwin();
if (SP)
diff --git a/lib/libcurses/tty/lib_twait.c b/lib/libcurses/tty/lib_twait.c
index 5a7cffeae2b..0d330245f48 100644
--- a/lib/libcurses/tty/lib_twait.c
+++ b/lib/libcurses/tty/lib_twait.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_twait.c,v 1.1 1999/01/18 19:10:27 millert Exp $ */
+/* $OpenBSD: lib_twait.c,v 1.2 1999/11/28 17:49:54 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -42,6 +42,10 @@
** comments, none of the original code remains - T.Dickey).
*/
+#ifdef __BEOS__
+#include <OS.h>
+#endif
+
#include <curses.priv.h>
#if USE_FUNC_POLL
@@ -59,28 +63,32 @@
# endif
#endif
-#ifdef __BEOS__
-/* BeOS select() only works on sockets. Use the tty hack instead */
-#include <socket.h>
-#define select check_select
-#endif
-
-MODULE_ID("$From: lib_twait.c,v 1.32 1998/06/06 22:44:14 tom Exp $")
+MODULE_ID("$From: lib_twait.c,v 1.34 1999/10/16 21:25:10 tom Exp $")
-static int _nc_gettime(void)
+static long _nc_gettime(bool first)
{
- int res;
+ long res;
#if HAVE_GETTIMEOFDAY
# define PRECISE_GETTIME 1
- struct timeval t;
- gettimeofday(&t, (struct timezone *)0);
- res = t.tv_sec*1000 + t.tv_usec/1000;
+ static struct timeval t0;
+ struct timeval t1;
+ gettimeofday(&t1, (struct timezone *)0);
+ if (first) {
+ t0 = t1;
+ }
+ res = (t1.tv_sec - t0.tv_sec) * 1000
+ + (t1.tv_usec - t0.tv_usec) / 1000;
#else
# define PRECISE_GETTIME 0
- res = time(0)*1000;
+ static time_t t0;
+ time_t t1 = time((time_t*)0);
+ if (first) {
+ t0 = t1;
+ }
+ res = (t1 - t0) * 1000;
#endif
- T(("time: %d msec", res));
+ T(("%s time: %ld msec", first ? "get" : "elapsed", res));
return res;
}
@@ -106,18 +114,19 @@ int result;
#if USE_FUNC_POLL
struct pollfd fds[2];
+#elif defined(__BEOS__)
#elif HAVE_SELECT
static fd_set set;
#endif
-int starttime, returntime;
+long starttime, returntime;
T(("start twait: %d milliseconds, mode: %d", milliseconds, mode));
#if PRECISE_GETTIME
retry:
#endif
- starttime = _nc_gettime();
+ starttime = _nc_gettime(TRUE);
count = 0;
@@ -135,6 +144,40 @@ retry:
}
result = poll(fds, count, milliseconds);
+#elif defined(__BEOS__)
+ /*
+ * BeOS's select() is declared in socket.h, so the configure script does
+ * not see it. That's just as well, since that function works only for
+ * sockets. This (using snooze and ioctl) was distilled from Be's patch
+ * for ncurses which uses a separate thread to simulate select().
+ *
+ * FIXME: the return values from the ioctl aren't very clear if we get
+ * interrupted.
+ */
+ result = 0;
+ if (mode & 1) {
+ bigtime_t d;
+ bigtime_t useconds = milliseconds * 1000;
+ int n, howmany;
+
+ if (useconds == 0) /* we're here to go _through_ the loop */
+ useconds = 1;
+
+ for (d = 0; d < useconds; d += 5000) {
+ n = 0;
+ howmany = ioctl(0, 'ichr', &n);
+ if (howmany >= 0 && n > 0) {
+ result = 1;
+ break;
+ }
+ if (useconds > 1)
+ snooze(5000);
+ milliseconds -= 5;
+ }
+ } else if (milliseconds > 0) {
+ snooze(milliseconds * 1000);
+ milliseconds = 0;
+ }
#elif HAVE_SELECT
/*
* select() modifies the fd_set arguments; do this in the
@@ -162,10 +205,10 @@ retry:
}
#endif
- returntime = _nc_gettime();
+ returntime = _nc_gettime(FALSE);
if (milliseconds >= 0)
- milliseconds -= returntime-starttime;
+ milliseconds -= (returntime - starttime);
#if PRECISE_GETTIME
/*
@@ -205,6 +248,8 @@ retry:
count++;
}
}
+#elif defined(__BEOS__)
+ result = 1; /* redundant, but simple */
#elif HAVE_SELECT
if ((mode & 2)
&& (fd = SP->_mouse_fd) >= 0
diff --git a/lib/libcurses/tty/lib_vidattr.c b/lib/libcurses/tty/lib_vidattr.c
index 9db4ee5aec9..8e836442f0f 100644
--- a/lib/libcurses/tty/lib_vidattr.c
+++ b/lib/libcurses/tty/lib_vidattr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_vidattr.c,v 1.2 1999/06/14 02:29:16 millert Exp $ */
+/* $OpenBSD: lib_vidattr.c,v 1.3 1999/11/28 17:49:55 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -66,7 +66,7 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$From: lib_vidattr.c,v 1.23 1999/06/12 21:20:41 tom Exp $")
+MODULE_ID("$From: lib_vidattr.c,v 1.24 1999/11/14 02:53:43 tom Exp $")
#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
@@ -78,10 +78,11 @@ MODULE_ID("$From: lib_vidattr.c,v 1.23 1999/06/12 21:20:41 tom Exp $")
/* if there is no current screen, assume we *can* do color */
#define SetColorsIf(why,old_attr) \
- if ((!SP || SP->_coloron) && (why)) { \
+ if (can_color && (1)) { \
int old_pair = PAIR_NUMBER(old_attr); \
T(("old pair = %d -- new pair = %d", old_pair, pair)); \
if ((pair != old_pair) \
+ || (fix_pair0 && (pair == 0)) \
|| (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
_nc_do_color(pair, reverse, outc); \
} \
@@ -94,6 +95,12 @@ attr_t turn_on, turn_off;
int pair;
bool reverse = FALSE;
bool used_ncv = FALSE;
+bool can_color = (SP == 0 || SP->_coloron);
+#ifdef NCURSES_EXT_FUNCS
+bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
+#else
+#define fix_pair0 FALSE
+#endif
T((T_CALLED("vidputs(%s)"), _traceattr(newmode)));
@@ -163,6 +170,7 @@ bool used_ncv = FALSE;
}
if (previous_attr) {
doPut(exit_attribute_mode);
+ if (fix_pair0) _nc_do_color(0, FALSE, _nc_outch);
previous_attr &= ~A_COLOR;
}
@@ -199,6 +207,7 @@ bool used_ncv = FALSE;
if (turn_off && exit_attribute_mode) {
doPut(exit_attribute_mode);
+ if (fix_pair0) _nc_do_color(0, FALSE, _nc_outch);
turn_on |= (newmode & (chtype)(~A_COLOR));
previous_attr &= ~A_COLOR;
}
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index 6389748139b..2df0aa2f81d 100644
--- a/lib/libcurses/tty/tty_update.c
+++ b/lib/libcurses/tty/tty_update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_update.c,v 1.3 1999/03/02 06:23:30 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.4 1999/11/28 17:49:55 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -44,6 +44,10 @@
*
*-----------------------------------------------------------------*/
+#ifdef __BEOS__
+#include <OS.h>
+#endif
+
#include <curses.priv.h>
#if defined(TRACE) && HAVE_SYS_TIMES_H && HAVE_TIMES
@@ -69,15 +73,9 @@
#endif
#endif
-#ifdef __BEOS__
-/* BeOS select() only works on sockets. Use the tty hack instead */
-#include <socket.h>
-#define select check_select
-#endif
-
#include <term.h>
-MODULE_ID("$From: tty_update.c,v 1.111 1999/02/27 20:07:56 tom Exp $")
+MODULE_ID("$From: tty_update.c,v 1.122 1999/11/28 03:07:38 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -99,10 +97,10 @@ MODULE_ID("$From: tty_update.c,v 1.111 1999/02/27 20:07:56 tom Exp $")
static inline chtype ClrBlank ( WINDOW *win );
static int ClrBottom(int total);
-static int InsStr( chtype *line, int count );
static void ClearScreen( chtype blank );
static void ClrUpdate( void );
static void DelChar( int count );
+static void InsStr( chtype *line, int count );
static void TransformLine( int const lineno );
#ifdef POSITION_DEBUG
@@ -112,29 +110,40 @@ static void TransformLine( int const lineno );
*
****************************************************************************/
-void position_check(int expected_y, int expected_x, char *legend)
+static void position_check(int expected_y, int expected_x, char *legend)
/* check to see if the real cursor position matches the virtual */
{
- static char buf[9];
+ char buf[20];
int y, x;
- if (_nc_tracing)
+ if (!_nc_tracing || (expected_y < 0 && expected_x < 0))
return;
memset(buf, '\0', sizeof(buf));
- (void) write(1, "\033[6n", 4); /* only works on ANSI-compatibles */
- (void) read(0, (void *)buf, 8);
+ putp("\033[6n"); /* only works on ANSI-compatibles */
+ _nc_flush();
+ (void) read(0, buf, sizeof(buf)-1);
_tracef("probe returned %s", _nc_visbuf(buf));
/* try to interpret as a position report */
- if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2)
+ if (sscanf(buf, "\033[%d;%dR", &y, &x) != 2) {
_tracef("position probe failed in %s", legend);
- else if (y - 1 != expected_y || x - 1 != expected_x)
- _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
- y-1, x-1, expected_y, expected_x, legend);
- else
- _tracef("position matches OK in %s", legend);
+ } else {
+ if (expected_x < 0)
+ expected_x = x - 1;
+ if (expected_y < 0)
+ expected_y = y - 1;
+ if (y - 1 != expected_y || x - 1 != expected_x) {
+ beep();
+ _tracef("position seen (%d, %d) doesn't match expected one (%d, %d) in %s",
+ y-1, x-1, expected_y, expected_x, legend);
+ } else {
+ _tracef("position matches OK in %s", legend);
+ }
+ }
}
+#else
+#define position_check(expected_y, expected_x, legend) /* nothing */
#endif /* POSITION_DEBUG */
/****************************************************************************
@@ -150,9 +159,7 @@ static inline void GoTo(int const row, int const col)
TR(TRACE_MOVE, ("GoTo(%d, %d) from (%d, %d)",
row, col, SP->_cursrow, SP->_curscol));
-#ifdef POSITION_DEBUG
position_check(SP->_cursrow, SP->_curscol, "GoTo");
-#endif /* POSITION_DEBUG */
/*
* Force restore even if msgr is on when we're in an alternate
@@ -170,6 +177,7 @@ static inline void GoTo(int const row, int const col)
mvcur(SP->_cursrow, SP->_curscol, row, col);
SP->_cursrow = row;
SP->_curscol = col;
+ position_check(SP->_cursrow, SP->_curscol, "GoTo2");
}
static inline void PutAttrChar(chtype ch)
@@ -181,10 +189,14 @@ static inline void PutAttrChar(chtype ch)
_tracechtype(ch),
SP->_cursrow, SP->_curscol));
UpdateAttrs(ch);
- putc((int)TextOf(ch), SP->_ofp);
+ if (SP->_cleanup) {
+ _nc_outch((int)TextOf(ch));
+ } else {
+ putc((int)TextOf(ch), SP->_ofp); /* macro's fastest... */
#ifdef TRACE
- _nc_outchars++;
+ _nc_outchars++;
#endif /* TRACE */
+ }
SP->_curscol++;
if (char_padding) {
TPUTS_TRACE("char_padding");
@@ -214,6 +226,21 @@ static bool check_pending(void)
{
have_pending = TRUE;
}
+#elif defined(__BEOS__)
+ /*
+ * BeOS's select() is declared in socket.h, so the configure script does
+ * not see it. That's just as well, since that function works only for
+ * sockets. This (using snooze and ioctl) was distilled from Be's patch
+ * for ncurses which uses a separate thread to simulate select().
+ *
+ * FIXME: the return values from the ioctl aren't very clear if we get
+ * interrupted.
+ */
+ int n = 0;
+ int howmany = ioctl(0, 'ichr', &n);
+ if (howmany >= 0 && n > 0) {
+ have_pending = TRUE;
+ }
#elif HAVE_SELECT
fd_set fdset;
struct timeval ktimeout;
@@ -231,7 +258,7 @@ static bool check_pending(void)
}
if (have_pending) {
SP->_fifohold = 5;
- fflush(SP->_ofp);
+ _nc_flush();
}
return FALSE;
}
@@ -263,6 +290,8 @@ static void PutCharLR(chtype const ch)
putp(exit_am_mode);
PutAttrChar(ch);
+ SP->_curscol--;
+ position_check(SP->_cursrow, SP->_curscol, "exit_am_mode");
TPUTS_TRACE("enter_am_mode");
putp(enter_am_mode);
@@ -309,6 +338,7 @@ static void wrap_cursor(void)
{
SP->_curscol--;
}
+ position_check(SP->_cursrow, SP->_curscol, "wrap_cursor");
}
static inline void PutChar(chtype const ch)
@@ -322,9 +352,7 @@ static inline void PutChar(chtype const ch)
if (SP->_curscol >= screen_columns)
wrap_cursor();
-#ifdef POSITION_DEBUG
position_check(SP->_cursrow, SP->_curscol, "PutChar");
-#endif /* POSITION_DEBUG */
}
/*
@@ -755,7 +783,7 @@ struct tms before, after;
*/
UpdateAttrs(A_NORMAL);
- fflush(SP->_ofp);
+ _nc_flush();
curscr->_attrs = newscr->_attrs;
/* curscr->_bkgd = newscr->_bkgd; */
@@ -844,7 +872,11 @@ bool needclear = FALSE;
{
UpdateAttrs(blank);
TPUTS_TRACE("clr_eol");
- if (SP->_el_cost > (screen_columns - SP->_curscol))
+ if (SP->_el_cost > (screen_columns - SP->_curscol)
+#ifdef NCURSES_EXT_FUNCS
+ || (SP->_coloron && !SP->_default_color && !back_color_erase)
+#endif
+ )
{
int count = (screen_columns - SP->_curscol);
while (count-- > 0)
@@ -865,13 +897,30 @@ static void ClrToEOS(chtype blank)
{
int row, col;
- UpdateAttrs(blank);
- TPUTS_TRACE("clr_eos");
row = SP->_cursrow;
- tputs(clr_eos, screen_lines-row, _nc_outch);
+ col = SP->_curscol;
+
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_coloron && !SP->_default_color && !back_color_erase) {
+ int i, j, k = col;
+ for (i = row; i < screen_lines; i++) {
+ GoTo(i, k);
+ UpdateAttrs(blank);
+ for (j = k; j < screen_columns; j++)
+ PutChar(blank);
+ k = 0;
+ }
+ GoTo(row, col);
+ } else
+#endif
+ {
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clr_eos");
+ tputs(clr_eos, screen_lines-row, _nc_outch);
+ }
- for (col = SP->_curscol; col < screen_columns; col++)
- curscr->_line[row].text[col] = blank;
+ while (col < screen_columns)
+ curscr->_line[row].text[col++] = blank;
for (row++; row < screen_lines; row++)
{
@@ -903,13 +952,14 @@ chtype blank = newscr->_line[total-1].text[last-1]; /* lower right char */
if ((tstLine == 0) || (last > (int)lenLine)) {
tstLine = typeRealloc(chtype, last, tstLine);
+ if (tstLine != 0) {
+ lenLine = last;
+ for (col = 0; col < last; col++)
+ tstLine[col] = blank;
+ }
}
if (tstLine != 0) {
- lenLine = last;
- for (col = 0; col < last; col++)
- tstLine[col] = blank;
-
for (row = total-1; row >= 0; row--) {
if (memcmp(tstLine, newscr->_line[row].text, length))
break;
@@ -930,8 +980,9 @@ chtype blank = newscr->_line[total-1].text[last-1]; /* lower right char */
}
}
#if NO_LEAKS
- if (tstLine != 0)
+ if (tstLine != 0) {
FreeAndNull(tstLine);
+ }
#endif
return total;
}
@@ -1206,37 +1257,53 @@ bool attrchanged = FALSE;
static void ClearScreen(chtype blank)
{
int i, j;
+ bool fast_clear = (clear_screen || clr_eos || clr_eol);
T(("ClearScreen() called"));
- if (clear_screen) {
- UpdateAttrs(blank);
- TPUTS_TRACE("clear_screen");
- putp(clear_screen);
- SP->_cursrow = SP->_curscol = 0;
-#ifdef POSITION_DEBUG
- position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
-#endif /* POSITION_DEBUG */
- } else if (clr_eos) {
- SP->_cursrow = SP->_curscol = -1;
- GoTo(0,0);
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_coloron
+ && !SP->_default_color) {
+ _nc_do_color(0, FALSE, _nc_outch);
+ if (!back_color_erase) {
+ fast_clear = FALSE;
+ }
+ }
+#endif
- UpdateAttrs(blank);
- TPUTS_TRACE("clr_eos");
- putp(clr_eos);
- } else if (clr_eol) {
- SP->_cursrow = SP->_curscol = -1;
+ if (fast_clear) {
+ if (clear_screen) {
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clear_screen");
+ putp(clear_screen);
+ SP->_cursrow = SP->_curscol = 0;
+ position_check(SP->_cursrow, SP->_curscol, "ClearScreen");
+ } else if (clr_eos) {
+ SP->_cursrow = SP->_curscol = -1;
+ GoTo(0,0);
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clr_eos");
+ putp(clr_eos);
+ } else if (clr_eol) {
+ SP->_cursrow = SP->_curscol = -1;
+
+ for (i = 0; i < screen_lines; i++) {
+ GoTo(i, 0);
+ UpdateAttrs(blank);
+ TPUTS_TRACE("clr_eol");
+ putp(clr_eol);
+ }
+ GoTo(0,0);
+ }
+ } else {
for (i = 0; i < screen_lines; i++) {
GoTo(i, 0);
UpdateAttrs(blank);
- TPUTS_TRACE("clr_eol");
- putp(clr_eol);
+ for (j = 0; j < screen_columns; j++)
+ PutChar(blank);
}
GoTo(0,0);
- } else {
- T(("cannot clear screen"));
- return;
}
for (i = 0; i < screen_lines; i++) {
@@ -1254,7 +1321,7 @@ static void ClearScreen(chtype blank)
**
*/
-static int InsStr(chtype *line, int count)
+static void InsStr(chtype *line, int count)
{
T(("InsStr(%p,%d) called", line, count));
@@ -1269,7 +1336,6 @@ static int InsStr(chtype *line, int count)
line++;
count--;
}
- return(OK);
} else if (enter_insert_mode && exit_insert_mode) {
TPUTS_TRACE("enter_insert_mode");
putp(enter_insert_mode);
@@ -1285,7 +1351,6 @@ static int InsStr(chtype *line, int count)
}
TPUTS_TRACE("exit_insert_mode");
putp(exit_insert_mode);
- return(OK);
} else {
while (count) {
TPUTS_TRACE("insert_character");
@@ -1299,8 +1364,8 @@ static int InsStr(chtype *line, int count)
line++;
count--;
}
- return(OK);
}
+ position_check(SP->_cursrow, SP->_curscol, "InsStr");
}
/*
@@ -1334,14 +1399,8 @@ static void DelChar(int count)
void _nc_outstr(const char *str)
{
- FILE *ofp = SP ? SP->_ofp : stdout;
-
- (void) fputs(str, ofp);
- (void) fflush(ofp);
-
-#ifdef TRACE
- _nc_outchars += strlen(str);
-#endif /* TRACE */
+ (void) putp(str);
+ _nc_flush();
}
/*
@@ -1379,7 +1438,7 @@ void _nc_outstr(const char *str)
/* Try to scroll up assuming given csr (miny, maxy). Returns ERR on failure */
static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtype blank)
{
- int i;
+ int i, j;
if (n == 1 && scroll_forward && top == miny && bot == maxy)
{
@@ -1432,6 +1491,15 @@ static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtyp
else
return ERR;
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_coloron && !SP->_default_color && !back_color_erase) {
+ for (i = 0; i < n; i++) {
+ GoTo(bot-i, 0);
+ for (j = 0; j < screen_columns; j++)
+ PutChar(blank);
+ }
+ }
+#endif
return OK;
}
@@ -1439,7 +1507,7 @@ static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtyp
/* n > 0 */
static int scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chtype blank)
{
- int i;
+ int i, j;
if (n == 1 && scroll_reverse && top == miny && bot == maxy)
{
@@ -1492,6 +1560,15 @@ static int scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chty
else
return ERR;
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_coloron && !SP->_default_color && !back_color_erase) {
+ for (i = 0; i < n; i++) {
+ GoTo(top+i, 0);
+ for (j = 0; j < screen_columns; j++)
+ PutChar(blank);
+ }
+ }
+#endif
return OK;
}
@@ -1720,6 +1797,14 @@ void _nc_screen_init()
void _nc_screen_wrap()
{
UpdateAttrs(A_NORMAL);
+#ifdef NCURSES_EXT_FUNCS
+ if (SP->_coloron
+ && !SP->_default_color) {
+ SP->_default_color = TRUE;
+ _nc_do_color(0, FALSE, _nc_outch);
+ SP->_default_color = FALSE;
+ }
+#endif
}
#if USE_XMC_SUPPORT