Lines Matching defs:sp

33 static void      vs_insert(SCR *sp, GS *gp);
44 SCR *sp,
53 gp = sp->gp;
57 if (sp->rows < 4) {
58 msgq(sp, M_ERR,
64 vs_resolve(sp, NULL, 1);
67 CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP));
70 _HMAP(new)->lno = sp->lno;
75 half = sp->rows / 2;
83 issmallscreen = IS_SMALL(sp);
86 new->coff = sp->coff;
87 new->cols = sp->cols;
95 * Recalculate current cursor position based on sp->lno, we're called
100 !ccl && (vs_sm_cursor(sp, &smp) ? 0 : (smp - HMAP) + 1) >= half;
102 new->rows = sp->rows - half; /* New. */
103 new->roff = sp->roff;
104 sp->rows = half; /* Old. */
105 sp->roff += new->rows;
111 memcpy(_HMAP(sp), _HMAP(sp) + new->rows,
112 (sp->t_maxrows - new->rows) * sizeof(SMAP));
115 sp->rows -= half; /* Old. */
116 new->roff = sp->roff + sp->rows;
120 sp->t_maxrows = IS_ONELINE(sp) ? 1 : sp->rows - 1;
133 sp->t_rows -= new->rows;
136 if (sp->t_rows > sp->t_maxrows)
137 sp->t_rows = sp->t_maxrows;
138 if (sp->t_minrows > sp->t_maxrows)
139 sp->t_minrows = sp->t_maxrows;
142 new->t_minrows = new->t_rows = O_VAL(sp, O_WINDOW);
148 sp->t_minrows = sp->t_rows = IS_ONELINE(sp) ? 1 : sp->rows - 1;
156 new->t_minrows = new->t_rows = O_VAL(sp, O_WINDOW);
163 _TMAP(sp) = IS_ONELINE(sp) ?
164 _HMAP(sp) : _HMAP(sp) + (sp->t_rows - 1);
169 if ((sp->defscroll = sp->t_maxrows / 2) == 0)
170 sp->defscroll = 1;
175 vs_insert(new, sp->gp);
178 (void)gp->scr_split(sp, new);
197 F_ISSET(sp, SC_EX | SC_VI | SC_SCR_VI | SC_SCR_EX | SC_READONLY));
208 vs_vsplit(SCR *sp, SCR *new)
213 gp = sp->gp;
216 if (sp->cols / 2 <= MINIMUM_SCREEN_COLS) {
217 msgq(sp, M_ERR,
224 vs_resolve(sp, NULL, 1);
227 CALLOC(sp, _HMAP(new), SMAP *, SIZE_HMAP(sp), sizeof(SMAP));
230 _HMAP(new)->lno = sp->lno;
247 cols = sp->cols / 2;
248 new->cols = sp->cols - cols - 1;
249 sp->cols = cols;
250 new->coff = sp->coff + cols + 1;
251 sp->cno = 0;
254 new->rows = sp->rows;
255 new->t_rows = sp->t_rows;
256 new->t_maxrows = sp->t_maxrows;
257 new->t_minrows = sp->t_minrows;
258 new->roff = sp->roff;
259 new->defscroll = sp->defscroll;
263 vs_insert(new, sp->gp);
266 (void)gp->scr_split(sp, new);
269 F_SET(sp, SC_SCR_REFORMAT | SC_STATUS);
288 F_ISSET(sp, SC_EX | SC_VI | SC_SCR_VI | SC_SCR_EX | SC_READONLY));
298 vs_insert(SCR *sp, GS *gp)
302 gp = sp->gp;
306 if (tsp->roff >= sp->roff)
313 if (tsp->roff != sp->roff || tsp->coff > sp->coff)
321 TAILQ_INSERT_TAIL(gp->dq, sp, q);
322 } else if (tsp->roff < sp->roff ||
323 (tsp->roff == sp->roff && tsp->coff < sp->coff)) {
324 TAILQ_INSERT_AFTER(gp->dq, tsp, sp, q);
326 TAILQ_INSERT_BEFORE(tsp, sp, q);
337 vs_discard(SCR *sp, SCR **spp)
343 gp = sp->gp;
352 if (sp->frp != NULL) {
353 sp->frp->lno = sp->lno;
354 sp->frp->cno = sp->cno;
355 F_SET(sp->frp, FR_CURSORSET);
359 if (!IS_SPLIT(sp)) {
360 (void)gp->scr_discard(sp, NULL);
376 if (vs_join(sp, list, &jdir))
400 tsp->rows += sp->rows;
412 tsp->roff = sp->roff;
428 tsp->coff = sp->coff;
429 tsp->cols += sp->cols + 1; /* XXX: DIVIDER */
444 (void)gp->scr_discard(sp, list);
454 vs_join(SCR *sp, SCR **listp, jdir_t *jdirp)
461 gp = sp->gp;
464 for (lp = listp, tlen = sp->rows,
467 if (sp == tsp)
470 if (tsp->coff + tsp->cols + 1 != sp->coff)
476 if (tsp->roff > sp->roff + sp->rows)
478 if (tsp->roff < sp->roff) {
479 if (tsp->roff + tsp->rows >= sp->roff)
483 if (tsp->roff + tsp->rows > sp->roff + sp->rows)
499 for (lp = listp, tlen = sp->rows,
502 if (sp == tsp)
505 if (tsp->coff != sp->coff + sp->cols + 1)
511 if (tsp->roff > sp->roff + sp->rows)
513 if (tsp->roff < sp->roff) {
514 if (tsp->roff + tsp->rows >= sp->roff)
518 if (tsp->roff + tsp->rows > sp->roff + sp->rows)
534 for (first = 0, lp = listp, tlen = sp->cols,
537 if (sp == tsp)
540 if (tsp->roff + tsp->rows != sp->roff)
546 if (tsp->coff > sp->coff + sp->cols)
548 if (tsp->coff < sp->coff) {
549 if (tsp->coff + tsp->cols >= sp->coff)
553 if (tsp->coff + tsp->cols > sp->coff + sp->cols)
570 for (first = 0, lp = listp, tlen = sp->cols,
573 if (sp == tsp)
576 if (tsp->roff != sp->roff + sp->rows)
582 if (tsp->coff > sp->coff + sp->cols)
584 if (tsp->coff < sp->coff) {
585 if (tsp->coff + tsp->cols >= sp->coff)
589 if (tsp->coff + tsp->cols > sp->coff + sp->cols)
614 vs_fg(SCR *sp, SCR **nspp, CHAR_T *name, int newscreen)
621 gp = sp->gp;
624 INT2CHAR(sp, name, STRLEN(name) + 1, np, nlen);
629 nsp = vs_getbg(sp, np);
632 if (vs_swap(sp, &nsp, np))
636 msgq_wstr(sp, M_ERR, name,
648 if (vs_split(sp, nsp, 0)) {
654 TAILQ_REMOVE(gp->dq, sp, q);
655 TAILQ_INSERT_TAIL(gp->hq, sp, q);
667 vs_bg(SCR *sp)
672 gp = sp->gp;
675 if (vs_discard(sp, &nsp))
678 msgq(sp, M_ERR,
684 TAILQ_REMOVE(gp->dq, sp, q);
685 TAILQ_INSERT_TAIL(gp->hq, sp, q);
688 free(_HMAP(sp));
689 _HMAP(sp) = NULL;
692 sp->nextdisp = nsp;
693 F_SET(sp, SC_SSWITCH);
705 vs_swap(SCR *sp, SCR **nspp, char *name)
710 gp = sp->gp;
713 if ((*nspp = nsp = vs_getbg(sp, name)) == NULL)
723 if (sp->frp != NULL) {
724 sp->frp->lno = sp->lno;
725 sp->frp->cno = sp->cno;
726 F_SET(sp->frp, FR_CURSORSET);
730 sp->nextdisp = nsp;
731 F_SET(sp, SC_SSWITCH);
734 VIP(nsp)->srows = VIP(sp)->srows;
737 nsp->cols = sp->cols;
738 nsp->rows = sp->rows; /* XXX: Only place in vi that sets rows. */
739 nsp->roff = sp->roff;
750 if (nsp->t_rows > sp->t_maxrows)
752 if (nsp->t_minrows > sp->t_maxrows)
765 nsp->gp = sp->gp;
776 TAILQ_INSERT_AFTER(gp->dq, sp, nsp, q);
788 (void)gp->scr_discard(sp, list);
800 vs_resize(SCR *sp, long int count, adj_t adj)
806 gp = sp->gp;
815 if (sp->t_maxrows == count)
817 if (sp->t_maxrows > count) {
819 count = sp->t_maxrows - count;
822 count = count - sp->t_maxrows;
827 for (next = TAILQ_NEXT(sp, q); next != NULL &&
828 (next->coff >= sp->coff + sp->cols ||
829 next->coff + next->cols <= sp->coff);
833 (sp->coff != next->coff || sp->cols != next->cols))
835 for (prev = TAILQ_PREV(sp, _dqh, q); prev != NULL &&
836 (prev->coff >= sp->coff + sp->cols ||
837 prev->coff + prev->cols <= sp->coff);
840 (sp->coff != prev->coff || sp->cols != prev->cols))
847 s = sp;
857 g = sp;
865 toobig: msgq(sp, M_BERR, adj == A_DECREASE ?
871 toosmall: msgq(sp, M_BERR,
917 vs_getbg(SCR *sp, char *name)
923 gp = sp->gp;