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

  1. #include    "stdio.h"
  2. #include    "ed.h"
  3.  
  4. /*
  5.  * This command makes the current
  6.  * window the only window on the screen.
  7.  * Bound to "C-X 1". Try to set the framing
  8.  * so that "." does not have to move on
  9.  * the display. Some care has to be taken
  10.  * to keep the values of dot and mark
  11.  * in the buffer structures right if the
  12.  * distruction of a window makes a buffer
  13.  * become undisplayed.
  14.  */
  15. ovmain(x, f, n)
  16. {
  17.     register WINDOW    *wp;
  18.     register LINE    *lp;
  19.     register int    i;
  20.  
  21.     if ( x == 1 ) return ( reposition( f, n ));
  22.     if ( x == 2 ) return ( refresh( f, n ));
  23.  
  24.     while (wheadp != curwp) {
  25.         wp = wheadp;
  26.         wheadp = wp->w_wndp;
  27.         if (--wp->w_bufp->b_nwnd == 0) {
  28.             wp->w_bufp->b_dotp  = wp->w_dotp;
  29.             wp->w_bufp->b_doto  = wp->w_doto;
  30.             wp->w_bufp->b_markp = wp->w_markp;
  31.             wp->w_bufp->b_marko = wp->w_marko;
  32.         }
  33.         free((char *) wp);
  34.     }
  35.     while (curwp->w_wndp != NULL) {
  36.         wp = curwp->w_wndp;
  37.         curwp->w_wndp = wp->w_wndp;
  38.         if (--wp->w_bufp->b_nwnd == 0) {
  39.             wp->w_bufp->b_dotp  = wp->w_dotp;
  40.             wp->w_bufp->b_doto  = wp->w_doto;
  41.             wp->w_bufp->b_markp = wp->w_markp;
  42.             wp->w_bufp->b_marko = wp->w_marko;
  43.         }
  44.         free((char *) wp);
  45.     }
  46.     lp = curwp->w_linep;
  47.     i  = curwp->w_toprow;
  48.     while (i!=0 && lback(lp)!=curbp->b_linep) {
  49.         --i;
  50.         lp = lback(lp);
  51.     }
  52.     curwp->w_toprow = 0;
  53.     curwp->w_ntrows = 22 /* term.t_nrow-1 */;
  54.     curwp->w_linep  = lp;
  55.     curwp->w_flag  |= WFMODE|WFHARD;
  56.     return (TRUE);
  57. }
  58.  
  59. /*
  60.  * Reposition dot in the current
  61.  * window to line "n". If the argument is
  62.  * positive, it is that line. If it is negative it
  63.  * is that line from the bottom. If it is 0 the window
  64.  * is centered (this is what the standard redisplay code
  65.  * does). With no argument it defaults to 1. Bound to
  66.  * M-!. Because of the default, it works like in
  67.  * Gosling.
  68.  */
  69. reposition(f, n)
  70. {
  71.     curwp->w_force = n;
  72.     curwp->w_flag |= WFFORCE;
  73.     return (TRUE);
  74. }
  75.  
  76. /*
  77.  * Refresh the screen. With no
  78.  * argument, it just does the refresh. With an
  79.  * argument it recenters "." in the current
  80.  * window. Bound to "C-L".
  81.  */
  82. refresh(f, n)
  83. {
  84.     if (f == FALSE)
  85.     {    curwp->w_flag |= WFHARD | WFFORCE;
  86.         sgarbf = TRUE;
  87.     }
  88.     else
  89.     {    curwp->w_force = 0;        /* Center dot.        */
  90.         curwp->w_flag |= WFFORCE;
  91.     }
  92.     return (TRUE);
  93. }
  94.