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

Diff for /src/usr.bin/mg/util.c between version 1.32 and 1.33

version 1.32, 2013/03/25 11:41:44 version 1.33, 2014/03/26 22:02:06
Line 103 
Line 103 
 }  }
   
 /*  /*
  * Twiddle the two characters on either side of dot.  If dot is at the end   * Twiddle the two characters in front of and under dot, then move forward
  * of the line twiddle the two characters before it.  Return with an error   * one character.  Treat new-line characters the same as any other.
  * if dot is at the beginning of line; it seems to be a bit pointless to   * Normally bound to "C-t".  This always works within a line, so "WFEDIT"
  * make this work.  This fixes up a very common typo with a single stroke.  
  * Normally bound to "C-T".  This always works within a line, so "WFEDIT"  
  * is good enough.   * is good enough.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 116 
Line 114 
 {  {
         struct line     *dotp;          struct line     *dotp;
         int      doto, cr;          int      doto, cr;
         int      fudge = FALSE;  
   
         dotp = curwp->w_dotp;          dotp = curwp->w_dotp;
         doto = curwp->w_doto;          doto = curwp->w_doto;
         if (doto == llength(dotp)) {  
                 if (--doto <= 0)          /* Don't twiddle if the dot is on the first char of buffer */
                         return (FALSE);          if (doto == 0 && lback(dotp) == curbp->b_headp) {
                 (void)backchar(FFRAND, 1);                  dobeep();
                 fudge = TRUE;                  ewprintf("Beginning of buffer");
         } else {                  return(FALSE);
                 if (doto == 0)  
                         return (FALSE);  
         }          }
           /* Don't twiddle if the dot is on the last char of buffer */
           if (doto == llength(dotp) && lforw(dotp) == curbp->b_headp) {
                   dobeep();
                   return(FALSE);
           }
         undo_boundary_enable(FFRAND, 0);          undo_boundary_enable(FFRAND, 0);
         cr = lgetc(dotp, doto - 1);          if (doto == 0 && doto == llength(dotp)) { /* only '\n' on this line */
         (void)backdel(FFRAND, 1);                  (void)forwline(FFRAND, 1);
         (void)forwchar(FFRAND, 1);                  curwp->w_doto = 0;
         linsert(1, cr);          } else {
         if (fudge != TRUE)                  if (doto == 0) { /* 1st twiddle is on 1st character of a line */
                 (void)backchar(FFRAND, 1);                          cr = lgetc(dotp, doto);
                           (void)backdel(FFRAND, 1);
                           (void)forwchar(FFRAND, 1);
                           lnewline();
                           linsert(1, cr);
                           (void)backdel(FFRAND, 1);
                   } else {        /* twiddle is elsewhere in line */
                           cr = lgetc(dotp, doto - 1);
                           (void)backdel(FFRAND, 1);
                           (void)forwchar(FFRAND, 1);
                           linsert(1, cr);
                   }
           }
         undo_boundary_enable(FFRAND, 1);          undo_boundary_enable(FFRAND, 1);
         lchange(WFEDIT);          lchange(WFEDIT);
         return (TRUE);          return (TRUE);

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33