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