home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / TextEditors&Viewers / Texteditors / FFRED10.LHA / fpl / EmacsKill.FPL < prev    next >
Encoding:
Text File  |  1994-10-19  |  1.7 KB  |  47 lines

  1. /*
  2.  * Emacs kill-line embryo.
  3.  * Killed lines will get copied into the block buffer before deleted. Note that
  4.  * the first killed line will first clear the block buffer, and kills following
  5.  * that one will append them to the current one.
  6.  *
  7.  * Paste the buffer with BlockPaste() or BlockPasteRect() just as usual blocks.
  8.  */
  9.  
  10. int __counter; /* internal counter, were we invoked last interactive round? */
  11. export int __yankID;  /* ID of the block buffer */
  12.  
  13. void export kill_line()
  14. {
  15.    int this_count = ReadInfo("counter");
  16.    if ((this_count != __counter)&&(this_count != __counter+1)) {
  17.        /* We were not invoked this/last action, clear the buffer */
  18.        Clean("Clear(__yankID);"); /* Clear the block without any hooks */
  19.    }
  20.    __counter = ReadInfo("counter");
  21.    if(Isnewline(GetChar())) {
  22.        /* standing on a newline character */
  23.        int oldID = GetEntryID(); /* get current entry */
  24.        Delete();                 /* delete the newline character */
  25.        CurrentBuffer(__yankID);  /* switch to the block buffer */
  26.        GotoLine(-1);             /* jump to the bottom */
  27.        GotoLine(ReadInfo("line"),
  28.                 ReadInfo("line_length")); /* jump to end of line */
  29.        Output("\n");             /* add a newline to the buffer */
  30.        CurrentBuffer(oldID);     /* switch back to previous buffer */
  31.    }
  32.    else {
  33.        /* delete to end of line */
  34.        int curr_col = ReadInfo("column"); /* get current column */
  35.        int end_col = GetCursor(ReadInfo("line_length")); /* get column of the
  36.                                                             end of line */
  37.        int curr_line = ReadInfo("line");  /* get line number */
  38.  
  39.        BlockCopyAppend(__yankID, end_col, curr_line, curr_col, curr_line);  /* append the line to the block */
  40.  
  41.        DeleteEol();    /* delete to the end of line */
  42.    }
  43. }
  44.  
  45. __yankID = GetBufferID("DefaultBlock");
  46.  
  47.