1: #ifndef lint
   2: static char sccsid[] = "@(#)wwclreol.c	3.14 4/24/85";
   3: #endif
   4: 
   5: /*
   6:  * Copyright (c) 1983 Regents of the University of California,
   7:  * All rights reserved.  Redistribution permitted subject to
   8:  * the terms of the Berkeley Software License Agreement.
   9:  */
  10: 
  11: #include "ww.h"
  12: #include "tt.h"
  13: 
  14: /*
  15:  * Clear w to the end of line.
  16:  * If cleared is true, then the screen line has already been cleared
  17:  * previously.
  18:  */
  19: wwclreol1(w, row, col, cleared)
  20: register struct ww *w;
  21: int row, col;
  22: char cleared;
  23: {
  24:     register i;
  25:     int gain;
  26: 
  27:     /*
  28: 	 * Clear the buffer right off
  29: 	 */
  30:     {
  31:         register union ww_char *buf;
  32: 
  33:         buf = &w->ww_buf[row][col];
  34:         for (i = w->ww_b.r - col; --i >= 0;)
  35:             buf++->c_w = ' ';
  36:     }
  37: 
  38:     /*
  39: 	 * If can't see it, just return.
  40: 	 */
  41:     if (row < w->ww_i.t || row >= w->ww_i.b
  42:         || w->ww_i.r <= 0 || w->ww_i.r <= col)
  43:         return;
  44: 
  45:     if (col < w->ww_i.l)
  46:         col = w->ww_i.l;
  47: 
  48:     /*
  49: 	 * Now find out how much is actually cleared, and fix wwns.
  50: 	 */
  51:     if (cleared) {
  52:         register union ww_char *s;
  53:         register char *smap, *win;
  54: 
  55:         i = col;
  56:         smap = &wwsmap[row][i];
  57:         s = &wwns[row][i];
  58:         win = &w->ww_win[row][i];
  59:         for (i = w->ww_i.r - i; --i >= 0;) {
  60:             if (*smap++ != w->ww_index)
  61:                 continue;
  62:             s++->c_w = ' ' | *win++ << WWC_MSHIFT;
  63:         }
  64:     } else {
  65:         register union ww_char *s;
  66:         register char *smap, *win;
  67:         int ntouched = 0;
  68: 
  69:         i = col;
  70:         smap = &wwsmap[row][i];
  71:         s = wwns[row];
  72:         win = w->ww_win[row];
  73:         gain = 0;
  74:         for (; i < w->ww_i.r; i++) {
  75:             if (*smap++ != w->ww_index) {
  76:                 if (s[i].c_w != ' ')
  77:                     gain--;
  78:             } else if (win[i] == 0) {
  79:                 if (s[i].c_w != ' ') {
  80:                     gain++;
  81:                     ntouched++;
  82:                     s[i].c_w = ' ';
  83:                 }
  84:             } else {
  85:                 short c = ' ' | win[i] << WWC_MSHIFT;
  86:                 if (s[i].c_w == c)
  87:                     gain--;
  88:                 else {
  89:                     s[i].c_w = c;
  90:                     ntouched++;
  91:                 }
  92:             }
  93:         }
  94:         s += i;
  95:         for (i = wwncol - i; --i >= 0;)
  96:             if (s++->c_w != ' ')
  97:                 gain--;
  98:         if (ntouched > 0)
  99:             wwtouched[row] |= WWU_TOUCHED;
 100:     }
 101: 
 102:     /*
 103: 	 * Can/Should we use clear eol?
 104: 	 */
 105:     if (!cleared && tt.tt_clreol != 0 && gain > 4) {
 106:         register union ww_char *s;
 107: 
 108:         /* clear to the end */
 109:         (*tt.tt_move)(row, col);
 110:         (*tt.tt_clreol)();
 111:         s = &wwos[row][col];
 112:         for (i = wwncol - col; --i >= 0;)
 113:             s++->c_w = ' ';
 114:     }
 115: }

Defined functions

Defined variables

sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1903
Valid CSS Valid XHTML 1.0 Strict