home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / rvi / part1 / rv_dot.c < prev   
Encoding:
C/C++ Source or Header  |  1986-11-30  |  1.7 KB  |  89 lines

  1. #include "rv.h"
  2.  
  3. void
  4. rv_dot()
  5. /*
  6.  * repeat last change
  7.  */
  8. {
  9.     register struct sc_screen *sc;
  10.     register struct ya_yank      *yk;
  11.     INT direction = -1;
  12.     INT saveline, savecol;
  13.  
  14.     sc = &screen;
  15.     yk = &yank_array[0];
  16.  
  17.     /*
  18.      * See if there is something to repeat
  19.      */
  20.     if (undo.un_deleted == FALSE && undo.un_inserted == FALSE) {
  21.         flash();
  22.         errflag = 1;
  23.         return;
  24.     }
  25.  
  26.     /*
  27.      * Put last inserted text
  28.      */
  29.     if (undo.un_inserted) {
  30.         saveline = sc->sc_lineno;
  31.         savecol = sc->sc_column;
  32.         /*
  33.          * Yank text from old location
  34.          */
  35.         move_abs_cursor(undo.un_firstline, 0);
  36.         sc->sc_firstline = undo.un_firstline;
  37.         sc->sc_lastline = undo.un_lastline;
  38.         if (undo.un_validcol == FALSE)
  39.             sc->sc_validcol = FALSE;
  40.         else {
  41.             sc->sc_validcol = TRUE;
  42.             sc->sc_firstcol = undo.un_firstcol;
  43.             sc->sc_lastcol = undo.un_lastcol;
  44.         }
  45.         yank_cmd = '.';
  46.         yank();
  47.         move_abs_cursor(saveline, savecol);
  48.     }
  49.  
  50.     /*
  51.      * Repeat last deletion
  52.      */
  53.     if (undo.un_deleted && yk->ya_type != YANK_EMPTY) {
  54.         sc->sc_firstline = sc->sc_lineno;
  55.         if (yk->ya_type != YANK_COLS) {
  56.             sc->sc_validcol = FALSE;
  57.             sc->sc_lastline = sc->sc_firstline + yk->ya_numlines-1;
  58.         }
  59.         else {
  60.             sc->sc_validcol = TRUE;
  61.             sc->sc_lastline = sc->sc_firstline;
  62.             sc->sc_firstcol = sc->sc_column;
  63.             sc->sc_lastcol = sc->sc_firstcol + yk->ya_width - 1;
  64.             if (sc->sc_lastcol >= sc->sc_curline->li_width)
  65.                 sc->sc_lastcol = sc->sc_curline->li_width-1;
  66.             if (sc->sc_lastcol < 0) {
  67.                 flash();
  68.                 errflag = 1;
  69.                 return;
  70.             }
  71.         }
  72.         yank_cmd = ' ';
  73.         delete();
  74.     }
  75.  
  76.     /*
  77.      * Repeat last insertion
  78.      */
  79.     if (undo.un_inserted) {
  80.         yank_cmd = '.';
  81.         if (undo.un_validcol == TRUE)
  82.             /*
  83.              * Dot inserts changes before the cursor
  84.              */
  85.             sc->sc_column--;
  86.         put(direction);
  87.     }
  88. }
  89.