[BACK]Return to display.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/display.c between version 1.51 and 1.52

version 1.51, 2023/04/17 09:49:04 version 1.52, 2023/04/21 13:39:37
Line 52 
Line 52 
 };  };
   
 void    vtmove(int, int);  void    vtmove(int, int);
 void    vtputc(int);  void    vtputc(int, struct mgwin *);
 void    vtpute(int);  void    vtpute(int, struct mgwin *);
 int     vtputs(const char *);  int     vtputs(const char *, struct mgwin *);
 void    vteeol(void);  void    vteeol(void);
 void    updext(int, int);  void    updext(int, int);
 void    modeline(struct mgwin *, int);  void    modeline(struct mgwin *, int);
Line 308 
Line 308 
  * Three guesses how we found this.   * Three guesses how we found this.
  */   */
 void  void
 vtputc(int c)  vtputc(int c, struct mgwin *wp)
 {  {
         struct video    *vp;          struct video    *vp;
           int              target;
   
         c &= 0xff;          c &= 0xff;
   
Line 318 
Line 319 
         if (vtcol >= ncol)          if (vtcol >= ncol)
                 vp->v_text[ncol - 1] = '$';                  vp->v_text[ncol - 1] = '$';
         else if (c == '\t') {          else if (c == '\t') {
                   target = ntabstop(vtcol, wp->w_bufp->b_tabw);
                 do {                  do {
                         vtputc(' ');                          vtputc(' ', wp);
                 } while (vtcol < ncol && (vtcol & 0x07) != 0);                  } while (vtcol < ncol && vtcol < target);
         } else if (ISCTRL(c)) {          } else if (ISCTRL(c)) {
                 vtputc('^');                  vtputc('^', wp);
                 vtputc(CCHR(c));                  vtputc(CCHR(c), wp);
         } else if (isprint(c))          } else if (isprint(c))
                 vp->v_text[vtcol++] = c;                  vp->v_text[vtcol++] = c;
         else {          else {
                 char bf[5];                  char bf[5];
   
                 snprintf(bf, sizeof(bf), "\\%o", c);                  snprintf(bf, sizeof(bf), "\\%o", c);
                 vtputs(bf);                  vtputs(bf, wp);
         }          }
 }  }
   
Line 340 
Line 342 
  * margin.   * margin.
  */   */
 void  void
 vtpute(int c)  vtpute(int c, struct mgwin *wp)
 {  {
         struct video *vp;          struct video *vp;
           int target;
   
         c &= 0xff;          c &= 0xff;
   
Line 350 
Line 353 
         if (vtcol >= ncol)          if (vtcol >= ncol)
                 vp->v_text[ncol - 1] = '$';                  vp->v_text[ncol - 1] = '$';
         else if (c == '\t') {          else if (c == '\t') {
                   target = ntabstop(vtcol + lbound, wp->w_bufp->b_tabw);
                 do {                  do {
                         vtpute(' ');                          vtpute(' ', wp);
                 } while (((vtcol + lbound) & 0x07) != 0 && vtcol < ncol);                  } while (((vtcol + lbound) < target) && vtcol < ncol);
         } else if (ISCTRL(c) != FALSE) {          } else if (ISCTRL(c) != FALSE) {
                 vtpute('^');                  vtpute('^', wp);
                 vtpute(CCHR(c));                  vtpute(CCHR(c), wp);
         } else if (isprint(c)) {          } else if (isprint(c)) {
                 if (vtcol >= 0)                  if (vtcol >= 0)
                         vp->v_text[vtcol] = c;                          vp->v_text[vtcol] = c;
Line 365 
Line 369 
   
                 snprintf(bf, sizeof(bf), "\\%o", c);                  snprintf(bf, sizeof(bf), "\\%o", c);
                 for (cp = bf; *cp != '\0'; cp++)                  for (cp = bf; *cp != '\0'; cp++)
                         vtpute(*cp);                          vtpute(*cp, wp);
         }          }
 }  }
   
Line 476 
Line 480 
                         vscreen[i]->v_flag |= (VFCHG | VFHBAD);                          vscreen[i]->v_flag |= (VFCHG | VFHBAD);
                         vtmove(i, 0);                          vtmove(i, 0);
                         for (j = 0; j < llength(lp); ++j)                          for (j = 0; j < llength(lp); ++j)
                                 vtputc(lgetc(lp, j));                                  vtputc(lgetc(lp, j), wp);
                         vteeol();                          vteeol();
                 } else if ((wp->w_rflag & (WFEDIT | WFFULL)) != 0) {                  } else if ((wp->w_rflag & (WFEDIT | WFFULL)) != 0) {
                         hflag = TRUE;                          hflag = TRUE;
Line 486 
Line 490 
                                 vtmove(i, 0);                                  vtmove(i, 0);
                                 if (lp != wp->w_bufp->b_headp) {                                  if (lp != wp->w_bufp->b_headp) {
                                         for (j = 0; j < llength(lp); ++j)                                          for (j = 0; j < llength(lp); ++j)
                                                 vtputc(lgetc(lp, j));                                                  vtputc(lgetc(lp, j), wp);
                                         lp = lforw(lp);                                          lp = lforw(lp);
                                 }                                  }
                                 vteeol();                                  vteeol();
Line 509 
Line 513 
         while (i < curwp->w_doto) {          while (i < curwp->w_doto) {
                 c = lgetc(lp, i++);                  c = lgetc(lp, i++);
                 if (c == '\t') {                  if (c == '\t') {
                         curcol |= 0x07;                          curcol = ntabstop(curcol, curwp->w_bufp->b_tabw);
                         curcol++;  
                 } else if (ISCTRL(c) != FALSE)                  } else if (ISCTRL(c) != FALSE)
                         curcol += 2;                          curcol += 2;
                 else if (isprint(c))                  else if (isprint(c))
Line 545 
Line 548 
                                     (curcol < ncol - 1)) {                                      (curcol < ncol - 1)) {
                                         vtmove(i, 0);                                          vtmove(i, 0);
                                         for (j = 0; j < llength(lp); ++j)                                          for (j = 0; j < llength(lp); ++j)
                                                 vtputc(lgetc(lp, j));                                                  vtputc(lgetc(lp, j), wp);
                                         vteeol();                                          vteeol();
                                         /* this line no longer is extended */                                          /* this line no longer is extended */
                                         vscreen[i]->v_flag &= ~VFEXT;                                          vscreen[i]->v_flag &= ~VFEXT;
Line 677 
Line 680 
         vtmove(currow, -lbound);                /* start scanning offscreen */          vtmove(currow, -lbound);                /* start scanning offscreen */
         lp = curwp->w_dotp;                     /* line to output */          lp = curwp->w_dotp;                     /* line to output */
         for (j = 0; j < llength(lp); ++j)       /* until the end-of-line */          for (j = 0; j < llength(lp); ++j)       /* until the end-of-line */
                 vtpute(lgetc(lp, j));                  vtpute(lgetc(lp, j), curwp);
         vteeol();                               /* truncate the virtual line */          vteeol();                               /* truncate the virtual line */
         vscreen[currow]->v_text[0] = '$';       /* and put a '$' in column 1 */          vscreen[currow]->v_text[0] = '$';       /* and put a '$' in column 1 */
 }  }
Line 793 
Line 796 
         vscreen[n]->v_flag |= (VFCHG | VFHBAD); /* Recompute, display.   */          vscreen[n]->v_flag |= (VFCHG | VFHBAD); /* Recompute, display.   */
         vtmove(n, 0);                           /* Seek to right line.   */          vtmove(n, 0);                           /* Seek to right line.   */
         bp = wp->w_bufp;          bp = wp->w_bufp;
         vtputc('-');          vtputc('-', wp);
         vtputc('-');          vtputc('-', wp);
         if ((bp->b_flag & BFREADONLY) != 0) {          if ((bp->b_flag & BFREADONLY) != 0) {
                 vtputc('%');                  vtputc('%', wp);
                 if ((bp->b_flag & BFCHG) != 0)                  if ((bp->b_flag & BFCHG) != 0)
                         vtputc('*');                          vtputc('*', wp);
                 else                  else
                         vtputc('%');                          vtputc('%', wp);
         } else if ((bp->b_flag & BFCHG) != 0) { /* "*" if changed.       */          } else if ((bp->b_flag & BFCHG) != 0) { /* "*" if changed.       */
                 vtputc('*');                  vtputc('*', wp);
                 vtputc('*');                  vtputc('*', wp);
         } else {          } else {
                 vtputc('-');                  vtputc('-', wp);
                 vtputc('-');                  vtputc('-', wp);
         }          }
         vtputc('-');          vtputc('-', wp);
         n = 5;          n = 5;
         n += vtputs("Mg: ");          n += vtputs("Mg: ", wp);
         if (bp->b_bname[0] != '\0')          if (bp->b_bname[0] != '\0')
                 n += vtputs(&(bp->b_bname[0]));                  n += vtputs(&(bp->b_bname[0]), wp);
         while (n < 42) {                        /* Pad out with blanks.  */          while (n < 42) {                        /* Pad out with blanks.  */
                 vtputc(' ');                  vtputc(' ', wp);
                 ++n;                  ++n;
         }          }
         vtputc('(');          vtputc('(', wp);
         ++n;          ++n;
         for (md = 0; ; ) {          for (md = 0; ; ) {
                 n += vtputs(bp->b_modes[md]->p_name);                  n += vtputs(bp->b_modes[md]->p_name, wp);
                 if (++md > bp->b_nmodes)                  if (++md > bp->b_nmodes)
                         break;                          break;
                 vtputc('-');                  vtputc('-', wp);
                 ++n;                  ++n;
         }          }
         /* XXX These should eventually move to a real mode */          /* XXX These should eventually move to a real mode */
         if (macrodef == TRUE)          if (macrodef == TRUE)
                 n += vtputs("-def");                  n += vtputs("-def", wp);
         if (globalwd == TRUE)          if (globalwd == TRUE)
                 n += vtputs("-gwd");                  n += vtputs("-gwd", wp);
         vtputc(')');          vtputc(')', wp);
         ++n;          ++n;
   
         if (linenos && colnos)          if (linenos && colnos)
Line 842 
Line 845 
         else if (colnos)          else if (colnos)
                 len = snprintf(sl, sizeof(sl), "--C%d", getcolpos(wp));                  len = snprintf(sl, sizeof(sl), "--C%d", getcolpos(wp));
         if ((linenos || colnos) && len < sizeof(sl) && len != -1)          if ((linenos || colnos) && len < sizeof(sl) && len != -1)
                 n += vtputs(sl);                  n += vtputs(sl, wp);
   
         while (n < ncol) {                      /* Pad out.              */          while (n < ncol) {                      /* Pad out.              */
                 vtputc('-');                  vtputc('-', wp);
                 ++n;                  ++n;
         }          }
 }  }
Line 854 
Line 857 
  * Output a string to the mode line, report how long it was.   * Output a string to the mode line, report how long it was.
  */   */
 int  int
 vtputs(const char *s)  vtputs(const char *s, struct mgwin *wp)
 {  {
         int n = 0;          int n = 0;
   
         while (*s != '\0') {          while (*s != '\0') {
                 vtputc(*s++);                  vtputc(*s++, wp);
                 ++n;                  ++n;
         }          }
         return (n);          return (n);

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52