BSD 2 development
[unix-history] / .ref-BSD-1 / ex-1.1 / exo.c
CommitLineData
658ebcd4
BJ
1#include "ex.h"
2#include "ex_re.h"
3#include "ex_vis.h"
4#include "ex_tty.h"
5/*
6 * Ex - a text editor
7 * Bill Joy UCB June 1977
8 */
9
10oop()
11{
12#ifndef VISUAL
13
14 error("No open in this version");
15}
16#endif
17#ifdef VISUAL
18 char *ic, atube[TUBESIZE + LBSIZE];
19 int lines;
20
21 if (!value(OPEN))
22 error("Can't open unless open option is set");
23 if (OS)
24 error("Can't open on a terminal which overstrikes (yet)");
25 VCOLUMNS = COLUMNS;
26 if (!CA && AM)
27 VCOLUMNS--;
28 visual = 0;
29 setdot();
30 nonzero();
31 skipwh();
32 if (!inglobal)
33 saveall();
34 lines = dol - zero;
35 if (peekchar() == '/') {
36 compile(getchar(), 1);
37 savere(&scanre);
38 if (execute(0, addr1) == 0)
39 error("Fail|Pattern not found on addressed line");
40 ic = loc1;
41 if (ic > linebuf && *ic == 0)
42 ic--;
43 } else {
44 getline(*addr1);
45 ic = vskipwh(linebuf);
46 }
47 newline();
48 VLINES = LINES;
49 vok(atube);
50 Outchar = &vputchar;
51 ostart();
52 vch = 0;
53 if (CA) {
54 if (outcol == -20)
55 outcol = 0;
56 vup1();
57 } else if (!UPLINE)
58 outline = destline = LINES - 1;
59 vholdmove = 1;
60 dot = addr1;
61 for (;;) {
62 if (!vholdmove)
63 vup1();
64 vholdmove = 0;
65 voinit();
66 if (vmain(ic) == -1 || vch != '.')
67 break;
68 getDOT();
69 ic = vskipwh(linebuf);
70 }
71 ostop();
72 inopen = 0;
73 if (!CA)
74 vup1();
75 flusho();
76 setlastchar('\n');
77 setoutt();
78 netchHAD(lines);
79}
80
81vskipwh(cp)
82 register char *cp;
83{
84
85 while (white(*cp) && cp[1])
86 cp++;
87 return (cp);
88}
89
90voinit()
91{
92 register int i;
93
94 vcnt = 0;
95 vcline = 0;
96 i = LINES - 1;
97 vclrbyte(vtube[i], VCOLUMNS);
98 if (CA) {
99 i--;
100 vclrbyte(vtube[i], VCOLUMNS);
101 }
102 vopen(dot, i);
103}
104#endif