home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / emacs / src / basic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-07  |  2.1 KB  |  91 lines

  1. /*
  2.  * The routines in this file
  3.  * move the cursor around on the screen.
  4.  * They compute a new value for the cursor, then
  5.  * adjust ".". The display code always updates the
  6.  * cursor location, so only moves between lines,
  7.  * or functions that adjust the top line in the window
  8.  * and invalidate the framing, are hard.
  9.  */
  10. #include    "stdio.h"
  11. #include    "ed.h"
  12. int tabsize;
  13. #ifdef OLDMAP
  14. /*
  15.  * Move the cursor to the
  16.  * beginning of the current line.
  17.  * Trivial.
  18.  */
  19. gotobol(f, n)
  20. {
  21.     curwp->w_doto  = 0;
  22.     return (TRUE);
  23. }
  24. #endif
  25. /*
  26.  * Move the cursor backwards by
  27.  * "n" characters. If "n" is less than
  28.  * zero call "forwchar" to actually do the
  29.  * move. Otherwise compute the new cursor
  30.  * location. Error if you try and move
  31.  * out of the buffer. Set the flag if the
  32.  * line pointer for dot changes.
  33.  */
  34. backchar(f, n)
  35. register int    n;
  36. {
  37.     register LINE    *lp;
  38.  
  39.     if (n < 0)
  40.         return (forwchar(f, -n));
  41.     while (n--)
  42.     {    if (curwp->w_doto == 0)
  43.         {    if ((lp=lback(curwp->w_dotp)) == curbp->b_linep)
  44.                 return (FALSE);
  45.             curwp->w_dotp  = lp;
  46.             curwp->w_doto  = llength(lp);
  47.             curwp->w_flag |= WFMOVE;
  48.         } else     curwp->w_doto--;
  49.     }
  50.     return (TRUE);
  51. }
  52. #ifdef OLDMAP
  53. /*
  54.  * Move the cursor to the end
  55.  * of the current line. Trivial.
  56.  * No errors.
  57.  */
  58. gotoeol(f, n)
  59. {
  60.     curwp->w_doto  = llength(curwp->w_dotp);
  61.     return (TRUE);
  62. }
  63. #endif
  64. /*
  65.  * Move the cursor forwwards by
  66.  * "n" characters. If "n" is less than
  67.  * zero call "backchar" to actually do the
  68.  * move. Otherwise compute the new cursor
  69.  * location, and move ".". Error if you
  70.  * try and move off the end of the
  71.  * buffer. Set the flag if the line pointer
  72.  * for dot changes.
  73.  */
  74. forwchar(f, n)
  75. register int    n;
  76. {
  77.     if (n < 0)
  78.         return (backchar(f, -n));
  79.     while (n--)
  80.     {    if (curwp->w_doto == llength(curwp->w_dotp))
  81.         {    if (curwp->w_dotp == curbp->b_linep)
  82.                 return (FALSE);
  83.             curwp->w_dotp  = lforw(curwp->w_dotp);
  84.             curwp->w_doto  = 0;
  85.             curwp->w_flag |= WFMOVE;
  86.         } else
  87.             curwp->w_doto++;
  88.     }
  89.     return (TRUE);
  90. }
  91.