* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char *sccsid
= "@(#)ex_vwind.c 7.4 (Berkeley) %G%";
* Routines to adjust the window, showing specified lines
* in certain positions on the screen, and scrolling in both
* directions. Code here is very dependent on mode (open versus visual).
* Move in a nonlocal way to line addr.
* If it isn't on screen put it in specified context.
* New position for cursor is curs.
* Like most routines here, we vsave().
vmoveto(addr
, curs
, context
)
vjumpto(addr
, curs
, context
);
* Vjumpto is like vmoveto, but doesn't mark previous
* context or save linebuf as current line.
vjumpto(addr
, curs
, context
)
* Go up or down cnt (negative is up) to new position curs.
* Go up cnt lines, afterwards preferring to be ind
* logical lines from the top of the screen.
* If scroll, then we MUST use a scroll.
* Otherwise clear and redraw if motion is far.
if (!scroll
&& cnt
<= vcline
) {
vshow(dot
- cnt
, NOLINE
);
cnt
-= vcline
, dot
-= vcline
, vcline
= 0;
if (state
== VISUAL
&& !AL
&& !SR
&&
cnt
<= WTOP
- ex_ZERO
&& vfit(dot
- cnt
, cnt
) <= WTOP
- ex_ZERO
)
if (state
!= VISUAL
|| (!AL
&& !SR
) || (!scroll
&& (cnt
> tot
|| vfit(dot
- cnt
, cnt
) > tot
/ 3 + 1))) {
vcontext(dot
+ ind
- cnt
, '.');
vcline
+= ind
, dot
+= ind
;
dot
-= vcline
- vcnt
+ 1, vcline
= vcnt
- 1;
* Like vup, but scrolling down.
if (!scroll
&& cnt
<= i
) {
vshow(dot
+ cnt
, NOLINE
);
cnt
-= i
, dot
+= i
, vcline
+= i
;
if (state
!= VISUAL
|| cnt
- tot
> 0 || vfit(dot
, cnt
) > tot
/ 3 + 1) {
vcontext(dot
+ cnt
, '.');
if (state
== VISUAL
&& scroll
) {
vcline
-= ind
, dot
-= ind
;
dot
-= vcline
, vcline
= 0;
* Show line addr in context where on the screen.
* Work here is in determining new top line implied by
* this placement of line addr, since we always draw from the top.
addr
= vback(addr
, basWLINES
- vdepth());
top
= vback(addr
, basWLINES
- vdepth());
top
= vback(addr
, basWLINES
/ 2 - vdepth());
if (state
== ONEOPEN
&& LINE(0) == WBOT
)
* Get a clean line. If we are in a hard open
* we may be able to reuse the line we are on
* if it is blank. This is a real win.
if (state
!= VISUAL
&& state
!= CRTOPEN
) {
* Show line addr with the specified top line on the screen.
* Top may be 0; in this case have vcontext compute the top
* (and call us recursively). Eventually, we clear the screen
* (or its open mode equivalent) and redraw.
register int cnt
= addr
- dot
;
register int i
= vcline
+ cnt
;
if (state
!= HARDOPEN
&& state
!= ONEOPEN
&& i
>= 0 && i
< vcnt
) {
/* error if vcline >= vcnt ! */
* If inecho then leave us at the beginning of the echo
* area; we are called this way in the middle of a :e escape
splitw
= 1, vgoto(WECHO
, 0);
* Starting from which line preceding tp uses almost (but not more
* than) cnt physical lines?
* How much scrolling will it take to roll cnt lines starting at tp?
* Roll cnt lines onto the screen.
tfixnl(), fprintf(trace
, "vroll(%d)\n", cnt
);
for (; cnt
> 0 && Peek_key
!= ATTN
; cnt
--) {
* Roll backwards (scroll up).
tfixnl(), fprintf(trace
, "vrollR(%d), dot=%d\n", cnt
, lineDOT());
for (; cnt
> 0 && Peek_key
!= ATTN
; cnt
--) {
* Go into cooked mode (allow interrupts) during
* a scroll if we are at less than 1200 baud and not
* a 'vi' command, of if we are in a 'vi' command and the
* scroll is more than 2 full screens.
* BUG: An interrupt during a scroll in this way
return (cnt
> 1 && (ospeed
< B1200
&& !initev
|| cnt
> LINES
* 2));
* Determine displayed depth of current line.
d
= (column(NOSTR
) + WCOLS
- 1 + (Put_char
== listchar
) + IN
) / WCOLS
;
tfixnl(), fprintf(trace
, "vdepth returns %d\n", d
== 0 ? 1 : d
);
* Move onto a new line, with cursor at position curs.
wcursor
= vfindcol(vmovcol
);
wcursor
= vskipwh(linebuf
);