[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.5 and 1.6

version 1.5, 2001/05/23 22:20:36 version 1.6, 2001/05/24 03:05:25
Line 2 
Line 2 
   
 /*  /*
  *              Assorted commands.   *              Assorted commands.
  * This file contains the command processors for a large assortment of   * This file contains the command processors for a large assortment of
  * unrelated commands.  The only thing they have in common is that they   * unrelated commands.  The only thing they have in common is that they
  * are all command processors.   * are all command processors.
  */   */
   
 #include "def.h"  #include "def.h"
   
 /*  /*
  * Display a bunch of useful information about the current location of dot.   * Display a bunch of useful information about the current location of dot.
  * The character under the cursor (in octal), the current line, row, and   * The character under the cursor (in octal), the current line, row, and
  * column, and approximate position of the cursor in the file (as a   * column, and approximate position of the cursor in the file (as a
  * percentage) is displayed.  The column position assumes an infinite   * percentage) is displayed.  The column position assumes an infinite
  * position display; it does not truncate just because the screen does.   * position display; it does not truncate just because the screen does.
  * This is normally bound to "C-X =".   * This is normally bound to "C-X =".
  */   */
Line 23 
Line 23 
         int f, n;          int f, n;
 {  {
         LINE    *clp;          LINE    *clp;
         long     nchar;          long     nchar;
         long     cchar;          long     cchar;
         int      nline, row;          int      nline, row;
         int      cline, cbyte;          /* Current line/char/byte */          int      cline, cbyte;          /* Current line/char/byte */
Line 36 
Line 36 
         cbyte = 0;          cbyte = 0;
         nchar = 0;          nchar = 0;
         nline = 0;          nline = 0;
         for (;;) {          for (;;) {
                 /* count this line */                  /* count this line */
                 ++nline;                  ++nline;
                 if (clp == curwp->w_dotp) {                  if (clp == curwp->w_dotp) {
Line 95 
Line 95 
 }  }
   
 /*  /*
  * Twiddle the two characters on either side of dot.  If dot is at the end   * Twiddle the two characters on either side of dot.  If dot is at the end
  * of the line twiddle the two characters before it.  Return with an error   * of the line twiddle the two characters before it.  Return with an error
  * if dot is at the beginning of line; it seems to be a bit pointless to   * if dot is at the beginning of line; it seems to be a bit pointless to
  * make this work.  This fixes up a very common typo with a single stroke.   * 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"   * Normally bound to "C-T".  This always works within a line, so "WFEDIT"
  * is good enough.   * is good enough.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 128 
Line 128 
 }  }
   
 /*  /*
  * Open up some blank space.  The basic plan is to insert a bunch of   * Open up some blank space.  The basic plan is to insert a bunch of
  * newlines, and then back up over them.  Everything is done by the   * newlines, and then back up over them.  Everything is done by the
  * subcommand procerssors.  They even handle the looping.  Normally this   * subcommand procerssors.  They even handle the looping.  Normally this
  * is bound to "C-O".   * is bound to "C-O".
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 161 
Line 161 
 /*  /*
  * Insert a newline.  [following "feature" not present in current version of   * Insert a newline.  [following "feature" not present in current version of
  * Gnu, and now disabled here too] If you are at the end of the line and the   * Gnu, and now disabled here too] If you are at the end of the line and the
  * next line is a blank line, just move into the blank line.  This makes   * next line is a blank line, just move into the blank line.  This makes
  * "C-O" and "C-X C-O" work nicely, and reduces the ammount of screen update   * "C-O" and "C-X C-O" work nicely, and reduces the ammount of screen update
  * that has to be done.  This would not be as critical if screen update were a   * that has to be done.  This would not be as critical if screen update were a
  * lot more efficient.   * lot more efficient.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 195 
Line 195 
   
 /*  /*
  * Delete blank lines around dot. What this command does depends if dot is   * Delete blank lines around dot. What this command does depends if dot is
  * sitting on a blank line. If dot is sitting on a blank line, this command   * sitting on a blank line. If dot is sitting on a blank line, this command
  * deletes all the blank lines above and below the current line. If it is   * deletes all the blank lines above and below the current line. If it is
  * sitting on a non blank line then it deletes all of the blank lines after   * sitting on a non blank line then it deletes all of the blank lines after
  * the line. Normally this command is bound to "C-X C-O". Any argument is   * the line. Normally this command is bound to "C-X C-O". Any argument is
  * ignored.   * ignored.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 266 
Line 266 
   
 /*  /*
  * Insert a newline, then enough tabs and spaces to duplicate the indentation   * Insert a newline, then enough tabs and spaces to duplicate the indentation
  * of the previous line.  Assumes tabs are every eight characters.  Quite   * of the previous line.  Assumes tabs are every eight characters.  Quite
  * simple.  Figure out the indentation of the current line.  Insert a newline   * simple.  Figure out the indentation of the current line.  Insert a newline
  * by calling the standard routine.  Insert the indentation by inserting the   * by calling the standard routine.  Insert the indentation by inserting the
  * right number of tabs and spaces.  Return TRUE if all ok.  Return FALSE if   * right number of tabs and spaces.  Return TRUE if all ok.  Return FALSE if
  * one of the subcomands failed. Normally bound to "C-J".   * one of the subcomands failed. Normally bound to "C-J".
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 307 
Line 307 
   
 /*  /*
  * Delete forward.  This is real easy, because the basic delete routine does   * Delete forward.  This is real easy, because the basic delete routine does
  * all of the work.  Watches for negative arguments, and does the right thing.   * all of the work.  Watches for negative arguments, and does the right thing.
  * If any argument is present, it kills rather than deletes, to prevent loss   * If any argument is present, it kills rather than deletes, to prevent loss
  * of text if typed with a big argument.  Normally bound to "C-D".   * of text if typed with a big argument.  Normally bound to "C-D".
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 330 
Line 330 
 }  }
   
 /*  /*
  * Delete backwards.  This is quite easy too, because it's all done with   * Delete backwards.  This is quite easy too, because it's all done with
  * other functions.  Just move the cursor back, and delete forwards.  Like   * other functions.  Just move the cursor back, and delete forwards.  Like
  * delete forward, this actually does a kill if presented with an argument.   * delete forward, this actually does a kill if presented with an argument.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 357 
Line 357 
 }  }
   
 /*  /*
  * Kill line.  If called without an argument, it kills from dot to the end   * Kill line.  If called without an argument, it kills from dot to the end
  * of the line, unless it is at the end of the line, when it kills the   * of the line, unless it is at the end of the line, when it kills the
  * newline.  If called with an argument of 0, it kills from the start of the   * newline.  If called with an argument of 0, it kills from the start of the
  * line to dot.  If called with a positive argument, it kills from dot   * line to dot.  If called with a positive argument, it kills from dot
  * forward over that number of newlines.  If called with a negative argument   * forward over that number of newlines.  If called with a negative argument
  * it kills any text before dot on the current line, then it kills back   * it kills any text before dot on the current line, then it kills back
  * abs(arg) lines.   * abs(arg) lines.
  */   */
 /* ARGSUSED */  /* ARGSUSED */
Line 420 
Line 420 
 }  }
   
 /*  /*
  * Yank text back from the kill buffer.  This is really easy.  All of the work   * Yank text back from the kill buffer.  This is really easy.  All of the work
  * is done by the standard insert routines.  All you do is run the loop, and   * is done by the standard insert routines.  All you do is run the loop, and
  * check for errors.  The blank lines are inserted with a call to "newline"   * check for errors.  The blank lines are inserted with a call to "newline"
  * instead of a call to "lnewline" so that the magic stuff that happens when   * instead of a call to "lnewline" so that the magic stuff that happens when
  * you type a carriage return also happens when a carriage return is yanked   * you type a carriage return also happens when a carriage return is yanked
  * back from the kill buffer.  An attempt has been made to fix the cosmetic   * back from the kill buffer.  An attempt has been made to fix the cosmetic
  * bug associated with a yank when dot is on the top line of the window   * bug associated with a yank when dot is on the top line of the window
  * (nothing moves, because all of the new text landed off screen).   * (nothing moves, because all of the new text landed off screen).
  */   */
 /* ARGSUSED */  /* ARGSUSED */

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6