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

  1. #include "rv.h"
  2.  
  3. void
  4. change()
  5. /*
  6.  *  Change - change text
  7.  */
  8. {
  9.     register struct li_line      *line;
  10.     register struct sc_screen *sc;
  11.     register struct wi_window *wi;
  12.  
  13.     sc = &screen;
  14.     wi = &window;
  15.  
  16.     file.fi_modified = TRUE;
  17.     /*
  18.      * Three cases:  lines, columns, or both
  19.      */
  20.     if (sc->sc_validcol) { /* If columns */
  21.         if (sc->sc_firstline != sc->sc_lastline) { /* If both */
  22.             botprint(TRUE,
  23.                 "Cant change columns within multiple lines yet.\n");
  24.             return;
  25.         }
  26.         sc->sc_column = sc->sc_firstcol;
  27.         insert();
  28.     }
  29.     else { /* If lines */
  30.         if (sc->sc_firstline == sc->sc_lastline) {
  31.             /*
  32.              * Simple case - change 1 line
  33.              */
  34.             sc->sc_column = 0;
  35.             sc->sc_firstcol = 0;
  36.             sc->sc_lastcol = sc->sc_curline->li_width-1;
  37.             yank_cmd = ' ';
  38.             if (sc->sc_lastcol >= 0) {
  39.                 undo.un_deleted = TRUE;
  40.                 yank();  /* Save for later undo */
  41.             }
  42.             sc->sc_curline->li_width = 0;
  43.             sc->sc_curline->li_segments = 1;
  44.             sc->sc_curline->li_text[0] = '\0';
  45.             sc->sc_lastcol = -1;
  46.             insert();
  47.         }
  48.         else {
  49.             /*
  50.              * Change multiple lines
  51.              */
  52.             delete();
  53.             sc->sc_column = 0;
  54.             if (sc->sc_lineno == file.fi_numlines) /* If bottom */
  55.                 if (sc->sc_lineno != 1) /* If not top */
  56.                     openline(1);
  57.                 else { /* Single line in file, replace */
  58.                     sc->sc_firstcol = 0;
  59.                     sc->sc_lastcol = -1;
  60.                 }
  61.             else
  62.                 openline(-1);
  63.             botprint(FALSE, "%d lines changed",
  64.                 sc->sc_lastline - sc->sc_firstline + 1);
  65.             insert();
  66.         }
  67.     }
  68. }
  69.