-
Notifications
You must be signed in to change notification settings - Fork 3
/
ex_vclear.c
96 lines (85 loc) · 1.25 KB
/
ex_vclear.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "ex.h"
#ifdef VISUAL
#include "ex_tty.h"
#include "ex_vis.h"
/*
* Ex - a text editor
* Bill Joy UCB September, 1977
*/
static void vputs(char *);
/*
* Clear the entire (physical and logical) screen
*/
void
vclear(void)
{
vputs(CLEAR);
destcol = 0;
outcol = 0;
destline = 0;
outline = 0;
vclrbyte(vtube0, LINES * COLUMNS);
}
/*
* Put out a control sequence to the terminal.
*/
static void
vputs(char *cp)
{
while (*cp)
vputc(*cp++);
}
/*
* Clear bytes logically
*/
void
vclrbyte(char *cp, int i)
{
if (i > 0)
do
*cp++ = 0;
while (--i != 0);
}
/*
* Clear a physical line
*/
void
vclrlin(int l, int *tp)
{
vigoto(l, 0);
if (!holdat)
ex_putchar(tp > dol ? '~' : '@');
vclreol();
}
/*
* Clear to the end of the current physical line
*/
void
vclreol(void)
{
register int i;
register char *tp;
if (destcol == VCOLUMNS)
return;
destline += destcol / VCOLUMNS;
destcol %= VCOLUMNS;
#ifdef DEBUG
if (destline < 0 || destline > TUBELINES)
error("Internal error: vclreol@- please tell someone");
#endif
i = VCOLUMNS - destcol;
tp = vtube[destline] + destcol;
if (*tp == 0)
return;
if (CE) {
vcsync();
vputs(CE);
vclrbyte(tp, i);
return;
}
while (i > 0 && *tp != 0) {
vputchar(' ');
--i, tp++;
}
}
#endif