home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / cpm / emacs / emacssrc.lzh / medisp.c < prev    next >
C/C++ Source or Header  |  1992-03-11  |  2KB  |  81 lines

  1. #include "medisp.h"
  2.  
  3. /*
  4.  * Update a single line. This
  5.  * does not know how to use insert
  6.  * or delete character sequences; we are
  7.  * using VT52 functionality. Update the physical
  8.  * row and column variables. It does try an
  9.  * exploit erase to end of line. The RAINBOW version
  10.  * of this routine uses fast video.
  11.  */
  12. updateline(row, vline, pline)
  13. char    *vline;
  14. char    *pline;
  15. {
  16.     register char    *cp1;
  17.     register char    *cp2;
  18. #define cp3 (*(char **)0x110)
  19. #define cp4 (*(char **)0x112)
  20. #define cp5 (*(char **)0x114)
  21. #define nbflag (*(int *)0x116)
  22.  
  23.     cp1 = vline;    /* Compute left match.    */
  24.     cp2 = pline;
  25.     cp5 = &vline[80];
  26.     while ( *cp1 == *cp2 )
  27.     {    if (cp1 == cp5) return;/* All equal. */
  28.         ++cp1;
  29.         ++cp2;
  30.     }
  31.     /* This can still happen, even though we only call this routine    */
  32.     /* on changed lines. A hard update is always done when a line    */
  33.     /* splits, a massive change is done, or a buffer is displayed    */
  34.     /* twice. This optimizes out most of the excess updating. A lot    */
  35.     /* of computes are used, but these tend to be hard operations    */
  36.     /* that do a lot of update, so I don't really care.        */
  37.     nbflag = FALSE;
  38.     cp3 = cp5;    /* Compute right match.    */
  39.     cp4 = &pline[80];
  40.     while ( *(--cp3) == *(--cp4) )
  41.     {    if ( *cp3 != ' ')        /* Note if any nonblank    */
  42.             nbflag = TRUE;        /* in right match.    */
  43.     }
  44.     cp5 = ++cp3; ++cp4;
  45.     if (nbflag == FALSE)    /* Erase to EOL ?    */
  46.     {    while ( cp5 != cp1 && cp5[ -1 ] == ' ' )
  47.             --cp5;
  48. #ifdef NEVER
  49.         if ( cp3 - cp5 <= 3 )        /* Use only if erase is    */
  50.             cp5 = cp3;        /* fewer characters.    */
  51. #endif
  52.     }
  53.     movecursor(row, cp1 - &vline[0]);    /* Go to start of line.    */
  54.     while (cp1 != cp5)    /* Ordinary.        */
  55.     {    conout( *cp2++ = *cp1++ );
  56.         ++ttcol;
  57.         /* *cp2++ = *cp1++; */
  58.     }
  59.     if (cp5 != cp3)        /* Erase.        */
  60.     {    ansieeol();
  61.         while (cp1 != cp3)
  62.             *cp2++ = *cp1++;
  63.     }
  64. }
  65. /*
  66.  * Send a command to the terminal
  67.  * to move the hardware cursor to row "row"
  68.  * and column "col". The row and column arguments
  69.  * are origin 0. Optimize out random calls.
  70.  * Update "ttrow" and "ttcol".
  71.  */
  72. movecursor(row, col)
  73. int row, col;
  74. {
  75.     if ( row != ttrow || col != ttcol )
  76.     {    ttrow = row;
  77.         ttcol = col;
  78.         ansimove( row, col );
  79.     }
  80. }
  81.