Lines Matching +full:smp +full:- +full:offset
1 /*-
35 * vs_change --
74 if (lno > TMAP->lno) in vs_change()
82 if (lno < HMAP->lno) { in vs_change()
88 for (p = HMAP, cnt = sp->t_rows; cnt--; ++p) in vs_change()
89 --p->lno; in vs_change()
90 if (sp->lno >= lno) in vs_change()
91 --sp->lno; in vs_change()
95 for (p = HMAP, cnt = sp->t_rows; cnt--; ++p) in vs_change()
96 ++p->lno; in vs_change()
97 if (sp->lno >= lno) in vs_change()
98 ++sp->lno; in vs_change()
114 if (sp->lno == lno) in vs_change()
119 * or if we've switched into ex canonical mode, don't touch it -- we'll in vs_change()
123 (F_ISSET(sp, SC_SCR_EXWROTE) || VIP(sp)->totalcount > 1)) { in vs_change()
129 (void)sp->gp->scr_cursor(sp, &oldy, &oldx); in vs_change()
135 if (sp->lno > lno) in vs_change()
136 --sp->lno; in vs_change()
142 if (sp->lno > lno) in vs_change()
143 ++sp->lno; in vs_change()
154 (void)sp->gp->scr_move(sp, oldy, oldx); in vs_change()
159 * vs_sm_fill --
179 for (p = HMAP, cnt = sp->t_rows; cnt--; ++p) in vs_sm_fill()
187 * is already in the map or close by -- scrolling the screen would in vs_sm_fill()
212 TMAP->lno = tmp.lno; in vs_sm_fill()
213 TMAP->coff = tmp.coff; in vs_sm_fill()
214 TMAP->soff = tmp.soff; in vs_sm_fill()
220 top: HMAP->lno = lno; in vs_sm_fill()
221 HMAP->coff = 0; in vs_sm_fill()
222 HMAP->soff = 1; in vs_sm_fill()
225 * If number of lines HMAP->lno (top line) spans in vs_sm_fill()
227 * fewer than HMAP->soff, reset so the line is in vs_sm_fill()
230 cnt = vs_screens(sp, HMAP->lno, NULL); in vs_sm_fill()
231 if (cnt < HMAP->soff) in vs_sm_fill()
232 HMAP->soff = 1; in vs_sm_fill()
235 for (p = HMAP, cnt = sp->t_rows; --cnt; ++p) in vs_sm_fill()
241 middle: p = HMAP + sp->t_rows / 2; in vs_sm_fill()
242 p->lno = lno; in vs_sm_fill()
243 p->coff = 0; in vs_sm_fill()
244 p->soff = 1; in vs_sm_fill()
245 for (; p > HMAP; --p) in vs_sm_fill()
246 if (vs_sm_prev(sp, p, p - 1)) { in vs_sm_fill()
252 p = HMAP + sp->t_rows / 2; in vs_sm_fill()
259 TMAP->lno = lno; in vs_sm_fill()
260 TMAP->coff = 0; in vs_sm_fill()
261 TMAP->soff = vs_screens(sp, lno, NULL); in vs_sm_fill()
264 bottom: for (p = TMAP; p > HMAP; --p) in vs_sm_fill()
265 if (vs_sm_prev(sp, p, p - 1)) { in vs_sm_fill()
279 err: HMAP->lno = 1; in vs_sm_fill()
280 HMAP->coff = 0; in vs_sm_fill()
281 HMAP->soff = 1; in vs_sm_fill()
296 if (cnt >= sp->t_rows) { \
303 * vs_sm_delete --
316 for (p = HMAP; p->lno != lno; ++p); in vs_sm_delete()
321 t <= TMAP && t->lno == lno; ++cnt_orig, ++t); in vs_sm_delete()
326 (void)sp->gp->scr_move(sp, p - HMAP, 0); in vs_sm_delete()
331 memmove(p, p + cnt_orig, (((TMAP - p) - cnt_orig) + 1) * sizeof(SMAP)); in vs_sm_delete()
334 for (t = TMAP - cnt_orig; p <= t; ++p) in vs_sm_delete()
335 --p->lno; in vs_sm_delete()
338 for (p = TMAP - cnt_orig;;) { in vs_sm_delete()
351 * vs_sm_insert --
360 /* Save the offset. */ in vs_sm_insert()
361 coff = HMAP->coff; in vs_sm_insert()
367 for (p = HMAP; p->lno != lno; ++p); in vs_sm_insert()
376 cnt = (TMAP - p) + 1; in vs_sm_insert()
381 (void)sp->gp->scr_move(sp, p - HMAP, 0); in vs_sm_insert()
386 memmove(p + cnt_orig, p, (((TMAP - p) - cnt_orig) + 1) * sizeof(SMAP)); in vs_sm_insert()
390 ++t->lno; in vs_sm_insert()
394 t->lno = lno; in vs_sm_insert()
395 t->coff = coff; in vs_sm_insert()
396 t->soff = cnt; in vs_sm_insert()
405 * vs_sm_reset --
415 * See if the number of on-screen rows taken up by the old display in vs_sm_reset()
419 for (p = HMAP; p->lno != lno; ++p); in vs_sm_reset()
425 t = p; t <= TMAP && t->lno == lno; ++cnt_orig, ++t); in vs_sm_reset()
442 diff = cnt_new - cnt_orig; in vs_sm_reset()
448 cnt = (TMAP - p) + 1; in vs_sm_reset()
454 (void)sp->gp->scr_move(sp, p - HMAP, 0); in vs_sm_reset()
460 (((TMAP - p) - diff) + 1) * sizeof(SMAP)); in vs_sm_reset()
464 for (cnt = 1, t = p; cnt_new-- && t <= TMAP; ++t, ++cnt) { in vs_sm_reset()
465 t->lno = lno; in vs_sm_reset()
466 t->soff = cnt; in vs_sm_reset()
473 diff = cnt_orig - cnt_new; in vs_sm_reset()
476 (void)sp->gp->scr_move(sp, p - HMAP, 0); in vs_sm_reset()
481 memmove(p, p + diff, (((TMAP - p) - diff) + 1) * sizeof(SMAP)); in vs_sm_reset()
484 for (cnt = 1, t = p; cnt_new--; ++t, ++cnt) { in vs_sm_reset()
485 t->lno = lno; in vs_sm_reset()
486 t->soff = cnt; in vs_sm_reset()
493 for (t = TMAP - diff;;) { in vs_sm_reset()
516 SMAP *smp; in vs_sm_scroll() local
526 if (vs_sm_cursor(sp, &smp)) in vs_sm_scroll()
534 if (vs_sm_down(sp, rp, count, scmd, smp)) in vs_sm_scroll()
541 if (vs_sm_up(sp, rp, count, scmd, smp)) in vs_sm_scroll()
550 * If we're at the start of a line, go for the first non-blank. in vs_sm_scroll()
560 rp->cno == 0 && nonblank(sp, rp->lno, &rp->cno)) in vs_sm_scroll()
567 * vs_sm_up --
571 vs_sm_up(SCR *sp, MARK *rp, recno_t count, scroll_t scmd, SMAP *smp) in vs_sm_up() argument
589 if (s1.lno > TMAP->lno && !db_exist(sp, s1.lno)) { in vs_sm_up()
590 if (scmd == CNTRL_E || scmd == Z_PLUS || smp == TMAP) { in vs_sm_up()
594 if (vs_sm_next(sp, smp, &s1)) in vs_sm_up()
596 if (s1.lno > smp->lno && !db_exist(sp, s1.lno)) { in vs_sm_up()
615 if (count >= sp->t_maxrows || scmd == CNTRL_F) { in vs_sm_up()
619 for (; count--; s1 = s2) { in vs_sm_up()
632 sp->t_rows != sp->t_maxrows; --count, ++sp->t_rows) { in vs_sm_up()
635 if (TMAP->lno != s1.lno && !db_exist(sp, s1.lno)) in vs_sm_up()
646 rp->lno = ssmp->lno; in vs_sm_up()
647 rp->cno = ssmp->c_sboff; in vs_sm_up()
653 for (echanged = zset = 0; count; --count) { in vs_sm_up()
659 if (TMAP->lno != s1.lno && !db_exist(sp, s1.lno)) in vs_sm_up()
667 if (smp > HMAP) in vs_sm_up()
668 --smp; in vs_sm_up()
674 if (smp > HMAP) in vs_sm_up()
675 --smp; in vs_sm_up()
677 smp = TMAP; in vs_sm_up()
698 rp->lno = smp->lno; in vs_sm_up()
699 rp->cno = vs_colpos(sp, smp->lno, in vs_sm_up()
701 smp->coff : (smp->soff - 1) * sp->cols) + in vs_sm_up()
702 sp->rcm % sp->cols); in vs_sm_up()
711 smp = HMAP; in vs_sm_up()
722 for (; count; --count, ++smp) in vs_sm_up()
723 if (smp == TMAP || !db_exist(sp, smp[1].lno)) in vs_sm_up()
733 if (!SMAP_CACHE(smp) && vs_line(sp, smp, NULL, NULL)) in vs_sm_up()
735 rp->lno = smp->lno; in vs_sm_up()
736 rp->cno = smp->c_scoff == 255 ? 0 : smp->c_sboff; in vs_sm_up()
741 * vs_sm_1up --
753 (void)sp->gp->scr_move(sp, 0, 0); in vs_sm_1up()
757 /* One-line screens can fail. */ in vs_sm_1up()
762 memmove(HMAP, HMAP + 1, (sp->rows - 1) * sizeof(SMAP)); in vs_sm_1up()
763 if (vs_sm_next(sp, TMAP - 1, TMAP)) in vs_sm_1up()
771 * vs_deleteln --
781 gp = sp->gp; in vs_deleteln()
790 (void)gp->scr_clrtoeol(sp); in vs_deleteln()
792 (void)gp->scr_cursor(sp, &oldy, &oldx); in vs_deleteln()
793 while (cnt--) { in vs_deleteln()
794 (void)gp->scr_deleteln(sp); in vs_deleteln()
795 (void)gp->scr_move(sp, LASTLINE(sp), 0); in vs_deleteln()
796 (void)gp->scr_insertln(sp); in vs_deleteln()
797 (void)gp->scr_move(sp, oldy, oldx); in vs_deleteln()
804 * vs_sm_down --
808 vs_sm_down(SCR *sp, MARK *rp, recno_t count, scroll_t scmd, SMAP *smp) in vs_sm_down() argument
814 if (HMAP->lno == 1 && in vs_sm_down()
815 (O_ISSET(sp, O_LEFTRIGHT) || HMAP->soff == 1) && in vs_sm_down()
816 (scmd == CNTRL_Y || scmd == Z_CARAT || smp == HMAP)) { in vs_sm_down()
834 if (count >= sp->t_maxrows || scmd == CNTRL_B) { in vs_sm_down()
838 for (; count--; s1 = s2) { in vs_sm_down()
852 sp->t_rows != sp->t_maxrows; --count, ++sp->t_rows) { in vs_sm_down()
853 if (HMAP->lno == 1 && in vs_sm_down()
854 (O_ISSET(sp, O_LEFTRIGHT) || HMAP->soff == 1)) in vs_sm_down()
861 rp->lno = ssmp->lno; in vs_sm_down()
862 rp->cno = ssmp->c_sboff; in vs_sm_down()
868 for (ychanged = zset = 0; count; --count) { in vs_sm_down()
870 if (HMAP->lno == 1 && in vs_sm_down()
871 (O_ISSET(sp, O_LEFTRIGHT) || HMAP->soff == 1)) in vs_sm_down()
879 if (smp < TMAP) in vs_sm_down()
880 ++smp; in vs_sm_down()
886 if (smp < TMAP) in vs_sm_down()
887 ++smp; in vs_sm_down()
889 smp = HMAP; in vs_sm_down()
909 for (smp = TMAP; smp > HMAP; --smp) in vs_sm_down()
910 if (db_exist(sp, smp->lno)) in vs_sm_down()
920 if (count < smp - HMAP) in vs_sm_down()
921 smp -= count; in vs_sm_down()
923 smp = HMAP; in vs_sm_down()
933 rp->lno = smp->lno; in vs_sm_down()
934 rp->cno = vs_colpos(sp, smp->lno, in vs_sm_down()
936 smp->coff : (smp->soff - 1) * sp->cols) + in vs_sm_down()
937 sp->rcm % sp->cols); in vs_sm_down()
947 if (!SMAP_CACHE(smp) && vs_line(sp, smp, NULL, NULL)) in vs_sm_down()
949 rp->lno = smp->lno; in vs_sm_down()
950 rp->cno = smp->c_scoff == 255 ? 0 : smp->c_sboff; in vs_sm_down()
955 * vs_sm_erase --
963 gp = sp->gp; in vs_sm_erase()
964 (void)gp->scr_move(sp, LASTLINE(sp), 0); in vs_sm_erase()
965 (void)gp->scr_clrtoeol(sp); in vs_sm_erase()
966 for (; sp->t_rows > sp->t_minrows; --sp->t_rows, --TMAP) { in vs_sm_erase()
967 (void)gp->scr_move(sp, TMAP - HMAP, 0); in vs_sm_erase()
968 (void)gp->scr_clrtoeol(sp); in vs_sm_erase()
974 * vs_sm_1down --
986 (void)sp->gp->scr_move(sp, 0, 0); in vs_sm_1down()
990 /* One-line screens can fail. */ in vs_sm_1down()
995 memmove(HMAP + 1, HMAP, (sp->rows - 1) * sizeof(SMAP)); in vs_sm_1down()
1004 * vs_insertln --
1014 gp = sp->gp; in vs_insertln()
1023 (void)gp->scr_move(sp, LASTLINE(sp), 0); in vs_insertln()
1024 (void)gp->scr_clrtoeol(sp); in vs_insertln()
1026 (void)gp->scr_cursor(sp, &oldy, &oldx); in vs_insertln()
1027 while (cnt--) { in vs_insertln()
1028 (void)gp->scr_move(sp, LASTLINE(sp) - 1, 0); in vs_insertln()
1029 (void)gp->scr_deleteln(sp); in vs_insertln()
1030 (void)gp->scr_move(sp, oldy, oldx); in vs_insertln()
1031 (void)gp->scr_insertln(sp); in vs_insertln()
1038 * vs_sm_next --
1050 t->lno = p->lno + 1; in vs_sm_next()
1051 t->coff = p->coff; in vs_sm_next()
1053 lcnt = vs_screens(sp, p->lno, NULL); in vs_sm_next()
1054 if (lcnt == p->soff) { in vs_sm_next()
1055 t->lno = p->lno + 1; in vs_sm_next()
1056 t->soff = 1; in vs_sm_next()
1058 t->lno = p->lno; in vs_sm_next()
1059 t->soff = p->soff + 1; in vs_sm_next()
1066 * vs_sm_prev --
1076 t->lno = p->lno - 1; in vs_sm_prev()
1077 t->coff = p->coff; in vs_sm_prev()
1079 if (p->soff != 1) { in vs_sm_prev()
1080 t->lno = p->lno; in vs_sm_prev()
1081 t->soff = p->soff - 1; in vs_sm_prev()
1083 t->lno = p->lno - 1; in vs_sm_prev()
1084 t->soff = vs_screens(sp, t->lno, NULL); in vs_sm_prev()
1087 return (t->lno == 0); in vs_sm_prev()
1091 * vs_sm_cursor --
1102 if (sp->lno < HMAP->lno || sp->lno > TMAP->lno) in vs_sm_cursor()
1106 for (p = HMAP; p->lno != sp->lno; ++p); in vs_sm_cursor()
1111 if (p != TMAP && (p + 1)->lno != p->lno) { in vs_sm_cursor()
1117 if (p->c_eboff >= sp->cno) { in vs_sm_cursor()
1128 * vs_sm_position --
1138 SMAP *smp; in vs_sm_position() local
1149 if (cnt > TMAP - HMAP) in vs_sm_position()
1151 smp = HMAP + cnt; in vs_sm_position()
1152 if (cnt && !db_exist(sp, smp->lno)) { in vs_sm_position()
1153 sof: msgq(sp, M_BERR, "220|Movement past the end-of-screen"); in vs_sm_position()
1164 if (!db_exist(sp, TMAP->lno)) { in vs_sm_position()
1167 for (smp = TMAP; smp->lno > last && smp > HMAP; --smp); in vs_sm_position()
1168 if (smp > HMAP) in vs_sm_position()
1169 smp -= (smp - HMAP) / 2; in vs_sm_position()
1171 smp = (HMAP + (TMAP - HMAP) / 2) + cnt; in vs_sm_position()
1178 * real and try to offset from there. in vs_sm_position()
1180 if (cnt > TMAP - HMAP) in vs_sm_position()
1182 smp = TMAP - cnt; in vs_sm_position()
1183 if (!db_exist(sp, smp->lno)) { in vs_sm_position()
1186 for (; smp->lno > last && smp > HMAP; --smp); in vs_sm_position()
1187 if (cnt > smp - HMAP) { in vs_sm_position()
1189 "221|Movement past the beginning-of-screen"); in vs_sm_position()
1192 smp -= cnt; in vs_sm_position()
1200 if (!SMAP_CACHE(smp) && vs_line(sp, smp, NULL, NULL)) in vs_sm_position()
1202 rp->lno = smp->lno; in vs_sm_position()
1203 rp->cno = smp->c_sboff; in vs_sm_position()
1209 * vs_sm_nlines --
1221 return (from_sp->lno > to_lno ? in vs_sm_nlines()
1222 from_sp->lno - to_lno : to_lno - from_sp->lno); in vs_sm_nlines()
1224 if (from_sp->lno == to_lno) in vs_sm_nlines()
1225 return (from_sp->soff - 1); in vs_sm_nlines()
1227 if (from_sp->lno > to_lno) { in vs_sm_nlines()
1228 lcnt = from_sp->soff - 1; /* Correct for off-by-one. */ in vs_sm_nlines()
1229 for (lno = from_sp->lno; --lno >= to_lno && lcnt <= max;) in vs_sm_nlines()
1232 lno = from_sp->lno; in vs_sm_nlines()
1233 lcnt = (vs_screens(sp, lno, NULL) - from_sp->soff) + 1; in vs_sm_nlines()