Back to index

tetex-bin  3.0
Defines | Functions | Variables
hardscroll.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Defines

#define OLDNUM(n)   newscr->_line[n].oldindex

Functions

 _nc_scroll_optimize (void)

Variables

 _nc_oldnums = 0

Define Documentation

#define OLDNUM (   n)    newscr->_line[n].oldindex

Definition at line 174 of file hardscroll.c.


Function Documentation

Definition at line 180 of file hardscroll.c.

{
    int i;
    int start, end, shift;

    TR(TRACE_ICALLS, ("_nc_scroll_optimize() begins"));

#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
#if USE_HASHMAP
    /* get enough storage */
    if (oldnums_allocated < screen_lines) {
       int *new_oldnums = typeRealloc(int, screen_lines, oldnums);
       if (!new_oldnums)
           return;
       oldnums = new_oldnums;
       oldnums_allocated = screen_lines;
    }
    /* calculate the indices */
    _nc_hash_map();
#endif
#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */

#ifdef TRACE
    if (_nc_tracing & (TRACE_UPDATE | TRACE_MOVE))
       _nc_linedump();
#endif /* TRACE */

    /* pass 1 - from top to bottom scrolling up */
    for (i = 0; i < screen_lines;) {
       while (i < screen_lines && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) <= i))
           i++;
       if (i >= screen_lines)
           break;

       shift = OLDNUM(i) - i;      /* shift > 0 */
       start = i;

       i++;
       while (i < screen_lines && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i
              == shift)
           i++;
       end = i - 1 + shift;

       TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
       if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
           TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
           continue;
       }
#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
    }

    /* pass 2 - from bottom to top scrolling down */
    for (i = screen_lines - 1; i >= 0;) {
       while (i >= 0 && (OLDNUM(i) == _NEWINDEX || OLDNUM(i) >= i))
           i--;
       if (i < 0)
           break;

       shift = OLDNUM(i) - i;      /* shift < 0 */
       end = i;

       i--;
       while (i >= 0 && OLDNUM(i) != _NEWINDEX && OLDNUM(i) - i == shift)
           i--;
       start = i + 1 - (-shift);

       TR(TRACE_UPDATE | TRACE_MOVE, ("scroll [%d, %d] by %d", start, end, shift));
#if !defined(SCROLLDEBUG) && !defined(HASHDEBUG)
       if (_nc_scrolln(shift, start, end, screen_lines - 1) == ERR) {
           TR(TRACE_UPDATE | TRACE_MOVE, ("unable to scroll"));
           continue;
       }
#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 167 of file hardscroll.c.