10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 22*802Scf46844 /* 23*802Scf46844 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*802Scf46844 * Use is subject to license terms. 25*802Scf46844 */ 26*802Scf46844 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */ 32*802Scf46844 33*802Scf46844 #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include "ex.h" 360Sstevel@tonic-gate #include "ex_tty.h" 370Sstevel@tonic-gate #include "ex_vis.h" 380Sstevel@tonic-gate 390Sstevel@tonic-gate /* 400Sstevel@tonic-gate * Routines to adjust the window, showing specified lines 410Sstevel@tonic-gate * in certain positions on the screen, and scrolling in both 420Sstevel@tonic-gate * directions. Code here is very dependent on mode (open versus visual). 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* 460Sstevel@tonic-gate * Move in a nonlocal way to line addr. 470Sstevel@tonic-gate * If it isn't on screen put it in specified context. 480Sstevel@tonic-gate * New position for cursor is curs. 490Sstevel@tonic-gate * Like most routines here, we vsave(). 500Sstevel@tonic-gate */ 51*802Scf46844 void 520Sstevel@tonic-gate vmoveto(addr, curs, context) 53*802Scf46844 line *addr; 540Sstevel@tonic-gate unsigned char *curs; 550Sstevel@tonic-gate unsigned char context; 560Sstevel@tonic-gate { 570Sstevel@tonic-gate 580Sstevel@tonic-gate markit(addr); 590Sstevel@tonic-gate vsave(); 600Sstevel@tonic-gate vjumpto(addr, curs, context); 610Sstevel@tonic-gate } 620Sstevel@tonic-gate 630Sstevel@tonic-gate /* 640Sstevel@tonic-gate * Vjumpto is like vmoveto, but doesn't mark previous 650Sstevel@tonic-gate * context or save linebuf as current line. 660Sstevel@tonic-gate */ 67*802Scf46844 void 68*802Scf46844 vjumpto(line *addr, unsigned char *curs, unsigned char context) 690Sstevel@tonic-gate { 700Sstevel@tonic-gate 710Sstevel@tonic-gate noteit(0); 720Sstevel@tonic-gate if (context != 0) 730Sstevel@tonic-gate vcontext(addr, context); 740Sstevel@tonic-gate else 750Sstevel@tonic-gate vshow(addr, NOLINE); 760Sstevel@tonic-gate noteit(1); 770Sstevel@tonic-gate vnline(curs); 780Sstevel@tonic-gate } 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* 810Sstevel@tonic-gate * Go up or down cnt (negative is up) to new position curs. 820Sstevel@tonic-gate */ 83*802Scf46844 void 84*802Scf46844 vupdown(int cnt, unsigned char *curs) 850Sstevel@tonic-gate { 860Sstevel@tonic-gate 870Sstevel@tonic-gate if (cnt > 0) 880Sstevel@tonic-gate vdown(cnt, 0, 0); 890Sstevel@tonic-gate else if (cnt < 0) 900Sstevel@tonic-gate vup(-cnt, 0, 0); 910Sstevel@tonic-gate if (vcnt == 0) 920Sstevel@tonic-gate vrepaint(curs); 930Sstevel@tonic-gate else 940Sstevel@tonic-gate vnline(curs); 950Sstevel@tonic-gate } 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* 980Sstevel@tonic-gate * Go up cnt lines, afterwards preferring to be ind 990Sstevel@tonic-gate * logical lines from the top of the screen. 1000Sstevel@tonic-gate * If scroll, then we MUST use a scroll. 1010Sstevel@tonic-gate * Otherwise clear and redraw if motion is far. 1020Sstevel@tonic-gate */ 103*802Scf46844 void 104*802Scf46844 vup(int cnt, int ind, bool scroll) 1050Sstevel@tonic-gate { 106*802Scf46844 int i, tot; 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate if (dot == one) { 109*802Scf46844 (void) beep(); 1100Sstevel@tonic-gate return; 1110Sstevel@tonic-gate } 1120Sstevel@tonic-gate vsave(); 1130Sstevel@tonic-gate i = lineDOT() - 1; 1140Sstevel@tonic-gate if (cnt > i) { 1150Sstevel@tonic-gate ind -= cnt - i; 1160Sstevel@tonic-gate if (ind < 0) 1170Sstevel@tonic-gate ind = 0; 1180Sstevel@tonic-gate cnt = i; 1190Sstevel@tonic-gate } 1200Sstevel@tonic-gate if (!scroll && cnt <= vcline) { 1210Sstevel@tonic-gate vshow(dot - cnt, NOLINE); 1220Sstevel@tonic-gate return; 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate cnt -= vcline, dot -= vcline, vcline = 0; 1250Sstevel@tonic-gate if (hold & HOLDWIG) 1260Sstevel@tonic-gate goto contxt; 1270Sstevel@tonic-gate if (state == VISUAL && !insert_line && !scroll_reverse && 1280Sstevel@tonic-gate cnt <= WTOP - ZERO && vfit(dot - cnt, cnt) <= WTOP - ZERO) 1290Sstevel@tonic-gate goto okr; 1300Sstevel@tonic-gate tot = WECHO - WTOP; 1310Sstevel@tonic-gate if (state != VISUAL || (!insert_line && !scroll_reverse) || (!scroll && (cnt > tot || vfit(dot - cnt, cnt) > tot / 3 + 1))) { 1320Sstevel@tonic-gate if (ind > basWLINES / 2) 1330Sstevel@tonic-gate ind = basWLINES / 3; 1340Sstevel@tonic-gate contxt: 1350Sstevel@tonic-gate vcontext(dot + ind - cnt, '.'); 1360Sstevel@tonic-gate return; 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate okr: 1390Sstevel@tonic-gate vrollR(cnt); 1400Sstevel@tonic-gate if (scroll) { 1410Sstevel@tonic-gate vcline += ind, dot += ind; 1420Sstevel@tonic-gate if (vcline >= vcnt) 1430Sstevel@tonic-gate dot -= vcline - vcnt + 1, vcline = vcnt - 1; 1440Sstevel@tonic-gate getDOT(); 1450Sstevel@tonic-gate } 1460Sstevel@tonic-gate } 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate /* 1490Sstevel@tonic-gate * Like vup, but scrolling down. 1500Sstevel@tonic-gate */ 151*802Scf46844 void 152*802Scf46844 vdown(int cnt, int ind, bool scroll) 1530Sstevel@tonic-gate { 154*802Scf46844 int i, tot; 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate if (dot == dol) { 157*802Scf46844 (void) beep(); 1580Sstevel@tonic-gate return; 1590Sstevel@tonic-gate } 1600Sstevel@tonic-gate vsave(); 1610Sstevel@tonic-gate i = dol - dot; 1620Sstevel@tonic-gate if (cnt > i) { 1630Sstevel@tonic-gate ind -= cnt - i; 1640Sstevel@tonic-gate if (ind < 0) 1650Sstevel@tonic-gate ind = 0; 1660Sstevel@tonic-gate cnt = i; 1670Sstevel@tonic-gate } 1680Sstevel@tonic-gate i = vcnt - vcline - 1; 1690Sstevel@tonic-gate if (!scroll && cnt <= i) { 1700Sstevel@tonic-gate vshow(dot + cnt, NOLINE); 1710Sstevel@tonic-gate return; 1720Sstevel@tonic-gate } 1730Sstevel@tonic-gate cnt -= i, dot += i, vcline += i; 1740Sstevel@tonic-gate if (hold & HOLDWIG) 1750Sstevel@tonic-gate goto dcontxt; 1760Sstevel@tonic-gate if (!scroll) { 1770Sstevel@tonic-gate tot = WECHO - WTOP; 1780Sstevel@tonic-gate if (state != VISUAL || cnt - tot > 0 || vfit(dot, cnt) > tot / 3 + 1) { 1790Sstevel@tonic-gate dcontxt: 1800Sstevel@tonic-gate vcontext(dot + cnt, '.'); 1810Sstevel@tonic-gate return; 1820Sstevel@tonic-gate } 1830Sstevel@tonic-gate } 1840Sstevel@tonic-gate if (cnt > 0) 1850Sstevel@tonic-gate vroll(cnt); 1860Sstevel@tonic-gate if (state == VISUAL && scroll) { 1870Sstevel@tonic-gate vcline -= ind, dot -= ind; 1880Sstevel@tonic-gate if (vcline < 0) 1890Sstevel@tonic-gate dot -= vcline, vcline = 0; 1900Sstevel@tonic-gate getDOT(); 1910Sstevel@tonic-gate } 1920Sstevel@tonic-gate } 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate /* 1950Sstevel@tonic-gate * Show line addr in context where on the screen. 1960Sstevel@tonic-gate * Work here is in determining new top line implied by 1970Sstevel@tonic-gate * this placement of line addr, since we always draw from the top. 1980Sstevel@tonic-gate */ 199*802Scf46844 void 200*802Scf46844 vcontext(line *addr, unsigned char where) 2010Sstevel@tonic-gate { 202*802Scf46844 line *top; 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate getline(*addr); 2050Sstevel@tonic-gate if (state != VISUAL) 2060Sstevel@tonic-gate top = addr; 2070Sstevel@tonic-gate else switch (where) { 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate case '^': 2100Sstevel@tonic-gate addr = vback(addr, basWLINES - vdepth()); 2110Sstevel@tonic-gate getline(*addr); 2120Sstevel@tonic-gate /* fall into ... */ 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate case '-': 2150Sstevel@tonic-gate top = vback(addr, basWLINES - vdepth()); 2160Sstevel@tonic-gate getline(*addr); 2170Sstevel@tonic-gate break; 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate case '.': 2200Sstevel@tonic-gate top = vback(addr, basWLINES / 2 - vdepth()); 2210Sstevel@tonic-gate getline(*addr); 2220Sstevel@tonic-gate break; 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate default: 2250Sstevel@tonic-gate top = addr; 2260Sstevel@tonic-gate break; 2270Sstevel@tonic-gate } 2280Sstevel@tonic-gate if (state == ONEOPEN && LINE(0) == WBOT) 2290Sstevel@tonic-gate vup1(); 2300Sstevel@tonic-gate vcnt = vcline = 0; 2310Sstevel@tonic-gate vclean(); 2320Sstevel@tonic-gate if (state == CRTOPEN) 2330Sstevel@tonic-gate vup1(); 2340Sstevel@tonic-gate vshow(addr, top); 2350Sstevel@tonic-gate } 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * Get a clean line. If we are in a hard open 2390Sstevel@tonic-gate * we may be able to reuse the line we are on 2400Sstevel@tonic-gate * if it is blank. This is a real win. 2410Sstevel@tonic-gate */ 242*802Scf46844 void 243*802Scf46844 vclean(void) 2440Sstevel@tonic-gate { 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate if (state != VISUAL && state != CRTOPEN) { 2470Sstevel@tonic-gate destcol = 0; 2480Sstevel@tonic-gate if (!ateopr()) 2490Sstevel@tonic-gate vup1(); 2500Sstevel@tonic-gate vcnt = 0; 2510Sstevel@tonic-gate } 2520Sstevel@tonic-gate } 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate * Show line addr with the specified top line on the screen. 2560Sstevel@tonic-gate * Top may be 0; in this case have vcontext compute the top 2570Sstevel@tonic-gate * (and call us recursively). Eventually, we clear the screen 2580Sstevel@tonic-gate * (or its open mode equivalent) and redraw. 2590Sstevel@tonic-gate */ 260*802Scf46844 void 261*802Scf46844 vshow(line *addr, line *top) 2620Sstevel@tonic-gate { 2630Sstevel@tonic-gate #ifndef CBREAK 264*802Scf46844 bool fried = 0; 2650Sstevel@tonic-gate #endif 266*802Scf46844 int cnt = addr - dot; 267*802Scf46844 int i = vcline + cnt; 2680Sstevel@tonic-gate short oldhold = hold; 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate if (state != HARDOPEN && state != ONEOPEN && i >= 0 && i < vcnt) { 2710Sstevel@tonic-gate dot = addr; 2720Sstevel@tonic-gate getDOT(); 2730Sstevel@tonic-gate vcline = i; 2740Sstevel@tonic-gate return; 2750Sstevel@tonic-gate } 2760Sstevel@tonic-gate if (state != VISUAL) { 2770Sstevel@tonic-gate dot = addr; 2780Sstevel@tonic-gate vopen(dot, WBOT); 2790Sstevel@tonic-gate return; 2800Sstevel@tonic-gate } 2810Sstevel@tonic-gate if (top == 0) { 2820Sstevel@tonic-gate vcontext(addr, '.'); 2830Sstevel@tonic-gate return; 2840Sstevel@tonic-gate } 2850Sstevel@tonic-gate dot = top; 2860Sstevel@tonic-gate #ifndef CBREAK 2870Sstevel@tonic-gate if (vcookit(2)) 2880Sstevel@tonic-gate fried++, vcook(); 2890Sstevel@tonic-gate #endif 2900Sstevel@tonic-gate oldhold = hold; 2910Sstevel@tonic-gate hold |= HOLDAT; 2920Sstevel@tonic-gate vclear(); 2930Sstevel@tonic-gate vreset(0); 2940Sstevel@tonic-gate vredraw(WTOP); 2950Sstevel@tonic-gate /* error if vcline >= vcnt ! */ 2960Sstevel@tonic-gate vcline = addr - top; 2970Sstevel@tonic-gate dot = addr; 2980Sstevel@tonic-gate getDOT(); 2990Sstevel@tonic-gate hold = oldhold; 3000Sstevel@tonic-gate vsync(LASTLINE); 3010Sstevel@tonic-gate #ifndef CBREAK 3020Sstevel@tonic-gate if (fried) 3030Sstevel@tonic-gate flusho(), vraw(); 3040Sstevel@tonic-gate #endif 3050Sstevel@tonic-gate } 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate /* 3080Sstevel@tonic-gate * reset the state. 3090Sstevel@tonic-gate * If inecho then leave us at the beginning of the echo 3100Sstevel@tonic-gate * area; we are called this way in the middle of a :e escape 3110Sstevel@tonic-gate * from visual, e.g. 3120Sstevel@tonic-gate */ 313*802Scf46844 void 314*802Scf46844 vreset(bool inecho) 3150Sstevel@tonic-gate { 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate vcnt = vcline = 0; 3180Sstevel@tonic-gate WTOP = basWTOP; 3190Sstevel@tonic-gate WLINES = basWLINES; 3200Sstevel@tonic-gate if (inecho) 3210Sstevel@tonic-gate splitw = 1, vgoto(WECHO, 0); 3220Sstevel@tonic-gate } 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate /* 3250Sstevel@tonic-gate * Starting from which line preceding tp uses almost (but not more 3260Sstevel@tonic-gate * than) cnt physical lines? 3270Sstevel@tonic-gate */ 3280Sstevel@tonic-gate line * 3290Sstevel@tonic-gate vback(tp, cnt) 330*802Scf46844 int cnt; 331*802Scf46844 line *tp; 3320Sstevel@tonic-gate { 333*802Scf46844 int d; 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate if (cnt > 0) 3360Sstevel@tonic-gate for (; tp > one; tp--) { 3370Sstevel@tonic-gate getline(tp[-1]); 3380Sstevel@tonic-gate d = vdepth(); 3390Sstevel@tonic-gate if (d > cnt) 3400Sstevel@tonic-gate break; 3410Sstevel@tonic-gate cnt -= d; 3420Sstevel@tonic-gate } 3430Sstevel@tonic-gate return (tp); 3440Sstevel@tonic-gate } 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate /* 3470Sstevel@tonic-gate * How much scrolling will it take to roll cnt lines starting at tp? 3480Sstevel@tonic-gate */ 349*802Scf46844 int 350*802Scf46844 vfit(line *tp, int cnt) 3510Sstevel@tonic-gate { 352*802Scf46844 int j; 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate j = 0; 3550Sstevel@tonic-gate while (cnt > 0) { 3560Sstevel@tonic-gate cnt--; 3570Sstevel@tonic-gate getline(tp[cnt]); 3580Sstevel@tonic-gate j += vdepth(); 3590Sstevel@tonic-gate } 3600Sstevel@tonic-gate if (tp > dot) 3610Sstevel@tonic-gate j -= WBOT - LASTLINE; 3620Sstevel@tonic-gate return (j); 3630Sstevel@tonic-gate } 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate /* 3660Sstevel@tonic-gate * Roll cnt lines onto the screen. 3670Sstevel@tonic-gate */ 368*802Scf46844 void 369*802Scf46844 vroll(int cnt) 3700Sstevel@tonic-gate { 3710Sstevel@tonic-gate #ifndef CBREAK 372*802Scf46844 bool fried = 0; 3730Sstevel@tonic-gate #endif 3740Sstevel@tonic-gate short oldhold = hold; 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate #ifdef ADEBUG 3770Sstevel@tonic-gate if (trace) 3780Sstevel@tonic-gate tfixnl(), fprintf(trace, "vroll(%d)\n", cnt); 3790Sstevel@tonic-gate #endif 3800Sstevel@tonic-gate if (state != VISUAL) 3810Sstevel@tonic-gate hold |= HOLDAT|HOLDROL; 3820Sstevel@tonic-gate if (WBOT == WECHO) { 3830Sstevel@tonic-gate vcnt = 0; 3840Sstevel@tonic-gate if (state == ONEOPEN) 3850Sstevel@tonic-gate vup1(); 3860Sstevel@tonic-gate } 3870Sstevel@tonic-gate #ifndef CBREAK 3880Sstevel@tonic-gate if (vcookit(cnt)) 3890Sstevel@tonic-gate fried++, vcook(); 3900Sstevel@tonic-gate #endif 3910Sstevel@tonic-gate for (; cnt > 0 && Peekkey != ATTN; cnt--) { 3920Sstevel@tonic-gate dot++, vcline++; 3930Sstevel@tonic-gate vopen(dot, LASTLINE); 3940Sstevel@tonic-gate vscrap(); 3950Sstevel@tonic-gate } 3960Sstevel@tonic-gate hold = oldhold; 3970Sstevel@tonic-gate if (state == HARDOPEN) 3980Sstevel@tonic-gate sethard(); 3990Sstevel@tonic-gate vsyncCL(); 4000Sstevel@tonic-gate #ifndef CBREAK 4010Sstevel@tonic-gate if (fried) 4020Sstevel@tonic-gate flusho(), vraw(); 4030Sstevel@tonic-gate #endif 4040Sstevel@tonic-gate } 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate /* 4070Sstevel@tonic-gate * Roll backwards (scroll up). 4080Sstevel@tonic-gate */ 409*802Scf46844 void 410*802Scf46844 vrollR(int cnt) 4110Sstevel@tonic-gate { 412*802Scf46844 bool fried = 0; 4130Sstevel@tonic-gate short oldhold = hold; 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate #ifdef ADEBUG 4160Sstevel@tonic-gate if (trace) 4170Sstevel@tonic-gate tfixnl(), fprintf(trace, "vrollR(%d), dot=%d\n", cnt, lineDOT()); 4180Sstevel@tonic-gate #endif 4190Sstevel@tonic-gate #ifndef CBREAK 4200Sstevel@tonic-gate if (vcookit(cnt)) 4210Sstevel@tonic-gate fried++, vcook(); 4220Sstevel@tonic-gate #endif 4230Sstevel@tonic-gate if (WBOT == WECHO) 4240Sstevel@tonic-gate vcnt = 0; 4250Sstevel@tonic-gate heldech = 0; 4260Sstevel@tonic-gate hold |= HOLDAT|HOLDECH; 4270Sstevel@tonic-gate for (; cnt > 0 && Peekkey != ATTN; cnt--) { 4280Sstevel@tonic-gate dot--; 4290Sstevel@tonic-gate vopen(dot, WTOP); 4300Sstevel@tonic-gate vscrap(); 4310Sstevel@tonic-gate } 4320Sstevel@tonic-gate hold = oldhold; 4330Sstevel@tonic-gate if (heldech) 4340Sstevel@tonic-gate vclrech(0); 4350Sstevel@tonic-gate vsync(LINE(vcnt-1)); 4360Sstevel@tonic-gate #ifndef CBREAK 4370Sstevel@tonic-gate if (fried) 4380Sstevel@tonic-gate flusho(), vraw(); 4390Sstevel@tonic-gate #endif 4400Sstevel@tonic-gate } 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /* 4430Sstevel@tonic-gate * Go into cooked mode (allow interrupts) during 4440Sstevel@tonic-gate * a scroll if we are at less than 1200 baud and not 4450Sstevel@tonic-gate * a 'vi' command, of if we are in a 'vi' command and the 4460Sstevel@tonic-gate * scroll is more than 2 full screens. 4470Sstevel@tonic-gate * 4480Sstevel@tonic-gate * BUG: An interrupt during a scroll in this way 4490Sstevel@tonic-gate * dumps to command mode. 4500Sstevel@tonic-gate */ 451*802Scf46844 int 452*802Scf46844 vcookit(int cnt) 4530Sstevel@tonic-gate { 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate return (cnt > 1 && (ospeed < B1200 && !initev || cnt > lines * 2)); 4560Sstevel@tonic-gate } 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate /* 4590Sstevel@tonic-gate * Determine displayed depth of current line. 4600Sstevel@tonic-gate */ 461*802Scf46844 int 462*802Scf46844 vdepth(void) 4630Sstevel@tonic-gate { 464*802Scf46844 int d; 4650Sstevel@tonic-gate 4660Sstevel@tonic-gate d = (column(NOSTR) + WCOLS - 1 + (Putchar == listchar) + insert_null_glitch) / WCOLS; 4670Sstevel@tonic-gate #ifdef ADEBUG 4680Sstevel@tonic-gate if (trace) 4690Sstevel@tonic-gate tfixnl(), fprintf(trace, "vdepth returns %d\n", d == 0 ? 1 : d); 4700Sstevel@tonic-gate #endif 4710Sstevel@tonic-gate return (d == 0 ? 1 : d); 4720Sstevel@tonic-gate } 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate /* 4750Sstevel@tonic-gate * Move onto a new line, with cursor at position curs. 4760Sstevel@tonic-gate */ 477*802Scf46844 void 478*802Scf46844 vnline(unsigned char *curs) 4790Sstevel@tonic-gate { 4800Sstevel@tonic-gate unsigned char *owcursor; 4810Sstevel@tonic-gate int j; 4820Sstevel@tonic-gate if (curs) { 4830Sstevel@tonic-gate if(curs >= strend(linebuf)) { 4840Sstevel@tonic-gate if(!*linebuf) 4850Sstevel@tonic-gate wcursor = linebuf; 4860Sstevel@tonic-gate else { 4870Sstevel@tonic-gate wcursor = strend(linebuf); 4880Sstevel@tonic-gate wcursor = lastchr(linebuf, wcursor); 4890Sstevel@tonic-gate } 4900Sstevel@tonic-gate } else { 4910Sstevel@tonic-gate owcursor = wcursor = curs; 4920Sstevel@tonic-gate j = wcursor - linebuf; 4930Sstevel@tonic-gate for(wcursor = linebuf; wcursor - linebuf < j; ) { 4940Sstevel@tonic-gate owcursor = wcursor; 4950Sstevel@tonic-gate wcursor = nextchr(wcursor); 4960Sstevel@tonic-gate } 4970Sstevel@tonic-gate if(wcursor - linebuf > j) 4980Sstevel@tonic-gate wcursor = owcursor; 4990Sstevel@tonic-gate } 5000Sstevel@tonic-gate 5010Sstevel@tonic-gate } else if (vmoving) 5020Sstevel@tonic-gate wcursor = vfindcol(vmovcol); 5030Sstevel@tonic-gate else 5040Sstevel@tonic-gate wcursor = vskipwh(linebuf); 5050Sstevel@tonic-gate cursor = linebuf; 506*802Scf46844 (void) vmove(); 5070Sstevel@tonic-gate } 508