Annotation of src/usr.bin/mg/buffer.c, Revision 1.4
1.1 deraadt 1: /*
2: * Buffer handling.
3: */
1.4 ! millert 4:
! 5: #include "def.h"
! 6: #include "kbd.h" /* needed for modes */
1.1 deraadt 7:
1.3 millert 8: static RSIZE itor __P((char *, int, RSIZE));
9: static BUFFER *makelist __P((void));
1.1 deraadt 10:
11: /*
12: * Attach a buffer to a window. The values of dot and mark come
13: * from the buffer if the use count is 0. Otherwise, they come
14: * from some other window. *scratch* is the default alternate
15: * buffer.
16: */
1.3 millert 17: /* ARGSUSED */
18: int
1.1 deraadt 19: usebuffer(f, n)
1.3 millert 20: int f, n;
1.1 deraadt 21: {
1.3 millert 22: BUFFER *bp;
23: int s;
24: char bufn[NBUFN];
1.1 deraadt 25:
26: /* Get buffer to use from user */
27: if ((curbp->b_altb == NULL)
28: && ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
1.3 millert 29: s = eread("Switch to buffer: ", bufn, NBUFN, EFNEW | EFBUF);
1.1 deraadt 30: else
1.3 millert 31: s = eread("Switch to buffer: (default %s) ", bufn, NBUFN,
32: EFNEW | EFBUF, curbp->b_altb->b_bname);
1.1 deraadt 33:
1.3 millert 34: if (s == ABORT)
35: return s;
36: if (s == FALSE && curbp->b_altb != NULL)
37: bp = curbp->b_altb;
38: else if ((bp = bfind(bufn, TRUE)) == NULL)
39: return FALSE;
1.1 deraadt 40:
41: /* and put it in current window */
42: curbp = bp;
1.3 millert 43: return showbuffer(bp, curwp, WFFORCE | WFHARD);
1.1 deraadt 44: }
45:
46: /*
47: * pop to buffer asked for by the user.
48: */
1.3 millert 49: /* ARGSUSED */
50: int
1.1 deraadt 51: poptobuffer(f, n)
1.3 millert 52: int f, n;
1.1 deraadt 53: {
1.3 millert 54: BUFFER *bp;
55: MGWIN *wp;
56: int s;
57: char bufn[NBUFN];
1.1 deraadt 58:
59: /* Get buffer to use from user */
60: if ((curbp->b_altb == NULL)
61: && ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
1.3 millert 62: s = eread("Switch to buffer in other window: ", bufn, NBUFN,
63: EFNEW | EFBUF);
1.1 deraadt 64: else
1.3 millert 65: s = eread("Switch to buffer in other window: (default %s) ",
66: bufn, NBUFN, EFNEW | EFBUF, curbp->b_altb->b_bname);
67: if (s == ABORT)
68: return s;
69: if (s == FALSE && curbp->b_altb != NULL)
70: bp = curbp->b_altb;
71: else if ((bp = bfind(bufn, TRUE)) == NULL)
72: return FALSE;
1.1 deraadt 73:
74: /* and put it in a new window */
1.3 millert 75: if ((wp = popbuf(bp)) == NULL)
76: return FALSE;
1.1 deraadt 77: curbp = bp;
78: curwp = wp;
79: return TRUE;
80: }
81:
82: /*
83: * Dispose of a buffer, by name.
84: * Ask for the name. Look it up (don't get too
85: * upset if it isn't there at all!). Clear the buffer (ask
86: * if the buffer has been changed). Then free the header
87: * line and the buffer header. Bound to "C-X K".
88: */
1.3 millert 89: /* ARGSUSED */
90: int
1.1 deraadt 91: killbuffer(f, n)
1.3 millert 92: int f, n;
1.1 deraadt 93: {
1.3 millert 94: BUFFER *bp;
95: BUFFER *bp1;
96: BUFFER *bp2;
97: MGWIN *wp;
98: int s;
99: char bufn[NBUFN];
100:
101: if ((s = eread("Kill buffer: (default %s) ", bufn, NBUFN, EFNEW | EFBUF,
102: curbp->b_bname)) == ABORT)
103: return (s);
104: else if (s == FALSE)
105: bp = curbp;
106: else if ((bp = bfind(bufn, FALSE)) == NULL)
107: return FALSE;
108:
109: /*
110: * Find some other buffer to display. try the alternate buffer,
111: * then the first different buffer in the buffer list. If there's
112: * only one buffer, create buffer *scratch* and make it the alternate
113: * buffer. Return if *scratch* is only buffer...
1.1 deraadt 114: */
115: if ((bp1 = bp->b_altb) == NULL) {
116: bp1 = (bp == bheadp) ? bp->b_bufp : bheadp;
117: if (bp1 == NULL) {
118: /* only one buffer. see if it's *scratch* */
1.3 millert 119: if (bp == bfind("*scratch*", FALSE))
1.1 deraadt 120: return FALSE;
121: /* create *scratch* for alternate buffer */
1.3 millert 122: if ((bp1 = bfind("*scratch*", TRUE)) == NULL)
1.1 deraadt 123: return FALSE;
124: }
125: }
1.3 millert 126: if (bclear(bp) != TRUE)
127: return TRUE;
1.1 deraadt 128: for (wp = wheadp; bp->b_nwnd > 0; wp = wp->w_wndp) {
1.3 millert 129: if (wp->w_bufp == bp) {
130: bp2 = bp1->b_altb; /* save alternate buffer */
131: if (showbuffer(bp1, wp, WFMODE | WFFORCE | WFHARD))
132: bp1->b_altb = bp2;
133: else
134: bp1 = bp2;
135: }
136: }
137: if (bp == curbp)
138: curbp = bp1;
139: free(bp->b_linep); /* Release header line. */
140: bp2 = NULL; /* Find the header. */
1.1 deraadt 141: bp1 = bheadp;
142: while (bp1 != bp) {
143: if (bp1->b_altb == bp)
144: bp1->b_altb = (bp->b_altb == bp1) ? NULL : bp->b_altb;
145: bp2 = bp1;
146: bp1 = bp1->b_bufp;
147: }
1.3 millert 148: bp1 = bp1->b_bufp; /* Next one in chain. */
149: if (bp2 == NULL) /* Unlink it. */
1.1 deraadt 150: bheadp = bp1;
151: else
152: bp2->b_bufp = bp1;
1.3 millert 153: while (bp1 != NULL) { /* Finish with altb's */
1.1 deraadt 154: if (bp1->b_altb == bp)
155: bp1->b_altb = (bp->b_altb == bp1) ? NULL : bp->b_altb;
156: bp1 = bp1->b_bufp;
157: }
1.3 millert 158: free(bp->b_bname); /* Release name block */
159: free(bp); /* Release buffer block */
1.1 deraadt 160: return TRUE;
161: }
162:
163: /*
164: * Save some buffers - just call anycb with the arg flag.
165: */
1.3 millert 166: /* ARGSUSED */
167: int
1.1 deraadt 168: savebuffers(f, n)
1.3 millert 169: int f, n;
1.1 deraadt 170: {
1.3 millert 171: if (anycb(f) == ABORT)
172: return ABORT;
1.1 deraadt 173: return TRUE;
174: }
175:
176: /*
177: * Display the buffer list. This is done
178: * in two parts. The "makelist" routine figures out
179: * the text, and puts it in a buffer. "popbuf"
180: * then pops the data onto the screen. Bound to
181: * "C-X C-B".
182: */
1.3 millert 183: /* ARGSUSED */
184: int
1.1 deraadt 185: listbuffers(f, n)
1.4 ! millert 186: int f, n;
1.1 deraadt 187: {
1.3 millert 188: BUFFER *bp;
189: MGWIN *wp;
1.1 deraadt 190:
1.3 millert 191: if ((bp = makelist()) == NULL || (wp = popbuf(bp)) == NULL)
1.1 deraadt 192: return FALSE;
1.3 millert 193: wp->w_dotp = bp->b_dotp;/* fix up if window already on screen */
1.1 deraadt 194: wp->w_doto = bp->b_doto;
195: return TRUE;
196: }
197:
198: /*
199: * This routine rebuilds the text for the
200: * list buffers command. Return TRUE if
201: * everything works. Return FALSE if there
202: * is an error (if there is no memory).
203: */
1.3 millert 204: static BUFFER *
205: makelist()
206: {
207: char *cp1;
208: char *cp2;
209: int c;
210: BUFFER *bp;
211: LINE *lp;
212: RSIZE nbytes;
213: BUFFER *blp;
214: char b[6 + 1];
215: char line[128];
216:
217: if ((blp = bfind("*Buffer List*", TRUE)) == NULL)
218: return NULL;
219: if (bclear(blp) != TRUE)
220: return NULL;
221: blp->b_flag &= ~BFCHG; /* Blow away old. */
1.1 deraadt 222:
223: (VOID) strcpy(line, " MR Buffer");
224: cp1 = line + 10;
1.3 millert 225: while (cp1 < line + 4 + NBUFN + 1)
226: *cp1++ = ' ';
1.1 deraadt 227: (VOID) strcpy(cp1, "Size File");
1.3 millert 228: if (addline(blp, line) == FALSE)
229: return NULL;
1.1 deraadt 230: (VOID) strcpy(line, " -- ------");
231: cp1 = line + 10;
1.3 millert 232: while (cp1 < line + 4 + NBUFN + 1)
233: *cp1++ = ' ';
1.1 deraadt 234: (VOID) strcpy(cp1, "---- ----");
1.3 millert 235: if (addline(blp, line) == FALSE)
236: return NULL;
237: bp = bheadp; /* For all buffers */
1.1 deraadt 238: while (bp != NULL) {
1.3 millert 239: cp1 = &line[0]; /* Start at left edge */
1.1 deraadt 240: *cp1++ = (bp == curbp) ? '.' : ' ';
1.3 millert 241: *cp1++ = ((bp->b_flag & BFCHG) != 0) ? '*' : ' ';
242: *cp1++ = ' '; /* Gap. */
1.1 deraadt 243: *cp1++ = ' ';
1.3 millert 244: cp2 = &bp->b_bname[0]; /* Buffer name */
1.1 deraadt 245: while ((c = *cp2++) != 0)
246: *cp1++ = c;
1.3 millert 247: while (cp1 < &line[4 + NBUFN + 1])
1.1 deraadt 248: *cp1++ = ' ';
1.3 millert 249: nbytes = 0; /* Count bytes in buf. */
1.1 deraadt 250: if (bp != blp) {
251: lp = lforw(bp->b_linep);
252: while (lp != bp->b_linep) {
1.3 millert 253: nbytes += llength(lp) + 1;
1.1 deraadt 254: lp = lforw(lp);
255: }
1.3 millert 256: if (nbytes)
257: nbytes--; /* no bonus newline */
1.1 deraadt 258: }
259: (VOID) itor(b, 6, nbytes); /* 6 digit buffer size. */
260: cp2 = &b[0];
261: while ((c = *cp2++) != 0)
262: *cp1++ = c;
1.3 millert 263: *cp1++ = ' '; /* Gap.. */
264: cp2 = &bp->b_fname[0]; /* File name */
1.1 deraadt 265: if (*cp2 != 0) {
266: while ((c = *cp2++) != 0) {
1.3 millert 267: if (cp1 < &line[128 - 1])
1.1 deraadt 268: *cp1++ = c;
269: }
270: }
1.3 millert 271: *cp1 = 0; /* Add to the buffer. */
1.1 deraadt 272: if (addline(blp, line) == FALSE)
273: return NULL;
274: bp = bp->b_bufp;
275: }
1.3 millert 276: blp->b_dotp = lforw(blp->b_linep); /* put dot at beginning of
277: * buffer */
1.1 deraadt 278: blp->b_doto = 0;
1.3 millert 279: return blp; /* All done */
1.1 deraadt 280: }
281:
282: /*
283: * Used above.
284: */
1.3 millert 285: static RSIZE
286: itor(buf, width, num)
287: char *buf;
288: int width;
289: RSIZE num;
290: {
291: RSIZE r;
1.1 deraadt 292:
293: if (num / 10 == 0) {
294: buf[0] = (num % 10) + '0';
1.3 millert 295: for (r = 1; r < width; buf[r++] = ' ');
1.1 deraadt 296: buf[width] = '\0';
297: return 1;
298: } else {
1.3 millert 299: buf[r = itor(buf, width, num / (RSIZE) 10)] =
300: (num % (RSIZE) 10) + '0';
1.1 deraadt 301: return r + 1;
302: }
1.3 millert 303: /* NOTREACHED */
1.1 deraadt 304: }
305:
306: /*
1.3 millert 307: * The argument "text" points to a string. Append this line to the
308: * buffer. Handcraft the EOL on the end. Return TRUE if it worked and
1.1 deraadt 309: * FALSE if you ran out of room.
310: */
1.3 millert 311: int
312: addline(bp, text)
313: BUFFER *bp;
314: char *text;
315: {
316: LINE *lp;
317: int i;
318: int ntext;
1.1 deraadt 319:
320: ntext = strlen(text);
1.3 millert 321: if ((lp = lalloc(ntext)) == NULL)
1.1 deraadt 322: return FALSE;
1.3 millert 323: for (i = 0; i < ntext; ++i)
1.1 deraadt 324: lputc(lp, i, text[i]);
1.3 millert 325: bp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */
1.1 deraadt 326: lp->l_bp = bp->b_linep->l_bp;
327: bp->b_linep->l_bp = lp;
328: lp->l_fp = bp->b_linep;
329: #ifdef CANTHAPPEN
1.3 millert 330: if (bp->b_dotp == bp->b_linep) /* If "." is at the end */
331: bp->b_dotp = lp; /* move it to new line */
332: if (bp->b_markp == bp->b_linep) /* ditto for mark */
1.1 deraadt 333: bp->b_markp = lp;
334: #endif
335: return TRUE;
336: }
337:
338: /*
1.3 millert 339: * Look through the list of buffers, giving the user a chance to save them.
340: * Return TRUE if there are any changed buffers afterwards. Buffers that
341: * don't have an associated file don't count. Return FALSE if there are
342: * no changed buffers.
343: */
344: int
345: anycb(f)
346: int f;
347: {
348: BUFFER *bp;
349: int s = FALSE, save = FALSE;
350: char prompt[NFILEN + 11];
1.1 deraadt 351:
352: for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
353: if (*(bp->b_fname) != '\0'
1.3 millert 354: && (bp->b_flag & BFCHG) != 0) {
1.1 deraadt 355: (VOID) strcpy(prompt, "Save file ");
356: (VOID) strcpy(prompt + 10, bp->b_fname);
357: if ((f == TRUE || (save = eyorn(prompt)) == TRUE)
1.3 millert 358: && buffsave(bp) == TRUE) {
1.1 deraadt 359: bp->b_flag &= ~BFCHG;
360: upmodes(bp);
1.3 millert 361: } else
362: s = TRUE;
363: if (save == ABORT)
364: return (save);
1.1 deraadt 365: save = TRUE;
366: }
367: }
368: if (save == FALSE /* && kbdmop == NULL */ ) /* experimental */
369: ewprintf("(No files need saving)");
370: return s;
371: }
372:
373: /*
374: * Search for a buffer, by name.
375: * If not found, and the "cflag" is TRUE,
376: * create a buffer and put it in the list of
377: * all buffers. Return pointer to the BUFFER
378: * block for the buffer.
379: */
1.3 millert 380: BUFFER *
381: bfind(bname, cflag)
1.4 ! millert 382: char *bname;
! 383: int cflag;
1.3 millert 384: {
1.4 ! millert 385: BUFFER *bp;
! 386: LINE *lp;
! 387: int i;
1.1 deraadt 388:
389: bp = bheadp;
390: while (bp != NULL) {
391: if (fncmp(bname, bp->b_bname) == 0)
392: return bp;
393: bp = bp->b_bufp;
394: }
1.3 millert 395: if (cflag != TRUE)
396: return NULL;
397: /* NOSTRICT */
398: if ((bp = (BUFFER *) malloc(sizeof(BUFFER))) == NULL) {
1.1 deraadt 399: ewprintf("Can't get %d bytes", sizeof(BUFFER));
400: return NULL;
401: }
1.3 millert 402: if ((bp->b_bname = malloc((strlen(bname) + 1))) == NULL) {
403: ewprintf("Can't get %d bytes", strlen(bname) + 1);
1.1 deraadt 404: free((char *) bp);
405: return NULL;
406: }
407: if ((lp = lalloc(0)) == NULL) {
408: free(bp->b_bname);
409: free((char *) bp);
410: return NULL;
411: }
1.3 millert 412: bp->b_altb = bp->b_bufp = NULL;
413: bp->b_dotp = lp;
414: bp->b_doto = 0;
1.1 deraadt 415: bp->b_markp = NULL;
416: bp->b_marko = 0;
1.3 millert 417: bp->b_flag = defb_flag;
418: bp->b_nwnd = 0;
1.1 deraadt 419: bp->b_linep = lp;
420: bp->b_nmodes = defb_nmodes;
421: i = 0;
422: do {
1.3 millert 423: bp->b_modes[i] = defb_modes[i];
424: } while (i++ < defb_nmodes);
1.1 deraadt 425: bp->b_fname[0] = '\0';
426: bzero(&bp->b_fi, sizeof(bp->b_fi));
427: (VOID) strcpy(bp->b_bname, bname);
428: lp->l_fp = lp;
429: lp->l_bp = lp;
430: bp->b_bufp = bheadp;
431: bheadp = bp;
432: return bp;
433: }
434:
435: /*
436: * This routine blows away all of the text
437: * in a buffer. If the buffer is marked as changed
438: * then we ask if it is ok to blow it away; this is
439: * to save the user the grief of losing text. The
440: * window chain is nearly always wrong if this gets
441: * called; the caller must arrange for the updates
442: * that are required. Return TRUE if everything
443: * looks good.
444: */
1.3 millert 445: int
446: bclear(bp)
447: BUFFER *bp;
448: {
449: LINE *lp;
450: int s;
1.1 deraadt 451:
1.3 millert 452: if ((bp->b_flag & BFCHG) != 0 /* Changed. */
453: && (s = eyesno("Buffer modified; kill anyway")) != TRUE)
1.1 deraadt 454: return (s);
1.3 millert 455: bp->b_flag &= ~BFCHG; /* Not changed */
456: while ((lp = lforw(bp->b_linep)) != bp->b_linep)
1.1 deraadt 457: lfree(lp);
1.3 millert 458: bp->b_dotp = bp->b_linep; /* Fix "." */
459: bp->b_doto = 0;
460: bp->b_markp = NULL; /* Invalidate "mark" */
1.1 deraadt 461: bp->b_marko = 0;
462: return TRUE;
463: }
464:
465: /*
466: * Display the given buffer in the given window. Flags indicated
467: * action on redisplay.
468: */
1.3 millert 469: int
470: showbuffer(bp, wp, flags)
471: BUFFER *bp;
472: MGWIN *wp;
473: int flags;
474: {
475: BUFFER *obp;
476: MGWIN *owp;
1.1 deraadt 477:
1.3 millert 478: if (wp->w_bufp == bp) { /* Easy case! */
1.1 deraadt 479: wp->w_flag |= flags;
480: return TRUE;
481: }
482: /* First, dettach the old buffer from the window */
483: if ((bp->b_altb = obp = wp->w_bufp) != NULL) {
484: if (--obp->b_nwnd == 0) {
1.3 millert 485: obp->b_dotp = wp->w_dotp;
486: obp->b_doto = wp->w_doto;
1.1 deraadt 487: obp->b_markp = wp->w_markp;
488: obp->b_marko = wp->w_marko;
489: }
490: }
491: /* Now, attach the new buffer to the window */
492: wp->w_bufp = bp;
493:
1.3 millert 494: if (bp->b_nwnd++ == 0) { /* First use. */
495: wp->w_dotp = bp->b_dotp;
496: wp->w_doto = bp->b_doto;
1.1 deraadt 497: wp->w_markp = bp->b_markp;
498: wp->w_marko = bp->b_marko;
499: } else
1.3 millert 500: /* already on screen, steal values from other window */
1.1 deraadt 501: for (owp = wheadp; owp != NULL; owp = wp->w_wndp)
502: if (wp->w_bufp == bp && owp != wp) {
1.3 millert 503: wp->w_dotp = owp->w_dotp;
504: wp->w_doto = owp->w_doto;
1.1 deraadt 505: wp->w_markp = owp->w_markp;
506: wp->w_marko = owp->w_marko;
507: break;
508: }
1.3 millert 509: wp->w_flag |= WFMODE | flags;
1.1 deraadt 510: return TRUE;
511: }
512:
513: /*
514: * Pop the buffer we got passed onto the screen.
515: * Returns a status.
516: */
1.2 millert 517: MGWIN *
1.3 millert 518: popbuf(bp)
519: BUFFER *bp;
520: {
521: MGWIN *wp;
1.1 deraadt 522:
1.3 millert 523: if (bp->b_nwnd == 0) { /* Not on screen yet. */
524: if ((wp = wpopup()) == NULL)
525: return NULL;
1.1 deraadt 526: } else
527: for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
528: if (wp->w_bufp == bp) {
1.3 millert 529: wp->w_flag |= WFHARD | WFFORCE;
530: return wp;
1.1 deraadt 531: }
1.3 millert 532: if (showbuffer(bp, wp, WFHARD) != TRUE)
533: return NULL;
1.1 deraadt 534: return wp;
535: }
536:
537: /*
538: * Insert another buffer at dot. Very useful.
539: */
1.3 millert 540: /* ARGSUSED */
541: int
1.1 deraadt 542: bufferinsert(f, n)
543: {
1.3 millert 544: BUFFER *bp;
545: LINE *clp;
546: int clo;
547: int nline;
548: int s;
549: char bufn[NBUFN];
1.1 deraadt 550:
551: /* Get buffer to use from user */
552: if (curbp->b_altb != NULL)
1.3 millert 553: s = eread("Insert buffer: (default %s) ", bufn, NBUFN,
554: EFNEW | EFBUF, &(curbp->b_altb->b_bname),
555: (char *) NULL);
1.1 deraadt 556: else
1.3 millert 557: s = eread("Insert buffer: ", bufn, NBUFN, EFNEW | EFBUF,
558: (char *) NULL);
559: if (s == ABORT)
560: return (s);
561: if (s == FALSE && curbp->b_altb != NULL)
562: bp = curbp->b_altb;
563: else if ((bp = bfind(bufn, FALSE)) == NULL)
564: return FALSE;
1.1 deraadt 565:
1.3 millert 566: if (bp == curbp) {
1.1 deraadt 567: ewprintf("Cannot insert buffer into self");
568: return FALSE;
569: }
570: /* insert the buffer */
571: nline = 0;
572: clp = lforw(bp->b_linep);
1.3 millert 573: for (;;) {
1.1 deraadt 574: for (clo = 0; clo < llength(clp); clo++)
575: if (linsert(1, lgetc(clp, clo)) == FALSE)
576: return FALSE;
1.3 millert 577: if ((clp = lforw(clp)) == bp->b_linep)
578: break;
579: if (newline(FFRAND, 1) == FALSE) /* fake newline */
1.1 deraadt 580: return FALSE;
581: nline++;
582: }
1.3 millert 583: if (nline == 1)
584: ewprintf("[Inserted 1 line]");
585: else
586: ewprintf("[Inserted %d lines]", nline);
1.1 deraadt 587:
1.3 millert 588: clp = curwp->w_linep; /* cosmetic adjustment */
589: if (curwp->w_dotp == clp) { /* for offscreen insert */
590: while (nline-- && lback(clp) != curbp->b_linep)
1.1 deraadt 591: clp = lback(clp);
1.3 millert 592: curwp->w_linep = clp; /* adjust framing. */
1.1 deraadt 593: curwp->w_flag |= WFHARD;
594: }
595: return (TRUE);
596: }
597:
598: /*
599: * Turn off the dirty bit on this buffer.
600: */
1.3 millert 601: /* ARGSUSED */
602: int
1.1 deraadt 603: notmodified(f, n)
604: {
1.3 millert 605: MGWIN *wp;
1.1 deraadt 606:
607: curbp->b_flag &= ~BFCHG;
1.3 millert 608: wp = wheadp; /* Update mode lines. */
1.1 deraadt 609: while (wp != NULL) {
610: if (wp->w_bufp == curbp)
611: wp->w_flag |= WFMODE;
612: wp = wp->w_wndp;
613: }
614: ewprintf("Modification-flag cleared");
615: return TRUE;
616: }
617:
618: #ifndef NO_HELP
619: /*
620: * Popbuf and set all windows to top of buffer. Currently only used by
621: * help functions.
622: */
1.3 millert 623: int
1.1 deraadt 624: popbuftop(bp)
1.3 millert 625: BUFFER *bp;
1.1 deraadt 626: {
1.3 millert 627: MGWIN *wp;
1.1 deraadt 628:
1.3 millert 629: bp->b_dotp = lforw(bp->b_linep);
630: bp->b_doto = 0;
631: if (bp->b_nwnd != 0) {
632: for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
633: if (wp->w_bufp == bp) {
634: wp->w_dotp = bp->b_dotp;
635: wp->w_doto = 0;
636: wp->w_flag |= WFHARD;
637: }
638: }
639: return popbuf(bp) != NULL;
1.1 deraadt 640: }
641: #endif