2 * Copyright (c) 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "$Id: vs_split.c,v 10.42 2001/06/25 15:19:38 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:38 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
27 #include "../common/common.h"
30 typedef enum { HORIZ_FOLLOW
, HORIZ_PRECEDE
, VERT_FOLLOW
, VERT_PRECEDE
} jdir_t
;
32 static SCR
*vs_getbg
__P((SCR
*, char *));
33 static void vs_insert
__P((SCR
*sp
, WIN
*wp
));
34 static int vs_join
__P((SCR
*, SCR
**, jdir_t
*));
38 * Create a new screen, horizontally.
40 * PUBLIC: int vs_split __P((SCR *, SCR *, int));
43 vs_split(SCR
*sp
, SCR
*new, int ccl
)
45 /* Colon-command line split. */
50 int issmallscreen
, splitup
;
54 /* Check to see if it's possible. */
55 /* XXX: The IS_ONELINE fix will change this, too. */
58 "222|Screen must be larger than %d lines to split", 4 - 1);
62 /* Wait for any messages in the screen. */
63 vs_resolve(sp
, NULL
, 1);
65 /* Get a new screen map. */
66 CALLOC(sp
, _HMAP(new), SMAP
*, SIZE_HMAP(sp
), sizeof(SMAP
));
67 if (_HMAP(new) == NULL
)
69 _HMAP(new)->lno
= sp
->lno
;
73 /* Split the screen in half. */
79 * Small screens: see vs_refresh.c section 6a. Set a flag so
80 * we know to fix the screen up later.
82 issmallscreen
= IS_SMALL(sp
);
84 /* The columns in the screen don't change. */
89 * Split the screen, and link the screens together. If creating a
90 * screen to edit the colon command line or the cursor is in the top
91 * half of the current screen, the new screen goes under the current
92 * screen. Else, it goes above the current screen.
94 * Recalculate current cursor position based on sp->lno, we're called
95 * with the cursor on the colon command line. Then split the screen
96 * in half and update the shared information.
99 !ccl
&& (vs_sm_cursor(sp
, &smp
) ? 0 : (smp
- HMAP
) + 1) >= half
;
100 if (splitup
) { /* Old is bottom half. */
101 new->rows
= sp
->rows
- half
; /* New. */
102 new->roff
= sp
->roff
;
103 sp
->rows
= half
; /* Old. */
104 sp
->roff
+= new->rows
;
107 * If the parent is the bottom half of the screen, shift
108 * the map down to match on-screen text.
110 memcpy(_HMAP(sp
), _HMAP(sp
) + new->rows
,
111 (sp
->t_maxrows
- new->rows
) * sizeof(SMAP
));
112 } else { /* Old is top half. */
113 new->rows
= half
; /* New. */
114 sp
->rows
-= half
; /* Old. */
115 new->roff
= sp
->roff
+ sp
->rows
;
118 /* Adjust maximum text count. */
119 sp
->t_maxrows
= IS_ONELINE(sp
) ? 1 : sp
->rows
- 1;
120 new->t_maxrows
= IS_ONELINE(new) ? 1 : new->rows
- 1;
123 * Small screens: see vs_refresh.c, section 6a.
125 * The child may have different screen options sizes than the parent,
126 * so use them. Guarantee that text counts aren't larger than the
130 /* Fix the text line count for the parent. */
132 sp
->t_rows
-= new->rows
;
134 /* Fix the parent screen. */
135 if (sp
->t_rows
> sp
->t_maxrows
)
136 sp
->t_rows
= sp
->t_maxrows
;
137 if (sp
->t_minrows
> sp
->t_maxrows
)
138 sp
->t_minrows
= sp
->t_maxrows
;
140 /* Fix the child screen. */
141 new->t_minrows
= new->t_rows
= O_VAL(sp
, O_WINDOW
);
142 if (new->t_rows
> new->t_maxrows
)
143 new->t_rows
= new->t_maxrows
;
144 if (new->t_minrows
> new->t_maxrows
)
145 new->t_minrows
= new->t_maxrows
;
147 sp
->t_minrows
= sp
->t_rows
= IS_ONELINE(sp
) ? 1 : sp
->rows
- 1;
150 * The new screen may be a small screen, even if the parent
151 * was not. Don't complain if O_WINDOW is too large, we're
152 * splitting the screen so the screen is much smaller than
155 new->t_minrows
= new->t_rows
= O_VAL(sp
, O_WINDOW
);
156 if (new->t_rows
> new->rows
- 1)
157 new->t_minrows
= new->t_rows
=
158 IS_ONELINE(new) ? 1 : new->rows
- 1;
161 /* Adjust the ends of the new and old maps. */
162 _TMAP(sp
) = IS_ONELINE(sp
) ?
163 _HMAP(sp
) : _HMAP(sp
) + (sp
->t_rows
- 1);
164 _TMAP(new) = IS_ONELINE(new) ?
165 _HMAP(new) : _HMAP(new) + (new->t_rows
- 1);
167 /* Reset the length of the default scroll. */
168 if ((sp
->defscroll
= sp
->t_maxrows
/ 2) == 0)
170 if ((new->defscroll
= new->t_maxrows
/ 2) == 0)
173 /* Fit the screen into the logical chain. */
174 vs_insert(new, sp
->wp
);
176 /* Tell the display that we're splitting. */
177 (void)gp
->scr_split(sp
, new);
180 * Initialize the screen flags:
182 * If we're in vi mode in one screen, we don't have to reinitialize.
183 * This isn't just a cosmetic fix. The path goes like this:
185 * return into vi(), SC_SSWITCH set
186 * call vs_refresh() with SC_STATUS set
187 * call vs_resolve to display the status message
188 * call vs_refresh() because the SC_SCR_VI bit isn't set
190 * Things go downhill at this point.
192 * Draw the new screen from scratch, and add a status line.
195 SC_SCR_REFORMAT
| SC_STATUS
|
196 F_ISSET(sp
, SC_EX
| SC_VI
| SC_SCR_VI
| SC_SCR_EX
));
202 * Create a new screen, vertically.
204 * PUBLIC: int vs_vsplit __P((SCR *, SCR *));
207 vs_vsplit(SCR
*sp
, SCR
*new)
214 /* Check to see if it's possible. */
215 if (sp
->cols
/ 2 <= MINIMUM_SCREEN_COLS
) {
217 "288|Screen must be larger than %d columns to split",
218 MINIMUM_SCREEN_COLS
* 2);
222 /* Wait for any messages in the screen. */
223 vs_resolve(sp
, NULL
, 1);
225 /* Get a new screen map. */
226 CALLOC(sp
, _HMAP(new), SMAP
*, SIZE_HMAP(sp
), sizeof(SMAP
));
227 if (_HMAP(new) == NULL
)
229 _HMAP(new)->lno
= sp
->lno
;
230 _HMAP(new)->coff
= 0;
231 _HMAP(new)->soff
= 1;
234 * Split the screen in half; we have to sacrifice a column to delimit
238 * We always split to the right... that makes more sense to me, and
239 * I don't want to play the stupid games that I play when splitting
243 * We reserve a column for the screen, "knowing" that curses needs
244 * one. This should be worked out with the display interface.
247 new->cols
= sp
->cols
- cols
- 1;
249 new->coff
= sp
->coff
+ cols
+ 1;
252 /* Nothing else changes. */
253 new->rows
= sp
->rows
;
254 new->t_rows
= sp
->t_rows
;
255 new->t_maxrows
= sp
->t_maxrows
;
256 new->t_minrows
= sp
->t_minrows
;
257 new->roff
= sp
->roff
;
258 new->defscroll
= sp
->defscroll
;
259 _TMAP(new) = _HMAP(new) + (new->t_rows
- 1);
261 /* Fit the screen into the logical chain. */
262 vs_insert(new, sp
->wp
);
264 /* Tell the display that we're splitting. */
265 (void)gp
->scr_split(sp
, new);
267 /* Redraw the old screen from scratch. */
268 F_SET(sp
, SC_SCR_REFORMAT
| SC_STATUS
);
271 * Initialize the screen flags:
273 * If we're in vi mode in one screen, we don't have to reinitialize.
274 * This isn't just a cosmetic fix. The path goes like this:
276 * return into vi(), SC_SSWITCH set
277 * call vs_refresh() with SC_STATUS set
278 * call vs_resolve to display the status message
279 * call vs_refresh() because the SC_SCR_VI bit isn't set
281 * Things go downhill at this point.
283 * Draw the new screen from scratch, and add a status line.
286 SC_SCR_REFORMAT
| SC_STATUS
|
287 F_ISSET(sp
, SC_EX
| SC_VI
| SC_SCR_VI
| SC_SCR_EX
));
293 * Insert the new screen into the correct place in the logical
297 vs_insert(SCR
*sp
, WIN
*wp
)
306 /* Move past all screens with lower row numbers. */
307 for (tsp
= wp
->scrq
.cqh_first
;
308 tsp
!= (void *)&wp
->scrq
; tsp
= tsp
->q
.cqe_next
)
309 if (tsp
->roff
>= sp
->roff
)
312 * Move past all screens with the same row number and lower
315 for (; tsp
!= (void *)&wp
->scrq
; tsp
= tsp
->q
.cqe_next
)
316 if (tsp
->roff
!= sp
->roff
|| tsp
->coff
> sp
->coff
)
320 * If we reached the end, this screen goes there. Otherwise,
321 * put it before or after the screen where we stopped.
323 if (tsp
== (void *)&wp
->scrq
) {
324 CIRCLEQ_INSERT_TAIL(&wp
->scrq
, sp
, q
);
325 } else if (tsp
->roff
< sp
->roff
||
326 (tsp
->roff
== sp
->roff
&& tsp
->coff
< sp
->coff
)) {
327 CIRCLEQ_INSERT_AFTER(&wp
->scrq
, tsp
, sp
, q
);
329 CIRCLEQ_INSERT_BEFORE(&wp
->scrq
, tsp
, sp
, q
);
334 * Discard the screen, folding the real-estate into a related screen,
335 * if one exists, and return that screen.
337 * PUBLIC: int vs_discard __P((SCR *, SCR **));
340 vs_discard(SCR
*sp
, SCR
**spp
)
343 SCR
*tsp
, **lp
, *list
[100];
349 * Save the old screen's cursor information.
352 * If called after file_end(), and the underlying file was a tmp
353 * file, it may have gone away.
355 if (sp
->frp
!= NULL
) {
356 sp
->frp
->lno
= sp
->lno
;
357 sp
->frp
->cno
= sp
->cno
;
358 F_SET(sp
->frp
, FR_CURSORSET
);
361 /* If no other screens to join, we're done. */
363 (void)gp
->scr_discard(sp
, NULL
);
371 * Find a set of screens that cover one of the screen's borders.
372 * Check the vertical axis first, for no particular reason.
375 * It's possible (I think?), to create a screen that shares no full
376 * border with any other set of screens, so we can't discard it. We
377 * just complain at the user until they clean it up.
379 if (vs_join(sp
, list
, &jdir
))
383 * Modify the affected screens. Redraw the modified screen(s) from
384 * scratch, setting a status line. If this is ever a performance
385 * problem we could play games with the map, but I wrote that code
386 * before and it was never clean or easy.
388 * Don't clean up the discarded screen's information. If the screen
389 * isn't exiting, we'll do the work when the user redisplays it.
394 for (lp
= &list
[0]; (tsp
= *lp
) != NULL
; ++lp
) {
396 * Small screens: see vs_refresh.c section 6a. Adjust
397 * text line info, unless it's a small screen.
399 * Reset the length of the default scroll.
401 * Reset the map references.
403 tsp
->rows
+= sp
->rows
;
405 tsp
->t_rows
= tsp
->t_minrows
= tsp
->rows
- 1;
406 tsp
->t_maxrows
= tsp
->rows
- 1;
408 tsp
->defscroll
= tsp
->t_maxrows
/ 2;
410 *(_HMAP(tsp
) + (tsp
->t_rows
- 1)) = *_TMAP(tsp
);
411 _TMAP(tsp
) = _HMAP(tsp
) + (tsp
->t_rows
- 1);
415 tsp
->roff
= sp
->roff
;
416 vs_sm_fill(tsp
, OOBLNO
, P_TOP
);
419 vs_sm_fill(tsp
, OOBLNO
, P_BOTTOM
);
424 F_SET(tsp
, SC_STATUS
);
429 for (lp
= &list
[0]; (tsp
= *lp
) != NULL
; ++lp
) {
430 if (jdir
== VERT_FOLLOW
)
431 tsp
->coff
= sp
->coff
;
432 tsp
->cols
+= sp
->cols
+ 1; /* XXX: DIVIDER */
433 vs_sm_fill(tsp
, OOBLNO
, P_TOP
);
434 F_SET(tsp
, SC_STATUS
);
441 /* Find the closest screen that changed and move to it. */
446 /* Tell the display that we're discarding a screen. */
447 (void)gp
->scr_discard(sp
, list
);
454 * Find a set of screens that covers a screen's border.
457 vs_join(SCR
*sp
, SCR
**listp
, jdir_t
*jdirp
)
468 /* Check preceding vertical. */
469 for (lp
= listp
, tlen
= sp
->rows
,
470 tsp
= wp
->scrq
.cqh_first
;
471 tsp
!= (void *)&wp
->scrq
; tsp
= tsp
->q
.cqe_next
) {
474 /* Test if precedes the screen vertically. */
475 if (tsp
->coff
+ tsp
->cols
+ 1 != sp
->coff
)
478 * Test if a subset on the vertical axis. If overlaps the
479 * beginning or end, we can't join on this axis at all.
481 if (tsp
->roff
> sp
->roff
+ sp
->rows
)
483 if (tsp
->roff
< sp
->roff
) {
484 if (tsp
->roff
+ tsp
->rows
>= sp
->roff
)
488 if (tsp
->roff
+ tsp
->rows
> sp
->roff
+ sp
->rows
)
491 if (tlen
< tsp
->rows
)
499 *jdirp
= VERT_PRECEDE
;
503 /* Check following vertical. */
504 for (lp
= listp
, tlen
= sp
->rows
,
505 tsp
= wp
->scrq
.cqh_first
;
506 tsp
!= (void *)&wp
->scrq
; tsp
= tsp
->q
.cqe_next
) {
509 /* Test if follows the screen vertically. */
510 if (tsp
->coff
!= sp
->coff
+ sp
->cols
+ 1)
513 * Test if a subset on the vertical axis. If overlaps the
514 * beginning or end, we can't join on this axis at all.
516 if (tsp
->roff
> sp
->roff
+ sp
->rows
)
518 if (tsp
->roff
< sp
->roff
) {
519 if (tsp
->roff
+ tsp
->rows
>= sp
->roff
)
523 if (tsp
->roff
+ tsp
->rows
> sp
->roff
+ sp
->rows
)
526 if (tlen
< tsp
->rows
)
534 *jdirp
= VERT_FOLLOW
;
538 /* Check preceding horizontal. */
539 for (first
= 0, lp
= listp
, tlen
= sp
->cols
,
540 tsp
= wp
->scrq
.cqh_first
;
541 tsp
!= (void *)&wp
->scrq
; tsp
= tsp
->q
.cqe_next
) {
544 /* Test if precedes the screen horizontally. */
545 if (tsp
->roff
+ tsp
->rows
!= sp
->roff
)
548 * Test if a subset on the horizontal axis. If overlaps the
549 * beginning or end, we can't join on this axis at all.
551 if (tsp
->coff
> sp
->coff
+ sp
->cols
)
553 if (tsp
->coff
< sp
->coff
) {
554 if (tsp
->coff
+ tsp
->cols
>= sp
->coff
)
558 if (tsp
->coff
+ tsp
->cols
> sp
->coff
+ sp
->cols
)
561 if (tlen
< tsp
->cols
)
564 tlen
-= tsp
->cols
+ first
;
570 *jdirp
= HORIZ_PRECEDE
;
574 /* Check following horizontal. */
575 for (first
= 0, lp
= listp
, tlen
= sp
->cols
,
576 tsp
= wp
->scrq
.cqh_first
;
577 tsp
!= (void *)&wp
->scrq
; tsp
= tsp
->q
.cqe_next
) {
580 /* Test if precedes the screen horizontally. */
581 if (tsp
->roff
!= sp
->roff
+ sp
->rows
)
584 * Test if a subset on the horizontal axis. If overlaps the
585 * beginning or end, we can't join on this axis at all.
587 if (tsp
->coff
> sp
->coff
+ sp
->cols
)
589 if (tsp
->coff
< sp
->coff
) {
590 if (tsp
->coff
+ tsp
->cols
>= sp
->coff
)
594 if (tsp
->coff
+ tsp
->cols
> sp
->coff
+ sp
->cols
)
597 if (tlen
< tsp
->cols
)
600 tlen
-= tsp
->cols
+ first
;
606 *jdirp
= HORIZ_FOLLOW
;
614 * Background the current screen, and foreground a new one.
616 * PUBLIC: int vs_fg __P((SCR *, SCR **, CHAR_T *, int));
619 vs_fg(SCR
*sp
, SCR
**nspp
, CHAR_T
*name
, int newscreen
)
631 INT2CHAR(sp
, name
, STRLEN(name
) + 1, np
, nlen
);
635 /* Get the specified background screen. */
636 nsp
= vs_getbg(sp
, np
);
639 if (vs_swap(sp
, &nsp
, np
))
642 if ((*nspp
= nsp
) == NULL
) {
643 msgq_wstr(sp
, M_ERR
, name
,
645 "223|There are no background screens" :
646 "224|There's no background screen editing a file named %s");
651 /* Remove the new screen from the background queue. */
652 CIRCLEQ_REMOVE(&gp
->hq
, nsp
, q
);
654 /* Split the screen; if we fail, hook the screen back in. */
655 if (vs_split(sp
, nsp
, 0)) {
656 CIRCLEQ_INSERT_TAIL(&gp
->hq
, nsp
, q
);
660 /* Move the old screen to the background queue. */
661 CIRCLEQ_REMOVE(&wp
->scrq
, sp
, q
);
662 CIRCLEQ_INSERT_TAIL(&gp
->hq
, sp
, q
);
669 * Background the screen, and switch to the next one.
671 * PUBLIC: int vs_bg __P((SCR *));
683 /* Try and join with another screen. */
684 if (vs_discard(sp
, &nsp
))
688 "225|You may not background your only displayed screen");
692 /* Move the old screen to the background queue. */
693 CIRCLEQ_REMOVE(&wp
->scrq
, sp
, q
);
694 CIRCLEQ_INSERT_TAIL(&gp
->hq
, sp
, q
);
696 /* Toss the screen map. */
700 /* Switch screens. */
702 F_SET(sp
, SC_SSWITCH
);
709 * Swap the current screen with a backgrounded one.
711 * PUBLIC: int vs_swap __P((SCR *, SCR **, char *));
714 vs_swap(SCR
*sp
, SCR
**nspp
, char *name
)
723 /* Get the specified background screen. */
724 if ((*nspp
= nsp
= vs_getbg(sp
, name
)) == NULL
)
728 * Save the old screen's cursor information.
731 * If called after file_end(), and the underlying file was a tmp
732 * file, it may have gone away.
734 if (sp
->frp
!= NULL
) {
735 sp
->frp
->lno
= sp
->lno
;
736 sp
->frp
->cno
= sp
->cno
;
737 F_SET(sp
->frp
, FR_CURSORSET
);
740 /* Switch screens. */
742 F_SET(sp
, SC_SSWITCH
);
744 /* Initialize terminal information. */
745 VIP(nsp
)->srows
= VIP(sp
)->srows
;
747 /* Initialize screen information. */
748 nsp
->cols
= sp
->cols
;
749 nsp
->rows
= sp
->rows
; /* XXX: Only place in vi that sets rows. */
750 nsp
->roff
= sp
->roff
;
753 * Small screens: see vs_refresh.c, section 6a.
755 * The new screens may have different screen options sizes than the
756 * old one, so use them. Make sure that text counts aren't larger
757 * than the new screen sizes.
760 nsp
->t_minrows
= nsp
->t_rows
= O_VAL(nsp
, O_WINDOW
);
761 if (nsp
->t_rows
> sp
->t_maxrows
)
762 nsp
->t_rows
= nsp
->t_maxrows
;
763 if (nsp
->t_minrows
> sp
->t_maxrows
)
764 nsp
->t_minrows
= nsp
->t_maxrows
;
766 nsp
->t_rows
= nsp
->t_maxrows
= nsp
->t_minrows
= nsp
->rows
- 1;
768 /* Reset the length of the default scroll. */
769 nsp
->defscroll
= nsp
->t_maxrows
/ 2;
771 /* Allocate a new screen map. */
772 CALLOC_RET(nsp
, _HMAP(nsp
), SMAP
*, SIZE_HMAP(nsp
), sizeof(SMAP
));
773 _TMAP(nsp
) = _HMAP(nsp
) + (nsp
->t_rows
- 1);
776 if (vs_sm_fill(nsp
, nsp
->lno
, P_FILL
))
780 * The new screen replaces the old screen in the parent/child list.
781 * We insert the new screen after the old one. If we're exiting,
782 * the exit will delete the old one, if we're foregrounding, the fg
783 * code will move the old one to the background queue.
785 CIRCLEQ_REMOVE(&gp
->hq
, nsp
, q
);
786 CIRCLEQ_INSERT_AFTER(&wp
->scrq
, sp
, nsp
, q
);
790 * Don't change the screen's cursor information other than to
791 * note that the cursor is wrong.
793 F_SET(VIP(nsp
), VIP_CUR_INVALID
);
795 /* Draw the new screen from scratch, and add a status line. */
796 F_SET(nsp
, SC_SCR_REDRAW
| SC_STATUS
);
798 list
[0] = nsp
; list
[1] = NULL
;
799 (void)gp
->scr_discard(sp
, list
);
806 * Change the absolute size of the current screen.
808 * PUBLIC: int vs_resize __P((SCR *, long, adj_t));
811 vs_resize(SCR
*sp
, long int count
, adj_t adj
)
815 SCR
*g
, *s
, *prev
, *next
, *list
[3] = {NULL
, NULL
, NULL
};
822 * Figure out which screens will grow, which will shrink, and
823 * make sure it's possible.
828 if (sp
->t_maxrows
== count
)
830 if (sp
->t_maxrows
> count
) {
832 count
= sp
->t_maxrows
- count
;
835 count
= count
- sp
->t_maxrows
;
839 /* Find first overlapping screen */
840 for (next
= sp
->q
.cqe_next
;
841 next
!= (void *)&wp
->scrq
&&
842 (next
->coff
>= sp
->coff
+ sp
->cols
||
843 next
->coff
+ next
->cols
<= sp
->coff
);
844 next
= next
->q
.cqe_next
);
845 /* See if we can use it */
846 if (next
!= (void *)&wp
->scrq
&&
847 (sp
->coff
!= next
->coff
|| sp
->cols
!= next
->cols
))
848 next
= (void *)&wp
->scrq
;
849 for (prev
= sp
->q
.cqe_prev
;
850 prev
!= (void *)&wp
->scrq
&&
851 (prev
->coff
>= sp
->coff
+ sp
->cols
||
852 prev
->coff
+ prev
->cols
<= sp
->coff
);
853 prev
= prev
->q
.cqe_prev
);
854 if (prev
!= (void *)&wp
->scrq
&&
855 (sp
->coff
!= prev
->coff
|| sp
->cols
!= prev
->cols
))
856 prev
= (void *)&wp
->scrq
;
859 if (adj
== A_DECREASE
) {
863 if (s
->t_maxrows
< MINIMUM_SCREEN_ROWS
+ count
)
865 if ((g
= prev
) == (void *)&wp
->scrq
) {
866 if ((g
= next
) == (void *)&wp
->scrq
)
873 if ((s
= next
) != (void *)&wp
->scrq
&&
874 s
->t_maxrows
>= MINIMUM_SCREEN_ROWS
+ count
)
879 if ((s
= prev
) == (void *)&wp
->scrq
) {
880 toobig
: msgq(sp
, M_BERR
, adj
== A_DECREASE
?
881 "227|The screen cannot shrink" :
882 "228|The screen cannot grow");
885 if (s
->t_maxrows
< MINIMUM_SCREEN_ROWS
+ count
) {
886 toosmall
: msgq(sp
, M_BERR
,
887 "226|The screen can only shrink to %d rows",
888 MINIMUM_SCREEN_ROWS
);
896 * Fix up the screens; we could optimize the reformatting of the
897 * screen, but this isn't likely to be a common enough operation
898 * to make it worthwhile.
906 if (g
->t_minrows
== g
->t_maxrows
)
907 g
->t_minrows
+= count
;
908 g
->t_maxrows
+= count
;
910 F_SET(g
, SC_SCR_REFORMAT
| SC_STATUS
);
913 s
->t_maxrows
-= count
;
914 if (s
->t_minrows
> s
->t_maxrows
)
915 s
->t_minrows
= s
->t_maxrows
;
917 F_SET(s
, SC_SCR_REFORMAT
| SC_STATUS
);
920 list
[0] = g
; list
[1] = s
;
921 gp
->scr_discard(0, list
);
928 * Get the specified background screen, or, if name is NULL, the first
932 vs_getbg(SCR
*sp
, char *name
)
940 /* If name is NULL, return the first background screen on the list. */
942 nsp
= gp
->hq
.cqh_first
;
943 return (nsp
== (void *)&gp
->hq
? NULL
: nsp
);
946 /* Search for a full match. */
947 for (nsp
= gp
->hq
.cqh_first
;
948 nsp
!= (void *)&gp
->hq
; nsp
= nsp
->q
.cqe_next
)
949 if (!strcmp(nsp
->frp
->name
, name
))
951 if (nsp
!= (void *)&gp
->hq
)
954 /* Search for a last-component match. */
955 for (nsp
= gp
->hq
.cqh_first
;
956 nsp
!= (void *)&gp
->hq
; nsp
= nsp
->q
.cqe_next
) {
957 if ((p
= strrchr(nsp
->frp
->name
, '/')) == NULL
)
961 if (!strcmp(p
, name
))
964 if (nsp
!= (void *)&gp
->hq
)