X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftty%2Ftty_update.c;h=cdf173a3434d50fe2ea87cfa37df7877e8db6867;hp=57222f15f5ff31bbe98af66e3968aed6b560a18a;hb=2782cd7cf38dc9cfaa9d90b7e66792dbc7537b08;hpb=7a27c7d49c2e8b4a1ecbe85b4423d647cbc75ea5 diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index 57222f15..cdf173a3 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 * @@ -30,6 +30,7 @@ * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * ****************************************************************************/ /*----------------------------------------------------------------- @@ -44,6 +45,10 @@ #include +#if defined __HAIKU__ && defined __BEOS__ +#undef __BEOS__ +#endif + #ifdef __BEOS__ #undef false #undef true @@ -74,7 +79,7 @@ #include #include -MODULE_ID("$Id: tty_update.c,v 1.239 2007/04/19 20:57:49 tom Exp $") +MODULE_ID("$Id: tty_update.c,v 1.248 2009/02/15 00:51:22 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -289,7 +294,7 @@ PutAttrChar(CARG_CH_T ch) #endif { PUTC(CHDEREF(ch), SP->_ofp); /* macro's fastest... */ - TRACE_OUTCHARS(1); + COUNT_OUTCHARS(1); } SP->_curscol += chlen; if (char_padding) { @@ -614,7 +619,7 @@ PutRange(const NCURSES_CH_T * otext, if_USE_SCROLL_HINTS(win->_line[row].oldindex = row) NCURSES_EXPORT(int) -doupdate(void) +NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0) { int i; int nonempty; @@ -624,23 +629,28 @@ doupdate(void) T((T_CALLED("doupdate()"))); + if (curscr == 0 + || newscr == 0) + returnCode(ERR); + #ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) { + if (USE_TRACEF(TRACE_UPDATE)) { if (curscr->_clear) _tracef("curscr is clear"); else _tracedump("curscr", curscr); _tracedump("newscr", newscr); + _nc_unlock_global(tracef); } #endif /* TRACE */ _nc_signal_handler(FALSE); - if (SP->_fifohold) - SP->_fifohold--; + if (SP_PARM->_fifohold) + SP_PARM->_fifohold--; #if USE_SIZECHANGE - if (SP->_endwin || _nc_handle_sigwinch(FALSE)) { + if (SP_PARM->_endwin || _nc_handle_sigwinch(SP_PARM)) { /* * This is a transparent extension: XSI does not address it, * and applications need not know that ncurses can do it. @@ -649,24 +659,24 @@ doupdate(void) * (this can happen in an xterm, for example), and resize the * ncurses data structures accordingly. */ - _nc_update_screensize(); + _nc_update_screensize(SP_PARM); } #endif - if (SP->_endwin) { + if (SP_PARM->_endwin) { T(("coming back from shell mode")); reset_prog_mode(); _nc_mvcur_resume(); _nc_screen_resume(); - SP->_mouse_resume(SP); + SP_PARM->_mouse_resume(SP_PARM); - SP->_endwin = FALSE; + SP_PARM->_endwin = FALSE; } #if USE_TRACE_TIMES /* zero the metering machinery */ - _nc_outchars = 0; + RESET_OUTCHARS(); (void) times(&before); #endif /* USE_TRACE_TIMES */ @@ -690,7 +700,7 @@ doupdate(void) for (j = 0; j < screen_columns; j++) { bool failed = FALSE; NCURSES_CH_T *thisline = newscr->_line[i].text; - attr_t thisattr = AttrOf(thisline[j]) & SP->_xmc_triggers; + attr_t thisattr = AttrOf(thisline[j]) & SP_PARM->_xmc_triggers; attr_t turnon = thisattr & ~rattr; /* is an attribute turned on here? */ @@ -708,7 +718,7 @@ doupdate(void) * there's enough room to set the attribute before the first * non-blank in the run. */ -#define SAFE(a) (!((a) & SP->_xmc_triggers)) +#define SAFE(a) (!((a) & SP_PARM->_xmc_triggers)) if (ISBLANK(thisline[j]) && SAFE(turnon)) { RemAttr(thisline[j], turnon); continue; @@ -739,7 +749,7 @@ doupdate(void) for (m = i; m < screen_lines; m++) { for (; n < screen_columns; n++) { attr_t testattr = AttrOf(newscr->_line[m].text[n]); - if ((testattr & SP->_xmc_triggers) == rattr) { + if ((testattr & SP_PARM->_xmc_triggers) == rattr) { end_onscreen = TRUE; TR(TRACE_ATTRS, ("Range attributed with %s ends at (%d, %d)", @@ -800,7 +810,7 @@ doupdate(void) for (p = i; p < screen_lines; p++) { for (; q < screen_columns; q++) { attr_t testattr = AttrOf(newscr->_line[p].text[q]); - if ((testattr & SP->_xmc_triggers) == rattr) + if ((testattr & SP_PARM->_xmc_triggers) == rattr) goto foundend; RemAttr(newscr->_line[p].text[q], turnon); } @@ -826,9 +836,10 @@ doupdate(void) #ifdef TRACE /* show altered highlights after magic-cookie check */ - if (_nc_tracing & TRACE_UPDATE) { + if (USE_TRACEF(TRACE_UPDATE)) { _tracef("After magic-cookie check..."); _tracedump("newscr", newscr); + _nc_unlock_global(tracef); } #endif /* TRACE */ } @@ -836,7 +847,6 @@ doupdate(void) nonempty = 0; if (curscr->_clear || newscr->_clear) { /* force refresh ? */ - TR(TRACE_UPDATE, ("clearing and updating from scratch")); ClrUpdate(); curscr->_clear = FALSE; /* reset flag */ newscr->_clear = FALSE; /* reset flag */ @@ -848,7 +858,7 @@ doupdate(void) nonempty = min(screen_lines, newscr->_maxy + 1); - if (SP->_scrolling) { + if (SP_PARM->_scrolling) { _nc_scroll_optimize(); } @@ -931,6 +941,14 @@ doupdate(void) returnCode(OK); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +doupdate(void) +{ + return NCURSES_SP_NAME(doupdate) (CURRENT_SCREEN); +} +#endif + /* * ClrBlank(win) * @@ -967,7 +985,7 @@ ClrUpdate(void) NCURSES_CH_T blank = ClrBlank(stdscr); int nonempty = min(screen_lines, newscr->_maxy + 1); - TR(TRACE_UPDATE, ("ClrUpdate() called")); + TR(TRACE_UPDATE, (T_CALLED("ClrUpdate"))); ClearScreen(blank); @@ -977,6 +995,8 @@ ClrUpdate(void) for (i = 0; i < nonempty; i++) TransformLine(i); + + TR(TRACE_UPDATE, (T_RETURN(""))); } /* @@ -1154,8 +1174,8 @@ TransformLine(int const lineno) newPair = GetPair(newLine[n]); if (oldPair != newPair && unColor(oldLine[n]) == unColor(newLine[n])) { - if (oldPair < COLOR_PAIRS - && newPair < COLOR_PAIRS + if (oldPair < SP->_pair_limit + && newPair < SP->_pair_limit && SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) { SetPair(oldLine[n], GetPair(newLine[n])); }